mod_portaudio
About
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.
Many Softphones use embedded FreeSWITCH and portaudio at their core. Two examples are FSComm a QT4 cross platform communicator and FSClient a Windows .NET 4.0 softphone.
Portaudio (PA) is a cross-platform library.
Beware mod_portaudio recently had a large hunk of code injected into it and the configuration related to Shared Streams. For most scenarios this is not required and my throw (generally harmless) errors. Please see the note on #Shared_Streams_and_Endpoints for more details.
Features
- Mulitiple calls with hold/call switching.
- Inbound calls can play a ring file on specified device. (global and per call)
- Optional hold music for backgrounded calls. (global and per call)
- Switch audio devices even during a call (see live-stream-switching)
- DTMF and deaf/mute options
Click here to expand Table of Contents
- 1 Features
- 2 Command Reference
- 2.1 pa help - print usage summary
- 2.2 pa devlist [xml] - list audio devices
- 2.3 pa indev (device_ident), pa outdev (device_ident), pa switchstream (in_device_ident) (out_device_ident) - Set input/output device streams
- 2.4 pa ringdev (device_ident)
- 2.5 pa preparestream (in_device_ident) (out_device_ident) - Prepare an input and output device stream for use
- 2.6 pa call (number) [(dialplan)] [(cid_name)] [(cid_num)] - Place a new call
- 2.7 pa switch [(call_id)|none] - swap to a new active call
- 2.8 pa list - view the current calls
- 2.9 pa dtmf (dtmf_digits) - send a dtmf string (1234) to the current call
- 2.10 pa answer [(call_id)] - Answer a ringing call
- 2.11 pa hangup [(call_id)] - End a call
- 2.12 pa rescan - Look for new devices
- 2.13 pa play [ringtest|(filename)] [(seconds)] [no_close] - Play an audio file or test stream to a device
- 2.14 pa playdev (device_ident) [ringtest|(filename)] [(seconds)] [no_close] - Play an audio file or test stream to a specific device
- 2.15 pa flags on|off [ear] [mouth] - Set mute or deaf
- 2.16 pa closestreams - Will close all active open streams
- 2.17 pa dump - Debug dump of all the devices
- 3 Sample Implementations
- 4 Web GUI
- 5 Install Notes
- 5.1 RHEL/CentOS
- 5.2 Windows
- 5.3 macOS
- 5.4 FreeBSD
- 6 Reference
- 7 See Also
Command Reference
- A device_ident is either part of the device name or the device ID number (prefixed with a #) seen in pa devlist.
pa help - print usage summary
Will show the available commands
pa devlist [xml] - list audio devices
The list will be in the following format: device number;short name;input channels;output channels;freeswitch device configuration
The freeswitch device configuration is a comma separated list of these elements:
r device is ring device i device is input device o device is output device
For example:
API CALL [pa(devlist)] output:
0;AC97 Audio (PCM);2;0
1;AC97 Audio (PCM);0;2
2;AC97 Audio (SPDIF);0;2
3;Jabra BT500;1;1
pa indev (device_ident), pa outdev (device_ident), pa switchstream (in_device_ident) (out_device_ident) - Set input/output device streams
Set the input (indev) or output (outdev) audio stream identified by device_ident. pa switchstream can switch both streams at once. These functions can only be use during a call if live-stream-switch configuration option is on.
pa ringdev (device_ident)
Set the device for portaudio to ring on a ringing call.
pa preparestream (in_device_ident) (out_device_ident) - Prepare an input and output device stream for use
Not required but preparing a stream prior to switching to it using the indev/outdev/switchstream allows portaudio to open the stream prior to using it. This makes for much more seamless switching between streams (no audio cut out). You only need to call this once before switching to that stream, streams are kept open until the end of all active calls. Calling it multiple times on the same stream will not cause delays or have negative effects.
pa call (number) [(dialplan)] [(cid_name)] [(cid_num)] - Place a new call
If you currently are on a call the existing call is placed on hold.
pa switch [(call_id)|none] - swap to a new active call
If used without args will switch to the previously active call. If a call_id (from pa list) is past will make that call active. If none is past then all calls are placed on hold.
pa list - view the current calls
pa list
pa dtmf (dtmf_digits) - send a dtmf string (1234) to the current call
pa dtmf 1234
pa answer [(call_id)] - Answer a ringing call
Without a call_id will answer the oldest call, with the call ID will answer that specific call
pa hangup [(call_id)] - End a call
Will end the current call if no ID is given otherwise will end the call with that ID.
pa rescan - Look for new devices
Portaudio assumes devices will not change during use, if they do you will need to use rescan for portaudio to see them. As this causes portaudio to re-init several things it cannot be used during an active call.
pa play [ringtest|(filename)] [(seconds)] [no_close] - Play an audio file or test stream to a device
Allows playing of arbitrary audio on the outdev device, optionally for only a specific number of seconds. no_close causes the audio stream to remain open after playing (allows for faster concurrent playing)
pa playdev (device_ident) [ringtest|(filename)] [(seconds)] [no_close] - Play an audio file or test stream to a specific device
Same as play but takes the device to play to also
pa flags on|off [ear] [mouth] - Set mute or deaf
Mutes the indev so no audio is directed to an active call, or deaf will silence the outdev from playing and audio
pa closestreams - Will close all active open streams
By default all streams are only closed at the end of all active calls, you can force them to close using pa closestreams as long as there is not an active call.
pa dump - Debug dump of all the devices
Dumps a variety of information about the various audio devices PA sees