Created
November 8, 2024 17:58
-
-
Save rgonzalezfluendo/ae47c81262760018b159b172ff2d3215 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import ctypes | |
from pathlib import Path | |
class GstPluginDesc(ctypes.Structure): | |
_fields_ = [ | |
("major_version", ctypes.c_int), | |
("minor_version", ctypes.c_int), | |
("name", ctypes.c_char_p), | |
("description", ctypes.c_char_p), | |
("plugin_init", ctypes.c_void_p), # Assuming it's a function pointer | |
("version", ctypes.c_char_p), | |
("license", ctypes.c_char_p), | |
("source", ctypes.c_char_p), | |
("package", ctypes.c_char_p), | |
("origin", ctypes.c_char_p), | |
] | |
def print(self): | |
print("Major version:", self.major_version) | |
print("Minor version:", self.minor_version) | |
print("Name:", self.name.decode('utf-8')) | |
print("Description:", self.description.decode('utf-8')) | |
print("Version:", self.version.decode('utf-8')) | |
print("License:", self.license.decode('utf-8')) | |
print("Source:", self.source.decode('utf-8')) | |
print("Package:", self.package.decode('utf-8')) | |
print("Origin:", self.origin.decode('utf-8')) | |
parser = argparse.ArgumentParser("mini-gst-inspect") | |
parser.add_argument('libfile') | |
args = parser.parse_args() | |
lib = ctypes.CDLL(args.libfile) | |
gst_plugin_desc_sym = getattr(lib, "gst_plugin_desc", None) | |
if gst_plugin_desc_sym: | |
plugin_desc = ctypes.cast(gst_plugin_desc_sym, ctypes.POINTER(GstPluginDesc)).contents | |
else: | |
p = Path(args.libfile).stem | |
name = p[6:] if p[0:6] == "libgst" else p # TODO mimic extract_symname | |
gst_plugin_get_desc_sym = getattr(lib, f"gst_plugin_{name}_get_desc") | |
gst_plugin_get_desc_sym.restype = ctypes.POINTER(GstPluginDesc) | |
plugin_desc = gst_plugin_get_desc_sym().contents | |
plugin_desc.print() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment