Ejemplo n.º 1
0
    def setup(self):
        self.log.info('Initializing Ui')

        # Aquire the Main-Window from the UI-File
        self.win = self.get_check_widget('window')

        # Connect Close-Handler
        self.win.connect('delete-event', Gtk.main_quit)

        # Create Audio-Level Display
        drawing_area = self.find_widget_recursive(self.win, 'audiolevel_main')
        self.audio_level_display = AudioLevelDisplay(drawing_area)

        # Create Main-Video Overlay Controller
        drawing_area = self.find_widget_recursive(self.win,
                                                  'video_overlay_drawingarea')
        self.video_warning_overlay = VideoWarningOverlay(drawing_area)

        # Create Main-Video Display
        drawing_area = self.find_widget_recursive(self.win, 'video_main')
        self.main_video_display = VideoDisplay(
            drawing_area,
            port=11000,
            play_audio=Config.getboolean('mainvideo', 'playaudio'),
            level_callback=self.audio_level_display.level_callback)

        # Setup Preview Controller
        box_left = self.find_widget_recursive(self.win, 'box_left')
        self.video_previews_controller = VideoPreviewsController(
            box_left, win=self.win, uibuilder=self)

        # check if there is a fixed audio source configured.
        # if so, remove the combo-box entirely instead of setting it up.
        if Config.has_option('mix', 'audiosource'):
            box_audio = self.find_widget_recursive(self.win, 'box_audio')
            box_left.remove(box_audio)
        else:
            combo_audio = self.find_widget_recursive(self.win, 'combo_audio')
            self.audio_selector_controller = AudioSelectorController(
                combo=combo_audio, win=self.win, uibuilder=self)

        # Setup Toolbar Controllers
        toolbar = self.find_widget_recursive(self.win, 'toolbar')
        self.composition_toolbar_controller = CompositionToolbarController(
            toolbar, win=self.win, uibuilder=self)

        self.streamblank_toolbar_controller = StreamblankToolbarController(
            toolbar,
            win=self.win,
            uibuilder=self,
            warning_overlay=self.video_warning_overlay)

        self.misc_controller = MiscToolbarController(toolbar,
                                                     win=self.win,
                                                     uibuilder=self)

        # Setup Shortcuts window
        self.win.connect('key-press-event', self.handle_keypress)
Ejemplo n.º 2
0
    def setup(self):
        self.log.info('Initializing Ui')

        # Aquire the Main-Window from the UI-File
        self.win = self.get_check_widget('window')

        # Connect Close-Handler
        self.win.connect('delete-event', Gtk.main_quit)

        # Create Audio-Level Display
        drawing_area = self.find_widget_recursive(self.win, 'audiolevel_main')
        self.audio_level_display = AudioLevelDisplay(drawing_area)

        # Create Main-Video Overlay Controller
        self.video_warning_overlay = VideoWarningOverlay()

        # Create Main-Video Display
        drawing_area = self.find_widget_recursive(self.win, 'video_main')
        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)

        # Setup Preview Controller
        drawing_area = self.find_widget_recursive(self.win, 'box_left')
        self.video_previews_controller = VideoPreviewsController(
            drawing_area, win=self.win, uibuilder=self)

        drawing_area = self.find_widget_recursive(self.win, 'combo_audio')
        self.audio_selector_controller = AudioSelectorController(
            drawing_area, win=self.win, uibuilder=self)

        # Setup Toolbar Controllers
        toolbar = self.find_widget_recursive(self.win, 'toolbar')
        self.composition_toolbar_controller = CompositionToolbarController(
            toolbar, win=self.win, uibuilder=self)

        self.streamblank_toolbar_controller = StreamblankToolbarController(
            toolbar,
            win=self.win,
            uibuilder=self,
            warning_overlay=self.video_warning_overlay)

        self.special_functions_toolbar_controller = SpecialFunctionsToolbarController(
            toolbar,
            win=self.win,
            uibuilder=self,
            video_display=self.main_video_display)
    def __init__(self, preview_box, win, uibuilder):
        self.log = logging.getLogger('VideoPreviewsController')

        self.preview_box = preview_box
        self.win = win

        self.sources = Config.getlist('mix', 'sources')
        self.preview_players = {}
        self.previews = {}
        self.a_btns = {}
        self.b_btns = {}

        self.current_source = {'a': None, 'b': None}

        try:
            width = Config.getint('previews', 'width')
            self.log.debug('Preview-Width configured to %u', width)
        except NoOptionError:
            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', height)
        except NoOptionError:
            height = int(width * 9 / 16)
            self.log.debug('Preview-Height calculated to %u', height)

        # 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)
            preview_box.pack_start(preview, fill=False,
                                   expand=False, padding=0)

            player = VideoDisplay(video, port=13000 + idx,
                                  width=width, height=height)

            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)
            tooltip = Gtk.accelerator_get_label(key, mod)
            btn_a.set_tooltip_text(tooltip)

            key, mod = Gtk.accelerator_parse('<Ctrl>%u' % (idx + 1))
            btn_b.add_accelerator('activate', accelerators,
                                  key, mod, Gtk.AccelFlags.VISIBLE)
            tooltip = Gtk.accelerator_get_label(key, mod)
            btn_b.set_tooltip_text(tooltip)

            btn_fullscreen = uibuilder.find_widget_recursive(preview,
                                                             'btn_fullscreen')
            btn_fullscreen.set_name("%c %u" % ('f', idx))

            btn_fullscreen.connect('clicked', self.btn_fullscreen_clicked)

            key, mod = Gtk.accelerator_parse('<Alt>%u' % (idx + 1))
            btn_fullscreen.add_accelerator('activate', accelerators,
                                           key, mod, Gtk.AccelFlags.VISIBLE)
            tooltip = Gtk.accelerator_get_label(key, mod)
            btn_fullscreen.set_tooltip_text(tooltip)

            self.preview_players[source] = player
            self.previews[source] = preview
            self.a_btns[source] = btn_a
            self.b_btns[source] = btn_b

        # connect event-handler and request initial state
        Connection.on('video_status', self.on_video_status)
        Connection.send('get_video')
Ejemplo n.º 4
0
	def __init__(self, drawing_area, win, uibuilder):
		self.log = logging.getLogger('VideoPreviewsController')

		self.drawing_area = drawing_area
		self.win = win

		self.sources = Config.getlist('mix', 'sources')
		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
Ejemplo n.º 5
0
    def __init__(self, preview_box, win, uibuilder):
        self.log = logging.getLogger('VideoPreviewsController')

        self.preview_box = preview_box
        self.win = win

        self.sources = Config.getlist('mix', 'sources')
        self.preview_players = {}
        self.previews = {}
        self.a_btns = {}
        self.b_btns = {}
        self.volume_sliders = {}

        self.current_source = {'a': None, 'b': None}

        try:
            width = Config.getint('previews', 'width')
            self.log.debug('Preview-Width configured to %u', width)
        except NoOptionError:
            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', height)
        except NoOptionError:
            height = int(width * 9 / 16)
            self.log.debug('Preview-Height calculated to %u', height)

        # Accelerators
        accelerators = Gtk.AccelGroup()
        win.add_accel_group(accelerators)

        group_a = None
        group_b = None

        # Check if there is a fixed audio source configured.
        # If so, we will remove the volume sliders entirely
        # instead of setting them up.
        volume_control = \
            Config.getboolean('audio', 'volumecontrol', fallback=True) or \
            Config.getboolean('audio', 'forcevolumecontrol', fallback=False)

        for idx, source in enumerate(self.sources):
            self.log.info('Initializing Video Preview %s', source)

            preview = uibuilder.load_check_widget(
                'widget_preview',
                os.path.dirname(uibuilder.uifile) + "/widgetpreview.ui")
            video = uibuilder.find_widget_recursive(preview, 'video')

            video.set_size_request(width, height)
            preview_box.pack_start(preview, fill=False,
                                   expand=False, padding=0)

            player = VideoDisplay(video, port=13000 + idx,
                                  width=width, height=height)

            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)
            tooltip = Gtk.accelerator_get_label(key, mod)
            btn_a.set_tooltip_text(tooltip)

            key, mod = Gtk.accelerator_parse('<Ctrl>%u' % (idx + 1))
            btn_b.add_accelerator('activate', accelerators,
                                  key, mod, Gtk.AccelFlags.VISIBLE)
            tooltip = Gtk.accelerator_get_label(key, mod)
            btn_b.set_tooltip_text(tooltip)

            volume_slider = uibuilder.find_widget_recursive(preview,
                                                            'audio_level')

            if not volume_control:
                box = uibuilder.find_widget_recursive(preview, 'box')
                box.remove(volume_slider)
            else:
                volume_slider.set_name("volume {}".format(source))
                volume_signal = volume_slider.connect('value-changed',
                                                      self.slider_changed)

                def slider_format(scale, value):
                    if value == -20.0:
                        return "-\u221e\u202fdB"
                    else:
                        return "{:.{}f}\u202fdB".format(value,
                                                        scale.get_digits())

                volume_slider.connect('format-value', slider_format)
                self.volume_sliders[source] = (volume_slider, volume_signal)

            self.preview_players[source] = player
            self.previews[source] = preview
            self.a_btns[source] = btn_a
            self.b_btns[source] = btn_b

        # connect event-handler and request initial state
        Connection.on('video_status', self.on_video_status)
        Connection.send('get_video')

        if volume_control:
            Connection.on('audio_status', self.on_audio_status)
            Connection.send('get_audio')
Ejemplo n.º 6
0
    def setup(self):
        self.log.info('Initializing Ui')

        # Aquire the Main-Window from the UI-File
        self.win = self.get_check_widget('window')

        # check for configuration option mainwindow/force_fullscreen
        if Config.getboolean('mainwindow', 'forcefullscreen', fallback=False):
            self.log.info(
                'Forcing main window to full screen by configuration')
            # set window into fullscreen mode
            self.win.fullscreen()
        else:
            # check for configuration option mainwindow/width and /height
            if Config.has_option('mainwindow', 'width') \
                    and Config.has_option('mainwindow', 'height'):
                # get size from config
                width = Config.getint('mainwindow', 'width')
                height = Config.getint('mainwindow', 'height')
                self.log.info(
                    'Set window size by configuration to %d:%d', width, height)
                # set window size
                self.win.set_size_request(width, height)
                self.win.set_resizable(False)

        # Connect Close-Handler
        self.win.connect('delete-event', Gtk.main_quit)

        # Create Audio-Level Display
        drawing_area = self.find_widget_recursive(self.win, 'audiolevel_main')
        self.audio_level_display = AudioLevelDisplay(drawing_area)

        # Create Main-Video Overlay Controller
        drawing_area = self.find_widget_recursive(self.win,
                                                  'video_overlay_drawingarea')
        self.video_warning_overlay = VideoWarningOverlay(drawing_area)

        # Create Main-Video Display
        drawing_area = self.find_widget_recursive(self.win, 'video_main')
        self.main_video_display = VideoDisplay(
            drawing_area,
            port=11000,
            play_audio=Config.getboolean('mainvideo', 'playaudio'),
            level_callback=self.audio_level_display.level_callback
        )

        # Setup Preview Controller
        box_left = self.find_widget_recursive(self.win, 'box_left')
        self.video_previews_controller = VideoPreviewsController(
            box_left,
            win=self.win,
            uibuilder=self
        )

        # Setup Toolbar Controllers
        toolbar = self.find_widget_recursive(self.win, 'toolbar')
        self.composition_toolbar_controller = CompositionToolbarController(
            toolbar,
            win=self.win,
            uibuilder=self
        )

        self.streamblank_toolbar_controller = StreamblankToolbarController(
            toolbar,
            win=self.win,
            uibuilder=self,
            warning_overlay=self.video_warning_overlay
        )

        self.misc_controller = MiscToolbarController(
            toolbar,
            win=self.win,
            uibuilder=self
        )

        self.rec_controller = RecordingToolbarController(
            toolbar,
            win=self.win,
            uibuilder=self
        )

        toolbar.insert(StudioClock(), len(toolbar.get_children()) - 1)

        # Setup Shortcuts window
        self.win.connect('key-press-event', self.handle_keypress)
        self.win.connect('window-state-event', self.handle_state)