gstplugin.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367
  1. /* GStreamer
  2. * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
  3. * 2000 Wim Taymans <wtay@chello.be>
  4. *
  5. * gstplugin.h: Header for plugin subsystem
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  20. * Boston, MA 02110-1301, USA.
  21. */
  22. #ifndef __GST_PLUGIN_H__
  23. #define __GST_PLUGIN_H__
  24. #include <gst/gstconfig.h>
  25. #include <gst/gstobject.h>
  26. #include <gst/gstmacros.h>
  27. #include <gst/gststructure.h>
  28. G_BEGIN_DECLS
  29. /**
  30. * GstPlugin:
  31. *
  32. * The opaque plugin object
  33. */
  34. typedef struct _GstPlugin GstPlugin;
  35. typedef struct _GstPluginClass GstPluginClass;
  36. typedef struct _GstPluginDesc GstPluginDesc;
  37. /**
  38. * gst_plugin_error_quark:
  39. *
  40. * Get the error quark.
  41. *
  42. * Returns: The error quark used in GError messages
  43. */
  44. GQuark gst_plugin_error_quark (void);
  45. /**
  46. * GST_PLUGIN_ERROR:
  47. *
  48. * The error message category quark
  49. */
  50. #define GST_PLUGIN_ERROR gst_plugin_error_quark ()
  51. /**
  52. * GstPluginError:
  53. * @GST_PLUGIN_ERROR_MODULE: The plugin could not be loaded
  54. * @GST_PLUGIN_ERROR_DEPENDENCIES: The plugin has unresolved dependencies
  55. * @GST_PLUGIN_ERROR_NAME_MISMATCH: The plugin has already be loaded from a different file
  56. *
  57. * The plugin loading errors
  58. */
  59. typedef enum
  60. {
  61. GST_PLUGIN_ERROR_MODULE,
  62. GST_PLUGIN_ERROR_DEPENDENCIES,
  63. GST_PLUGIN_ERROR_NAME_MISMATCH
  64. } GstPluginError;
  65. /**
  66. * GstPluginFlags:
  67. * @GST_PLUGIN_FLAG_CACHED: Temporarily loaded plugins
  68. * @GST_PLUGIN_FLAG_BLACKLISTED: The plugin won't be scanned (again)
  69. *
  70. * The plugin loading state
  71. */
  72. typedef enum
  73. {
  74. GST_PLUGIN_FLAG_CACHED = (GST_OBJECT_FLAG_LAST << 0),
  75. GST_PLUGIN_FLAG_BLACKLISTED = (GST_OBJECT_FLAG_LAST << 1)
  76. } GstPluginFlags;
  77. /**
  78. * GstPluginDependencyFlags:
  79. * @GST_PLUGIN_DEPENDENCY_FLAG_NONE : no special flags
  80. * @GST_PLUGIN_DEPENDENCY_FLAG_RECURSE : recurse into subdirectories
  81. * @GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY : use paths
  82. * argument only if none of the environment variables is set
  83. * @GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX : interpret
  84. * filename argument as filter suffix and check all matching files in
  85. * the directory
  86. * @GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX : interpret
  87. * filename argument as filter prefix and check all matching files in
  88. * the directory. Since 1.8.
  89. *
  90. * Flags used in connection with gst_plugin_add_dependency().
  91. */
  92. typedef enum {
  93. GST_PLUGIN_DEPENDENCY_FLAG_NONE = 0,
  94. GST_PLUGIN_DEPENDENCY_FLAG_RECURSE = (1 << 0),
  95. GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY = (1 << 1),
  96. GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX = (1 << 2),
  97. GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX = (1 << 3)
  98. } GstPluginDependencyFlags;
  99. /**
  100. * GstPluginInitFunc:
  101. * @plugin: The plugin object
  102. *
  103. * A plugin should provide a pointer to a function of this type in the
  104. * plugin_desc struct.
  105. * This function will be called by the loader at startup. One would then
  106. * register each #GstPluginFeature.
  107. *
  108. * Returns: %TRUE if plugin initialised successfully
  109. */
  110. /* FIXME 0.11: Make return void */
  111. typedef gboolean (*GstPluginInitFunc) (GstPlugin *plugin);
  112. /**
  113. * GstPluginInitFullFunc:
  114. * @plugin: The plugin object
  115. * @user_data: extra data
  116. *
  117. * A plugin should provide a pointer to a function of either #GstPluginInitFunc
  118. * or this type in the plugin_desc struct.
  119. * The function will be called by the loader at startup. One would then
  120. * register each #GstPluginFeature. This version allows
  121. * user data to be passed to init function (useful for bindings).
  122. *
  123. * Returns: %TRUE if plugin initialised successfully
  124. */
  125. /* FIXME 0.11: Merge with GstPluginInitFunc */
  126. typedef gboolean (*GstPluginInitFullFunc) (GstPlugin *plugin, gpointer user_data);
  127. /**
  128. * GstPluginDesc:
  129. * @major_version: the major version number of core that plugin was compiled for
  130. * @minor_version: the minor version number of core that plugin was compiled for
  131. * @name: a unique name of the plugin
  132. * @description: description of plugin
  133. * @plugin_init: pointer to the init function of this plugin.
  134. * @version: version of the plugin
  135. * @license: effective license of plugin
  136. * @source: source module plugin belongs to
  137. * @package: shipped package plugin belongs to
  138. * @origin: URL to provider of plugin
  139. * @release_datetime: (allow-none): date time string in ISO 8601
  140. * format (or rather, a subset thereof), or %NULL. Allowed are the
  141. * following formats: "YYYY-MM-DD" and "YYY-MM-DDTHH:MMZ" (with
  142. * 'T' a separator and 'Z' indicating UTC/Zulu time). This field
  143. * should be set via the GST_PACKAGE_RELEASE_DATETIME
  144. * preprocessor macro.
  145. *
  146. * A plugin should export a variable of this type called plugin_desc. The plugin
  147. * loader will use the data provided there to initialize the plugin.
  148. *
  149. * The @licence parameter must be one of: LGPL, GPL, QPL, GPL/QPL, MPL,
  150. * BSD, MIT/X11, Proprietary, unknown.
  151. */
  152. struct _GstPluginDesc {
  153. gint major_version;
  154. gint minor_version;
  155. const gchar *name;
  156. const gchar *description;
  157. GstPluginInitFunc plugin_init;
  158. const gchar *version;
  159. const gchar *license;
  160. const gchar *source;
  161. const gchar *package;
  162. const gchar *origin;
  163. const gchar *release_datetime;
  164. /*< private >*/
  165. gpointer _gst_reserved[GST_PADDING];
  166. };
  167. #define GST_TYPE_PLUGIN (gst_plugin_get_type())
  168. #define GST_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLUGIN))
  169. #define GST_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLUGIN))
  170. #define GST_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLUGIN, GstPluginClass))
  171. #define GST_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLUGIN, GstPlugin))
  172. #define GST_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLUGIN, GstPluginClass))
  173. #define GST_PLUGIN_CAST(obj) ((GstPlugin*)(obj))
  174. #ifdef GST_PACKAGE_RELEASE_DATETIME
  175. #define __GST_PACKAGE_RELEASE_DATETIME GST_PACKAGE_RELEASE_DATETIME
  176. #else
  177. #define __GST_PACKAGE_RELEASE_DATETIME NULL
  178. #endif
  179. /**
  180. * GST_PLUGIN_STATIC_DECLARE:
  181. * @name: short, but unique name of the plugin
  182. *
  183. * This macro can be used to initialize statically linked plugins. It is
  184. * necessary to call this macro before the plugin can be used.
  185. * It has to be used in combination with GST_PLUGIN_STATIC_REGISTER
  186. * and must be placed outside any block to declare the plugin initialization
  187. * function.
  188. *
  189. * Since: 1.2
  190. */
  191. #define GST_PLUGIN_STATIC_DECLARE(name) \
  192. extern void G_PASTE(gst_plugin_, G_PASTE(name, _register)) (void)
  193. /**
  194. * GST_PLUGIN_STATIC_REGISTER:
  195. * @name: short, but unique name of the plugin
  196. *
  197. * This macro can be used to initialize statically linked plugins. It is
  198. * necessary to call this macro before the plugin can be used.
  199. * It has to be used in combination with GST_PLUGIN_STATIC_DECLARE and
  200. * calls the plugin initialization function.
  201. *
  202. * Since: 1.2
  203. */
  204. #define GST_PLUGIN_STATIC_REGISTER(name) G_PASTE(gst_plugin_, G_PASTE(name, _register)) ()
  205. /**
  206. * GST_PLUGIN_DEFINE:
  207. * @major: major version number of the gstreamer-core that plugin was compiled for
  208. * @minor: minor version number of the gstreamer-core that plugin was compiled for
  209. * @name: short, but unique name of the plugin
  210. * @description: information about the purpose of the plugin
  211. * @init: function pointer to the plugin_init method with the signature of <code>static gboolean plugin_init (GstPlugin * plugin)</code>.
  212. * @version: full version string (e.g. VERSION from config.h)
  213. * @license: under which licence the package has been released, e.g. GPL, LGPL.
  214. * @package: the package-name (e.g. PACKAGE_NAME from config.h)
  215. * @origin: a description from where the package comes from (e.g. the homepage URL)
  216. *
  217. * This macro needs to be used to define the entry point and meta data of a
  218. * plugin. One would use this macro to export a plugin, so that it can be used
  219. * by other applications.
  220. *
  221. * The macro uses a define named PACKAGE for the #GstPluginDesc,source field.
  222. * When using autoconf, this is usually set automatically via the AC_INIT
  223. * macro, and set in config.h. If you are not using autoconf, you will need to
  224. * define PACKAGE yourself and set it to a short mnemonic string identifying
  225. * your application/package, e.g. 'someapp' or 'my-plugins-foo.
  226. *
  227. * If defined, the GST_PACKAGE_RELEASE_DATETIME will also be used for the
  228. * #GstPluginDesc,release_datetime field.
  229. */
  230. #ifdef GST_PLUGIN_BUILD_STATIC
  231. #define GST_PLUGIN_DEFINE(major,minor,name,description,init,version,license,package,origin) \
  232. G_BEGIN_DECLS \
  233. GST_PLUGIN_EXPORT void G_PASTE(gst_plugin_, G_PASTE(name, _register)) (void); \
  234. \
  235. void \
  236. G_PASTE(gst_plugin_, G_PASTE(name, _register)) (void) \
  237. { \
  238. gst_plugin_register_static (major, minor, G_STRINGIFY(name), \
  239. description, init, version, license, \
  240. PACKAGE, package, origin); \
  241. } \
  242. G_END_DECLS
  243. #else /* !GST_PLUGIN_BUILD_STATIC */
  244. #define GST_PLUGIN_DEFINE(major,minor,name,description,init,version,license,package,origin) \
  245. G_BEGIN_DECLS \
  246. GST_PLUGIN_EXPORT GstPluginDesc gst_plugin_desc = { \
  247. major, \
  248. minor, \
  249. G_STRINGIFY(name), \
  250. (gchar *) description, \
  251. init, \
  252. version, \
  253. license, \
  254. PACKAGE, \
  255. package, \
  256. origin, \
  257. __GST_PACKAGE_RELEASE_DATETIME, \
  258. GST_PADDING_INIT \
  259. }; \
  260. G_END_DECLS
  261. #endif /* GST_PLUGIN_BUILD_STATIC */
  262. /**
  263. * GST_LICENSE_UNKNOWN:
  264. *
  265. * To be used in GST_PLUGIN_DEFINE if unsure about the licence.
  266. */
  267. #define GST_LICENSE_UNKNOWN "unknown"
  268. /* function for filters */
  269. /**
  270. * GstPluginFilter:
  271. * @plugin: the plugin to check
  272. * @user_data: the user_data that has been passed on e.g. gst_registry_plugin_filter()
  273. *
  274. * A function that can be used with e.g. gst_registry_plugin_filter()
  275. * to get a list of plugins that match certain criteria.
  276. *
  277. * Returns: %TRUE for a positive match, %FALSE otherwise
  278. */
  279. typedef gboolean (*GstPluginFilter) (GstPlugin *plugin,
  280. gpointer user_data);
  281. GType gst_plugin_get_type (void);
  282. gboolean gst_plugin_register_static (gint major_version,
  283. gint minor_version,
  284. const gchar *name,
  285. const gchar *description,
  286. GstPluginInitFunc init_func,
  287. const gchar *version,
  288. const gchar *license,
  289. const gchar *source,
  290. const gchar *package,
  291. const gchar *origin);
  292. gboolean gst_plugin_register_static_full (gint major_version,
  293. gint minor_version,
  294. const gchar *name,
  295. const gchar *description,
  296. GstPluginInitFullFunc init_full_func,
  297. const gchar *version,
  298. const gchar *license,
  299. const gchar *source,
  300. const gchar *package,
  301. const gchar *origin,
  302. gpointer user_data);
  303. const gchar* gst_plugin_get_name (GstPlugin *plugin);
  304. const gchar* gst_plugin_get_description (GstPlugin *plugin);
  305. const gchar* gst_plugin_get_filename (GstPlugin *plugin);
  306. const gchar* gst_plugin_get_version (GstPlugin *plugin);
  307. const gchar* gst_plugin_get_license (GstPlugin *plugin);
  308. const gchar* gst_plugin_get_source (GstPlugin *plugin);
  309. const gchar* gst_plugin_get_package (GstPlugin *plugin);
  310. const gchar* gst_plugin_get_origin (GstPlugin *plugin);
  311. const gchar* gst_plugin_get_release_date_string (GstPlugin *plugin);
  312. const GstStructure* gst_plugin_get_cache_data (GstPlugin * plugin);
  313. void gst_plugin_set_cache_data (GstPlugin * plugin, GstStructure *cache_data);
  314. gboolean gst_plugin_is_loaded (GstPlugin *plugin);
  315. GstPlugin * gst_plugin_load_file (const gchar *filename, GError** error);
  316. GstPlugin * gst_plugin_load (GstPlugin *plugin);
  317. GstPlugin * gst_plugin_load_by_name (const gchar *name);
  318. void gst_plugin_add_dependency (GstPlugin * plugin,
  319. const gchar ** env_vars,
  320. const gchar ** paths,
  321. const gchar ** names,
  322. GstPluginDependencyFlags flags);
  323. void gst_plugin_add_dependency_simple (GstPlugin * plugin,
  324. const gchar * env_vars,
  325. const gchar * paths,
  326. const gchar * names,
  327. GstPluginDependencyFlags flags);
  328. void gst_plugin_list_free (GList *list);
  329. #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
  330. G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstPlugin, gst_object_unref)
  331. #endif
  332. G_END_DECLS
  333. #endif /* __GST_PLUGIN_H__ */