mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-10-14 20:02:38 +00:00
pvsrc: implement source selection
Allow pvsrc to select what source to connect to.
This commit is contained in:
parent
98861cb940
commit
4a61f988dc
|
@ -474,8 +474,8 @@ do_connect_capture (PvStream *stream)
|
|||
|
||||
g_dbus_proxy_call (context->priv->client,
|
||||
"CreateSourceOutput",
|
||||
g_variant_new ("(os)",
|
||||
(priv->target ? priv->target : "/"),
|
||||
g_variant_new ("(ss)",
|
||||
(priv->target ? priv->target : ""),
|
||||
g_bytes_get_data (priv->accepted_formats, NULL)),
|
||||
G_DBUS_CALL_FLAGS_NONE,
|
||||
-1,
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
Create a new output for @source with given @incaps
|
||||
-->
|
||||
<method name='CreateSourceOutput'>
|
||||
<arg type='o' name='source' direction='in'/>
|
||||
<arg type='s' name='source' direction='in'/>
|
||||
<arg type='s' name='accepted_formats' direction='in'/>
|
||||
<arg type='o' name='output' direction='out'/>
|
||||
</method>
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
* <refsect2>
|
||||
* <title>Example launch line</title>
|
||||
* |[
|
||||
* gst-launch -v pulsevideosink ! ximagesink
|
||||
* ]| Shows pulsevideo output in an X window.
|
||||
* gst-launch -v videotestsrc ! pulsevideosink
|
||||
* ]| Sends a test video source to pulsevideo
|
||||
* </refsect2>
|
||||
*/
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* <refsect2>
|
||||
* <title>Example launch line</title>
|
||||
* |[
|
||||
* gst-launch -v pulsevideosrc ! ximagesink
|
||||
* gst-launch -v pulsevideosrc ! videoconvert ! ximagesink
|
||||
* ]| Shows pulsevideo output in an X window.
|
||||
* </refsect2>
|
||||
*/
|
||||
|
@ -50,7 +50,7 @@ GST_DEBUG_CATEGORY_STATIC (pulsevideo_src_debug);
|
|||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_LAST
|
||||
PROP_SOURCE
|
||||
};
|
||||
|
||||
|
||||
|
@ -66,11 +66,6 @@ GST_STATIC_PAD_TEMPLATE ("src",
|
|||
#define gst_pulsevideo_src_parent_class parent_class
|
||||
G_DEFINE_TYPE (GstPulsevideoSrc, gst_pulsevideo_src, GST_TYPE_PUSH_SRC);
|
||||
|
||||
static void gst_pulsevideo_src_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec);
|
||||
static void gst_pulsevideo_src_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec);
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_pulsevideo_src_change_state (GstElement * element, GstStateChange transition);
|
||||
|
||||
|
@ -85,6 +80,51 @@ static GstFlowReturn gst_pulsevideo_src_create (GstPushSrc * psrc,
|
|||
static gboolean gst_pulsevideo_src_start (GstBaseSrc * basesrc);
|
||||
static gboolean gst_pulsevideo_src_stop (GstBaseSrc * basesrc);
|
||||
|
||||
static void
|
||||
gst_pulsevideo_src_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstPulsevideoSrc *pvsrc = GST_PULSEVIDEO_SRC (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SOURCE:
|
||||
g_free (pvsrc->source);
|
||||
pvsrc->source = g_value_dup_string (value);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pulsevideo_src_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
GstPulsevideoSrc *pvsrc = GST_PULSEVIDEO_SRC (object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SOURCE:
|
||||
g_value_set_string (value, pvsrc->source);
|
||||
break;
|
||||
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pulsevideo_src_finalize (GObject * object)
|
||||
{
|
||||
GstPulsevideoSrc *pvsrc = GST_PULSEVIDEO_SRC (object);
|
||||
|
||||
g_free (pvsrc->source);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pulsevideo_src_class_init (GstPulsevideoSrcClass * klass)
|
||||
{
|
||||
|
@ -98,9 +138,20 @@ gst_pulsevideo_src_class_init (GstPulsevideoSrcClass * klass)
|
|||
gstbasesrc_class = (GstBaseSrcClass *) klass;
|
||||
gstpushsrc_class = (GstPushSrcClass *) klass;
|
||||
|
||||
gobject_class->finalize = gst_pulsevideo_src_finalize;
|
||||
gobject_class->set_property = gst_pulsevideo_src_set_property;
|
||||
gobject_class->get_property = gst_pulsevideo_src_get_property;
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_SOURCE,
|
||||
g_param_spec_string ("source",
|
||||
"Source",
|
||||
"The source name to connect to (NULL = default)",
|
||||
NULL,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
|
||||
gstelement_class->change_state = gst_pulsevideo_src_change_state;
|
||||
|
||||
gst_element_class_set_static_metadata (gstelement_class,
|
||||
|
@ -172,28 +223,6 @@ gst_pulsevideo_src_src_fixate (GstBaseSrc * bsrc, GstCaps * caps)
|
|||
return caps;
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pulsevideo_src_set_property (GObject * object, guint prop_id,
|
||||
const GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gst_pulsevideo_src_get_property (GObject * object, guint prop_id,
|
||||
GValue * value, GParamSpec * pspec)
|
||||
{
|
||||
switch (prop_id) {
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_new_buffer (GObject *gobject,
|
||||
gpointer user_data)
|
||||
|
@ -263,7 +292,7 @@ gst_pulsevideo_src_negotiate (GstBaseSrc * basesrc)
|
|||
/* open a connection with these caps */
|
||||
str = gst_caps_to_string (caps);
|
||||
accepted = g_bytes_new_take (str, strlen (str) + 1);
|
||||
pv_stream_connect_capture (pvsrc->stream, NULL, 0, accepted);
|
||||
pv_stream_connect_capture (pvsrc->stream, pvsrc->source, 0, accepted);
|
||||
|
||||
g_mutex_lock (&pvsrc->lock);
|
||||
while (TRUE) {
|
||||
|
|
|
@ -54,6 +54,7 @@ struct _GstPulsevideoSrc {
|
|||
GstPushSrc element;
|
||||
|
||||
/*< private >*/
|
||||
gchar *source;
|
||||
|
||||
gboolean negotiated;
|
||||
|
||||
|
|
|
@ -372,19 +372,30 @@ pv_daemon_find_source (PvDaemon *daemon,
|
|||
GError **error)
|
||||
{
|
||||
PvDaemonPrivate *priv;
|
||||
PvSource *best = NULL;
|
||||
GList *walk;
|
||||
|
||||
g_return_val_if_fail (PV_IS_DAEMON (daemon), NULL);
|
||||
priv = daemon->priv;
|
||||
|
||||
if (priv->sources == NULL) {
|
||||
for (walk = priv->sources; walk; walk = g_list_next (walk)) {
|
||||
PvSource *s = walk->data;
|
||||
|
||||
if (name == NULL) {
|
||||
best = s;
|
||||
break;
|
||||
}
|
||||
else if (g_str_has_suffix (pv_source_get_object_path (s), name))
|
||||
best = s;
|
||||
}
|
||||
|
||||
if (best == NULL) {
|
||||
if (error)
|
||||
*error = g_error_new (G_IO_ERROR,
|
||||
G_IO_ERROR_NOT_FOUND,
|
||||
"No sources registered");
|
||||
return NULL;
|
||||
"Source not found");
|
||||
}
|
||||
|
||||
return priv->sources->data;
|
||||
return best;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE (PvDaemon, pv_daemon, G_TYPE_OBJECT);
|
||||
|
|
Loading…
Reference in a new issue