[farsight2/master] Have the server pass around the stream codecs to everyone
Olivier Crête
olivier.crete at collabora.co.uk
Tue Dec 23 15:24:12 PST 2008
---
tests/gui/fs2-gui.py | 32 ++++++++++++++++++++++++++++++--
tests/gui/fs2_gui_net.py | 2 ++
2 files changed, 32 insertions(+), 2 deletions(-)
diff --git a/tests/gui/fs2-gui.py b/tests/gui/fs2-gui.py
index 0edd644..d1d1161 100644
--- a/tests/gui/fs2-gui.py
+++ b/tests/gui/fs2-gui.py
@@ -443,10 +443,19 @@ class FsUISession:
"Callback from FsSession"
for s in self.streams:
try:
- s().check_send_local_codecs()
+ s().codecs_changed()
except AttributeError:
pass
+ def send_stream_codecs(self, codecs, sourcestream):
+ for s in self.streams:
+ stream = s()
+ if stream and stream is not sourcestream:
+ stream.connect.send_codecs(stream.participant.id,
+ sourcestream.id,
+ codecs,
+ sourcestream.participant.id)
+
class FsUIStream:
"One participant in one session"
@@ -459,7 +468,8 @@ class FsUIStream:
self.fsstream.uistream = self
self.fsstream.connect("src-pad-added", self.__src_pad_added)
self.send_codecs = False
- self.last_codecs = []
+ self.last_codecs = None
+ self.last_stream_codecs = None
self.candidates = []
def local_candidates_prepared(self):
@@ -489,11 +499,15 @@ class FsUIStream:
for c in codecs:
print "Got remote codec from %s/%s %s" % \
(self.participant.id, self.id, c.to_string())
+ oldcodecs = self.fsstream.get_property("remote-codecs")
+ if oldcodecs == codecs:
+ return
try:
self.fsstream.set_remote_codecs(codecs)
except AttributeError:
print "Tried to set codecs with 0 codec"
self.send_local_codecs()
+ self.send_stream_codecs()
def send_local_codecs(self):
@@ -501,6 +515,10 @@ class FsUIStream:
self.send_codecs = True
self.check_send_local_codecs()
+ def codecs_changed(self):
+ self.check_send_local_codecs()
+ self.send_stream_codecs()
+
def check_send_local_codecs(self):
"Internal function to send our local codecs when they're ready"
if not self.send_codecs:
@@ -516,6 +534,15 @@ class FsUIStream:
print "sending local codecs"
self.connect.send_codecs(self.participant.id, self.id, codecs)
+ def send_stream_codecs(self):
+ if not self.connect.is_server:
+ return
+ if not self.session.fssession.get_property("codecs-ready"):
+ return
+ codecs = self.fsstream.get_property("negotiated-codecs")
+ if codecs:
+ self.session.send_stream_codecs(codecs, self)
+
def recv_codecs_changed(self, codecs):
self.participant.recv_codecs_changed()
@@ -523,6 +550,7 @@ class FsUIStream:
def __remove_from_send_codecs_to(self, participant):
self.send_codecs_to.remote(participant)
+
def send_codecs_to(self, participant):
codecs = self.fsstream.get_property("negotiated-codecs")
print "sending stream %s codecs from %s to %s" % \
diff --git a/tests/gui/fs2_gui_net.py b/tests/gui/fs2_gui_net.py
index c7c0e16..c834d77 100644
--- a/tests/gui/fs2_gui_net.py
+++ b/tests/gui/fs2_gui_net.py
@@ -68,6 +68,7 @@ class FsUIConnect:
self.callbacks = callbacks
self.myid = myid
self.partid = 1
+ self.is_server = True
sock.setblocking(0)
gobject.io_add_watch(self.sock.fileno(), gobject.IO_IN,
self.__data_in)
@@ -235,6 +236,7 @@ class FsUIConnectClient (FsUIConnect):
sock = socket.socket()
sock.connect((ip, port))
FsUIConnect.__init__(self, sock, callbacks)
+ self.is_server = False
class FsUIListener:
def __init__(self, port, callback, *args):
--
1.5.6.5
More information about the farsight-commits
mailing list