mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-25 16:48:11 +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,9 +43,15 @@ 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):
|
||||
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)
|
||||
|
@ -56,9 +62,8 @@ class EncodingVideoProfile(GstPbutils.EncodingVideoProfile):
|
|||
self.set_restriction(restriction)
|
||||
self.set_presence(presence)
|
||||
|
||||
|
||||
@override
|
||||
class EncodingAudioProfile(GstPbutils.EncodingAudioProfile):
|
||||
@override
|
||||
class EncodingAudioProfile(GstPbutils.EncodingAudioProfile):
|
||||
def __init__(self, format, preset=None, restriction=None, presence=0):
|
||||
GstPbutils.EncodingAudioProfile.__init__(self)
|
||||
self.set_format(format)
|
||||
|
@ -69,9 +74,8 @@ class EncodingAudioProfile(GstPbutils.EncodingAudioProfile):
|
|||
self.set_restriction(restriction)
|
||||
self.set_presence(presence)
|
||||
|
||||
|
||||
@override
|
||||
class EncodingContainerProfile(GstPbutils.EncodingContainerProfile):
|
||||
@override
|
||||
class EncodingContainerProfile(GstPbutils.EncodingContainerProfile):
|
||||
def __init__(self, name, description, format, preset=None):
|
||||
GstPbutils.EncodingContainerProfile.__init__(self)
|
||||
self.set_format(format)
|
||||
|
@ -81,3 +85,8 @@ class EncodingContainerProfile(GstPbutils.EncodingContainerProfile):
|
|||
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