def setUp(self):
        super().setUp()
        self.videomixer = VideoMix()

        self.videomixer.getInputVideoSize = MagicMock(return_value=(42, 23))

        self.videomixer.setVideoSourceA = MagicMock()
        self.videomixer.setVideoSourceB = MagicMock()
class VideomixerSetCompositeMode(VoctomixTest):
    def setUp(self):
        super().setUp()
        self.videomixer = VideoMix()

        self.videomixer.getInputVideoSize = MagicMock(return_value=(42, 23))

        self.videomixer.setVideoSourceA = MagicMock()
        self.videomixer.setVideoSourceB = MagicMock()

    def test_can_set_composite_mode(self):
        Config.add_section('side-by-side-preview')

        self.videomixer.setCompositeMode(CompositeModes.side_by_side_preview)
        self.assertEqual(self.videomixer.compositeMode,
                         CompositeModes.side_by_side_preview)

    def test_set_composite_mode_sets_default_a_source(self):
        Config.given('side-by-side-preview', 'default-a', 'cam1')

        self.videomixer.setCompositeMode(CompositeModes.side_by_side_preview)

        self.videomixer.setVideoSourceA.assert_called_with(0)
        self.videomixer.setVideoSourceB.assert_not_called()

    def test_set_composite_mode_sets_default_b_source(self):
        Config.given('side-by-side-preview', 'default-b', 'cam2')

        self.videomixer.setCompositeMode(CompositeModes.side_by_side_preview)

        self.videomixer.setVideoSourceA.assert_not_called()
        self.videomixer.setVideoSourceB.assert_called_with(1)

    def test_set_composite_mode_sets_default_a_and_b_source(self):
        Config.given('side-by-side-preview', 'default-a', 'grabber')
        Config.given('side-by-side-preview', 'default-b', 'cam1')

        self.videomixer.setCompositeMode(CompositeModes.side_by_side_preview)

        self.videomixer.setVideoSourceA.assert_called_with(2)
        self.videomixer.setVideoSourceB.assert_called_with(0)

    def test_set_composite_mode_does_not_set_default_source_if_requested(self):
        Config.given('side-by-side-preview', 'default-a', 'grabber')
        Config.given('side-by-side-preview', 'default-b', 'cam1')

        self.videomixer.setCompositeMode(CompositeModes.side_by_side_preview,
                                         apply_default_source=False)

        self.videomixer.setVideoSourceA.assert_not_called()
        self.videomixer.setVideoSourceB.assert_not_called()
class VideomixerSetCompositeMode(VoctomixTest):
    def setUp(self):
        super().setUp()
        self.videomixer = VideoMix()

        self.videomixer.getInputVideoSize = MagicMock(return_value=(42, 23))

        self.videomixer.setVideoSourceA = MagicMock()
        self.videomixer.setVideoSourceB = MagicMock()

    def test_can_set_composite_mode(self):
        Config.add_section('side-by-side-preview')

        self.videomixer.setCompositeMode(CompositeModes.side_by_side_preview)
        self.assertEqual(self.videomixer.compositeMode, CompositeModes.side_by_side_preview)

    def test_set_composite_mode_sets_default_a_source(self):
        Config.given('side-by-side-preview', 'default-a', 'cam1')

        self.videomixer.setCompositeMode(CompositeModes.side_by_side_preview)

        self.videomixer.setVideoSourceA.assert_called_with(0)
        self.videomixer.setVideoSourceB.assert_not_called()

    def test_set_composite_mode_sets_default_b_source(self):
        Config.given('side-by-side-preview', 'default-b', 'cam2')

        self.videomixer.setCompositeMode(CompositeModes.side_by_side_preview)

        self.videomixer.setVideoSourceA.assert_not_called()
        self.videomixer.setVideoSourceB.assert_called_with(1)

    def test_set_composite_mode_sets_default_a_and_b_source(self):
        Config.given('side-by-side-preview', 'default-a', 'grabber')
        Config.given('side-by-side-preview', 'default-b', 'cam1')

        self.videomixer.setCompositeMode(CompositeModes.side_by_side_preview)

        self.videomixer.setVideoSourceA.assert_called_with(2)
        self.videomixer.setVideoSourceB.assert_called_with(0)

    def test_set_composite_mode_does_not_set_default_source_if_requested(self):
        Config.given('side-by-side-preview', 'default-a', 'grabber')
        Config.given('side-by-side-preview', 'default-b', 'cam1')

        self.videomixer.setCompositeMode(CompositeModes.side_by_side_preview,
                                         apply_default_source=False)

        self.videomixer.setVideoSourceA.assert_not_called()
        self.videomixer.setVideoSourceB.assert_not_called()
Example #4
0
class VideomixerSetSources(VoctomixTest):
    def setUp(self):
        super().setUp()
        self.videomixer = VideoMix()

    def test_can_set_source_a(self):
        self.videomixer.setVideoSourceA(42)
        self.assertEqual(self.videomixer.sourceA, 42)

    def test_can_set_source_b(self):
        self.videomixer.setVideoSourceB(23)
        self.assertEqual(self.videomixer.sourceB, 23)

    def test_setting_source_a_swaps_a_and_b_if_required(self):
        self.videomixer.sourceA = 42
        self.videomixer.sourceB = 23

        self.videomixer.setVideoSourceA(23)

        self.assertEqual(self.videomixer.sourceA, 23)
        self.assertEqual(self.videomixer.sourceB, 42)

    def test_setting_source_b_swaps_a_and_b_if_required(self):
        self.videomixer.sourceA = 13
        self.videomixer.sourceB = 78

        self.videomixer.setVideoSourceB(13)

        self.assertEqual(self.videomixer.sourceA, 78)
        self.assertEqual(self.videomixer.sourceB, 13)
    def setUp(self):
        super().setUp()
        self.videomixer = VideoMix()

        self.videomixer.getInputVideoSize = MagicMock(return_value=(42, 23))

        self.videomixer.setVideoSourceA = MagicMock()
        self.videomixer.setVideoSourceB = MagicMock()
Example #6
0
    def __init__(self):
        self.log = logging.getLogger('Pipeline')
        self.log.info('Video-Caps configured to: %s',
                      Config.get('mix', 'videocaps'))
        self.log.info('Audio-Caps configured to: %s',
                      Config.get('mix', 'audiocaps'))

        names = Config.getlist('mix', 'sources')
        if len(names) < 1:
            raise RuntimeException("At least one AVSource must be configured!")

        self.sources = []
        self.mirrors = []
        self.previews = []
        self.sbsources = []

        self.log.info('Creating %u Creating AVSources: %s', len(names), names)
        for idx, name in enumerate(names):
            port = 10000 + idx
            self.log.info('Creating AVSource %s at tcp-port %u', name, port)

            source = AVSource(name, port)
            self.sources.append(source)

            port = 13000 + idx
            self.log.info(
                'Creating Mirror-Output for AVSource %s at tcp-port %u', name,
                port)

            mirror = AVRawOutput('%s_mirror' % name, port)
            self.mirrors.append(mirror)

            if Config.getboolean('previews', 'enabled'):
                port = 14000 + idx
                self.log.info(
                    'Creating Preview-Output for AVSource %s at tcp-port %u',
                    name, port)

                preview = AVPreviewOutput('%s_preview' % name, port)
                self.previews.append(preview)

        self.log.info('Creating Videmixer')
        self.vmix = VideoMix()

        self.log.info('Creating Audiomixer')
        self.amix = AudioMix()

        port = 16000
        self.log.info('Creating Mixer-Background VSource at tcp-port %u', port)
        self.bgsrc = VSource('background', port)

        port = 11000
        self.log.info('Creating Mixer-Output at tcp-port %u', port)
        self.mixout = AVRawOutput('mix_out', port)

        if Config.getboolean('previews', 'enabled'):
            port = 12000
            self.log.info(
                'Creating Preview-Output for AVSource %s at tcp-port %u', name,
                port)

            self.mixpreview = AVPreviewOutput('mix_preview', port)

        if Config.getboolean('stream-blanker', 'enabled'):
            names = Config.getlist('stream-blanker', 'sources')
            if len(names) < 1:
                raise RuntimeException(
                    "At least one StreamBlanker-Source must be configured or the StreamBlanker disabled!"
                )
            for idx, name in enumerate(names):
                port = 17000 + idx
                self.log.info(
                    'Creating StreamBlanker VSource %s at tcp-port %u', name,
                    port)

                source = VSource('%s_streamblanker' % name, port)
                self.sbsources.append(source)

            port = 18000
            self.log.info('Creating StreamBlanker ASource at tcp-port %u',
                          port)

            source = ASource('streamblanker', port)
            self.sbsources.append(source)

        self.log.info('Creating StreamBlanker')
        self.streamblanker = StreamBlanker()

        port = 15000
        self.log.info('Creating StreamBlanker-Output at tcp-port %u', port)
        self.streamout = AVRawOutput('streamblanker_out', port)
Example #7
0
    def __init__(self):
        self.log = logging.getLogger('Pipeline')
        self.log.info('Video-Caps configured to: %s',
                      Config.get('mix', 'videocaps'))
        self.log.info('Audio-Caps configured to: %s',
                      Config.get('mix', 'audiocaps'))

        names = Config.getlist('mix', 'sources')
        if len(names) < 1:
            raise RuntimeError("At least one AVSource must be configured!")

        self.sources = []
        self.mirrors = []
        self.previews = []
        self.sbsources = []

        self.log.info('Creating %u Creating AVSources: %s', len(names), names)
        for idx, name in enumerate(names):
            port = 10000 + idx
            self.log.info('Creating AVSource %s at tcp-port %u', name, port)

            outputs = [name + '_mixer', name + '_mirror']
            if Config.getboolean('previews', 'enabled'):
                outputs.append(name + '_preview')

            source = AVSource(name, port, outputs=outputs)
            self.sources.append(source)

            port = 13000 + idx
            self.log.info(
                'Creating Mirror-Output for AVSource %s '
                'at tcp-port %u', name, port)

            mirror = AVRawOutput('%s_mirror' % name, port)
            self.mirrors.append(mirror)

            if Config.getboolean('previews', 'enabled'):
                port = 14000 + idx
                self.log.info(
                    'Creating Preview-Output for AVSource %s '
                    'at tcp-port %u', name, port)

                preview = AVPreviewOutput('%s_preview' % name, port)
                self.previews.append(preview)

        self.log.info('Creating Videmixer')
        self.vmix = VideoMix()

        # check if there is an audio source preconfigured
        try:
            audiosource = names.index(Config.get('mix', 'audiosource'))
        except NoOptionError:
            audiosource = 0

        self.log.info('Creating Audiomixer')
        self.amix = AudioMix(audiosource)

        port = 16000
        self.log.info('Creating Mixer-Background VSource at tcp-port %u', port)
        self.bgsrc = AVSource('background', port, has_audio=False)

        port = 11000
        self.log.info('Creating Mixer-Output at tcp-port %u', port)
        self.mixout = AVRawOutput('mix_out', port)

        if Config.getboolean('previews', 'enabled'):
            port = 12000
            self.log.info(
                'Creating Preview-Output for AVSource %s '
                'at tcp-port %u', name, port)

            self.mixpreview = AVPreviewOutput('mix_preview', port)

        if Config.getboolean('stream-blanker', 'enabled'):
            names = Config.getlist('stream-blanker', 'sources')
            if len(names) < 1:
                raise RuntimeError('At least one StreamBlanker-Source must '
                                   'be configured or the '
                                   'StreamBlanker disabled!')
            for idx, name in enumerate(names):
                port = 17000 + idx
                self.log.info(
                    'Creating StreamBlanker VSource %s '
                    'at tcp-port %u', name, port)

                source = AVSource('{}_streamblanker'.format(name),
                                  port,
                                  has_audio=False)
                self.sbsources.append(source)

            port = 18000
            self.log.info('Creating StreamBlanker ASource at tcp-port %u',
                          port)

            source = AVSource('streamblanker', port, has_video=False)
            self.sbsources.append(source)

            self.log.info('Creating StreamBlanker')
            self.streamblanker = StreamBlanker()

            port = 15000
            self.log.info('Creating StreamBlanker-Output at tcp-port %u', port)
            self.streamout = AVRawOutput('streamblanker_out', port)
Example #8
0
 def setUp(self):
     super().setUp()
     self.videomixer = VideoMix()