[Jingle] Don't end the session on a content failure, only remove the content
This commit is contained in:
parent
10554ff067
commit
50482f7c2a
|
@ -196,7 +196,7 @@ class JingleRTPContent(JingleContent):
|
||||||
if state == farsight.STREAM_STATE_FAILED:
|
if state == farsight.STREAM_STATE_FAILED:
|
||||||
reason = xmpp.Node('reason')
|
reason = xmpp.Node('reason')
|
||||||
reason.setTag('failed-transport')
|
reason.setTag('failed-transport')
|
||||||
self.session._session_terminate(reason)
|
self.session.remove_content(self.creator, self.name, reason)
|
||||||
elif name == 'farsight-error':
|
elif name == 'farsight-error':
|
||||||
print 'Farsight error #%d!' % message.structure['error-no']
|
print 'Farsight error #%d!' % message.structure['error-no']
|
||||||
print 'Message: %s' % message.structure['error-msg']
|
print 'Message: %s' % message.structure['error-msg']
|
||||||
|
@ -217,6 +217,7 @@ class JingleRTPContent(JingleContent):
|
||||||
|
|
||||||
# Remove old source
|
# Remove old source
|
||||||
self.src_bin.get_pad('src').unlink(sink_pad)
|
self.src_bin.get_pad('src').unlink(sink_pad)
|
||||||
|
self.src_bin.set_state(gst.STATE_NULL)
|
||||||
self.pipeline.remove(self.src_bin)
|
self.pipeline.remove(self.src_bin)
|
||||||
|
|
||||||
if not self.stream_failed_once:
|
if not self.stream_failed_once:
|
||||||
|
@ -229,7 +230,7 @@ class JingleRTPContent(JingleContent):
|
||||||
# TODO: remove content, don't kill session
|
# TODO: remove content, don't kill session
|
||||||
reason = xmpp.Node('reason')
|
reason = xmpp.Node('reason')
|
||||||
reason.setTag('failed-application')
|
reason.setTag('failed-application')
|
||||||
self.session._session_terminate(reason)
|
self.session.remove_content(self.creator, self.name, reason)
|
||||||
|
|
||||||
# Start playing again
|
# Start playing again
|
||||||
self.pipeline.set_state(gst.STATE_PLAYING)
|
self.pipeline.set_state(gst.STATE_PLAYING)
|
||||||
|
|
|
@ -184,17 +184,18 @@ class JingleSession(object):
|
||||||
# The content is from us, accept it
|
# The content is from us, accept it
|
||||||
content.accepted = True
|
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:
|
if (creator, name) in self.contents:
|
||||||
content = self.contents[(creator, name)]
|
content = self.contents[(creator, name)]
|
||||||
if len(self.contents) > 1:
|
if len(self.contents) > 1:
|
||||||
self.__content_remove(content)
|
self.__content_remove(content, reason)
|
||||||
self.contents[(creator, name)].destroy()
|
self.contents[(creator, name)].destroy()
|
||||||
if len(self.contents) == 0:
|
if not self.contents:
|
||||||
self.end_session()
|
self.end_session()
|
||||||
|
|
||||||
def modify_content(self, creator, name, *someother):
|
def modify_content(self, creator, name, *someother):
|
||||||
|
@ -549,7 +550,7 @@ class JingleSession(object):
|
||||||
break
|
break
|
||||||
return (reason, text)
|
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))
|
stanza = xmpp.Iq(typ='set', to=xmpp.JID(self.peerjid))
|
||||||
attrs = {'action': action,
|
attrs = {'action': action,
|
||||||
'sid': self.sid}
|
'sid': self.sid}
|
||||||
|
@ -558,6 +559,8 @@ class JingleSession(object):
|
||||||
elif action == 'session-accept':
|
elif action == 'session-accept':
|
||||||
attrs['responder'] = self.responder
|
attrs['responder'] = self.responder
|
||||||
jingle = stanza.addChild('jingle', attrs=attrs, namespace=xmpp.NS_JINGLE)
|
jingle = stanza.addChild('jingle', attrs=attrs, namespace=xmpp.NS_JINGLE)
|
||||||
|
if reason is not None:
|
||||||
|
jingle.addChild(node=reason)
|
||||||
return stanza, jingle
|
return stanza, jingle
|
||||||
|
|
||||||
def __send_error(self, stanza, error, jingle_error=None, text=None, type_=None):
|
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):
|
def _session_terminate(self, reason=None):
|
||||||
assert self.state != JingleStates.ended
|
assert self.state != JingleStates.ended
|
||||||
stanza, jingle = self.__make_jingle('session-terminate')
|
stanza, jingle = self.__make_jingle('session-terminate', reason=reason)
|
||||||
if reason is not None:
|
|
||||||
jingle.addChild(node=reason)
|
|
||||||
self.__broadcast_all(stanza, jingle, None, 'session-terminate-sent')
|
self.__broadcast_all(stanza, jingle, None, 'session-terminate-sent')
|
||||||
self.connection.connection.send(stanza)
|
self.connection.connection.send(stanza)
|
||||||
# TODO: Move to GUI?
|
# TODO: Move to GUI?
|
||||||
|
@ -659,9 +660,9 @@ class JingleSession(object):
|
||||||
def __content_modify(self):
|
def __content_modify(self):
|
||||||
assert self.state != JingleStates.ended
|
assert self.state != JingleStates.ended
|
||||||
|
|
||||||
def __content_remove(self, content):
|
def __content_remove(self, content, reason=None):
|
||||||
assert self.state != JingleStates.ended
|
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.__append_content(jingle, content)
|
||||||
self.connection.connection.send(stanza)
|
self.connection.connection.send(stanza)
|
||||||
# TODO: this will fail if content is not an RTP content
|
# TODO: this will fail if content is not an RTP content
|
||||||
|
|
Loading…
Reference in New Issue