Tiny refactoring bits of jingle code
This commit is contained in:
parent
04d098b4ec
commit
aed9690dc5
4 changed files with 13 additions and 15 deletions
|
@ -21,8 +21,6 @@ def get_jingle_content(node):
|
||||||
namespace = node.getNamespace()
|
namespace = node.getNamespace()
|
||||||
if namespace in contents:
|
if namespace in contents:
|
||||||
return contents[namespace](node)
|
return contents[namespace](node)
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class JingleContent(object):
|
class JingleContent(object):
|
||||||
|
@ -74,7 +72,7 @@ class JingleContent(object):
|
||||||
}
|
}
|
||||||
|
|
||||||
def is_ready(self):
|
def is_ready(self):
|
||||||
return (self.accepted and not self.sent)
|
return self.accepted and not self.sent
|
||||||
|
|
||||||
def add_remote_candidates(self, candidates):
|
def add_remote_candidates(self, candidates):
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -182,7 +182,9 @@ class JingleRTPContent(JingleContent):
|
||||||
self.session.content_negociated(self.media)
|
self.session.content_negociated(self.media)
|
||||||
|
|
||||||
def __on_remote_codecs(self, stanza, content, error, action):
|
def __on_remote_codecs(self, stanza, content, error, action):
|
||||||
''' Get peer codecs from what we get from peer. '''
|
"""
|
||||||
|
Get peer codecs from what we get from peer
|
||||||
|
"""
|
||||||
if self.got_codecs:
|
if self.got_codecs:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -198,7 +200,7 @@ class JingleRTPContent(JingleContent):
|
||||||
codec.iterTags('parameter')]
|
codec.iterTags('parameter')]
|
||||||
codecs.append(c)
|
codecs.append(c)
|
||||||
|
|
||||||
if len(codecs) > 0:
|
if codecs:
|
||||||
# FIXME: Handle this case:
|
# FIXME: Handle this case:
|
||||||
# glib.GError: There was no intersection between the remote codecs and
|
# glib.GError: There was no intersection between the remote codecs and
|
||||||
# the local ones
|
# the local ones
|
||||||
|
@ -216,7 +218,8 @@ class JingleRTPContent(JingleContent):
|
||||||
if codec.optional_params:
|
if codec.optional_params:
|
||||||
payload = (xmpp.Node('parameter', {'name': name, 'value': value})
|
payload = (xmpp.Node('parameter', {'name': name, 'value': value})
|
||||||
for name, value in codec.optional_params)
|
for name, value in codec.optional_params)
|
||||||
else: payload = ()
|
else:
|
||||||
|
payload = ()
|
||||||
yield xmpp.Node('payload-type', attrs, payload)
|
yield xmpp.Node('payload-type', attrs, payload)
|
||||||
|
|
||||||
def __stop(self, *things):
|
def __stop(self, *things):
|
||||||
|
@ -319,7 +322,5 @@ def get_content(desc):
|
||||||
return JingleAudio
|
return JingleAudio
|
||||||
elif desc['media'] == 'video':
|
elif desc['media'] == 'video':
|
||||||
return JingleVideo
|
return JingleVideo
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
contents[xmpp.NS_JINGLE_RTP] = get_content
|
contents[xmpp.NS_JINGLE_RTP] = get_content
|
||||||
|
|
|
@ -154,7 +154,7 @@ class JingleSession(object):
|
||||||
|
|
||||||
def get_content(self, media=None):
|
def get_content(self, media=None):
|
||||||
if media is None:
|
if media is None:
|
||||||
return None
|
return
|
||||||
|
|
||||||
for content in self.contents.values():
|
for content in self.contents.values():
|
||||||
if content.media == media:
|
if content.media == media:
|
||||||
|
@ -353,7 +353,7 @@ class JingleSession(object):
|
||||||
def __on_session_info(self, stanza, jingle, error, action):
|
def __on_session_info(self, stanza, jingle, error, action):
|
||||||
# TODO: ringing, active, (un)hold, (un)mute
|
# TODO: ringing, active, (un)hold, (un)mute
|
||||||
payload = jingle.getPayload()
|
payload = jingle.getPayload()
|
||||||
if len(payload) > 0:
|
if payload:
|
||||||
self.__send_error(stanza, 'feature-not-implemented', 'unsupported-info')
|
self.__send_error(stanza, 'feature-not-implemented', 'unsupported-info')
|
||||||
raise xmpp.NodeProcessed
|
raise xmpp.NodeProcessed
|
||||||
|
|
||||||
|
@ -367,7 +367,7 @@ class JingleSession(object):
|
||||||
self.connection.dispatch('JINGLE_DISCONNECTED',
|
self.connection.dispatch('JINGLE_DISCONNECTED',
|
||||||
(self.peerjid, self.sid, content.media, 'removed'))
|
(self.peerjid, self.sid, content.media, 'removed'))
|
||||||
content.destroy()
|
content.destroy()
|
||||||
if len(self.contents) == 0:
|
if not self.contents:
|
||||||
reason = xmpp.Node('reason')
|
reason = xmpp.Node('reason')
|
||||||
reason.setTag('success')
|
reason.setTag('success')
|
||||||
self._session_terminate(reason)
|
self._session_terminate(reason)
|
||||||
|
@ -469,7 +469,8 @@ class JingleSession(object):
|
||||||
if text:
|
if text:
|
||||||
text = '%s (%s)' % (reason, text)
|
text = '%s (%s)' % (reason, text)
|
||||||
else:
|
else:
|
||||||
text = reason#TODO
|
# TODO
|
||||||
|
text = reason
|
||||||
self.connection.dispatch('JINGLE_DISCONNECTED',
|
self.connection.dispatch('JINGLE_DISCONNECTED',
|
||||||
(self.peerjid, self.sid, None, text))
|
(self.peerjid, self.sid, None, text))
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,6 @@ def get_jingle_transport(node):
|
||||||
namespace = node.getNamespace()
|
namespace = node.getNamespace()
|
||||||
if namespace in transports:
|
if namespace in transports:
|
||||||
return transports[namespace]()
|
return transports[namespace]()
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
|
||||||
class TransportType(object):
|
class TransportType(object):
|
||||||
|
|
Loading…
Add table
Reference in a new issue