[Telepathy-commits] [mingle/master] Move Farsight object into private variables and add a function to remove them
Sjoerd Simons
sjoerd at luon.net
Tue Nov 11 10:48:04 PST 2008
---
fs2.py | 39 ++++++++++++++++++++++++++++++---------
1 files changed, 30 insertions(+), 9 deletions(-)
diff --git a/fs2.py b/fs2.py
index 14b81c6..deafd80 100644
--- a/fs2.py
+++ b/fs2.py
@@ -118,14 +118,15 @@ class ConferenceStream:
def __init__(self, conference, session, fsstream):
self.conference = conference
self.session = session
- self.fsstream = fsstream
+ self._fsstream = fsstream
self.newLocalCandidate = CallbackList()
self.componentStateChanged = CallbackList()
self.candidates = []
+ self.sinks = []
self.src_pad_hook = self.default_src_pad_added
- self.fsstream.connect("src-pad-added",
+ self._fsstream.connect("src-pad-added",
self.src_pad_added)
def new_local_candidate(self, candidate):
@@ -136,10 +137,10 @@ class ConferenceStream:
self.componentStateChanged.callback(component, state)
def add_remote_candidate(self, candidate):
- self.fsstream.set_remote_candidates([candidate])
+ self._fsstream.set_remote_candidates([candidate])
def set_remote_codecs(self, codecs):
- self.fsstream.set_remote_codecs(codecs)
+ self._fsstream.set_remote_codecs(codecs)
def default_src_pad_added (self, session, stream, pad, codec):
if self.session.type == farsight.MEDIA_TYPE_VIDEO:
@@ -156,7 +157,22 @@ class ConferenceStream:
self.src_pad_hook (self, stream, pad, codec)
def set_direction(self, direction):
- self.fsstream.set_property("direction", direction)
+ self._fsstream.set_property("direction", direction)
+
+ def add_sink(self, sink):
+ self.sinks.append(sink)
+
+ def destroy(self):
+ for sink in self.sinks:
+ sink.set_locked_state(True)
+ sink.set_state(gst.STATE_NULL)
+ self.conference.remove(sink)
+ self.sinks = []
+
+ # Ensure that there are no refs left to the _fsstream
+ f = self._fsstream
+ self._fsstream = None
+ del f
class ConferenceSession:
@@ -217,18 +233,18 @@ class ConferenceSession:
def add_participant(self, participant, transmitter,
transmitter_params = {}, direction = farsight.DIRECTION_BOTH):
- fsstream = self.fssession.new_stream (participant.fsparticipant,
+ fsstream = self.fssession.new_stream (participant._fsparticipant,
direction, transmitter, transmitter_params)
stream = ConferenceStream(self.conference, self, fsstream)
+ del fsstream
self.conference.add_stream(stream)
return stream
-
class ConferenceParticipant:
def __init__(self, conference, fsparticipant, cname):
self.conference = conference
- self.fsparticipant = fsparticipant
+ self._fsparticipant = fsparticipant
self.cname = cname
class Conference(gst.Pipeline):
@@ -251,7 +267,12 @@ class Conference(gst.Pipeline):
self.fsstreams = {}
def add_stream(self, stream):
- self.fsstreams[stream.fsstream] = stream
+ self.fsstreams[stream._fsstream] = stream
+
+ def remove_stream(self, stream):
+ self.fsstreams.pop(stream._fsstream)
+ stream.destroy()
+ del stream
def create_session(self, type):
fs = self.conf.new_session(type)
--
1.5.6.5
More information about the Telepathy-commits
mailing list