Specify RTMP server as command line argument.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Sat, 22 May 2021 18:18:11 +0000 (20:18 +0200)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Sat, 22 May 2021 18:18:11 +0000 (20:18 +0200)
lagarde.py

index 63782061dee0ed7288a2e482a6de7f6573ee07b2..7c6ce9a7d7e64c6acfaa777f978ce37b050fa86c 100755 (executable)
@@ -123,8 +123,9 @@ class SignalingClient:
 
 
 class WebRTCClient:
 
 
 class WebRTCClient:
-    def __init__(self, events: Events):
+    def __init__(self, events: Events, rtmp_uri: str):
         self.events = events
         self.events = events
+        self.rtmp_uri = rtmp_uri
         self.webrtcbin = Gst.ElementFactory.make('webrtcbin', 'laplace')
         self.pipe = Gst.Pipeline.new("pipeline")
         Gst.Bin.do_add_element(self.pipe, self.webrtcbin)
         self.webrtcbin = Gst.ElementFactory.make('webrtcbin', 'laplace')
         self.pipe = Gst.Pipeline.new("pipeline")
         Gst.Bin.do_add_element(self.pipe, self.webrtcbin)
@@ -170,7 +171,7 @@ class WebRTCClient:
                 capsfilter.set_properties(Gst.Caps.from_string('video/x-h264,stream-format=(string)avc'))
                 flmux = Gst.ElementFactory.make('flvmux')
                 sink = Gst.ElementFactory.make('rtmpsink')
                 capsfilter.set_properties(Gst.Caps.from_string('video/x-h264,stream-format=(string)avc'))
                 flmux = Gst.ElementFactory.make('flvmux')
                 sink = Gst.ElementFactory.make('rtmpsink')
-                sink.set_property('location', 'rtmp://192.168.1.46:1935/gregoa')
+                sink.set_property('location', self.rtmp_uri)
                 assert q and conv and enc and capsfilter and flmux and sink
 
                 self.pipe.add(q)
                 assert q and conv and enc and capsfilter and flmux and sink
 
                 self.pipe.add(q)
@@ -281,11 +282,11 @@ async def run_repeated(task):
         await asyncio.sleep(0.1)
 
 
         await asyncio.sleep(0.1)
 
 
-async def run(uri):
+async def run(laplace_uri: str, rtmp_uri: str):
     try:
         events = Events()
     try:
         events = Events()
-        webrtc = WebRTCClient(events)
-        signaling = SignalingClient(events, uri)
+        webrtc = WebRTCClient(events, rtmp_uri)
+        signaling = SignalingClient(events, laplace_uri)
 
         webrtc_task = asyncio.Task(webrtc.run())
         signaling_task = asyncio.Task(signaling.run())
 
         webrtc_task = asyncio.Task(webrtc.run())
         signaling_task = asyncio.Task(signaling.run())
@@ -302,13 +303,17 @@ async def run(uri):
 
 def main():
     logging.basicConfig(level=logging.DEBUG, format='%(asctime)-15s %(message)s')
 
 def main():
     logging.basicConfig(level=logging.DEBUG, format='%(asctime)-15s %(message)s')
+    default_source = 'wss://localhost:1234/ws_connect?id=cug'
+    default_dest = 'rtmp://localhost:1935/cug'
     parser = argparse.ArgumentParser()
     parser = argparse.ArgumentParser()
-    parser.add_argument('--uri', default='wss://localhost:1234/ws_connect?id=cug',
-                        help='Signalling server URI')
+    parser.add_argument('-s', '--source', default=default_source,
+                        help=f'Laplace signalling websocket URI, default: {default_source}')
+    parser.add_argument('-d', '--destination', default=default_dest,
+                        help=f'RTMP server URI, default: {default_dest}')
     args = parser.parse_args()
 
     Gst.init(None)
     args = parser.parse_args()
 
     Gst.init(None)
-    asyncio.run(run(args.uri), debug=True)
+    asyncio.run(run(args.source, args.destination), debug=True)
 
 
 if __name__ == '__main__':
 
 
 if __name__ == '__main__':