From 50482f7c2adb106672b014399986a560e345a4be Mon Sep 17 00:00:00 2001 From: Thibaut Girka <thib@sitedethib.com> Date: Tue, 4 May 2010 10:04:53 +0200 Subject: [PATCH] [Jingle] Don't end the session on a content failure, only remove the content --- src/common/jingle_rtp.py | 5 +++-- src/common/jingle_session.py | 23 ++++++++++++----------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/common/jingle_rtp.py b/src/common/jingle_rtp.py index 5b78fa6002..0bc6810036 100644 --- a/src/common/jingle_rtp.py +++ b/src/common/jingle_rtp.py @@ -196,7 +196,7 @@ class JingleRTPContent(JingleContent): if state == farsight.STREAM_STATE_FAILED: reason = xmpp.Node('reason') reason.setTag('failed-transport') - self.session._session_terminate(reason) + self.session.remove_content(self.creator, self.name, reason) elif name == 'farsight-error': print 'Farsight error #%d!' % message.structure['error-no'] print 'Message: %s' % message.structure['error-msg'] @@ -217,6 +217,7 @@ class JingleRTPContent(JingleContent): # Remove old source self.src_bin.get_pad('src').unlink(sink_pad) + self.src_bin.set_state(gst.STATE_NULL) self.pipeline.remove(self.src_bin) if not self.stream_failed_once: @@ -229,7 +230,7 @@ class JingleRTPContent(JingleContent): # TODO: remove content, don't kill session reason = xmpp.Node('reason') reason.setTag('failed-application') - self.session._session_terminate(reason) + self.session.remove_content(self.creator, self.name, reason) # Start playing again self.pipeline.set_state(gst.STATE_PLAYING) diff --git a/src/common/jingle_session.py b/src/common/jingle_session.py index 677bf5ec0d..65fcb180f0 100644 --- a/src/common/jingle_session.py +++ b/src/common/jingle_session.py @@ -184,17 +184,18 @@ class JingleSession(object): # The content is from us, accept it content.accepted = True - def remove_content(self, creator, name): + def remove_content(self, creator, name, reason=None): """ - We do not need this now + Remove the content `name` created by `creator` + by sending content-remove, or by sending session-terminate if + there is no content left. """ - #TODO: if (creator, name) in self.contents: content = self.contents[(creator, name)] if len(self.contents) > 1: - self.__content_remove(content) + self.__content_remove(content, reason) self.contents[(creator, name)].destroy() - if len(self.contents) == 0: + if not self.contents: self.end_session() def modify_content(self, creator, name, *someother): @@ -549,7 +550,7 @@ class JingleSession(object): break return (reason, text) - def __make_jingle(self, action): + def __make_jingle(self, action, reason=None): stanza = xmpp.Iq(typ='set', to=xmpp.JID(self.peerjid)) attrs = {'action': action, 'sid': self.sid} @@ -558,6 +559,8 @@ class JingleSession(object): elif action == 'session-accept': attrs['responder'] = self.responder jingle = stanza.addChild('jingle', attrs=attrs, namespace=xmpp.NS_JINGLE) + if reason is not None: + jingle.addChild(node=reason) return stanza, jingle def __send_error(self, stanza, error, jingle_error=None, text=None, type_=None): @@ -614,9 +617,7 @@ class JingleSession(object): def _session_terminate(self, reason=None): assert self.state != JingleStates.ended - stanza, jingle = self.__make_jingle('session-terminate') - if reason is not None: - jingle.addChild(node=reason) + stanza, jingle = self.__make_jingle('session-terminate', reason=reason) self.__broadcast_all(stanza, jingle, None, 'session-terminate-sent') self.connection.connection.send(stanza) # TODO: Move to GUI? @@ -659,9 +660,9 @@ class JingleSession(object): def __content_modify(self): assert self.state != JingleStates.ended - def __content_remove(self, content): + def __content_remove(self, content, reason=None): assert self.state != JingleStates.ended - stanza, jingle = self.__make_jingle('content-remove') + stanza, jingle = self.__make_jingle('content-remove', reason=reason) self.__append_content(jingle, content) self.connection.connection.send(stanza) # TODO: this will fail if content is not an RTP content -- GitLab