|
@ -62,6 +62,7 @@ class WebRTCCamera: |
|
|
self.webrtc = None |
|
|
self.webrtc = None |
|
|
|
|
|
|
|
|
def handle_sdp_answer(self, sdp): |
|
|
def handle_sdp_answer(self, sdp): |
|
|
|
|
|
print("handle_sdp_answer") |
|
|
print ('Received answer:\n%s' % sdp) |
|
|
print ('Received answer:\n%s' % sdp) |
|
|
res, sdpmsg = GstSdp.SDPMessage.new() |
|
|
res, sdpmsg = GstSdp.SDPMessage.new() |
|
|
GstSdp.sdp_message_parse_buffer(bytes(sdp.encode()), sdpmsg) |
|
|
GstSdp.sdp_message_parse_buffer(bytes(sdp.encode()), sdpmsg) |
|
@ -71,19 +72,23 @@ class WebRTCCamera: |
|
|
promise.interrupt() |
|
|
promise.interrupt() |
|
|
|
|
|
|
|
|
def handle_ice(self, ice): |
|
|
def handle_ice(self, ice): |
|
|
|
|
|
print("handle_ice") |
|
|
candidate = ice['candidate'] |
|
|
candidate = ice['candidate'] |
|
|
sdpmlineindex = ice['sdpMLineIndex'] |
|
|
sdpmlineindex = ice['sdpMLineIndex'] |
|
|
self.webrtc.emit('add-ice-candidate', sdpmlineindex, candidate) |
|
|
self.webrtc.emit('add-ice-candidate', sdpmlineindex, candidate) |
|
|
|
|
|
|
|
|
def on_negotiation_needed(self, element): |
|
|
def on_negotiation_needed(self, element): |
|
|
|
|
|
print("on_negotiation_needed") |
|
|
promise = Gst.Promise.new_with_change_func(self.on_offer_created, element, None) |
|
|
promise = Gst.Promise.new_with_change_func(self.on_offer_created, element, None) |
|
|
element.emit('create-offer', None, promise) |
|
|
element.emit('create-offer', None, promise) |
|
|
|
|
|
|
|
|
def send_ice_candidate_message(self, _, mlineindex, candidate): |
|
|
def send_ice_candidate_message(self, _, mlineindex, candidate): |
|
|
|
|
|
print("send_ice_candidate_message") |
|
|
icemsg = json.dumps({'type': 'candidate', 'candidate': {'candidate': candidate, 'sdpMLineIndex': mlineindex}}) |
|
|
icemsg = json.dumps({'type': 'candidate', 'candidate': {'candidate': candidate, 'sdpMLineIndex': mlineindex}}) |
|
|
self.socketio.emit('data', type='candidate', data=icemsg, room=self.room, namespace='/webrtc', skip_sid=self.sid) |
|
|
self.socketio.emit('data', type='candidate', data=icemsg, room=self.room, namespace='/webrtc', skip_sid=self.sid) |
|
|
|
|
|
|
|
|
def on_incoming_stream(self, _, pad): |
|
|
def on_incoming_stream(self, _, pad): |
|
|
|
|
|
print("on_incoming_stream") |
|
|
if pad.direction != Gst.PadDirection.SRC: |
|
|
if pad.direction != Gst.PadDirection.SRC: |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
@ -94,6 +99,7 @@ class WebRTCCamera: |
|
|
self.webrtc.link(decodebin) |
|
|
self.webrtc.link(decodebin) |
|
|
|
|
|
|
|
|
def on_incoming_decodebin_stream(self, _, pad): |
|
|
def on_incoming_decodebin_stream(self, _, pad): |
|
|
|
|
|
print("on_incoming_decodebin_stream") |
|
|
if not pad.has_current_caps(): |
|
|
if not pad.has_current_caps(): |
|
|
print (pad, 'has no caps, ignoring') |
|
|
print (pad, 'has no caps, ignoring') |
|
|
return |
|
|
return |
|
@ -124,6 +130,7 @@ class WebRTCCamera: |
|
|
resample.link(sink) |
|
|
resample.link(sink) |
|
|
|
|
|
|
|
|
def on_offer_created(self, promise, _, __): |
|
|
def on_offer_created(self, promise, _, __): |
|
|
|
|
|
print("on_offer_created") |
|
|
promise.wait() |
|
|
promise.wait() |
|
|
reply = promise.get_reply() |
|
|
reply = promise.get_reply() |
|
|
offer = reply['offer'] |
|
|
offer = reply['offer'] |
|
@ -136,10 +143,6 @@ class WebRTCCamera: |
|
|
self.socketio.emit('data', type='offer', data=msg, room=self.room, namespace='/webrtc', skip_sid=self.sid) |
|
|
self.socketio.emit('data', type='offer', data=msg, room=self.room, namespace='/webrtc', skip_sid=self.sid) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_plugins(): |
|
|
def check_plugins(): |
|
|
needed = ["opus", "vpx", "nice", "webrtc", "dtls", "srtp", "rtp", |
|
|
needed = ["opus", "vpx", "nice", "webrtc", "dtls", "srtp", "rtp", |
|
|
"rtpmanager", "videotestsrc", "audiotestsrc"] |
|
|
"rtpmanager", "videotestsrc", "audiotestsrc"] |
|
|