From 34b3d802babc3818f77057c8cd7665e58fe16bfd Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Tue, 4 Aug 2015 23:15:12 +0200 Subject: start the great refactoring --- voctogui/lib/warningoverlay.py | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 voctogui/lib/warningoverlay.py (limited to 'voctogui/lib/warningoverlay.py') diff --git a/voctogui/lib/warningoverlay.py b/voctogui/lib/warningoverlay.py new file mode 100644 index 0000000..73e1b33 --- /dev/null +++ b/voctogui/lib/warningoverlay.py @@ -0,0 +1,55 @@ +import logging +from gi.repository import GLib + +class VideoWarningOverlay: + """ Displays a Warning-Overlay above the Video-Feed of another VideoDisplay """ + + def __init__(self): + self.log = logging.getLogger('VideoWarningOverlay') + + self.text = None + self.enabled = False + self.blink_state = False + + GLib.timeout_add_seconds(1, self.on_blink_callback) + + + def on_blink_callback(self): + self.blink_state = not self.blink_state + return True + + def enable(self, text=None): + self.text = text + self.enabled = True + + def set_text(self, text=None): + self.text = text + + def disable(self): + self.enabled = False + + def draw_callback(self, cr, timestamp, duration): + if not self.enabled: + return + + w = 1920 + h = 1080/20 + + if self.blink_state: + cr.set_source_rgba(1.0, 0.0, 0.0, 0.8) + else: + cr.set_source_rgba(1.0, 0.5, 0.0, 0.8) + + cr.rectangle(0, 0, w, h) + cr.fill() + + text = "Stream is Blanked" + if self.text: + text += ": "+self.text + + cr.set_font_size(h*0.75) + xbearing, ybearing, txtwidth, txtheight, xadvance, yadvance = cr.text_extents(text) + + cr.move_to(w/2 - txtwidth/2, h*0.75) + cr.set_source_rgba(1.0, 1.0, 1.0, 1.0) + cr.show_text(text) -- cgit v1.2.3 From a753cd71a02cd64c3dd03bbf4d22b605bae82c7e Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Fri, 7 Aug 2015 08:37:55 +0200 Subject: Use New-Style Classes --- voctogui/lib/audioleveldisplay.py | 2 +- voctogui/lib/videodisplay.py | 2 +- voctogui/lib/warningoverlay.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'voctogui/lib/warningoverlay.py') diff --git a/voctogui/lib/audioleveldisplay.py b/voctogui/lib/audioleveldisplay.py index 8b9bf7e..bc2a38f 100644 --- a/voctogui/lib/audioleveldisplay.py +++ b/voctogui/lib/audioleveldisplay.py @@ -1,7 +1,7 @@ import logging from gi.repository import Gst, Gtk -class AudioLevelDisplay: +class AudioLevelDisplay(object): """ Displays a Level-Meter of another VideoDisplay into a GtkWidget """ def __init__(self, drawing_area): diff --git a/voctogui/lib/videodisplay.py b/voctogui/lib/videodisplay.py index 00648ef..a2f7f5a 100644 --- a/voctogui/lib/videodisplay.py +++ b/voctogui/lib/videodisplay.py @@ -1,7 +1,7 @@ import logging from gi.repository import Gst -class VideoDisplay: +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): diff --git a/voctogui/lib/warningoverlay.py b/voctogui/lib/warningoverlay.py index 73e1b33..ad86b69 100644 --- a/voctogui/lib/warningoverlay.py +++ b/voctogui/lib/warningoverlay.py @@ -1,7 +1,7 @@ import logging from gi.repository import GLib -class VideoWarningOverlay: +class VideoWarningOverlay(object): """ Displays a Warning-Overlay above the Video-Feed of another VideoDisplay """ def __init__(self): -- cgit v1.2.3