Created
March 9, 2015 05:46
-
-
Save calbrecht/ee073be73f8893f2f0ae to your computer and use it in GitHub Desktop.
DBus monitor empathy call state and setup module-echo-cancel with webrtc on pulseaudio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
case $1 in | |
dbus-monitor) | |
interface=org.freedesktop.Telepathy.Channel.Type.Call1 | |
member=CallStateChanged | |
dbus-monitor "interface='$interface',member='$member'" | | |
while read -r line; do | |
[[ "$line" =~ ^signal ]] && LINENUM=1 || LINENUM=$((LINENUM + 1)) | |
if [[ $LINENUM = 2 ]] ; then | |
case ${line#uint32 } in | |
# Unknown (0) | |
# The call ddstate is not known. This call state MUST NOT appear as a value of the CallState property, but MAY be used by client code to represent calls whose state is as yet unknown. | |
# Pending_Initiator (1) | |
# The initiator of the call hasn't accepted the call yet. This state only makes sense for outgoing calls, where it means that the local user has not yet sent any signalling messages to the remote user(s), and will not do so until Accept is called. | |
# Initialising (2) | |
# Progress has been made in placing the call, but the contact has not been made aware of the call yet. This corresponds to SIP's status code 183 Session Progress, and should be used for the period where the CM is waiting for the streaming implementation to initialise (before sending the initial INVITE or equivalent) and when the outgoing call has reached a gateway or ICE negotiation is pending. UIs should not produce a dialtone or start ringing if the call is in this state. | |
3|4) | |
# Initialised (3) | |
# In the outgoing case: at least one called user has been alerted about the call (a SIP 180 (Ringing) packet or equivalent has been received) but none have answered, so the call cannot go to Accepted (use Ringing to determine which members have been informed and which haven't, if you care). UIs SHOULD produce a dialtone for outgoing calls in this state. In the incoming case, the local user should be informed of the call as soon as the call reaches this state (and SetRinging should be called to inform the CM that this has happened, so that it can relay this fact to the caller using a SIP 180 (Ringing) packet or equivalent). | |
$0 start | |
;; | |
# Accepted (4) | |
# The contact being called has accepted the call, but the call is not in the Active state (The most common reason for this is that the streaming implementation hasn't connected yet). | |
# Active (5) | |
# The contact being called has accepted the call, and discourse between at least two parties should now be possible. | |
6) | |
$0 stop | |
# Ended (6) | |
# The call has ended, either via normal termination or an error. | |
;; | |
esac | |
fi | |
done | |
;; | |
start) | |
pactl load-module module-echo-cancel \ | |
sink_master=alsa_output.pci-0000_00_1b.0.analog-stereo \ | |
source_master=alsa_input.pci-0000_00_1b.0.analog-stereo \ | |
aec_method=webrtc \ | |
>/dev/null 2>&1 | |
;; | |
stop) | |
pactl unload-module module-echo-cancel | |
;; | |
esac | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment