Play with code.
[toast/stream2beamer.git] / lagarde.py
index e9fca23f68b9ee02c66211575c3b662f2c31ffa6..05b2fe008489ff19077277e06be98f9cadebd70b 100755 (executable)
@@ -177,7 +177,6 @@ class WebRTCClient:
         if not pad.has_current_caps():
             log.info(pad, 'has no caps, ignoring')
             return
-
         caps = pad.get_current_caps()
         padsize = caps.get_size()
         for i in range(padsize):
@@ -186,7 +185,9 @@ class WebRTCClient:
             if name.startswith('video'):
                 q = Gst.ElementFactory.make('queue')
                 conv = Gst.ElementFactory.make('videoconvert')
-                sink = Gst.ElementFactory.make('intervideosink')
+                sink = Gst.ElementFactory.make('rtmpsink')
+                sink.props.location = 'rtmp://127.0.0.1:1935/cug'
+                # sink.props.location = 'rtmp://127.0.0.1:1936/cug'
                 self.pipe.add(q)
                 self.pipe.add(conv)
                 self.pipe.add(sink)
@@ -194,7 +195,24 @@ class WebRTCClient:
                 pad.link(q.get_static_pad('sink'))
                 q.link(conv)
                 conv.link(sink)
-                self.pipe.set_state(Gst.State.PLAYING)
+                # self.pipe.set_state(Gst.State.PLAYING)
+                print(dir(Gst.DebugGraphDetails))
+                Gst.debug_bin_to_dot_data(element, Gst.DebugGraphDetails.ALL)
+
+            elif name.startswith('audio'):
+                q = Gst.ElementFactory.make('queue')
+                conv = Gst.ElementFactory.make('audioconvert')
+                resample = Gst.ElementFactory.make('audioresample')
+                sink = Gst.ElementFactory.make('autoaudiosink')
+                self.pipe.add(q)
+                self.pipe.add(conv)
+                self.pipe.add(resample)
+                self.pipe.add(sink)
+                self.pipe.sync_children_states()
+                pad.link(q.get_static_pad('sink'))
+                q.link(conv)
+                conv.link(resample)
+                resample.link(sink)
 
     def set_remote_desciption_done(self, gst_promise):
         gst_promise = Gst.Promise.new_with_change_func(self.create_answer_done)
@@ -280,7 +298,7 @@ async def run(uri):
     try:
         events = Events()
 
-        rtsp = RtspServer()
+        rtsp = RtspServer()
         webrtc = WebRTCClient(events)
         signaling = SignalingClient(events, uri)
 
@@ -300,7 +318,7 @@ async def run(uri):
 
 
 def main():
-    logging.basicConfig(level=logging.INFO, format='%(asctime)-15s %(message)s')
+    logging.basicConfig(level=logging.DEBUG, format='%(asctime)-15s %(message)s')
     parser = argparse.ArgumentParser()
     parser.add_argument('--uri', default='wss://localhost:1234/ws_connect?id=cug',
                         help='Signalling server URI')