webrtc_sendrecv.py: Fix styling errors

These are now enforced by the pre-commit python style hook.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1821>
This commit is contained in:
Nirbheek Chauhan 2022-03-01 19:52:28 +05:30 committed by GStreamer Marge Bot
parent d6799b069a
commit 4c2fd7f104

View file

@ -25,6 +25,7 @@ webrtcbin name=sendrecv bundle-policy=max-bundle stun-server=stun://stun.l.googl
from websockets.version import version as wsv from websockets.version import version as wsv
class WebRTCClient: class WebRTCClient:
def __init__(self, id_, peer_id, server): def __init__(self, id_, peer_id, server):
self.id_ = id_ self.id_ = id_
@ -34,7 +35,6 @@ class WebRTCClient:
self.peer_id = peer_id self.peer_id = peer_id
self.server = server or 'wss://webrtc.nirbheek.in:8443' self.server = server or 'wss://webrtc.nirbheek.in:8443'
async def connect(self): async def connect(self):
sslctx = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH) sslctx = ssl.create_default_context(purpose=ssl.Purpose.CLIENT_AUTH)
self.conn = await websockets.connect(self.server, ssl=sslctx) self.conn = await websockets.connect(self.server, ssl=sslctx)
@ -45,7 +45,7 @@ class WebRTCClient:
def send_sdp_offer(self, offer): def send_sdp_offer(self, offer):
text = offer.sdp.as_text() text = offer.sdp.as_text()
print ('Sending offer:\n%s' % text) print('Sending offer:\n%s' % text)
msg = json.dumps({'sdp': {'type': 'offer', 'sdp': text}}) msg = json.dumps({'sdp': {'type': 'offer', 'sdp': text}})
loop = asyncio.new_event_loop() loop = asyncio.new_event_loop()
loop.run_until_complete(self.conn.send(msg)) loop.run_until_complete(self.conn.send(msg))
@ -72,7 +72,7 @@ class WebRTCClient:
def on_incoming_decodebin_stream(self, _, pad): def on_incoming_decodebin_stream(self, _, pad):
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
caps = pad.get_current_caps() caps = pad.get_current_caps()
@ -125,7 +125,7 @@ class WebRTCClient:
sdp = msg['sdp'] sdp = msg['sdp']
assert(sdp['type'] == 'answer') assert(sdp['type'] == 'answer')
sdp = sdp['sdp'] sdp = sdp['sdp']
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)
answer = GstWebRTC.WebRTCSessionDescription.new(GstWebRTC.WebRTCSDPType.ANSWER, sdpmsg) answer = GstWebRTC.WebRTCSessionDescription.new(GstWebRTC.WebRTCSDPType.ANSWER, sdpmsg)
@ -151,7 +151,7 @@ class WebRTCClient:
elif message == 'SESSION_OK': elif message == 'SESSION_OK':
self.start_pipeline() self.start_pipeline()
elif message.startswith('ERROR'): elif message.startswith('ERROR'):
print (message) print(message)
self.close_pipeline() self.close_pipeline()
return 1 return 1
else: else:
@ -175,7 +175,7 @@ def check_plugins():
return True return True
if __name__=='__main__': if __name__ == '__main__':
Gst.init(None) Gst.init(None)
if not check_plugins(): if not check_plugins():
sys.exit(1) sys.exit(1)