def __init__(self, pid, id, connect): self.pid = pid self.id = id self.connect = connect candidate = Farstream.Candidate() candidate.component_id = 1 connect.send_candidate(self.pid, self.id, candidate) connect.send_candidates_done(self.pid, self.id)
def new_stream(self, id, participant): "Creates a new stream for a specific participant" transmitter_params = {} # If its video, we start at port 9078, to make it more easy # to differentiate it in a tcpdump log if self.source.get_type() == Farstream.MediaType.VIDEO and \ TRANSMITTER == "rawudp": cand = Farstream.Candidate.new("",Farstream.ComponentType.RTP, Farstream.CandidateType.HOST, Farstream.NetworkProtocol.UDP, None, 9078) value = GObject.Value() Farstream.value_set_candidate_list(value, [cand]) transmitter_params["preferred-local-candidates"] = value realstream = self.fssession.new_stream(participant.fsparticipant, Farstream.StreamDirection.BOTH) print TRANSMITTER + ": " + str(transmitter_params) realstream.set_transmitter_ht(TRANSMITTER, transmitter_params) stream = FsUIStream(id, self, participant, realstream) self.streams.add(stream) return stream
def codecs(self, codecs): "Callback for the network object. Set the codecs" print "Remote codecs" for c in codecs: print "Got remote codec from %s/%s %s" % \ (self.participant.id, self.id, c.to_string()) oldcodecs = self.fsstream.props.remote_codecs if Farstream.codec_list_are_equal(oldcodecs,codecs): return try: self.fsstream.set_remote_codecs(codecs) except AttributeError: print "Tried to set codecs with 0 codec" self.send_local_codecs() self.send_stream_codecs()
def __init__(self, conference, source): self.conference = conference self.source = source self.streams = weakref.WeakSet() self.fssession = conference.new_session(source.get_type()) self.fssession.uisession = self self.fssession.set_codec_preferences( Farstream.utils_get_default_codec_preferences(conference)) self.queue = Gst.ElementFactory.make("queue", None) self.source.pipeline.add(self.queue) self.sourcepad = self.source.get_src_pad() self.queue.get_static_pad("src").link(self.fssession.get_property("sink-pad")) self.queue.set_state(Gst.State.PLAYING) self.sourcepad.link(self.queue.get_static_pad("sink"))
def __init__(self, connection, channel): self.conn = connection self.channel = channel self.tfchannel = None channel.connect("state-changed", self.state_changed_cb) self.pipeline = Gst.Pipeline(None) self.pipeline.get_bus().add_signal_watch() self.pipeline.get_bus().connect("message", self.async_handler) self.notifier = notifier = Farstream.ElementAddedNotifier() notifier.set_properties_from_file("element-properties") notifier.add(self.pipeline) TelepathyFarstream.Channel.new_async(channel, self.tpfs_created)
def __init__(self, elementname="fsrtpconference"): GObject.GObject.__init__(self) self.pipeline = Gst.Pipeline() GLib.unix_signal_add_full(0, signal.SIGINT, self.g_int_handler, None,) signal.signal(signal.SIGINT, self.int_handler) #self.pipeline.get_bus().set_sync_handler(self.sync_handler, None) self.pipeline.get_bus().add_watch(0, self.async_handler, None) self.conf = Gst.ElementFactory.make(elementname, None) self.notifier = Farstream.ElementAddedNotifier() self.notifier.add(self.pipeline) self.notifier.set_default_properties(self.conf) self.pipeline.add(self.conf) if VIDEO: self.videosource = FsUIVideoSource(self.pipeline) self.videosession = FsUISession(self.conf, self.videosource) if AUDIO: self.audiosource = FsUIAudioSource(self.pipeline) self.audiosession = FsUISession(self.conf, self.audiosource) #self.adder = None self.pipeline.set_state(Gst.State.PLAYING)
def get_codecs(self): return [ Farstream.Codec(self.connect.myid, "nego-codecs", self.pid, self.id) ]