Projekat

Općenito

Profil

Akcije

Podrška #18328

Zatvoren

freeswitch upoznavanje, testovi, podešavanje na atom netbook

Dodano od Ernad Husremović prije više od 15 godina. Izmjenjeno prije skoro 15 godina.

Status:
Zatvoreno
Prioritet:
Normalan
Odgovorna osoba:
Kategorija:
-
Početak:
13.09.2009
Završetak:
% završeno:

0%

Procjena vremena:

Povezani tiketi 3 (0 otvoreno3 zatvorenih)

korelira sa voip - Podrška #18204: build freeswitch on acer atom netbookZatvorenoErnad Husremović28.08.2009

Akcije
korelira sa voip - Podrška #18392: dahdi, zaptel, qozap, mISDN ?!OdbačenoErnad Husremović18.09.2009

Akcije
korelira sa voip - Podrška #18749: build freeswitch on desk-c2ZastarjeloErnad Husremović02.11.2009

Akcije
Akcije #1

Izmjenjeno od Ernad Husremović prije više od 15 godina

moje bilješke od juče i danas:

5060 - for internal profile
5070 - for NAT profile
5080 - for external profile

5003 - neigborood

root@bringout-laptop:/opt/freeswitch/conf# grep

default_password vars.xml 
       YOU SHOULD CHANGE THIS default_password value if you don't want to be subject to any
  <X-PRE-PROCESS cmd="set" data="default_password=1234"/>

Anatomy of the XML Dialplan

There are several elements in the XML dialplan. In general you have context, extension, condition and action. Each is processed in order until you reach the action tag which tells FreeSWITCH what action to perform. You are not limited to only one condition or action tag for a given extension.

Context

Contexts are a logical grouping of extensions. You may have multiple extensions contained within a single context.

The context tag has a required parameter of 'name'. There is one reserved name 'any' which matches any context. The name is to assist you in identifying the context. The "dialplan" section of the freeswitch.xml meta document may contain several contexts

<?xml version="1.0"?>
<document type="freeswitch/xml">
  <section name="dialplan" description="Regex/XML Dialplan">
    <context name="default">
    </context>
  </section>
</document>

Extension

Extensions are destinations for a call. They are given a name and a grouping of conditions and actions are contained within them instructing FreeSWITCH what to do.

The extension tag has a required parameter of 'name'. This is just a arbitrary name that you give this extension to assist you in identifying it later. It has an optional argument of 'continue' which is set to true or false. If continue is true even if a match is found, FreeSWITCH will continue to execute the following extensions for matches once this extension has completed its actions. The default is to not continue.
For example, to add extension 500 to your dialplan, add the following section to your dialplan as indicated above:

 <!--- ext 500 -->
 <extension name="500">
   <condition field="destination_number" expression="^500$">
       <!--- The % behind the username tells FS to lookup the user in it's local sip_registration database -->
       <action application="bridge" data="sofia/profilename/500%x.x.x.x"/> 
       <!--- x.x.x.x in the line above is the IP address to the FreeSWITCH server/device -->
       <!--- If you don't want to bridge a call to a local registered user, but to a SIP URI, use the @ instead of %: 
       <action application="bridge" data="sofia/profilename/500@x.x.x.x"/> -->
   </condition>
 </extension>

<extension name="{exten_name}" [continue="[true|false]"]>

continue=true means even if an extension executes to continue parsing the next extension too. continue="false" is the default behavior and need not be specified.

In the example below, the particular extension will be selected only if the IP address of the calling endpoint is 192.168.1.1. In the second condition, the dialed number is extracted in variable $1 and put in the data of the bridge application, in order to dial out to IP address 192.168.2.2

<extension name="Test1">
  <condition field="network_addr" expression="^192\.168\.1\.1$"/>
  <condition field="destination_number" expression="^(\d+)$">
    <action application="bridge" data="sofia/profilename/$1@192.168.2.2"/>
  </condition>
</extension>

Akcije #2

Izmjenjeno od Ernad Husremović prije više od 15 godina

In this example we need to match a called number beginning with the prefix 1 AND match the incoming IP address at the same time.

<extension name="Test2">
  <condition field="network_addr" expression="^192\.168\.1\.1$"/>
  <condition field="destination_number" expression="^1(\d+)$">
    <action application="bridge" data="sofia/profilename/$0@192.168.2.2"/>
  </condition>
</extension>

In this example we need to match a called number beginning with 00 but we also need to strip the leading digits. Assuming that FreeSWITCH™ receives the number 00123456789 and we need to strip the leading 00 digits, then we can use the following extension:

<extension name="Test3.1">
  <condition field="destination_number" expression="^00(\d+)$">
    <action application="bridge" data="sofia/profilename/$1@192.168.2.2"/>
  </condition>
</extension>

In this example we will demonstrate the use of profiles when using a FreeSWITCH endpoint that supports profiles, like mod_sofia. Assuming that we want to use different call settings (codecs, DTMF modes, etc) for sending the calls to different IP addresses, we can create different profiles. For example, in the configuration of sofia.conf, we see an example profile named "test", which we rename to profile1 for this example, and add a profile2 for comparison:

<profile name="profile1">
  <param name="debug" value="1"/>
  <param name="rfc2833-pt" value="101"/>
  <param name="sip-port" value="5060"/>
  <param name="dialplan" value="XML"/>
  <param name="dtmf-duration" value="100"/>
  <param name="codec-prefs" value="PCMU@20i"/>
  <param name="codec-ms" value="20"/>
  <param name="use-rtp-timer" value="true"/>
</profile>
<profile name="profile2">
  <param name="debug" value="1"/>
  <param name="rfc2833-pt" value="101"/>
  <param name="sip-port" value="5070"/>
  <param name="dialplan" value="XML"/>
  <param name="dtmf-duration" value="100"/>
  <param name="codec-prefs" value="PCMA@20i"/>
  <param name="codec-ms" value="20"/>
  <param name="use-rtp-timer" value="true"/>
</profile>

The difference between the two profiles are in the codecs. The first uses G711 uLaw and the second G711 ALaw.

Continuing the examples above, we have:

<extension name="Test5ulaw">
  <condition field="network_addr" expression="^192\.168\.1\.1$"/>
  <condition field="destination_number" expression="^1(\d+)$">
    <action application="bridge" data="sofia/profile1/$0@192.168.2.2"/>
  </condition>
</extension>

to send the call in G711 uLaw and

<extension name="Test5alaw">
  <condition field="network_addr" expression="^192\.168\.1\.1$"/>
  <condition field="destination_number" expression="^1(\d+)$">
    <action application="bridge" data="sofia/profile2/$0@192.168.2.2"/>
  </condition>
</extension>

This example shows how to bridge to devices that have registered with your FreeSWITCH box. In this example we assume that you have setup a sofia profile called 'local_profile' and your phones are registering with the domain example.com. Note the '%' instead of '@' in the data string.

<extension name="internal">
  <condition field="source" expression="mod_sofia" />
  <condition field="destination_number" expression="^(4\d+)">
    <action application="bridge" data="sofia/local_profile/$0%example.com" />
  </condition>
</extension>

In this example we demonstrate routing to different destination based on NPANXX. Also how to respond to the calling party with a different failure message than the destination sends to FreeSWITCH.

<extension>
  <condition field="network_addr" expression="^(66\.123\.321\.231|70\.221\.221\.221)$" break="on-false"/>
  <condition field="destination_number" expression="^\d+$" break="never">
  <action application="set" data="continue_on_fail=NORMAL_TEMPORARY_FAILURE,TIMEOUT,NO_ROUTE_DESTINATION"/>
  <action application="set" data="bypass_media=true"/>
  <action application="set" data="accountcode=myaccount"/>
  </condition>
  <condition field="destination_number" expression="^(1813\d+|1863\d+|1727\d+|1941\d+|404\d+)$" break="never">
  <action application="bridge" data="sofia/outbound_profile/${sip_to_user}@switch1.mydomain.com"/>
  <action application="info"/>
  <action application="respond" data="503"/>
  <action application="hangup"/>
  </condition>
  <condition field="destination_number" expression="^(1404\d+|1678\d+|1770\d+)$">
  <action application="bridge" data="sofia/outbound_profile/${sip_to_user}@switch2.mydomain.com"/>
  <action application="info"/>
  <action application="respond" data="503"/>
  <action application="hangup"/>
  <anti-action application="respond" data="503"/>
  <anti-action application="hangup"/>
  </condition>
</extension>

channel variables

pass_rfc2833

If set it passes rfc2833 dtmf's from one side of a bridge to the other untouched. If unset, it decodes and reencodes them before passing them on.

Note: this has no effect when bypass_media or proxy_media is set.

&lt;action application=&quot;set&quot; data=&quot;pass_rfc2833=true&quot;/&gt;

dtmf_type

can be one of:

<action application="set" data="dtmf_type=info"/>

or

<action application="set" data="dtmf_type=rfc2833"/>

call_timeout

Controls how long (in seconds) to ring the B leg of a call when using the bridge application. The timeout is set on the A leg, and applies to any bridges that happen in the channel.

If you need to set a timeout on a call that has no A leg, use originate_timeout.

If you need to set the timeout on a per leg basis (i.e., a different timeout for each destination), use the leg_timeout variable.

Usage:

<action application="set" data="call_timeout=20"/>

caller_id_name

The caller id name set by the inbound call, not a real variable. Practically it is read only.

caller_id_number

The caller id phone number set by the inbound call, not a real variable. Practically it is read only.

hold_music

Per-channel hold music. Supports all audio formats and audio streams. The hold_music variable can also be set globally at vars.xml.

Usage:

<action application="set" data="hold_music=/sounds/holdmusic.wav" />

Akcije #3

Izmjenjeno od Ernad Husremović prije više od 15 godina

Multiple destinations in outbound calls

This means any dialstring may contain a '|' and/or ',' separated list of call URLs. The "|" calls one call at a time, the "," calls multiple calls simultaneously.

The example below will call 2 locations and connects the first to answer

<extension name="3002">
  <condition field="destination_number" expression="^3002$">
    <action application="bridge" data="iax/guest@somebox/1234,sofia/test-int/1000@somehost"/>
  </condition>
</extension>

Mod commands

freeswitch@internal> originate sofia/external/hernad_pc: 60

freeswitch@internal> reload mod_sofia

http://www.fsession.com/

root@bringout-laptop:/opt/freeswitch# cat scripts/HelloLua.lua

-- answer the call
session:answer();

-- sleep a second
session:sleep(100);

-- play a file
session:streamFile("digits/16000/0.wav");
session:streamFile("digits/16000/1.wav");
session:streamFile("digits/16000/9.wav");

-- hangup
session:hangup();

Freeswitch FAQ

Q: Does reloadxml reload all XML files?

It reloads the core XML cache, which doesn't mean all changes take effect.
  • Dialplan and Directory both get fully refreshed.
  • An event is fired (based on the ENUM config) that causes ENUM to reload.
  • Profile settings for sofia don't, but you can bounce a profile in sofia for new settings to take effect.
  • Conference settings will take affect next time a conf is created, but will not go away while the conference is up and running.
freeswitch@internal> reloadxml

freeswitch gui - distribucija bazirana na CentOS: http://www.freepbx.org/freepbx-v3

Q: Can I use FreeSWITCH with isdn BRI/BRA lines (S0 Basic Rate Interface)?

Initial BRI support has been added to the default ISDN module (ozmod_isdn). TE (user) and NT (net) mode are supported, including dialtone in NT mode and overlap receiving. This has been tested/developed with zaptel + bristuff / dahdi (ozmod_zt) and a single port HFC-S PCI card. NOTE: Advanced features (transfer, hold etc.) are not supported by the ozmod_isdn ISDN stack.

Freeswitch SIP stack: SOFIA from nokia

freeswitch@internal> sofia status

                     Name       Type                                  Data    State
=================================================================================================
                 internal    profile      sip:mod_sofia@192.168.45.93:5060    RUNNING (0)
                 external    profile      sip:mod_sofia@192.168.45.93:5080    RUNNING (0)
              example.com    gateway               sip:joeuser@example.com    NOREG
            internal-ipv6    profile              sip:mod_sofia@[::1]:5060    RUNNING (0)
            192.168.45.93      alias                              internal    ALIASED
=================================================================================================

gtalk

 <profile type="client">
   <param name="name" value="gmail.com"/>
   <param name="login" value="MyUserName@gmail.com/gtalk"/>
   <param name="password" value="myPassWord"/>
   <param name="server" value="talk.google.com"/>
   <param name="dialplan" value="XML"/>
   <param name="message" value="FreeSwitch (The Future of Telephony)"/>
   <param name="rtp-ip" value="auto"/>
   <!-- if you are behind NAT, you should probably use stun -->
   <param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
   <param name="auto-login" value="true"/>
   <param name="auto-reply" value="Press *Call* to join my conference"/>
   <param name="sasl" value="plain"/>
   <param name="tls" value="true"/>
   <param name="use-rtp-timer" value="true"/>
   <param name="exten" value="1000"/>
 </profile>

http://www.alijawad.org/cms/index.php?option=com_content&task=view&id=21&Itemid=2

GTALK Config "Works" this will allow you to call the account added below from any other gtalk client and the SIP extension defined in the lower part of the profile will ring

<profile type="client">
 <param name="name" value="gmail.com"/>
 <param name="login" value=" my_username@gmail.comThis email address is being protected from spam bots, you need Javascript enabled to view it /gtalk"/>
 <param name="password" value="my_password"/>
 <param name="server" value="talk.google.com"/>
 <param name="dialplan" value="XML"/>
 <param name="message" value="FreeSwitch (The Future of Telephony)"/>
 <param name="rtp-ip" value="auto"/>
 <!-- if you are behind NAT, you should probably use stun -->
 <param name="ext-rtp-ip" value="stun:stun.xten.com"/>
 <param name="auto-login" value="true"/>
 <param name="auto-reply" value="Press *Call* to join my conference"/>
 <param name="sasl" value="plain"/>
 <param name="tls" value="true"/>
 <param name="exten" value="1000"/>
</profile>

skypeiax

http://telecommusings.blogspot.com/2009/09/kicking-it-off-skype-for-asterisk-yawn.html

http://wiki.freeswitch.org/wiki/NAT_Traversal

Freeswitch Auto-nat UPnP

The FreeSWITCH "auto-nat" feature (added at SVN rev 13612) allows FreeSWITCH to use NAT-PMP or UPnP to discover the external IP address. No STUN lookup is needed. The device performing the NAT must support UPnP or NAT-PMP for the auto-nat feature to work. When the auto-nat feature is fully functioning, only a single SIP profile is needed. NOTE: It is still recommended that you use a second profile for your SIP providers. The default conf/sip_profiles/external.xml is set up specifically for use with providers.

The auto-nat feature will only perform NAT-PMP and UPnP requests and will NOT fall back in mechanisms like STUN. If you want to use STUN keep the option external rtp, external sip.

Devices known to work with FS UPNP

Linksys WRTxxx with dd-wrt or tomato firmware. dd-wrt version v24sp1 works functionally, but the UPNP UI page is always empty.

http://wiki.freeswitch.org/wiki/External_profile

Mod_fax

You can set the following channel's varialbles to control the behavior of the mod application:

  • fax_force_caller - Force to act as caller or receiver; Mode: Tx=1 or Rx=0
  • fax_ident
  • fax_header
  • fax_start_page - Saved document will start at specified page
  • fax_end_page - Saved document will end at specified page
  • fax_prefix
  • fax_use_ecm - Forces the use of ECM if globally disabled, on a per call basis
  • fax_disable_v17 - Disable V17 modem that is: use lower speed modems (lower speeds are auto-negotiated with the remote party and cannot be forced. That's a work that the spandsp modem handles on its own.)
  • fax_verbose - Be verbose when printing logs (per call basis)

Checking the results

Rx/Tx fax will set the following channel varilables when it terminates:
  • fax_success - 0 on error, 1 on success;
  • fax_result_code - 0 on error otherwise >= 1;
  • fax_result_text - fax error string, provide info where an error has happened;
  • fax_ecm_used - "on" or "off";
  • fax_local_station_id
  • fax_remote_station_id
  • fax_document_transferred_pages
  • fax_document_total_pages
  • fax_image_resolution - XxY
  • fax_image_size
  • fax_bad_rows
  • fax_transfer_rate - speed expressed in bauds (bit per seconds) like 14.400, 9.600, etc.;
  • fax_v17_disabled - 0/1
  • fax_ecm_requested - 0/1
  • fax_filename

http://steffler.info/my-first-python-script-receive-a-fax-via-freeswitch-spandsp/

I’ve tested this script to work on various builds of the May 2009 FreeSWITCH SVN trunk codebase, under FreeBSD 7.x, using a virtual server from the amazing VoIP provider Link2VoIP.com. It works great for receiving faxes in email and has no limitation of how many faxes it can receive at once (fax lines don’t ring busy unless FreeSWITCH runs out of CPU/capacity to keep handling them). On my Link2VoIP virtual server I was able to simultaneously send and receive 50 faxes to and from myself concurrently without anything crashing.

Once you have a working FreeSWITCH, with all of the above requirements met, create an extension similar to the following, which calls the script when the extension is called:

<extension name="test_rxfax_python"/>
       <condition field="destination_number" expression="^\*90012$">
               <action application="set" data="recipient=YOU@YOURDOMAINHERE.com"/>
               <action application="python" data="process-rxfax"/>
               <action application="hangup"/>
       </condition>
</extension>

Set the recipient variable in dialplan to the email address you want the fax to get sent to. The SMTP server specified in the script must be able to relay mail to this email address.

Thanks to the amazing developers of FreeSWITCH and spandsp.

Comments/improvements are appreciated!

http://steffler.info/wp-content/uploads/2009/06/process-rxfax.py

api docs freeswitch

Akcije #4

Izmjenjeno od Ernad Husremović prije više od 15 godina

portaudio

PortAudio is a free, cross platform, open-source, audio I/O library. It lets you write simple audio programs in 'C' that will compile and run on many platforms including Windows, Macintosh (8,9,X), Unix (OSS), SGI, and BeOS. PortAudio is intended to promote the exchange of audio synthesis software between developers on different platforms.

PortAudio provides a very simple API for recording and/or playing sound using a simple callback function. Example programs are included that synthesize sine waves and pink noise, perform fuzz distortion on a guitar, list available audio devices, etc.

http://wiki.freeswitch.org/wiki/Mod_portaudio

mod_portaudio is used for interfacing with sound card. This scenario is usually used when FreeSWITCH is used for a softphone basis, or as an easy way to get a local connection for development.

Interaction with mod_portaudio usually happens at the Freeswitch CLI, including setup, placing calls, answering calls, etc.

Portaudio (PA) is a cross-platform library.

freeswitch@internal> load mod_portaudio

+OK

2009-09-13 10:33:16.034204 [WARNING] mod_portaudio.c:982 Invalid ring device configured using output device
freeswitch@internal> 2009-09-13 10:33:16.034204 [INFO] mod_portaudio.c:1172 PortAudio version number = 1899
PortAudio version text = 'PortAudio V19-devel (built Sep  9 2009)'
2009-09-13 10:33:16.034204 [INFO] mod_portaudio.c:1196 Number of devices = 1
2009-09-13 10:33:16.035306 [DEBUG] mod_portaudio.c:818 Input Device: 0, Output Device: 0, Ring Device: 0 Sample Rate: 8000 MS: 20
2009-09-13 10:33:16.224531 [CONSOLE] switch_loadable_module.c:889 Successfully Loaded [mod_portaudio]
2009-09-13 10:33:16.224531 [NOTICE] switch_loadable_module.c:142 Adding Endpoint 'portaudio'
2009-09-13 10:33:16.225672 [NOTICE] switch_loadable_module.c:270 Adding API Function 'pa'

freeswitch@internal> pa devlist
0;/dev/dsp;16;16;r,i,o
?

http://wiki.freeswitch.org/wiki/Freeswitch_softphone

http://simon-listens.blogspot.com/2009/05/ubuntu-904-and-simon.html

Audacity

Audacity has now been packaged with a proper "alsa: pulse" device listed, in a ppa for ubuntu intrepid. See https://launchpad.net/~diwic/+archive

The following is information for versions without the pulseaudio patch:

Audacity doesn't support PulseAudio, nor Esound for the moment. You'll have to kill or suspend pulseaudio before you use this application. Audacity uses the PortAudio cross-platform Audio API which doesnt support pulseaudio. Some work was started on making portaudio support PulseAudio but this does not appear to be under active development currently and does not work in it's current state.

Audacity can use OSS for sound input and sound output. By changing the 2 settings in preferences to /dev/dsp, and running audacity as

padsp audacity

you route OSS sound through pulseaudio and can have successful playback and recording with audacity. You could also set the sound input to be ALSA which (for regular users) is less likely to be blocked by another application, as recording with multiple applications at once is less commonly done

Using pasuspender to momentarily suspend pulseaudio is another way to use Audacity.

pasuspender -- audacity <argument>

http://www.nabble.com/portaudio-and-pulseaudio-td19736624.html

pulseaudio security vulnerability

The PulseAudio binary is affected by a local race condition. If the binary is installed as SUID root, it is possible to exploit this vulnerability to gain root privileges. This attack requires that a local attacker can create hard links on the same hard disk partition on which PulseAudio is installed (i.e. /usr/bin and /tmp reside on the same partition).

freeswitch@bringout-laptop:~$ sudo chmod u-s `which pulseaudio`

freeswitch@bringout-laptop:~$ pa_devs

podešenje portaudio za freeswitch

kada sam stavio da freeswitch pripada grupi admin dobio sam 8 uređaja sa pa_devs

nakon toga restartovao freeswitch

fs_cli>load mod_portaudio

freeswitch@internal> pa devlist

0;/dev/dsp;16;16;r,i,o
1;HDA Intel: ALC268 Analog (hw:0,0);2;2;
2;front;0;2;
3;surround40;0;2;
4;surround51;0;2;
5;surround71;0;2;
6;dmix;0;2;

freeswitch@internal> pa indev #1
indev set to 1

freeswitch@internal> pa outdev #1
outdev set to 1

NE ne treba setovati device-ove, load mod_portaudio automatski dobro određuje ulazni i izlani uređaj

pjproject, pjsip

bringout@nmraka-2:~/devel/work/qjsimple/pjproject-1.3/pjsip-apps/src/python

relocation R_X86_64_32S against `pjsua_var' can not be used when making a shared object; recompile with -fPIC

http://dev.sipdoc.net/projects/yass/wiki/Intro

YASS - Yet Another SIP Softphone

YASS began as a university project, and after some effort to make it (really) work, has been released to the public. Apart from being a SIP softphone, YASS pretends to be a simple and small SDK to develop VoIP applications in Python.

It's based on PJSIP's pjsua Python bindings (thank you PJSIP guys!) for the core and the Qt4 libraries for the GUI part. Communication between the core and the GUI is made through callbacks, so it's completely detached.

Hope you enjoy using it the same I enjoyed coding it ;)

sudo apt-get install python-dns

deb http://deb.sipdoc.net debian main

apt-get install yass

http://www.pulseaudio.org/wiki/PerfectSetup#ALSAApplications

http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2008-August/004380.html

I think it's a good idea to use pulseaudio in PJSIP (even that I don't know how to do it). Ubuntu hardy heron 8.04 uses pulseaudio as the default sound mixer and is the tendency to just use pulseaudio, over ubuntu faisty 7.10 it uses portaudio.

I was using PJSIP over faisty and had no any problems with sound (well, I think), but when start using ubuntu 8.04 it has been a really mess working with PJSIP, and the compatibility is almost null.

The only way to use PJSIP with pulseaudio was doing the following thinks:

execute the software suspending pulseaudio.

$pasuspender ./sndtest-i686-pc-linux-gnu

And compiling PJSIP for OSS. Using Alsa doesn't show better results.

This two things makes to have only the sound of PJSIP and no other program.

Reading over the net, I found that portaudio is more cross platform and works really near of the kernel. Audacity is a software for record and manipulate audio, and uses portaudio, there is no wrapper for pulseaudio or
something.

Even that I know that VoIP has some of Real Time requirements (and maybe for this Pulseaudio could not be considered), not trying with pulseaudio could be something like being not compatible with Ubuntu over its lasts versions.

What I say here it's just my appreciation and is nothing formal.

Akcije #5

Izmjenjeno od Ernad Husremović prije skoro 15 godina

  • Status promijenjeno iz Dodijeljeno u Zatvoreno
Akcije

Također dostupno kao Atom PDF