aboutsummaryrefslogtreecommitdiff
path: root/voctogui/lib
diff options
context:
space:
mode:
Diffstat (limited to 'voctogui/lib')
-rw-r--r--voctogui/lib/ui.py4
-rw-r--r--voctogui/lib/videodisplay.py17
-rw-r--r--voctogui/lib/warningoverlay.py39
3 files changed, 17 insertions, 43 deletions
diff --git a/voctogui/lib/ui.py b/voctogui/lib/ui.py
index 451a619..68355df 100644
--- a/voctogui/lib/ui.py
+++ b/voctogui/lib/ui.py
@@ -36,7 +36,8 @@ class Ui(UiBuilder):
# Create Main-Video Overlay Controller
- self.video_warning_overlay = VideoWarningOverlay()
+ drawing_area = self.find_widget_recursive(self.win, 'video_overlay_drawingarea')
+ self.video_warning_overlay = VideoWarningOverlay(drawing_area)
# Create Main-Video Display
@@ -44,7 +45,6 @@ class Ui(UiBuilder):
self.main_video_display = VideoDisplay(drawing_area,
port=11000,
play_audio=Config.getboolean('mainvideo', 'playaudio'),
- draw_callback=self.video_warning_overlay.draw_callback,
level_callback=self.audio_level_display.level_callback)
diff --git a/voctogui/lib/videodisplay.py b/voctogui/lib/videodisplay.py
index 4195d70..bec6789 100644
--- a/voctogui/lib/videodisplay.py
+++ b/voctogui/lib/videodisplay.py
@@ -6,11 +6,10 @@ from lib.config import Config
class VideoDisplay(object):
""" Displays a Voctomix-Video-Stream into a GtkWidget """
- def __init__(self, drawing_area, port, play_audio=False, draw_callback=None, level_callback=None):
+ def __init__(self, drawing_area, port, play_audio=False, level_callback=None):
self.log = logging.getLogger('VideoDisplay[%s]' % drawing_area.get_name())
self.drawing_area = drawing_area
- self.draw_callback = draw_callback
self.level_callback = level_callback
caps = Config.get('mix', 'videocaps')
@@ -49,14 +48,6 @@ class VideoDisplay(object):
queue !
"""
- # If an overlay is required, add an cairooverlay-Element into the Video-Path
- if self.draw_callback:
- pipeline += """
- videoconvert !
- cairooverlay name=overlay !
- videoconvert !
- """
-
# Video Display
if Config.getboolean('x11', 'xv'):
pipeline += """
@@ -118,9 +109,6 @@ class VideoDisplay(object):
if self.level_callback:
bus.connect("message::element", self.on_level)
- if self.draw_callback:
- self.pipeline.get_by_name('overlay').connect('draw', self.on_draw)
-
self.log.debug('Launching Display-Pipeline')
self.pipeline.set_state(Gst.State.PLAYING)
@@ -146,6 +134,3 @@ class VideoDisplay(object):
peaks = msg.get_structure().get_value('peak')
rms = msg.get_structure().get_value('rms')
self.level_callback(peaks, rms)
-
- def on_draw(self, cairooverlay, cr, timestamp, duration):
- self.draw_callback(cr, timestamp, duration)
diff --git a/voctogui/lib/warningoverlay.py b/voctogui/lib/warningoverlay.py
index 3cbe13c..bf2c2cd 100644
--- a/voctogui/lib/warningoverlay.py
+++ b/voctogui/lib/warningoverlay.py
@@ -6,51 +6,40 @@ from lib.config import Config
class VideoWarningOverlay(object):
""" Displays a Warning-Overlay above the Video-Feed of another VideoDisplay """
- def __init__(self):
+ def __init__(self, drawing_area):
self.log = logging.getLogger('VideoWarningOverlay')
+ self.drawing_area = drawing_area
+ self.drawing_area.connect("draw", self.draw_callback)
+
self.text = None
- self.enabled = False
self.blink_state = False
GLib.timeout_add_seconds(1, self.on_blink_callback)
- caps_string = Config.get('mix', 'videocaps')
- self.log.debug('parsing video-caps: %s', caps_string)
- caps = Gst.Caps.from_string(caps_string)
- struct = caps.get_structure(0)
- _, self.width = struct.get_int('width')
- _, self.height = struct.get_int('height')
-
- self.log.debug('configuring size to %ux%u', self.width, self.height)
-
-
def on_blink_callback(self):
self.blink_state = not self.blink_state
+ self.drawing_area.queue_draw()
return True
def enable(self, text=None):
self.text = text
- self.enabled = True
+ self.drawing_area.show()
+ self.drawing_area.queue_draw()
def set_text(self, text=None):
self.text = text
+ self.drawing_area.queue_draw()
def disable(self):
- self.enabled = False
-
- def draw_callback(self, cr, timestamp, duration):
- if not self.enabled:
- return
+ self.drawing_area.hide()
+ self.drawing_area.queue_draw()
- w = self.width
- h = self.height / 20
+ def draw_callback(self, area, cr):
+ w = self.drawing_area.get_allocated_width();
+ h = self.drawing_area.get_allocated_height();
- # during startup, cr is sometimes another kind of context,
- # which does not expose set_source_rgba and other methods.
- # this check avoids the exceptions that would be thrown then.
- if isinstance(cr, cairo.Context):
- return
+ self.log.debug('draw_callback: w/h=%u/%u, blink_state=%u', w, h, self.blink_state)
if self.blink_state:
cr.set_source_rgba(1.0, 0.0, 0.0, 0.8)