mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
Gst.init() has to be called before GstPbutils is imported
This makes sure that we do not try to use GstPbutils before Gst is init and in case GstPbutils is imported while Gst is not imported, use the `GstPbutils.pb_utils_init()` function to have the oportunity to initialize the overrides. Not that we also introduce a `GstPbutils.init()` variant because `GstPbutils.pb_utils_init()` is an ugly name.
This commit is contained in:
parent
8e42b63201
commit
96ecb22468
2 changed files with 43 additions and 34 deletions
|
@ -626,7 +626,7 @@ def init_pygst():
|
|||
|
||||
def deinit_pygst():
|
||||
for fname, func in real_functions:
|
||||
if fname not in ["init", "init_check", "deinit"]:
|
||||
if fname not in ["init", "init_check", "deinit", "is_initialized"]:
|
||||
setattr(Gst, fname, fake_method)
|
||||
for cname_class, methods in class_methods:
|
||||
for mname, method in methods:
|
||||
|
|
|
@ -43,41 +43,50 @@ def override(cls):
|
|||
|
||||
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")
|
||||
|
||||
@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)
|
||||
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 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)
|
||||
|
||||
@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()
|
Loading…
Reference in a new issue