summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2017-11-14 17:31:03 -0500
committerOlivier CrĂȘte <olivier.crete@collabora.com>2017-11-14 17:31:03 -0500
commit6c3ded360addb03c75634adb521526f23028a85b (patch)
tree8ef2749704f4f5c808259c5a1ecf56eadadbd2ae
parent01f01a59cf6e39dd37c22caf3166e63a508903e1 (diff)
downloadfarstream-6c3ded360addb03c75634adb521526f23028a85b.tar.gz
fs-gui: Use accessor functions to parse messages
Getting boxed types from GstMessage manually is just too error prone.
-rwxr-xr-xexamples/gui/fs-gui.py61
1 files changed, 36 insertions, 25 deletions
diff --git a/examples/gui/fs-gui.py b/examples/gui/fs-gui.py
index 0ec16ac9..7ce937cc 100755
--- a/examples/gui/fs-gui.py
+++ b/examples/gui/fs-gui.py
@@ -140,34 +140,45 @@ class FsUIPipeline (GObject.Object):
elif message.type == Gst.MessageType.LATENCY:
self.pipeline.recalculate_latency()
elif message.type == Gst.MessageType.ELEMENT:
+ sessions = []
+ if AUDIO:
+ sessions += [self.audiosession]
+ if VIDEO:
+ sessions += [self.videosession]
+ for session in sessions:
+ (changed, codec, sec_codecs) = session.fssession.parse_send_codec_changed(message)
+ if changed:
+ print "Send codec changed: " + codec.to_string()
+ if changed or session.fssession.parse_codecs_changed(message):
+ print "Codecs changed"
+
+ if self.audiosession == session:
+ self.codecs_changed_audio()
+ if self.videosession == session:
+ self.codecs_changed_video()
+ return True
+
+ for stream in session.streams:
+ (res, candidate) = stream.fsstream.parse_new_local_candidate(message)
+ if res:
+ print "New Local candidate"
+ stream.new_local_candidate(candidate)
+ return True
+
+ (res, codecs) = stream.fsstream.parse_recv_codecs_changed(message)
+ if res:
+ print "Receive codecs changed"
+ stream.recv_codecs_changed(codecs)
+ return True
+
+ if stream.fsstream.parse_local_candidates_prepared(message):
+ print "Local candidates prepared"
+ stream.local_candidates_prepared()
+ return True
+
if message.get_structure().has_name("dtmf-event"):
print "dtmf-event: %d" % message.get_structure().get_int("number")
- elif message.get_structure().has_name("farstream-local-candidates-prepared"):
- message.get_structure().get_value("stream").uistream.local_candidates_prepared()
- elif message.get_structure().has_name("farstream-new-local-candidate"):
- message.get_structure().get_value("stream").uistream.new_local_candidate(
- message.get_structure().get_value("candidate"))
- elif message.get_structure().has_name("farstream-codecs-changed"):
- print message.src.get_name(), ": ", message.get_structure().get_name()
- message.get_structure().get_value("session").uisession.codecs_changed()
- if AUDIO and message.get_structure().get_value("session") == self.audiosession.fssession:
- self.codecs_changed_audio()
- if VIDEO and message.get_structure().get_value("session") == self.videosession.fssession:
- self.codecs_changed_video()
- elif message.get_structure().has_name("farstream-send-codec-changed"):
- print message.src.get_name(), ": ", message.get_structure().get_name()
- print "send codec changed: " + message.get_structure().get_value("codec").to_string()
- if AUDIO and message.get_structure().get_value("session") == self.audiosession.fssession:
- self.codecs_changed_audio()
- if VIDEO and message.get_structure().get_value("session") == self.videosession.fssession:
- self.codecs_changed_video()
- elif message.get_structure().has_name("farstream-recv-codecs-changed"):
- print message.src.get_name(), ": ", message.get_structure().get_name()
- message.get_structure().get_value("stream").uistream.recv_codecs_changed( \
- message.get_structure().get_value("codecs"))
-
-
elif message.get_structure().has_name("farstream-error"):
print "Async error ("+ str(message.get_structure().get_int("error-no")) +"): " + message.get_structure().get_string("error-msg")
elif message.get_structure().has_name("level"):