diff options
author | MaZderMind <git@mazdermind.de> | 2015-08-07 08:38:58 +0200 |
---|---|---|
committer | MaZderMind <git@mazdermind.de> | 2015-08-07 08:38:58 +0200 |
commit | 9eda09a1b66ceb3874c471910fc8c26874d2981e (patch) | |
tree | 45f9cfb1732b3ef0218328b47d2328c27347583f /voctogui/lib/videopreviews.py | |
parent | a753cd71a02cd64c3dd03bbf4d22b605bae82c7e (diff) |
implement audioselector, videopreviews and composition-toolbar
Diffstat (limited to 'voctogui/lib/videopreviews.py')
-rw-r--r-- | voctogui/lib/videopreviews.py | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/voctogui/lib/videopreviews.py b/voctogui/lib/videopreviews.py new file mode 100644 index 0000000..d6a18ec --- /dev/null +++ b/voctogui/lib/videopreviews.py @@ -0,0 +1,86 @@ +import logging +from gi.repository import Gst, Gtk + +from lib.videodisplay import VideoDisplay + +class VideoPreviewsController(object): + """ Displays Video-Previews and selection Buttons for them """ + + def __init__(self, drawing_area, win, uibuilder): + self.log = logging.getLogger('VideoPreviewsController') + + self.drawing_area = drawing_area + self.win = win + + self.sources = ['cam1', 'cam2', 'grabber'] + self.preview_players = {} + self.previews = {} + + try: + width = Config.getint('previews', 'width') + self.log.debug('Preview-Width configured to %u', width) + except: + width = 320 + self.log.debug('Preview-Width selected as %u', width) + + try: + height = Config.getint('previews', 'height') + self.log.debug('Preview-Height configured to %u', width) + except: + height = width*9/16 + self.log.debug('Preview-Height calculated to %u', width) + + # Accelerators + accelerators = Gtk.AccelGroup() + win.add_accel_group(accelerators) + + group_a = None + group_b = None + + for idx, source in enumerate(self.sources): + self.log.info('Initializing Video Preview %s', source) + + preview = uibuilder.get_check_widget('widget_preview', clone=True) + video = uibuilder.find_widget_recursive(preview, 'video') + + video.set_size_request(width, height) + drawing_area.pack_start(preview, fill=False, expand=False, padding=0) + + player = VideoDisplay(video, port=13000 + idx) + + uibuilder.find_widget_recursive(preview, 'label').set_label(source) + btn_a = uibuilder.find_widget_recursive(preview, 'btn_a') + btn_b = uibuilder.find_widget_recursive(preview, 'btn_b') + + btn_a.set_name("%c %u" % ('a', idx)) + btn_b.set_name("%c %u" % ('b', idx)) + + if not group_a: + group_a = btn_a + else: + btn_a.join_group(group_a) + + + if not group_b: + group_b = btn_b + else: + btn_b.join_group(group_b) + + + btn_a.connect('toggled', self.btn_toggled) + btn_b.connect('toggled', self.btn_toggled) + + key, mod = Gtk.accelerator_parse('%u' % (idx+1)) + btn_a.add_accelerator('activate', accelerators, key, mod, Gtk.AccelFlags.VISIBLE) + + key, mod = Gtk.accelerator_parse('<Ctrl>%u' % (idx+1)) + btn_b.add_accelerator('activate', accelerators, key, mod, Gtk.AccelFlags.VISIBLE) + + self.preview_players[source] = player + self.previews[source] = preview + + def btn_toggled(self, btn): + if not btn.get_active(): + return + + self.log.info('btn_toggled: %s', btn.get_name()) |