Commit e4e85fc8 authored by Olivier Crête's avatar Olivier Crête 👻 Committed by Tim-Philipp Müller

devicemonitor: Add GstDeviceMonitor and related

Also add GstDevice and GstDeviceMonitorFactory
And add code to the registry to save them

https://bugzilla.gnome.org/show_bug.cgi?id=678402
parent 10d53423
......@@ -71,6 +71,9 @@ libgstreamer_@GST_API_VERSION@_la_SOURCES = \
gstcontrolsource.c \
gstdatetime.c \
gstdebugutils.c \
gstdevice.c \
gstdevicemonitor.c \
gstdevicemonitorfactory.c \
gstelement.c \
gstelementfactory.c \
gsterror.c \
......@@ -172,6 +175,9 @@ gst_headers = \
gstdebugutils.h \
gstelement.h \
gstelementmetadata.h \
gstdevice.h \
gstdevicemonitor.h \
gstdevicemonitorfactory.h \
gstelementfactory.h \
gsterror.h \
gstevent.h \
......
......@@ -42,6 +42,8 @@
#include <gst/gstcontrolsource.h>
#include <gst/gstdatetime.h>
#include <gst/gstdebugutils.h>
#include <gst/gstdevice.h>
#include <gst/gstdevicemonitor.h>
#include <gst/gstelement.h>
#include <gst/gstelementmetadata.h>
#include <gst/gsterror.h>
......
......@@ -54,6 +54,9 @@ extern const char g_log_domain_gstreamer[];
/* for GstElement */
#include "gstelement.h"
/* for GstDeviceMonitor */
#include "gstdevicemonitor.h"
/* for GstToc */
#include "gsttoc.h"
......@@ -393,5 +396,24 @@ struct _GstElementFactoryClass {
gpointer _gst_reserved[GST_PADDING];
};
struct _GstDeviceMonitorFactory {
GstPluginFeature feature;
/* <private> */
GType type; /* unique GType the device factory or 0 if not loaded */
volatile GstDeviceMonitor *monitor;
gpointer metadata;
gpointer _gst_reserved[GST_PADDING];
};
struct _GstDeviceMonitorFactoryClass {
GstPluginFeatureClass parent;
/* <private> */
gpointer _gst_reserved[GST_PADDING];
};
G_END_DECLS
#endif /* __GST_PRIVATE_H__ */
/* GStreamer
* Copyright (C) 2012 Olivier Crete <olivier.crete@collabora.com>
*
* gstdevice.c: Device discovery
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gst/gst_private.h"
#include <gst/gstdevice.h>
#include <gst/gst.h>
enum
{
PROP_DISPLAY_NAME = 1,
PROP_CAPS
};
enum
{
REMOVED,
LAST_SIGNAL
};
struct _GstDevicePrivate
{
GstCaps *caps;
gchar *display_name;
};
static guint signals[LAST_SIGNAL];
G_DEFINE_ABSTRACT_TYPE (GstDevice, gst_device, GST_TYPE_OBJECT);
static void gst_device_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec);
static void gst_device_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec);
static void gst_device_finalize (GObject * object);
static void
gst_device_class_init (GstDeviceClass * klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
g_type_class_add_private (klass, sizeof (GstDevicePrivate));
object_class->get_property = gst_device_get_property;
object_class->set_property = gst_device_set_property;
object_class->finalize = gst_device_finalize;
g_object_class_install_property (object_class, PROP_DISPLAY_NAME,
g_param_spec_string ("display-name", "Display Name",
"The user-friendly name of the device", "",
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class, PROP_CAPS,
g_param_spec_boxed ("caps", "Device Caps",
"The possible caps of a device", GST_TYPE_CAPS,
G_PARAM_STATIC_STRINGS | G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
signals[REMOVED] = g_signal_new ("removed", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
}
static void
gst_device_init (GstDevice * device)
{
device->priv = G_TYPE_INSTANCE_GET_PRIVATE (device, GST_TYPE_DEVICE,
GstDevicePrivate);
}
static void
gst_device_finalize (GObject * object)
{
GstDevice *device = GST_DEVICE (object);
gst_caps_replace (&device->priv->caps, NULL);
g_free (device->priv->display_name);
G_OBJECT_CLASS (gst_device_parent_class)->finalize (object);
}
static void
gst_device_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstDevice *gstdevice;
gstdevice = GST_DEVICE_CAST (object);
switch (prop_id) {
case PROP_DISPLAY_NAME:
g_value_take_string (value, gst_device_get_display_name (gstdevice));
break;
case PROP_CAPS:
if (gstdevice->priv->caps)
g_value_take_boxed (value, gst_device_get_caps (gstdevice));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_device_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstDevice *gstdevice;
gstdevice = GST_DEVICE_CAST (object);
switch (prop_id) {
case PROP_DISPLAY_NAME:
gstdevice->priv->display_name = g_value_dup_string (value);
break;
case PROP_CAPS:
gst_caps_replace (&gstdevice->priv->caps, g_value_get_boxed (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/**
* gst_device_create_element:
* @device: a #GstDevice
* @name: (allow-none): name of new element, or NULL to automatically
* create a unique name.
*
* Returns: (transfer full): a new #GstElement configured to use this device
*
* Since: 1.4
*/
GstElement *
gst_device_create_element (GstDevice * device, const gchar * name)
{
GstDeviceClass *klass = GST_DEVICE_GET_CLASS (device);
if (klass->create_element)
return klass->create_element (device, name);
else
return NULL;
}
/**
* gst_device_get_caps:
* @device: a #GstDevice
*
* Getter for the #GstCaps that this device supports.
*
* Returns: The #GstCaps supported by this device. Unref with
* gst_caps_unref() when done.
*
* Since: 1.4
*/
GstCaps *
gst_device_get_caps (GstDevice * device)
{
if (device->priv->caps)
return gst_caps_ref (device->priv->caps);
else
return NULL;
}
/**
* gst_device_get_display_name:
* @device: a #GstDevice
*
* Gets the user-friendly name of the device.
*
* Returns: The device name. Free with g_free() after use.
*
* Since: 1.4
*/
gchar *
gst_device_get_display_name (GstDevice * device)
{
return g_strdup (device->priv->display_name);
}
/**
* gst_device_reconfigure_element:
* @device: a #GstDevice
* @element: a #GstElement
*
* Tries to reconfigure an existing element to use the device. If this
* function fails, then one must destroy the element and create a new one
* using gst_device_create_element().
*
* Note: This should only be implemented for elements can change their
* device in the PLAYING state.
*
* Returns: %TRUE if the element could be reconfigured to use this device,
* %FALSE otherwise.
*
* Since: 1.4
*/
gboolean
gst_device_reconfigure_element (GstDevice * device, GstElement * element)
{
GstDeviceClass *klass = GST_DEVICE_GET_CLASS (device);
if (klass->reconfigure_element)
return klass->reconfigure_element (device, element);
else
return FALSE;
}
/* GStreamer
* Copyright (C) 2012 Olivier Crete <olivier.crete@collabora.com>
*
* gstdevice.c: Device discovery
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_DEVICE_H__
#define __GST_DEVICE_H__
typedef struct _GstDevice GstDevice;
typedef struct _GstDeviceClass GstDeviceClass;
#include <gst/gstelement.h>
#include <gst/gstcaps.h>
G_BEGIN_DECLS
typedef struct _GstDevicePrivate GstDevicePrivate;
#define GST_TYPE_DEVICE (gst_device_get_type())
#define GST_IS_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEVICE))
#define GST_IS_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEVICE))
#define GST_DEVICE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEVICE, GstDeviceClass))
#define GST_DEVICE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEVICE, GstDevice))
#define GST_DEVICE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEVICE, GstDeviceClass))
#define GST_DEVICE_CAST(obj) ((GstDevice *)(obj))
struct _GstDevice {
GstObject parent;
/*< private >*/
GstDevicePrivate *priv;
gpointer _gst_reserved[GST_PADDING];
};
struct _GstDeviceClass {
GstObjectClass parent_class;
GstElement * (*create_element) (GstDevice * device, const gchar * name);
gboolean (*reconfigure_element) (GstDevice * device, GstElement * element);
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_device_get_type (void);
GstElement * gst_device_create_element (GstDevice * device, const gchar * name);
GstCaps * gst_device_get_caps (GstDevice * device);
gchar * gst_device_get_display_name (GstDevice * device);
gboolean gst_device_reconfigure_element (GstDevice * device,
GstElement * element);
G_END_DECLS
#endif /* __GST_DEVICE_H__ */
This diff is collapsed.
/* GStreamer
* Copyright (C) 2012 Olivier Crete <olivier.crete@collabora.com>
*
* gstdevicemonitor.h: Device probing and monitoring
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <gst/gstdevicemonitorfactory.h>
#ifndef __GST_DEVICE_MONITOR_H__
#define __GST_DEVICE_MONITOR_H__
#include <gst/gstelement.h>
G_BEGIN_DECLS
typedef struct _GstDeviceMonitor GstDeviceMonitor;
typedef struct _GstDeviceMonitorClass GstDeviceMonitorClass;
typedef struct _GstDeviceMonitorPrivate GstDeviceMonitorPrivate;
#define GST_TYPE_DEVICE_MONITOR (gst_device_monitor_get_type())
#define GST_IS_DEVICE_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEVICE_MONITOR))
#define GST_IS_DEVICE_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEVICE_MONITOR))
#define GST_DEVICE_MONITOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEVICE_MONITOR, GstDeviceMonitorClass))
#define GST_DEVICE_MONITOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEVICE_MONITOR, GstDeviceMonitor))
#define GST_DEVICE_MONITOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEVICE_MONITOR, GstDeviceMonitorClass))
#define GST_DEVICE_MONITOR_CAST(obj) ((GstDeviceMonitor *)(obj))
struct _GstDeviceMonitor {
GstObject parent;
/*< private >*/
/* Protected by the Object lock */
GList *devices;
GstDeviceMonitorPrivate *priv;
gpointer _gst_reserved[GST_PADDING];
};
/**
* GstDeviceMonitorClass:
* @factory: a pointer to the #GstDeviceMonitorFactory that creates this
* monitor
* @get_devices: Returns a list of devices that are currently available.
* This should never block.
* @start: Starts monitoring for new devices.
* @stop: Stops monitoring for new devices
*
* The structure of the base #GstDeviceMonitorClass
*
* Since: 1.4
*/
struct _GstDeviceMonitorClass {
GstObjectClass parent_class;
GstDeviceMonitorFactory *factory;
GList* (*probe) (GstDeviceMonitor * monitor);
gboolean (*start) (GstDeviceMonitor * monitor);
void (*stop) (GstDeviceMonitor * monitor);
gpointer metadata;
/*< private >*/
gpointer _gst_reserved[GST_PADDING];
};
GType gst_device_monitor_get_type (void);
GList * gst_device_monitor_get_devices (GstDeviceMonitor * monitor);
gboolean gst_device_monitor_start (GstDeviceMonitor * monitor);
void gst_device_monitor_stop (GstDeviceMonitor * monitor);
gboolean gst_device_monitor_can_monitor (GstDeviceMonitor * monitor);
GstBus * gst_device_monitor_get_bus (GstDeviceMonitor * monitor);
void gst_device_monitor_device_add (GstDeviceMonitor * monitor,
GstDevice * device);
void gst_device_monitor_device_remove (GstDeviceMonitor * monitor,
GstDevice * device);
/* device monitor class meta data */
void gst_device_monitor_class_set_metadata (GstDeviceMonitorClass *klass,
const gchar *longname,
const gchar *classification,
const gchar *description,
const gchar *author);
void gst_device_monitor_class_set_static_metadata (GstDeviceMonitorClass *klass,
const gchar *longname,
const gchar *classification,
const gchar *description,
const gchar *author);
void gst_device_monitor_class_add_metadata (GstDeviceMonitorClass * klass,
const gchar * key, const gchar * value);
void gst_device_monitor_class_add_static_metadata (GstDeviceMonitorClass * klass,
const gchar * key, const gchar * value);
const gchar * gst_device_monitor_class_get_metadata (GstDeviceMonitorClass * klass,
const gchar * key);
/* factory management */
GstDeviceMonitorFactory * gst_device_monitor_get_factory (GstDeviceMonitor * monitor);
G_END_DECLS
#endif /* __GST_DEVICE_MONITOR_H__ */
This diff is collapsed.
/* GStreamer
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
* 2000,2004 Wim Taymans <wim@fluendo.com>
* 2012 Olivier Crete <olivier.crete@collabora.com>
*
* gstdevicemonitorfactory.h: Header for GstDeviceMonitorFactory
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_DEVICE_MONITOR_FACTORY_H__
#define __GST_DEVICE_MONITOR_FACTORY_H__
/**
* GstDeviceMonitorFactory:
*
* The opaque #GstDeviceMonitorFactory data structure.
*
* Since: 1.4
*/
typedef struct _GstDeviceMonitorFactory GstDeviceMonitorFactory;
typedef struct _GstDeviceMonitorFactoryClass GstDeviceMonitorFactoryClass;
#include <gst/gstconfig.h>
#include <gst/gstplugin.h>
#include <gst/gstpluginfeature.h>
#include <gst/gstdevicemonitor.h>
G_BEGIN_DECLS
#define GST_TYPE_DEVICE_MONITOR_FACTORY (gst_device_monitor_factory_get_type())
#define GST_DEVICE_MONITOR_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DEVICE_MONITOR_FACTORY,\
GstDeviceMonitorFactory))
#define GST_DEVICE_MONITOR_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DEVICE_MONITOR_FACTORY,\
GstDeviceMonitorFactoryClass))
#define GST_IS_DEVICE_MONITOR_FACTORY(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DEVICE_MONITOR_FACTORY))
#define GST_IS_DEVICE_MONITOR_FACTORY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DEVICE_MONITOR_FACTORY))
#define GST_DEVICE_MONITOR_FACTORY_CAST(obj) ((GstDeviceMonitorFactory *)(obj))
GType gst_device_monitor_factory_get_type (void);
GstDeviceMonitorFactory * gst_device_monitor_factory_find (const gchar *name);
GType gst_device_monitor_factory_get_device_monitor_type (GstDeviceMonitorFactory *factory);
const gchar * gst_device_monitor_factory_get_metadata (GstDeviceMonitorFactory *factory, const gchar *key);
gchar ** gst_device_monitor_factory_get_metadata_keys (GstDeviceMonitorFactory *factory);
GstDeviceMonitor* gst_device_monitor_factory_get (GstDeviceMonitorFactory *factory) G_GNUC_MALLOC;
GstDeviceMonitor* gst_device_monitor_factory_get_by_name (const gchar *factoryname) G_GNUC_MALLOC;
gboolean gst_device_monitor_register (GstPlugin *plugin, const gchar *name,
guint rank,
GType type);
/* Factory list functions */
/**
* GstDeviceMonitorFactoryListType:
* @GST_DEVICE_MONITOR_FACTORY_TYPE_SINK: Sink elements
* @GST_DEVICE_MONITOR_FACTORY_TYPE_SRC: Source elements
* @GST_DEVICE_MONITOR_FACTORY_TYPE_MAX_DEVICE_MONITORS: Private, do not use
* @GST_DEVICE_MONITOR_FACTORY_TYPE_MEDIA_VIDEO: Elements handling video media types
* @GST_DEVICE_MONITOR_FACTORY_TYPE_MEDIA_AUDIO: Elements handling audio media types
* @GST_DEVICE_MONITOR_FACTORY_TYPE_MEDIA_IMAGE: Elements handling image media types
* @GST_DEVICE_MONITOR_FACTORY_TYPE_MEDIA_SUBTITLE: Elements handling subtitle media types
* @GST_DEVICE_MONITOR_FACTORY_TYPE_MEDIA_METADATA: Elements handling metadata media types
*
* The type of #GstDeviceMonitorFactory to filter.
*
* All @GstDeviceMonitorFactoryListType up to @GST_DEVICE_MONITOR_FACTORY_TYPE_MAX_DEVICE_MONITORS are exclusive.
*
* If one or more of the MEDIA types are specified, then only elements
* matching the specified media types will be selected.
*
* Since: 1.4
*/
typedef guint64 GstDeviceMonitorFactoryListType;
#define GST_DEVICE_MONITOR_FACTORY_TYPE_SINK (G_GUINT64_CONSTANT (1) << 0)
#define GST_DEVICE_MONITOR_FACTORY_TYPE_SRC (G_GUINT64_CONSTANT (1) << 1)
#define GST_DEVICE_MONITOR_FACTORY_TYPE_MAX_DEVICE_MONITORS (G_GUINT64_CONSTANT (1) << 48)
#define GST_DEVICE_MONITOR_FACTORY_TYPE_MEDIA_VIDEO (G_GUINT64_CONSTANT (1) << 49)
#define GST_DEVICE_MONITOR_FACTORY_TYPE_MEDIA_AUDIO (G_GUINT64_CONSTANT (1) << 50)
#define GST_DEVICE_MONITOR_FACTORY_TYPE_MEDIA_IMAGE (G_GUINT64_CONSTANT (1) << 51)
#define GST_DEVICE_MONITOR_FACTORY_TYPE_MEDIA_SUBTITLE (G_GUINT64_CONSTANT (1) << 52)
#define GST_DEVICE_MONITOR_FACTORY_TYPE_MEDIA_METADATA (G_GUINT64_CONSTANT (1) << 53)
/* Element klass defines */
#define GST_DEVICE_MONITOR_FACTORY_KLASS_DECODER "Decoder"
#define GST_DEVICE_MONITOR_FACTORY_KLASS_ENCODER "Encoder"
#define GST_DEVICE_MONITOR_FACTORY_KLASS_MEDIA_VIDEO "Video"
#define GST_DEVICE_MONITOR_FACTORY_KLASS_MEDIA_AUDIO "Audio"
#define GST_DEVICE_MONITOR_FACTORY_KLASS_MEDIA_IMAGE "Image"
#define GST_DEVICE_MONITOR_FACTORY_KLASS_MEDIA_SUBTITLE "Subtitle"
#define GST_DEVICE_MONITOR_FACTORY_KLASS_MEDIA_METADATA "Metadata"
gboolean gst_device_monitor_factory_list_is_type (GstDeviceMonitorFactory *factory,
GstDeviceMonitorFactoryListType type);
GList * gst_device_monitor_factory_list_get_device_monitors (GstDeviceMonitorFactoryListType type,
GstRank minrank) G_GNUC_MALLOC;
G_END_DECLS
#endif /* __GST_DEVICE_MONITOR_FACTORY_H__ */
......@@ -108,7 +108,8 @@ static GstMessageQuarks message_quarks[] = {
{GST_MESSAGE_NEED_CONTEXT, "need-context", 0},
{GST_MESSAGE_HAVE_CONTEXT, "have-context", 0},
{GST_MESSAGE_EXTENDED, "extended", 0},
{GST_MESSAGE_DEVICE, "device", 0},
{GST_MESSAGE_DEVICE_ADDED, "device-added", 0},
{GST_MESSAGE_DEVICE_REMOVED, "device-removed", 0},
{0, NULL, 0}
};
......@@ -2357,3 +2358,104 @@ gst_message_parse_have_context (GstMessage * message, GstContext ** context)
gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
GST_QUARK (CONTEXT), GST_TYPE_CONTEXT, context, NULL);
}
/**
* gst_message_new_device_added:
* @src: The #GstObject that created the message
* @device: (transfer none): The new #GstDevice
*
* Creates a new device-added message. The device-added message is produced by
* #GstDeviceMonitor or a #GstGlobalDeviceMonitor. They announce the appearance
* of monitored devices.
*
* Returns: a newly allocated #GstMessage
*
* Since: 1.4
*/
GstMessage *
gst_message_new_device_added (GstObject * src, GstDevice * device)
{
GstMessage *message;
GstStructure *structure;
structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_ADDED),
GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
message = gst_message_new_extended (GST_MESSAGE_DEVICE_ADDED, src, structure);
return message;
}
/**
* gst_message_parse_device_added:
* @device: (out) (allow-none) (transfer none): A location where to store a
* pointer to the new #GstDevice, or %NULL
*
* Parses a device-added message. The device-added message is produced by
* #GstDeviceMonitor or a #GstGlobalDeviceMonitor. It announces the appearance
* of monitored devices.
*
* Since: 1.4
*/
void
gst_message_parse_device_added (GstMessage * message, GstDevice ** device)
{
g_return_if_fail (GST_IS_MESSAGE (message));
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_EXTENDED);
g_return_if_fail (gst_message_get_extended_type (message) ==
GST_MESSAGE_DEVICE_ADDED);
if (device)
gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
}
/**
* gst_message_new_device_removed:
* @src: The #GstObject that created the message
* @device: (transfer none): The removed #GstDevice
*
* Creates a new device-removed message. The device-removed message is produced
* by #GstDeviceMonitor or a #GstGlobalDeviceMonitor. They announce the
* disappearance of monitored devices.
*
* Returns: a newly allocated #GstMessage
*
* Since: 1.4
*/
GstMessage *
gst_message_new_device_removed (GstObject * src, GstDevice * device)
{
GstMessage *message;
GstStructure *structure;
structure = gst_structure_new_id (GST_QUARK (MESSAGE_DEVICE_REMOVED),
GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
message = gst_message_new_extended (GST_MESSAGE_DEVICE_REMOVED, src,
structure);
return message;
}
/**
* gst_message_parse_device_removed:
* @device: (out) (allow-none) (transfer none): A location where to store a
* pointer to the removed #GstDevice, or %NULL
*
* Parses a device-removed message. The device-removed message is produced by
* #GstDeviceMonitor or a #GstGlobalDeviceMonitor. It announces the
* disappearance of monitored devices.
*
* Since: 1.4
*/
void
gst_message_parse_device_removed (GstMessage * message, GstDevice ** device)
{
g_return_if_fail (GST_IS_MESSAGE (message));
g_return_if_fail (GST_MESSAGE_TYPE (message) == GST_MESSAGE_EXTENDED);
g_return_if_fail (gst_message_get_extended_type (message) ==
GST_MESSAGE_DEVICE_REMOVED);
if (device)
gst_structure_id_get (GST_MESSAGE_STRUCTURE (message),
GST_QUARK (DEVICE), GST_TYPE_DEVICE, device, NULL);
}
......@@ -149,15 +149,20 @@ typedef enum
/**
* GstMessageExtendedType:
* @GST_MESSAGE_DEVICE: A #GstDevice addition or removal according to
* a #GstDeviceMonitor
* @GST_MESSAGE_DEVICE_ADDED: A #GstDevice addition according to
* a #GstDeviceMonitor (Since 1.4)
* @GST_MESSAGE_DEVICE_REMOVED: A #GstDevice removal according to