Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
type find: add convenience macros to register
This macros will help to register a device provider
apart from a given plugin such as in a static build
of gstreamer where libgstreamer-full is generated.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/661>
  • Loading branch information
Stéphane Cerveau committed Dec 10, 2020
1 parent ff36ce0 commit 9fd20cf
Showing 1 changed file with 87 additions and 0 deletions.
87 changes: 87 additions & 0 deletions gst/gsttypefind.h
Expand Up @@ -28,6 +28,93 @@
#include <gst/gstpluginfeature.h>

G_BEGIN_DECLS
/**
* GST_TYPE_FIND_REGISTER_DEFINE_CUSTOM:
*
* @type_find: The type find name in lower case, with words separated by '_'.
* Used to generate `gst_type_find_register_*(GstPlugin* plugin)`.
* @register_func: pointer to a method with the format: `gboolean register_func (GstPlugin* plugin);`
*
* A convenience macro to define the entry point of a
* type find `gst_type_find_register_*(GstPlugin* plugin)` which uses
* register_func as the main registration method for the type find.
* As an example, you may define the type find named "custom-typefind"
* as following using `type_find_register_custom`:
*
* ```
* GST_TYPE_FIND_REGISTER_DEFINE_CUSTOM (plugin, type_find_register_custom)
* ```
*
* Since: 1.20
*/
#define GST_TYPE_FIND_REGISTER_DEFINE_CUSTOM(type_find, register_func) \
G_BEGIN_DECLS \
gboolean G_PASTE (gst_type_find_register_, type_find) (GstPlugin * plugin) \
{ \
return register_func (plugin); \
} \
G_END_DECLS

/**
* GST_TYPE_FIND_REGISTER_DEFINE:
*
* @t_f: The type find name in lower case, with words separated by '_'.
* Used to generate `gst_type_find_register_*(GstPlugin* plugin)`.
* @t_f_n: The public name of the type find
* @r: The #GstRank of the type find (higher rank means more importance when autoplugging, see #GstRank)
* @func: The #GstTypeFindFunction to use
* @extensions: (nullable): Optional comma-separated list of extensions
* that could belong to this type
* @possible_caps: (nullable): Optionally the caps that could be returned when typefinding
* succeeds
* @data: Optional user data. This user data must be available until the plugin
* is unloaded.
* @data_notify: a #GDestroyNotify that will be called on @data when the plugin
* is unloaded.
*
* A convenience macro to define the entry point of a
* type find `gst_type_find_register_*(GstPlugin* plugin)`.
*
* Since: 1.20
*/
#define GST_TYPE_FIND_REGISTER_DEFINE(t_f, t_f_n, r, func, extensions, possible_caps, data, data_notify) \
G_BEGIN_DECLS \
gboolean G_PASTE (gst_type_find_register_, t_f) (GstPlugin * plugin) \
{ \
return gst_type_find_register (plugin, t_f_n, r, func, extensions, possible_caps, data, data_notify); \
} \
G_END_DECLS

/**
* GST_TYPE_FIND_REGISTER_DECLARE:
* @t_f: The type find name in lower case, with words separated by '_'.
*
* This macro can be used to declare a new type find.
* It has to be used in combination with #GST_TYPE_FIND_REGISTER_DEFINE macro
* and must be placed outside any block to declare the type find registration
* function.
*
* Since: 1.20
*/
#define GST_TYPE_FIND_REGISTER_DECLARE(t_f) \
G_BEGIN_DECLS \
gboolean G_PASTE(gst_type_find_register_, t_f) (GstPlugin * plugin); \
G_END_DECLS

/**
* GST_TYPE_FIND_REGISTER:
* @t_f: The type find name in lower case, with words separated by '_'.
* @plugin: The #GstPlugin where to register the type find.
*
* This macro can be used to register a type find into a #GstPlugin.
* This method will be usually called in the plugin init function
* but can also be called with a NULL plugin.
*
* Since: 1.20
*/
#define GST_TYPE_FIND_REGISTER(t_f, plugin) G_PASTE(gst_type_find_register_, t_f) (plugin)


#define GST_TYPE_TYPE_FIND (gst_type_find_get_type())

Expand Down

0 comments on commit 9fd20cf

Please sign in to comment.