def __init__(self, session, media, transport=None): if transport is None: transport = JingleTransportICEUDP(None) JingleContent.__init__(self, session, transport) self.media = media self._dtmf_running = False self.farstream_media = {'audio': farstream.MEDIA_TYPE_AUDIO, 'video': farstream.MEDIA_TYPE_VIDEO}[media] self.pipeline = None self.src_bin = None self.stream_failed_once = False self.candidates_ready = False # True when local candidates are prepared self.callbacks['session-initiate'] += [self.__on_remote_codecs] self.callbacks['content-add'] += [self.__on_remote_codecs] self.callbacks['description-info'] += [self.__on_remote_codecs] self.callbacks['content-accept'] += [self.__on_remote_codecs] self.callbacks['session-accept'] += [self.__on_remote_codecs] self.callbacks['session-terminate'] += [self.__stop] self.callbacks['session-terminate-sent'] += [self.__stop]
def __init__(self, session, transport=None, file_props=None, use_security=False): JingleContent.__init__(self, session, transport) log.info("transport value: %s" % transport) # events we might be interested in self.callbacks['session-initiate'] += [self.__on_session_initiate] self.callbacks['session-initiate-sent'] += [ self.__on_session_initiate_sent] self.callbacks['content-add'] += [self.__on_session_initiate] self.callbacks['session-accept'] += [self.__on_session_accept] self.callbacks['session-terminate'] += [self.__on_session_terminate] self.callbacks['session-info'] += [self.__on_session_info] self.callbacks['transport-accept'] += [self.__on_transport_accept] self.callbacks['transport-replace'] += [self.__on_transport_replace] self.callbacks['session-accept-sent'] += [self.__transport_setup] # fallback transport method self.callbacks['transport-reject'] += [self.__on_transport_reject] self.callbacks['transport-info'] += [self.__on_transport_info] self.callbacks['iq-result'] += [self.__on_iq_result] self.use_security = use_security self.x509_fingerprint = None self.file_props = file_props self.weinitiate = self.session.weinitiate self.werequest = self.session.werequest if self.file_props is not None: if self.session.werequest: self.file_props.sender = self.session.peerjid self.file_props.receiver = self.session.ourjid else: self.file_props.sender = self.session.ourjid self.file_props.receiver = self.session.peerjid self.file_props.session_type = 'jingle' self.file_props.sid = session.sid self.file_props.transfered_size = [] self.file_props.transport_sid = self.transport.sid log.info("FT request: %s" % file_props) if transport is None: self.transport = JingleTransportSocks5() self.transport.set_connection(session.connection) self.transport.set_file_props(self.file_props) self.transport.set_our_jid(session.ourjid) log.info('ourjid: %s' % session.ourjid) self.session = session self.media = 'file' self.nominated_cand = {} if gajim.contacts.is_gc_contact(session.connection.name, session.peerjid): roomjid = session.peerjid.split('/')[0] dstaddr = hashlib.sha1('%s%s%s' % (self.file_props.sid, session.ourjid, roomjid)).hexdigest() self.file_props.dstaddr = dstaddr self.state = STATE_NOT_STARTED self.states = {STATE_INITIALIZED : StateInitialized(self), STATE_CAND_SENT : StateCandSent(self), STATE_CAND_RECEIVED : StateCandReceived(self), STATE_TRANSFERING : StateTransfering(self), STATE_TRANSPORT_REPLACE : StateTransportReplace(self), STATE_CAND_SENT_AND_RECEIVED : StateCandSentAndRecv(self) } if jingle_xtls.PYOPENSSL_PRESENT: cert_name = os.path.join(configpaths.gajimpaths['MY_CERT'], jingle_xtls.SELF_SIGNED_CERTIFICATE) if not (os.path.exists(cert_name + '.cert') and os.path.exists(cert_name + '.pkey')): jingle_xtls.make_certs(cert_name, 'gajim')