mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-11-22 11:30:59 +00:00
webrtc: Fix Python custom signaller receiving SDP offer
The GstWebRTC API web interface defaults to receiving an SDP offer and generating an answer, but this can be overridden by entering "offer options" before clicking to open the remote stream. The Python webrtcsink-custom-signaller.py example failed in this mode as it was coded to only generate an offer and receive an answer. Fix this by implementing support for receiving an offer and sending an answer. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1883>
This commit is contained in:
parent
e30d80c71e
commit
5010ee872d
1 changed files with 10 additions and 3 deletions
|
@ -104,7 +104,12 @@ class WebRTCClient:
|
||||||
elif msg['type'] == 'sessionStarted':
|
elif msg['type'] == 'sessionStarted':
|
||||||
pass
|
pass
|
||||||
elif msg['type'] == 'startSession':
|
elif msg['type'] == 'startSession':
|
||||||
self.signaller_emit_session_requested(msg['sessionId'], msg['peerId'], None)
|
offer = None
|
||||||
|
if msg['offer']:
|
||||||
|
_, sdpmsg = GstSdp.SDPMessage.new()
|
||||||
|
GstSdp.sdp_message_parse_buffer(bytes(msg['offer'].encode()), sdpmsg)
|
||||||
|
offer = GstWebRTC.WebRTCSessionDescription.new(GstWebRTC.WebRTCSDPType.OFFER, sdpmsg)
|
||||||
|
self.signaller_emit_session_requested(msg['sessionId'], msg['peerId'], offer)
|
||||||
elif msg['type'] == 'endSession':
|
elif msg['type'] == 'endSession':
|
||||||
self.signaller_emit_session_ended(msg['sessionId'])
|
self.signaller_emit_session_ended(msg['sessionId'])
|
||||||
elif msg['type'] == 'peer':
|
elif msg['type'] == 'peer':
|
||||||
|
@ -147,9 +152,11 @@ class WebRTCClient:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def signaller_on_send_session_description(self, _, session_id, offer):
|
def signaller_on_send_session_description(self, _, session_id, offer):
|
||||||
|
typ = 'offer'
|
||||||
|
if offer.type == GstWebRTC.WebRTCSDPType.ANSWER:
|
||||||
|
typ = 'answer'
|
||||||
sdp = offer.sdp.as_text()
|
sdp = offer.sdp.as_text()
|
||||||
assert offer.type == GstWebRTC.WebRTCSDPType.OFFER
|
self.send_soon({'type': 'peer', 'sessionId': session_id, 'sdp': { 'type': typ, 'sdp': sdp }})
|
||||||
self.send_soon({'type': 'peer', 'sessionId': session_id, 'sdp': { 'type': 'offer', 'sdp': sdp }})
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def signaller_on_send_ice(self, _, session_id, candidate, sdp_m_line_index, sdp_mid):
|
def signaller_on_send_ice(self, _, session_id, candidate, sdp_m_line_index, sdp_mid):
|
||||||
|
|
Loading…
Reference in a new issue