File: GstPbutils.py

package info (click to toggle)
gst-python1.0 1.26.4-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 988 kB
  • sloc: python: 8,030; ansic: 1,869; makefile: 33
file content (90 lines) | stat: -rw-r--r-- 3,074 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# -*- Mode: Python; py-indent-offset: 4 -*-
# vim: tabstop=4 shiftwidth=4 expandtab
#
#       Gst.py
#
# Copyright (C) 2012 Alessandro Decina <alessandro.d@gmail.com>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This program 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this program; if not, write to the
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
# Boston, MA 02110-1301, USA.
#
# SPDX-License-Identifier: LGPL-2.0-or-later

from ..overrides import override as override_
from ..module import get_introspection_module

import gi
gi.require_version('Gst', '1.0')

from gi.repository import Gst  # noqa

GstPbutils = get_introspection_module('GstPbutils')
__all__ = []


def override(cls):
    name = cls.__name__
    globals()[name] = override_(cls)
    __all__.append(name)

    return cls

real_init = GstPbutils.pb_utils_init
def init():
    if not Gst.is_initialized():
        raise RuntimeError("Gst.init() needs to be called before importing GstPbutils")

    real_init()

    @override
    class EncodingVideoProfile(GstPbutils.EncodingVideoProfile):
        def __init__(self, format, preset=None, restriction=None, presence=0):
            GstPbutils.EncodingVideoProfile.__init__(self)
            self.set_format(format)
            if preset is not None:
                self.set_preset(preset)
            if restriction is None:
                restriction = Gst.Caps('ANY')
            self.set_restriction(restriction)
            self.set_presence(presence)

    @override
    class EncodingAudioProfile(GstPbutils.EncodingAudioProfile):
        def __init__(self, format, preset=None, restriction=None, presence=0):
            GstPbutils.EncodingAudioProfile.__init__(self)
            self.set_format(format)
            if preset is not None:
                self.set_preset(preset)
            if restriction is None:
                restriction = Gst.Caps('ANY')
            self.set_restriction(restriction)
            self.set_presence(presence)

    @override
    class EncodingContainerProfile(GstPbutils.EncodingContainerProfile):
        def __init__(self, name, description, format, preset=None):
            GstPbutils.EncodingContainerProfile.__init__(self)
            self.set_format(format)
            if name is not None:
                self.set_name(name)
            if description is not None:
                self.set_description(description)
            if preset is not None:
                self.set_preset(preset)

GstPbutils.pb_utils_init = init
GstPbutils.init = init
if Gst.is_initialized():
    init()