mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-13 13:30:05 -05:00
Add more generic gst source manager object
Use device manager to add/remove all video providers dynamically, remove v4l2 specific code. Get the client proxy from subscribe instead of waiting for the subscription callback. This way we can actually make an error on failure. Clean up the objects when the server disappears. Remove subscription from the server, we don't need it. Install server objects in bus_acquired.
This commit is contained in:
parent
e24398fe8c
commit
f50d1548d5
12 changed files with 562 additions and 173 deletions
|
|
@ -307,6 +307,33 @@ context_set_state (PvContext *context, PvContextState state)
|
|||
g_object_notify (G_OBJECT (context), "state");
|
||||
}
|
||||
}
|
||||
static void
|
||||
on_client_proxy (GObject *source_object,
|
||||
GAsyncResult *res,
|
||||
gpointer user_data)
|
||||
{
|
||||
PvContext *context = user_data;
|
||||
PvContextPrivate *priv = context->priv;
|
||||
GError *error = NULL;
|
||||
|
||||
priv->client = pv_subscribe_get_proxy_finish (priv->subscribe,
|
||||
res,
|
||||
&error);
|
||||
if (priv->client == NULL)
|
||||
goto client_failed;
|
||||
|
||||
context_set_state (context, PV_CONTEXT_STATE_READY);
|
||||
|
||||
return;
|
||||
|
||||
client_failed:
|
||||
{
|
||||
priv->error = error;
|
||||
context_set_state (context, PV_STREAM_STATE_ERROR);
|
||||
g_error ("failed to get client proxy: %s", error->message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_client_connected (GObject *source_object,
|
||||
|
|
@ -330,6 +357,14 @@ on_client_connected (GObject *source_object,
|
|||
|
||||
g_variant_get (ret, "(o)", &priv->client_path);
|
||||
g_variant_unref (ret);
|
||||
|
||||
pv_subscribe_get_proxy (priv->subscribe,
|
||||
PV_DBUS_SERVICE,
|
||||
priv->client_path,
|
||||
"org.pulsevideo.Client1",
|
||||
NULL,
|
||||
on_client_proxy,
|
||||
context);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -372,10 +407,6 @@ subscription_cb (PvSubscribe *subscribe,
|
|||
break;
|
||||
|
||||
case PV_SUBSCRIPTION_FLAGS_CLIENT:
|
||||
if (g_strcmp0 (g_dbus_proxy_get_object_path (object), priv->client_path) == 0) {
|
||||
priv->client = object;
|
||||
context_set_state (context, PV_CONTEXT_STATE_READY);
|
||||
}
|
||||
break;
|
||||
|
||||
case PV_SUBSCRIPTION_FLAGS_SOURCE:
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ pv_context_list_source_info (PvContext *context,
|
|||
GDBusProxy *proxy = walk->data;
|
||||
PvSourceInfo info;
|
||||
|
||||
info.name = "v4l2";
|
||||
info.name = "gst";
|
||||
|
||||
cb (context, &info, user_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,17 +134,28 @@ object_data_free (PvObjectData *data)
|
|||
static void
|
||||
remove_data (PvSubscribe *subscribe, PvObjectData *data)
|
||||
{
|
||||
PvSubscribePrivate *priv = subscribe->priv;
|
||||
|
||||
if (data->pending) {
|
||||
data->removed = TRUE;
|
||||
} else {
|
||||
priv->objects = g_list_remove (priv->objects, data);
|
||||
notify_event (subscribe, data, PV_SUBSCRIPTION_EVENT_REMOVE);
|
||||
object_data_free (data);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
remove_all_data (PvSubscribe *subscribe)
|
||||
{
|
||||
PvSubscribePrivate *priv = subscribe->priv;
|
||||
GList *walk;
|
||||
|
||||
for (walk = priv->objects; walk; walk = g_list_next (walk)) {
|
||||
PvObjectData *data = walk->data;
|
||||
remove_data (subscribe, data);
|
||||
}
|
||||
g_list_free (priv->objects);
|
||||
priv->objects = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
on_proxy_created (GObject *source_object,
|
||||
GAsyncResult *res,
|
||||
|
|
@ -185,8 +196,10 @@ on_proxy_created (GObject *source_object,
|
|||
if (--priv->pending_proxies == 0)
|
||||
subscription_set_state (subscribe, PV_SUBSCRIPTION_STATE_READY);
|
||||
|
||||
if (data->removed)
|
||||
if (data->removed) {
|
||||
priv->objects = g_list_remove (priv->objects, data);
|
||||
remove_data (subscribe, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -233,6 +246,7 @@ remove_interface (PvSubscribe *subscribe,
|
|||
|
||||
if (g_strcmp0 (data->object_path, object_path) == 0 &&
|
||||
g_strcmp0 (data->interface_name, interface_name) == 0) {
|
||||
priv->objects = g_list_remove (priv->objects, data);
|
||||
remove_data (subscribe, data);
|
||||
break;
|
||||
}
|
||||
|
|
@ -364,6 +378,7 @@ manager_proxy_appeared (PvSubscribe *subscribe)
|
|||
static void
|
||||
manager_proxy_disappeared (PvSubscribe *subscribe)
|
||||
{
|
||||
remove_all_data (subscribe);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue