summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2019-01-30 15:45:21 -0300
committerThibault Saunier <tsaunier@igalia.com>2019-01-30 15:46:35 -0300
commit96ecb224683f4a01217971308149e5a36f20895e (patch)
tree7c9eccc764a349cea032669ce9120f94226a2b50
parent8e42b632016ca0eb237721a002de23373cec04ca (diff)
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.
-rw-r--r--gi/overrides/Gst.py2
-rw-r--r--gi/overrides/GstPbutils.py75
2 files changed, 43 insertions, 34 deletions
diff --git a/gi/overrides/Gst.py b/gi/overrides/Gst.py
index 499e82f..075366b 100644
--- a/gi/overrides/Gst.py
+++ b/gi/overrides/Gst.py
@@ -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:
diff --git a/gi/overrides/GstPbutils.py b/gi/overrides/GstPbutils.py
index f8e5e73..74fd33e 100644
--- a/gi/overrides/GstPbutils.py
+++ b/gi/overrides/GstPbutils.py
@@ -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() \ No newline at end of file