Align default port number with Laplace.
[toast/stream2beamer.git] / laplace_client.py
index 4180f3014d233d1b4e101881673abfd92e6dba95..6ec2bb83862d92316459f285144701abe7cd0ff7 100755 (executable)
@@ -51,7 +51,7 @@ class WebRTCClient:
         log.info('on_offer_created')
         promise.wait()
         reply = promise.get_reply()
-        offer = reply['offer']
+        offer = reply.get_value('offer')
         promise = Gst.Promise.new()
         self.webrtc.emit('set-local-description', offer, promise)
         promise.interrupt()
@@ -120,16 +120,19 @@ class WebRTCClient:
 
     def start_pipeline(self):
         self.webrtc = Gst.ElementFactory.make('webrtcbin', 'laplace')
-        self.webrtc.set_property("bundle-policy", 3)
+        self.webrtc.set_property("bundle-policy", 3)
         direction = GstWebRTC.WebRTCRTPTransceiverDirection.RECVONLY
-        caps = Gst.caps_from_string("application/x-rtp,media=video,encoding-name=VP8/9000,payload=96")
-        self.webrtc.emit('add-transceiver', direction, caps)
+        video_caps = Gst.caps_from_string("application/x-rtp,media=video,encoding-name=VP8/9000,payload=96")
+        audio_caps = Gst.caps_from_string("application/x-rtp,media=audio,encoding-name=OPUS,clock-rate=48000,payload=111")
+        self.webrtc.emit('add-transceiver', direction, video_caps)
+        self.webrtc.emit('add-transceiver', direction, audio_caps)
         self.pipe = Gst.Pipeline.new("pipeline")
         Gst.Bin.do_add_element(self.pipe, self.webrtc)
         self.webrtc.connect('on-negotiation-needed', self.on_negotiation_needed)
         self.webrtc.connect('on-ice-candidate', self.send_ice_candidate_message)
         self.webrtc.connect('pad-added', self.on_incoming_stream)
         self.pipe.set_state(Gst.State.PLAYING)
+        self.webrtc.emit('create-data-channel', 'laplace', None)
     
     def close_pipeline(self):
         self.pipe.set_state(Gst.State.NULL)
@@ -190,7 +193,7 @@ def main():
     if not check_plugins():
         sys.exit(1)
     parser = argparse.ArgumentParser()
-    parser.add_argument('--uri', default='wss://localhost:2222/ws_connect?id=cug',
+    parser.add_argument('--uri', default='wss://localhost:1234/ws_connect?id=cug',
         help='Signalling server URI')
     args = parser.parse_args()
     c = WebRTCClient(args.uri)