mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-20 15:27:07 +00:00
device provider: 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>
This commit is contained in:
parent
7828237496
commit
ff36ce0051
2 changed files with 58 additions and 3 deletions
|
@ -26,6 +26,57 @@
|
||||||
|
|
||||||
#include <gst/gstelement.h>
|
#include <gst/gstelement.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_DEVICE_PROVIDER_REGISTER_DEFINE:
|
||||||
|
*
|
||||||
|
* @d_p: The device provider name in lower case, with words separated by '_'.
|
||||||
|
* Used to generate `gst_device_provider_register_*(GstPlugin* plugin)`.
|
||||||
|
* @d_p_n: The public name of the device provider
|
||||||
|
* @r: The #GstRank of the device provider (higher rank means more importance when autoplugging, see #GstRank)
|
||||||
|
* @t: The #GType of the device provider.
|
||||||
|
*
|
||||||
|
* A convenience macro to define the entry point of a
|
||||||
|
* device provider `gst_device_provider_register_*(GstPlugin* plugin)`.
|
||||||
|
*
|
||||||
|
* Since: 1.20
|
||||||
|
*/
|
||||||
|
#define GST_DEVICE_PROVIDER_REGISTER_DEFINE(d_p, d_p_n, r, t) \
|
||||||
|
G_BEGIN_DECLS \
|
||||||
|
gboolean G_PASTE (gst_device_provider_register_, d_p) (GstPlugin * plugin) \
|
||||||
|
{ \
|
||||||
|
return gst_device_provider_register (plugin, d_p_n, r, t); \
|
||||||
|
} \
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_DEVICE_PROVIDER_REGISTER_DECLARE:
|
||||||
|
* @d_p: The device provider name in lower case, with words separated by '_'.
|
||||||
|
*
|
||||||
|
* This macro can be used to declare a new device provider.
|
||||||
|
* It has to be used in combination with #GST_DEVICE_PROVIDER_REGISTER_DEFINE macro
|
||||||
|
* and must be placed outside any block to declare the device provider registration
|
||||||
|
* function.
|
||||||
|
*
|
||||||
|
* Since: 1.20
|
||||||
|
*/
|
||||||
|
#define GST_DEVICE_PROVIDER_REGISTER_DECLARE(d_p) \
|
||||||
|
G_BEGIN_DECLS \
|
||||||
|
gboolean G_PASTE(gst_device_provider_register_, d_p) (GstPlugin * plugin); \
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_DEVICE_PROVIDER_REGISTER:
|
||||||
|
* @d_p: The device provider name in lower case, with words separated by '_'.
|
||||||
|
* @plugin: The #GstPlugin where to register the device provider.
|
||||||
|
*
|
||||||
|
* This macro can be used to register a device provider 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_DEVICE_PROVIDER_REGISTER(d_p, plugin) G_PASTE(gst_device_provider_register_, d_p) (plugin)
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstDeviceProvider GstDeviceProvider;
|
typedef struct _GstDeviceProvider GstDeviceProvider;
|
||||||
|
|
|
@ -174,8 +174,12 @@ gst_test_device_provider_init (GstTestDeviceProvider * self)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
GST_DEVICE_PROVIDER_REGISTER_DECLARE (testdeviceprovider);
|
||||||
register_test_device_provider (void)
|
|
||||||
|
GST_DEVICE_PROVIDER_REGISTER_DEFINE (testdeviceprovider, "testdeviceprovider",
|
||||||
|
1, gst_test_device_provider_get_type ())
|
||||||
|
|
||||||
|
static void register_test_device_provider (void)
|
||||||
{
|
{
|
||||||
gst_device_provider_register (NULL, "testdeviceprovider", 1,
|
gst_device_provider_register (NULL, "testdeviceprovider", 1,
|
||||||
gst_test_device_provider_get_type ());
|
gst_test_device_provider_get_type ());
|
||||||
|
@ -187,7 +191,7 @@ GST_START_TEST (test_device_provider_factory)
|
||||||
GList *factories;
|
GList *factories;
|
||||||
GstDeviceProviderFactory *f;
|
GstDeviceProviderFactory *f;
|
||||||
|
|
||||||
register_test_device_provider ();
|
GST_DEVICE_PROVIDER_REGISTER (testdeviceprovider, NULL);
|
||||||
|
|
||||||
factories = gst_device_provider_factory_list_get_device_providers (1);
|
factories = gst_device_provider_factory_list_get_device_providers (1);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue