I'm working on a multi peer Gstreamer pipeline, multiple peers connect to a single host through the browser. The host is running the gstreamer piepline, which I created using Python. My pipeline looks something like this:
PIPELINE_DESC1 = ''' videotestsrc is-live=true ! queue ! video/x-raw,width=1280,height=720 ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay ! queue ! application/x-rtp,media=video,encoding-name=VP8, payload=96, clock-rate=90000 ! tee name=videotee ! queue ! fakesink sync=true ''' When a new offer is received, a webrtcbin and queue element are created and added to the tee. webrtc = Gst.ElementFactory.make("webrtcbin","webrtc" + peer) q = Gst.ElementFactory.make("queue") #q2 = Gst.ElementFactory.make("queue") tee = self.pipe.get_by_name('videotee') # tee2 = self.pipe.get_by_name('audiotee') self.pipe.add(q) # self.pipe.add(q2) self.pipe.add(webrtc) stun = iceServers[0] webrtc.set_property("stun-server", "stun://stun.l.google.com:19302") webrtc.set_property("bundle-policy", "max-bundle") webrtc.connect('on-ice-candidate', self.send_ice_candidate_message) webrtc.connect('on-data-channel', self.on_data_channel) webrtc.connect('pad-added', self.on_incoming_stream, peer) webrtc.connect('pad-removed', self.remove_peer, peer) tee_src_pad_template = tee.get_pad_template("src_%u") tee_video_pad = tee.request_pad(tee_src_pad_template, None, None) q_sink_pad = q.get_static_pad("sink") q_src_pad = q.get_static_pad("src") webrtc_src_pad_template = webrtc.get_pad_template("sink_%u") wrtc_pad = webrtc.request_pad(webrtc_src_pad_template) video_block = tee_video_pad.add_probe(Gst.PadProbeType.BLOCK_DOWNSTREAM, self.probe_block ) if (tee_video_pad.link(q_sink_pad) != Gst.PadLinkReturn.OK ): # print("ERROR: Video Tee could not be linked") sys.exit(1) if (q_src_pad.link(wrtc_pad) != Gst.PadLinkReturn.OK ): # print("ERROR: wrtc could not be linked") sys.exit(1) self.n_peers = self.n_peers + 1 q.sync_state_with_parent() #q2.sync_state_with_parent() webrtc.sync_state_with_parent() OPUS_CAPS = Gst.Caps.from_string('application/x-rtp,media=audio,encoding-name=OPUS,payload=111,clock-rate=48000') webrtc.emit('add-transceiver', GstWebRTC.WebRTCRTPTransceiverDirection.RECVONLY, OPUS_CAPS) trans = webrtc.emit('get-transceiver', 0) trans.set_property ('direction', GstWebRTC.WebRTCRTPTransceiverDirection.SENDRECV) trans = webrtc.emit('get-transceiver', 1) trans.set_property ('direction', GstWebRTC.WebRTCRTPTransceiverDirection.RECVONLY) webrtc.set_state(Gst.State.READY) webrtc.set_state(Gst.State.PLAYING) self.pipe.set_state(Gst.State.PLAYING) tee_video_pad.remove_probe(video_block) I'm able to connect multiple peers successfully as long as none disconnect. If any peer closes their tab, any peers added after show a frozen frame on screen. I've tried to detect connection loss by subscribing to multiple signals using webrtc.connect("notify::connection-state", self.state_change) However I'm not able to detect disconnection. Is there any way to detect the peer disconnection? if this is not the reason for the frozen video stream, what could be some potential problems Using gstreamer 18.4. Logs attached qith webrtcbin set to 6 log1.txt |
Free forum by Nabble | Edit this page |