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()
|
||||
if namespace in contents:
|
||||
return contents[namespace](node)
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class JingleContent(object):
|
||||
|
@ -74,7 +72,7 @@ class JingleContent(object):
|
|||
}
|
||||
|
||||
def is_ready(self):
|
||||
return (self.accepted and not self.sent)
|
||||
return self.accepted and not self.sent
|
||||
|
||||
def add_remote_candidates(self, candidates):
|
||||
"""
|
||||
|
|
|
@ -182,7 +182,9 @@ class JingleRTPContent(JingleContent):
|
|||
self.session.content_negociated(self.media)
|
||||
|
||||
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:
|
||||
return
|
||||
|
||||
|
@ -198,7 +200,7 @@ class JingleRTPContent(JingleContent):
|
|||
codec.iterTags('parameter')]
|
||||
codecs.append(c)
|
||||
|
||||
if len(codecs) > 0:
|
||||
if codecs:
|
||||
# FIXME: Handle this case:
|
||||
# glib.GError: There was no intersection between the remote codecs and
|
||||
# the local ones
|
||||
|
@ -216,7 +218,8 @@ class JingleRTPContent(JingleContent):
|
|||
if codec.optional_params:
|
||||
payload = (xmpp.Node('parameter', {'name': name, 'value': value})
|
||||
for name, value in codec.optional_params)
|
||||
else: payload = ()
|
||||
else:
|
||||
payload = ()
|
||||
yield xmpp.Node('payload-type', attrs, payload)
|
||||
|
||||
def __stop(self, *things):
|
||||
|
@ -319,7 +322,5 @@ def get_content(desc):
|
|||
return JingleAudio
|
||||
elif desc['media'] == 'video':
|
||||
return JingleVideo
|
||||
else:
|
||||
return None
|
||||
|
||||
contents[xmpp.NS_JINGLE_RTP] = get_content
|
||||
|
|
|
@ -154,7 +154,7 @@ class JingleSession(object):
|
|||
|
||||
def get_content(self, media=None):
|
||||
if media is None:
|
||||
return None
|
||||
return
|
||||
|
||||
for content in self.contents.values():
|
||||
if content.media == media:
|
||||
|
@ -353,7 +353,7 @@ class JingleSession(object):
|
|||
def __on_session_info(self, stanza, jingle, error, action):
|
||||
# TODO: ringing, active, (un)hold, (un)mute
|
||||
payload = jingle.getPayload()
|
||||
if len(payload) > 0:
|
||||
if payload:
|
||||
self.__send_error(stanza, 'feature-not-implemented', 'unsupported-info')
|
||||
raise xmpp.NodeProcessed
|
||||
|
||||
|
@ -367,7 +367,7 @@ class JingleSession(object):
|
|||
self.connection.dispatch('JINGLE_DISCONNECTED',
|
||||
(self.peerjid, self.sid, content.media, 'removed'))
|
||||
content.destroy()
|
||||
if len(self.contents) == 0:
|
||||
if not self.contents:
|
||||
reason = xmpp.Node('reason')
|
||||
reason.setTag('success')
|
||||
self._session_terminate(reason)
|
||||
|
@ -469,7 +469,8 @@ class JingleSession(object):
|
|||
if text:
|
||||
text = '%s (%s)' % (reason, text)
|
||||
else:
|
||||
text = reason#TODO
|
||||
# TODO
|
||||
text = reason
|
||||
self.connection.dispatch('JINGLE_DISCONNECTED',
|
||||
(self.peerjid, self.sid, None, text))
|
||||
|
||||
|
@ -481,7 +482,7 @@ class JingleSession(object):
|
|||
content.on_stanza(stanza, None, error, action)
|
||||
|
||||
def __parse_contents(self, jingle):
|
||||
#TODO: Needs some reworking
|
||||
# TODO: Needs some reworking
|
||||
contents = []
|
||||
contents_rejected = []
|
||||
contents_ok = False
|
||||
|
|
|
@ -23,8 +23,6 @@ def get_jingle_transport(node):
|
|||
namespace = node.getNamespace()
|
||||
if namespace in transports:
|
||||
return transports[namespace]()
|
||||
else:
|
||||
return None
|
||||
|
||||
|
||||
class TransportType(object):
|
||||
|
|
Loading…
Add table
Reference in a new issue