Changeset 8506
- Timestamp:
- 08/19/07 21:07:49 (17 months ago)
- Location:
- branches/jingle/src/common
- Files:
-
- 1 added
- 1 copied
-
jingle-handler.py (added)
-
jingle.popen.py (copied) (copied from branches/jingle/src/common/jingle.py) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/jingle/src/common/jingle.popen.py
r8498 r8506 15 15 import gajim 16 16 import xmpp 17 18 # ugly hack 19 import sys, dl, gst 17 import gobject 18 19 import sys, dl, gst, gobject 20 20 sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_GLOBAL) 21 21 import farsight 22 sys.setdlopenflags(dl.RTLD_NOW | dl.RTLD_LOCAL) 22 23 23 24 24 import meta … … 75 75 } 76 76 77 # for making streams using farsight78 import gc79 gc.disable()80 print self.weinitiate, "#farsight_session_factory_make"81 self.p2psession = farsight.farsight_session_factory_make('rtp')82 self.p2psession.connect('error', self.on_p2psession_error)83 84 77 ''' Middle-level functions to manage contents. Handle local content 85 78 cache and send change notifications. ''' … … 380 373 JingleContent.__init__(self, session, node) 381 374 self.got_codecs = False 375 self.codecs = [] 382 376 383 377 #if node is None: … … 418 412 if 'channels' in codec: c['channels']=codec['channels'] 419 413 codecs.append(c) 414 self.p2pin.write('%d %d %s %d %d %d\n' % (1, farsight.MEDIA_TYPE_AUDIO, 415 codec['encoding_name'], codec['id'], codec['clock_rate'], codec['channels'])) 420 416 if len(codecs)==0: return 421 417 422 418 print self.session.weinitiate, "#farsight_stream_set_remote_codecs" 423 self.p2pstream.set_remote_codecs(codecs) 419 #self.p2pstream.set_remote_codecs(codecs) 420 self.p2pin.write('%d %d %s %d %d %d\n' % (1, farsight.MEDIA_TYPE_AUDIO, 421 'LAST', 0, 0, 0)) 424 422 self.got_codecs=True 425 423 … … 445 443 if 'pwd' in candidate: cand['password']=candidate['pwd'] 446 444 445 self.p2pin.write('%d %d %s %s %d %s %s\n' % (0, int(candidate['type']), candidate['cid'], candidate['ip'], int(candidate['port']), candidate['ufrag'], candidate['pwd'])) 447 446 candidates.append(cand) 448 447 print self.session.weinitiate, "#add_remote_candidate" 449 self.p2pstream.add_remote_candidate(candidates)448 #self.p2pstream.add_remote_candidate(candidates) 450 449 451 450 def toXML(self): … … 464 463 payload=payload) 465 464 465 def new_data(self, *things): 466 buf = self.p2pout.readline() 467 print "RECV: %r"%buf 468 msg = buf.split(' ') 469 try: 470 type = int(msg.pop(0)) 471 except: 472 return True 473 #print msg 474 if type==0: 475 media_type, id, ip, port, username, password = msg[:6] 476 media_type=int(media_type) 477 port=int(port) 478 #print "Received %d %s %s %d %s %s" % (media_type, id, ip, port, username, password) 479 self.send_candidate({'candidate_id': id, 'component': 1, 'ip': ip, 480 'port': port, 'username': username, 'password': password, 481 'proto': farsight.NETWORK_PROTOCOL_UDP, 'proto_subtype': 'RTP', 482 'proto_profile': 'AVP', 'preference': 1.0, 'type': 0}) 483 elif type==1: 484 media_type, encoding_name, pt, clock_rate, channels=msg[:5] 485 media_type=int(media_type) 486 pt=int(pt) 487 clock_rate=int(clock_rate) 488 channels=int(channels) 489 490 #print "Received %d %s %d %d %d" % (media_type, encoding_name, pt, clock_rate, channels) 491 if encoding_name!='LAST': 492 self.codecs.append((media_type, encoding_name, pt, clock_rate, channels)) 493 else: 494 self.got_codecs=True 495 return True 496 466 497 def setupStream(self): 498 import popen2 499 self.p2pout, self.p2pin = popen2.popen2('/home/liori/Projekty/SoC/trunk/src/common/jingle-handler.py') 500 gobject.io_add_watch(self.p2pout, gobject.IO_IN, self.new_data) 501 while not self.got_codecs: 502 self.new_data() 503 return 467 504 print self.session.weinitiate, "#farsight_session_create_stream" 468 505 self.p2pstream = self.session.p2psession.create_stream( … … 548 585 549 586 def iterCodecs(self): 550 print self.session.weinitiate, "#farsight_stream_get_local_codecs" 551 codecs=self.p2pstream.get_local_codecs() 552 for codec in codecs: 553 a = {'name': codec['encoding_name'], 554 'id': codec['id'], 555 'channels': 1} 556 if 'clock_rate' in codec: a['clockrate']=codec['clock_rate'] 557 if 'optional_params' in codec: 558 p = (xmpp.Node('parameter', {'name': name, 'value': value}) 559 for name, value in codec['optional_params'].iteritems()) 560 else: p = () 561 yield xmpp.Node('payload-type', a, p) 587 for codec in self.codecs: 588 media_type, encoding_name, pt, clock_rate, channels=codec 589 yield xmpp.Node('payload-type', { 590 'name': encoding_name, 591 'id': pt, 592 'channels': channels, 593 'clock_rate': clock_rate}) 594 595 # print self.session.weinitiate, "#farsight_stream_get_local_codecs" 596 # codecs=self.p2pstream.get_local_codecs() 597 # for codec in codecs: 598 # a = {'name': codec['encoding_name'], 599 # 'id': codec['id'], 600 # 'channels': 1} 601 # if 'clock_rate' in codec: a['clockrate']=codec['clock_rate'] 602 # if 'optional_params' in codec: 603 # p = (xmpp.Node('parameter', {'name': name, 'value': value}) 604 # for name, value in codec['optional_params'].iteritems()) 605 # else: p = () 606 # yield xmpp.Node('payload-type', a, p) 562 607 563 608 class ConnectionJingle(object):
