From 2e28d09b04d66add839d4b43529ca11e25c699a3 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sun, 6 Sep 2015 13:49:48 +0200 Subject: Implement jpeg-previews and a/v receiving in ui --- voctocore/default-config.ini | 3 ++- voctogui/default-config.ini | 4 ++++ voctogui/lib/videodisplay.py | 57 +++++++++++++++++++++++++++++++++++++------- 3 files changed, 54 insertions(+), 10 deletions(-) diff --git a/voctocore/default-config.ini b/voctocore/default-config.ini index f2f2505..a5eaae4 100644 --- a/voctocore/default-config.ini +++ b/voctocore/default-config.ini @@ -21,10 +21,11 @@ sources=cam1,cam2,grabber ;pippos=948/528 [previews] -; disable if ui & server run on the same computer and exchange uncompressed video frames +; disable if ui & server run on the same computer and can exchange uncompressed video frames enabled=true ; default to mix-videocaps +; you can change the framerate and the width/height, but nothing else videocaps=video/x-raw,width=1024,height=576,framerate=25/1 [stream-blanker] diff --git a/voctogui/default-config.ini b/voctogui/default-config.ini index 03b0300..e51a33f 100644 --- a/voctogui/default-config.ini +++ b/voctogui/default-config.ini @@ -5,5 +5,9 @@ host=localhost width=320 #height=180 +; true = use if the server provides it +; false = never use it +use=true + [mainvideo] playaudio=false diff --git a/voctogui/lib/videodisplay.py b/voctogui/lib/videodisplay.py index a2f7f5a..4133d5a 100644 --- a/voctogui/lib/videodisplay.py +++ b/voctogui/lib/videodisplay.py @@ -1,6 +1,8 @@ import logging from gi.repository import Gst +from lib.config import Config + class VideoDisplay(object): """ Displays a Voctomix-Video-Stream into a GtkWidget """ @@ -11,14 +13,41 @@ class VideoDisplay(object): self.draw_callback = draw_callback self.level_callback = level_callback + caps = Config.get('mix', 'videocaps') + use_previews = Config.getboolean('previews', 'enabled') and Config.getboolean('previews', 'use') + + # Preview-Ports are Raw-Ports + 1000 + if use_previews: + self.log.info('using jpeg-previews instead of raw-video for gui') + port += 1000 + else: + self.log.info('using raw-video instead of jpeg-previews for gui') + # Setup Server-Connection, Demuxing and Decoding pipeline = """ - videotestsrc ! - timeoverlay ! - video/x-raw,width=1920,height=1080,framerate=25/1 ! - """.format( - port=port - ) + tcpclientsrc host={host} port={port} ! + queue ! + matroskademux name=demux + """ + + if use_previews: + pipeline += """ + demux. ! + image/jpeg ! + jpegdec ! + {previewcaps} ! + videoscale method=nearest-neighbour ! + videorate ! + {vcaps} ! + queue ! + """ + + else: + pipeline += """ + demux. ! + {vcaps} ! + queue ! + """ # If an overlay is required, add an cairooverlay-Element into the Video-Path if self.draw_callback: @@ -37,15 +66,17 @@ class VideoDisplay(object): # If an Audio-Path is required, add an Audio-Path through a level-Element if self.level_callback or play_audio: pipeline += """ - audiotestsrc wave=blue-noise ! - audio/x-raw ! + demux. ! + {acaps} ! + queue ! level name=lvl interval=50000000 ! """ # If Playback is requested, push fo alsa if play_audio: + # ts-offset=1000000000 (1s) - should keep audio & video in sync but delay by 1s pipeline += """ - alsasink + alsasink sync=False """ # Otherwise just trash the Audio @@ -54,6 +85,14 @@ class VideoDisplay(object): fakesink """ + pipeline = pipeline.format( + acaps=Config.get('mix', 'audiocaps'), + vcaps=Config.get('mix', 'videocaps'), + previewcaps=Config.get('previews', 'videocaps'), + host=Config.get('server', 'host'), + port=port, + ) + self.log.debug('Creating Display-Pipeline:\n%s', pipeline) self.pipeline = Gst.parse_launch(pipeline) -- cgit v1.2.3