aboutsummaryrefslogtreecommitdiff
path: root/voctocore
diff options
context:
space:
mode:
Diffstat (limited to 'voctocore')
-rwxr-xr-xvoctocore/experiments/intervideo.py146
1 files changed, 50 insertions, 96 deletions
diff --git a/voctocore/experiments/intervideo.py b/voctocore/experiments/intervideo.py
index 11b39ce..a3f49bf 100755
--- a/voctocore/experiments/intervideo.py
+++ b/voctocore/experiments/intervideo.py
@@ -15,106 +15,60 @@ class Example:
self.mainloop = GObject.MainLoop()
self.source_pipeline = None
- self.sink_pipeline = Gst.parse_launch("""
- intervideosrc channel=video !
- queue !
- video/x-raw,width=800,height=450,format=I420,framerate=25/1 !
- textoverlay halignment=left valignment=top ypad=50 text=intervideosrc !
- timeoverlay halignment=left valignment=top ypad=50 xpad=400 !
- tee name=vtee
+ video = True
+ if video:
+ self.pipeline1 = Gst.parse_launch("""
+ videotestsrc !
+ video/x-raw,width=800,height=450,format=I420,framerate=1/1 !
+ intervideosink channel=video
+ """)
+
+ self.pipeline2 = Gst.parse_launch("""
+ intervideosrc channel=video !
+ video/x-raw,width=800,height=450,format=I420,framerate=1/1 !
+ xvimagesink
+ """)
+
+ else:
+ self.pipeline1 = Gst.parse_launch("""
+ audiotestsrc !
+ audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000,channel-mask=(bitmask)0x3 !
+ interaudiosink channel=audio
+ """)
+
+ self.pipeline2 = Gst.parse_launch("""
+ interaudiosrc channel=audio !
+ audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000,channel-mask=(bitmask)0x3 !
+ alsasink
+ """)
+
+ self.pipeline1.bus.add_signal_watch()
+ self.pipeline1.bus.connect("message::eos", self.on_eos)
+ self.pipeline1.bus.connect("message::error", self.on_error)
+
+ self.pipeline2.bus.add_signal_watch()
+ self.pipeline2.bus.connect("message::eos", self.on_eos)
+ self.pipeline2.bus.connect("message::error", self.on_error)
+
+ GLib.timeout_add_seconds(3, self.on_timeout)
- interaudiosrc blocksize=4096 channel=audio !
- queue !
- audio/x-raw,format=S16LE,layout=interleaved,rate=48000,channels=2 !
- tee name=atee
-
-
- vtee. !
- queue !
- videoconvert !
- textoverlay halignment=left valignment=top ypad=75 text=avenc_mpeg2video !
- timeoverlay halignment=left valignment=top ypad=75 xpad=400 !
- avenc_mpeg2video bitrate=50000 max-key-interval=0 !
- queue !
- mux.
-
- atee. !
- queue !
- avenc_mp2 bitrate=192000 !
- queue !
- mux.
-
- mpegtsmux name=mux !
- filesink location=foo.ts
-
-
- vtee. !
- queue !
- textoverlay halignment=left valignment=top ypad=75 text=xvimagesink !
- timeoverlay halignment=left valignment=top ypad=75 xpad=400 !
- videoconvert !
- xvimagesink
-
- atee. !
- queue !
- audioconvert !
- alsasink
- """)
-
- # Create the server, binding to localhost on port 5000
- sock = socket.socket(socket.AF_INET6)
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, False)
- sock.bind(('::', 10000))
- sock.listen(1)
-
- # register socket for callback inside the GTK-Mainloop
- GObject.io_add_watch(sock, GObject.IO_IN, self.on_connect)
-
-
- def on_connect(self, sock, *args):
- '''Asynchronous connection listener. Starts a handler for each connection.'''
- if self.source_pipeline:
- return False
-
- conn, addr = sock.accept()
- print("Connection from", addr)
-
- self.source_pipeline = Gst.parse_launch("""
- fdsrc name=a fd=%u !
- matroskademux name=demux
-
- demux. !
- video/x-raw,width=800,height=450,format=I420,framerate=25/1 !
- queue !
- textoverlay halignment=left valignment=top ypad=25 text=intervideosink !
- timeoverlay halignment=left valignment=top ypad=25 xpad=400 !
- intervideosink channel=video
-
- demux. !
- audio/x-raw,format=S16LE,channels=2,layout=interleaved,rate=48000,channel-mask=(bitmask)0x3 !
- queue !
- interaudiosink channel=audio
-
- """ % conn.fileno())
-
- self.source_pipeline.bus.add_signal_watch()
- self.source_pipeline.bus.connect("message::eos", self.on_disconnect)
-
- self.source_pipeline.set_state(Gst.State.PLAYING)
+ def run(self):
+ print("starting pipeline2")
+ self.pipeline2.set_state(Gst.State.PLAYING)
+ self.mainloop.run()
- self.conn = conn
- return True
+ def on_timeout(self):
+ print("starting pipeline1")
+ self.pipeline1.set_state(Gst.State.PLAYING)
+ return False
- def on_disconnect(self, bus, message):
- self.source_pipeline.set_state(Gst.State.NULL)
- self.source_pipeline = None
- self.conn = None
- return True
+ def on_eos(self, bus, message):
+ self.log.debug('Received End-of-Stream-Signal on Pipeline')
- def run(self):
- self.sink_pipeline.set_state(Gst.State.PLAYING)
- self.mainloop.run()
+ def on_error(self, bus, message):
+ self.log.debug('Received Error-Signal on Pipeline')
+ (error, debug) = message.parse_error()
+ self.log.debug('Error-Details: #%u: %s', error.code, debug)
example = Example()
example.run()