Browse Source

debug

split-pipe
Hendrik Langer 4 years ago
parent
commit
2cdb1cef98
  1. 11
      raspberry/roberto/camera/camera_gstreamer_webrtc.py
  2. 11
      raspberry/roberto/views/websocket/routes.py

11
raspberry/roberto/camera/camera_gstreamer_webrtc.py

@ -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"]

11
raspberry/roberto/views/websocket/routes.py

@ -80,19 +80,28 @@ def webrtc_message(data):
print("CANDIDATE") print("CANDIDATE")
if 'candidiate' in data: if 'candidiate' in data:
webrtccamera.handle_ice(data) webrtccamera.handle_ice(data)
else:
print("got unknown data message!")
@socketio.on('disconnect', namespace='/webrtc') @socketio.on('disconnect', namespace='/webrtc')
def disconnect(): def disconnect():
sid = request.sid sid = request.sid
print("Received Disconnect message from %s" % sid) print("Received Disconnect message from %s" % sid)
leave_room(ROOM) leave_room(ROOM)
# if webrtccamera.connected:
# webrtccamera.disconnect()
@socketio.on('connect', namespace='/webrtc') @socketio.on('connect', namespace='/webrtc')
def connect(): def connect():
sid = request.sid sid = request.sid
print("Received Connect message from %s" % sid) print("Received Connect message from %s" % sid)
join_room(ROOM)
if not webrtccamera.connected: if not webrtccamera.connected:
webrtccamera.connect(socketio, ROOM, 'gstwebrtc1000') webrtccamera.connect(socketio, ROOM, 'gstwebrtc1000')
#socketio.emit('ready', room=ROOM, namespace='/webrtc', skip_sid=sid) #socketio.emit('ready', room=ROOM, namespace='/webrtc', skip_sid=sid)
socketio.emit('ready', room=ROOM, namespace='/webrtc') socketio.emit('ready', room=ROOM, namespace='/webrtc')
join_room(ROOM)
@socketio.on_error_default
def default_error_handler(e):
print(request.event["message"]) # "my error event"
print(request.event["args"]) # (data,)

Loading…
Cancel
Save