<commit_before>#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
Copyright 2012-2015 OpenBroadcaster, Inc.

This file is part of OpenBroadcaster Player.

OpenBroadcaster Player is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenBroadcaster Player is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with OpenBroadcaster Player.  If not, see <http://www.gnu.org/licenses/>.
"""

import obplayer

import os
import sys
import time
import traceback

import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst, GstVideo

Overlay = None


class ObOutputBin (object):
    def __init__(self, name):
        self.bin = Gst.ElementFactory.make('bin', name)

    def get_bin(self):
        return self.bin

    def build_pipeline(self, elements):
        for element in elements:
            obplayer.Log.log("adding element to bin: " + element.get_name(), 'debug')
            self.bin.add(element)
        for index in range(0, len(elements) - 1):
            elements[index].link(elements[index + 1])


class ObFakeOutputBin (ObOutputBin):
    def __init__(self):
        self.bin = Gst.ElementFactory.make('fakesink', 'fake-output-bin')


class ObAudioOutputBin (ObOutputBin):
    def __init__(self):
        ObOutputBin.__init__(self, 'audio-output-bin')

        self.elements = [ ]

        #self.elements.append(Gst.ElementFactory.make("audioconvert"))
        #self.elements.append(Gst.ElementFactory.make("audioresample"))

        ## create caps filter element to set the output audio parameters
        caps = Gst.ElementFactory.make('capsfilter', "audiocapsfilter")
        #caps.set_property('caps', Gst.Caps.from_string("audio/x-raw,channels=2,rate=44100,format=S16LE,layout=interleaved"))
        caps.set_property('caps', Gst.Caps.from_string("audio/x-raw,channels=2"))
        self.elements.append(caps)

        # create filter elements
        level = Gst.ElementFactory.make("level", "level")
        level.set_property('interval', int(0.5 * Gst.SECOND))
        self.elements.append(level)

        self.tee = Gst.ElementFactory.make("tee")
        self.elements.append(self.tee)
        self.elements.append(Gst.ElementFactory.make("queue2"))

        ## create audio sink element
        audio_output = obplayer.Config.setting('audio_out_mode')
        if audio_output == 'alsa':
            self.audiosink = Gst.ElementFactory.make('alsasink', 'audiosink')<commit_msg>Fixed bug where intersink with no output caused an exception<commit_after>#!/usr/bin/python3
# -*- coding: utf-8 -*-

"""
Copyright 2012-2015 OpenBroadcaster, Inc.

This file is part of OpenBroadcaster Player.

OpenBroadcaster Player is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

OpenBroadcaster Player is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License
along with OpenBroadcaster Player.  If not, see <http://www.gnu.org/licenses/>.
"""

import obplayer

import os
import sys
import time
import traceback

import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst, GstVideo

Overlay = None


class ObOutputBin (object):
    def __init__(self, name):
        self.bin = Gst.ElementFactory.make('bin', name)

    def get_bin(self):
        return self.bin

    def build_pipeline(self, elements):
        for element in elements:
            obplayer.Log.log("adding element to bin: " + element.get_name(), 'debug')
            self.bin.add(element)
        for index in range(0, len(elements) - 1):
            elements[index].link(elements[index + 1])


class ObFakeOutputBin (ObOutputBin):
    def __init__(self):
        self.bin = Gst.ElementFactory.make('fakesink', 'fake-output-bin')

    def add_inter_tap(self, name):
        pass


class ObAudioOutputBin (ObOutputBin):
    def __init__(self):
        ObOutputBin.__init__(self, 'audio-output-bin')

        self.elements = [ ]

        #self.elements.append(Gst.ElementFactory.make("audioconvert"))
        #self.elements.append(Gst.ElementFactory.make("audioresample"))

        ## create caps filter element to set the output audio parameters
        caps = Gst.ElementFactory.make('capsfilter', "audiocapsfilter")
        #caps.set_property('caps', Gst.Caps.from_string("audio/x-raw,channels=2,rate=44100,format=S16LE,layout=interleaved"))
        caps.set_property('caps', Gst.Caps.from_string("audio/x-raw,channels=2"))
        self.elements.append(caps)

        # create filter elements
        level = Gst.ElementFactory.make("level", "level")
        level.set_property('interval', int(0.5 * Gst.SECOND))
        self.elements.append(level)

        self.tee = Gst.ElementFactory.make("tee")
        self.elements.append(self.tee)
        self.elements.append(Gst.ElementFactory.make("queue2"))

        ## create audio sink element
        audio_output = obplayer.Config.setting('audio_out_mode')
        if audio_output == 'alsa':
            self.audiosink = Gst.ElementFactory.make('alsasink', 'audiosink')
{'fraction_non_alphanumeric': 0.107426597582038, 'fraction_numerical': 0.009671848013816925, 'mean_word_length': 3.4718146718146716, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1522496', 'n_tokens_mistral': 1730, 'n_tokens_neox': 1661, 'n_words': 482}