[farsight2/master] Add possibility to send DTMF from test-gui
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:21:46 PST 2008
---
tests/gui/fs2-gui.glade | 316 ++++++++++++++++++++++++++++++++++++++++++++++-
tests/gui/fs2-gui.py | 55 ++++++++-
2 files changed, 363 insertions(+), 8 deletions(-)
diff --git a/tests/gui/fs2-gui.glade b/tests/gui/fs2-gui.glade
index 962286e..a53687d 100644
--- a/tests/gui/fs2-gui.glade
+++ b/tests/gui/fs2-gui.glade
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.0 on Thu Dec 20 21:14:41 2007 -->
+<!--Generated with glade3 3.4.0 on Thu Mar 20 18:26:57 2008 -->
<glade-interface>
<widget class="GtkWindow" id="main_window">
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
@@ -85,7 +85,18 @@
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="spacing">6</property>
- <property name="layout_style">GTK_BUTTONBOX_END</property>
+ <property name="layout_style">GTK_BUTTONBOX_EDGE</property>
+ <child>
+ <widget class="GtkButton" id="dtmf_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">DTMF</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="show_dtmf"/>
+ </widget>
+ </child>
<child>
<widget class="GtkButton" id="button2">
<property name="visible">True</property>
@@ -99,6 +110,7 @@
</widget>
<packing>
<property name="pack_type">GTK_PACK_END</property>
+ <property name="position">1</property>
</packing>
</child>
</widget>
@@ -343,4 +355,304 @@
</widget>
</child>
</widget>
+ <widget class="GtkWindow" id="dtmf_window">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="title" translatable="yes">Send DTMF</property>
+ <child>
+ <widget class="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">12</property>
+ <child>
+ <widget class="GtkVBox" id="vbox3">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <child>
+ <widget class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Send DTMF as:</property>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="dtmf_as_event">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">RFC-4733 DTMF Event </property>
+ <property name="response_id">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkRadioButton" id="dtmf_as_sound">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Sound</property>
+ <property name="response_id">0</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">dtmf_as_event</property>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">6</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkTable" id="table1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="n_rows">4</property>
+ <property name="n_columns">3</property>
+ <property name="column_spacing">6</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <widget class="GtkButton" id="dtmf_1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">1</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="1"/>
+ <signal name="released" handler="dtmf_stop" object="1"/>
+ </widget>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_2">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">2</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="2"/>
+ <signal name="released" handler="dtmf_stop" object="2"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">3</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="3"/>
+ <signal name="released" handler="dtmf_stop" object="3"/>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_4">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">4</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="4"/>
+ <signal name="released" handler="dtmf_stop" object="4"/>
+ </widget>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_5">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">5</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="5"/>
+ <signal name="released" handler="dtmf_stop" object="5"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_6">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">6</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="6"/>
+ <signal name="released" handler="dtmf_stop" object="6"/>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_7">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">7</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="7"/>
+ <signal name="released" handler="dtmf_stop" object="7"/>
+ </widget>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_8">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">8</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="8"/>
+ <signal name="released" handler="dtmf_stop" object="8"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_9">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">9</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="9"/>
+ <signal name="released" handler="dtmf_stop" object="9"/>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_star">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">*</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="*"/>
+ <signal name="released" handler="dtmf_stop" object="*"/>
+ </widget>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_0">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">0</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="0"/>
+ <signal name="released" handler="dtmf_stop" object="0"/>
+ </widget>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkButton" id="dtmf_pound">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">#</property>
+ <property name="response_id">0</property>
+ <signal name="pressed" handler="dtmf_start" object="#"/>
+ <signal name="released" handler="dtmf_stop" object="#"/>
+ </widget>
+ <packing>
+ <property name="left_attach">2</property>
+ <property name="right_attach">3</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkHBox" id="hbox1">
+ <property name="visible">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="spacing">6</property>
+ <child>
+ <widget class="GtkButton" id="button1">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">gtk-close</property>
+ <property name="use_stock">True</property>
+ <property name="response_id">0</property>
+ <signal name="clicked" handler="dtmf_destroy"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">6</property>
+ <property name="pack_type">GTK_PACK_END</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="padding">6</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </widget>
+ </child>
+ </widget>
</glade-interface>
diff --git a/tests/gui/fs2-gui.py b/tests/gui/fs2-gui.py
index 35852b8..e8e36e2 100644
--- a/tests/gui/fs2-gui.py
+++ b/tests/gui/fs2-gui.py
@@ -143,7 +143,10 @@ class FsUIPipeline:
elif message.type == gst.MESSAGE_WARNING:
print message.src.get_name(), ": ", message.parse_warning()
elif message.type == gst.MESSAGE_ELEMENT:
- print message.src.get_name(), ": ", message.structure.get_name()
+ if message.structure.has_name("dtmf-event"):
+ print "dtmf-event: %d" % message.structure["number"]
+ else:
+ print message.src.get_name(), ": ", message.structure.get_name()
return True
@@ -270,11 +273,11 @@ class FsUIAudioSource(FsUISource):
return farsight.MEDIA_TYPE_AUDIO
def make_source(self):
- #source = gst.element_factory_make("audiotestsrc")
- #source.set_property("is-live", True)
- #source.set_property("wave", 5)
- #return source
- return gst.element_factory_make("alsasrc")
+ source = gst.element_factory_make("audiotestsrc")
+ source.set_property("is-live", True)
+ source.set_property("wave", 4)
+ return source
+ #return gst.element_factory_make("alsasrc")
@@ -349,6 +352,18 @@ class FsUISession:
stream = FsUIStream(id, self, participant, realstream)
self.streams[id] = stream
return stream
+
+ def dtmf_start(self, event, method):
+ if (event == "*"):
+ event = farsight.DTMF_EVENT_STAR
+ elif (event == "#"):
+ event = farsight.DTMF_EVENT_POUND
+ else:
+ event = int(event)
+ self.fssession.start_telephony_event(event, 2, method)
+
+ def dtmf_stop(self, method):
+ self.fssession.stop_telephony_event(method)
class FsUIStream:
@@ -619,6 +634,34 @@ class FsMainUI:
gtk.main_quit()
gtk.gdk.threads_leave()
+ def show_dtmf(self, button):
+ try:
+ self.dtmf.present()
+ except AttributeError:
+ self.dtmf = gtk.glade.XML(gladefile, "dtmf_window")
+ self.dtmf.signal_autoconnect(self)
+
+ def dtmf_start(self, button):
+ if (self.dtmf.get_widget("dtmf_as_event").get_active()):
+ self.dtmf_last_method = farsight.DTMF_METHOD_RTP_RFC4733
+ elif (self.dtmf.get_widget("dtmf_as_sound").get_active()):
+ self.dtmf_last_method = farsight.DTMF_METHOD_IN_BAND
+ else:
+ print "Invalid DTMF Method"
+ return
+ self.pipeline.audiosession.dtmf_start(button.get_label(), \
+ self.dtmf_last_method)
+
+ def dtmf_stop(self, button):
+ try:
+ self.pipeline.audiosession.dtmf_stop(self.dtmf_last_method)
+ del self.dtmf_last_method
+ except AttributeError:
+ pass
+ def dtmf_destroy(self, button):
+ self.dtmf.get_widget("dtmf_window").destroy()
+ del self.dtmf
+
class FsUIStartup:
"Displays the startup window and then creates the FsMainUI"
--
1.5.6.5
More information about the farsight-commits
mailing list