2019-12-09 16:35:15 +02:00
|
|
|
/* WirePlumber
|
|
|
|
|
*
|
2020-05-29 09:30:36 +03:00
|
|
|
* Copyright © 2019-2020 Collabora Ltd.
|
2019-12-09 16:35:15 +02:00
|
|
|
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*/
|
|
|
|
|
|
2020-04-22 18:29:40 +03:00
|
|
|
#include "../common/base-test-fixture.h"
|
|
|
|
|
#include <pipewire/extensions/session-manager/keys.h>
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
struct _TestSiEndpoint
|
|
|
|
|
{
|
|
|
|
|
WpSessionItem parent;
|
|
|
|
|
const gchar *name;
|
|
|
|
|
const gchar *media_class;
|
2020-05-29 09:30:36 +03:00
|
|
|
WpNode *node;
|
2020-03-20 14:45:17 +02:00
|
|
|
WpDirection direction;
|
2020-05-29 09:30:36 +03:00
|
|
|
gboolean changed_properties;
|
2021-03-17 14:52:41 -04:00
|
|
|
WpSession *session;
|
|
|
|
|
WpProxy *impl_endpoint;
|
2020-03-20 14:45:17 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
G_DECLARE_FINAL_TYPE (TestSiEndpoint, test_si_endpoint,
|
|
|
|
|
TEST, SI_ENDPOINT, WpSessionItem)
|
|
|
|
|
|
|
|
|
|
static GVariant *
|
|
|
|
|
test_si_endpoint_get_registration_info (WpSiEndpoint * item)
|
|
|
|
|
{
|
|
|
|
|
TestSiEndpoint *self = TEST_SI_ENDPOINT (item);
|
|
|
|
|
GVariantBuilder b;
|
|
|
|
|
|
|
|
|
|
g_variant_builder_init (&b, G_VARIANT_TYPE ("(ssya{ss})"));
|
|
|
|
|
g_variant_builder_add (&b, "s", self->name);
|
|
|
|
|
g_variant_builder_add (&b, "s", self->media_class);
|
|
|
|
|
g_variant_builder_add (&b, "y", (guchar) self->direction);
|
|
|
|
|
g_variant_builder_add (&b, "a{ss}", NULL);
|
|
|
|
|
|
|
|
|
|
return g_variant_builder_end (&b);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static WpProperties *
|
|
|
|
|
test_si_endpoint_get_properties (WpSiEndpoint * item)
|
|
|
|
|
{
|
2020-05-29 09:30:36 +03:00
|
|
|
TestSiEndpoint *self = TEST_SI_ENDPOINT (item);
|
|
|
|
|
if (self->changed_properties)
|
|
|
|
|
return wp_properties_new ("test.property", "changed-value", NULL);
|
|
|
|
|
else
|
|
|
|
|
return wp_properties_new ("test.property", "test-value", NULL);
|
2020-03-20 14:45:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_si_endpoint_endpoint_init (WpSiEndpointInterface * iface)
|
|
|
|
|
{
|
|
|
|
|
iface->get_registration_info = test_si_endpoint_get_registration_info;
|
|
|
|
|
iface->get_properties = test_si_endpoint_get_properties;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (TestSiEndpoint, test_si_endpoint, WP_TYPE_SESSION_ITEM,
|
2021-03-09 13:13:14 -05:00
|
|
|
G_IMPLEMENT_INTERFACE (WP_TYPE_SI_ENDPOINT, test_si_endpoint_endpoint_init))
|
2020-03-20 14:45:17 +02:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_si_endpoint_init (TestSiEndpoint * self)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
static gpointer
|
2021-03-17 14:52:41 -04:00
|
|
|
si_endpoint_get_associated_proxy (WpSessionItem * item, GType proxy_type)
|
|
|
|
|
{
|
|
|
|
|
TestSiEndpoint * self = TEST_SI_ENDPOINT (item);
|
|
|
|
|
|
|
|
|
|
if (proxy_type == WP_TYPE_NODE)
|
|
|
|
|
return self->node ? g_object_ref (self->node) : NULL;
|
|
|
|
|
else if (proxy_type == WP_TYPE_SESSION)
|
|
|
|
|
return self->session ? g_object_ref (self->session) : NULL;
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
si_endpoint_reset (WpSessionItem * item)
|
2020-05-29 09:30:36 +03:00
|
|
|
{
|
|
|
|
|
TestSiEndpoint * self = TEST_SI_ENDPOINT (item);
|
|
|
|
|
|
2021-03-17 14:52:41 -04:00
|
|
|
wp_object_deactivate (WP_OBJECT (self),
|
|
|
|
|
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED);
|
|
|
|
|
|
|
|
|
|
g_clear_object (&self->node);
|
|
|
|
|
g_clear_object (&self->session);
|
|
|
|
|
|
|
|
|
|
WP_SESSION_ITEM_CLASS (test_si_endpoint_parent_class)->reset (item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
si_endpoint_disable_active (WpSessionItem *si)
|
|
|
|
|
{
|
|
|
|
|
TestSiEndpoint * self = TEST_SI_ENDPOINT (si);
|
|
|
|
|
|
|
|
|
|
wp_object_update_features (WP_OBJECT (self), 0,
|
|
|
|
|
WP_SESSION_ITEM_FEATURE_ACTIVE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
si_endpoint_disable_exported (WpSessionItem *si)
|
|
|
|
|
{
|
|
|
|
|
TestSiEndpoint * self = TEST_SI_ENDPOINT (si);
|
|
|
|
|
|
|
|
|
|
g_clear_object (&self->impl_endpoint);
|
|
|
|
|
wp_object_update_features (WP_OBJECT (self), 0,
|
|
|
|
|
WP_SESSION_ITEM_FEATURE_EXPORTED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
si_endpoint_enable_active (WpSessionItem *si, WpTransition *transition)
|
|
|
|
|
{
|
|
|
|
|
TestSiEndpoint * self = TEST_SI_ENDPOINT (si);
|
2020-05-29 09:30:36 +03:00
|
|
|
|
2021-03-17 14:52:41 -04:00
|
|
|
wp_object_update_features (WP_OBJECT (self),
|
|
|
|
|
WP_SESSION_ITEM_FEATURE_ACTIVE, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
on_impl_endpoint_activated (WpObject * object, GAsyncResult * res,
|
|
|
|
|
WpTransition * transition)
|
|
|
|
|
{
|
|
|
|
|
TestSiEndpoint *self = wp_transition_get_source_object (transition);
|
|
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
|
|
|
|
|
|
if (!wp_object_activate_finish (object, res, &error)) {
|
|
|
|
|
wp_transition_return_error (transition, g_steal_pointer (&error));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wp_object_update_features (WP_OBJECT (self),
|
|
|
|
|
WP_SESSION_ITEM_FEATURE_EXPORTED, 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
si_endpoint_enable_exported (WpSessionItem *si, WpTransition *transition)
|
|
|
|
|
{
|
|
|
|
|
TestSiEndpoint * self = TEST_SI_ENDPOINT (si);
|
|
|
|
|
g_autoptr (WpCore) core = wp_object_get_core (WP_OBJECT (self));
|
|
|
|
|
|
|
|
|
|
self->impl_endpoint = WP_PROXY (wp_impl_endpoint_new (core,
|
|
|
|
|
WP_SI_ENDPOINT (self)));
|
|
|
|
|
g_signal_connect_object (self->impl_endpoint, "pw-proxy-destroyed",
|
|
|
|
|
G_CALLBACK (wp_session_item_handle_proxy_destroyed), self, 0);
|
|
|
|
|
|
|
|
|
|
wp_object_activate (WP_OBJECT (self->impl_endpoint),
|
|
|
|
|
WP_OBJECT_FEATURES_ALL, NULL,
|
|
|
|
|
(GAsyncReadyCallback) on_impl_endpoint_activated, transition);
|
2020-05-29 09:30:36 +03:00
|
|
|
}
|
|
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
static void
|
|
|
|
|
test_si_endpoint_class_init (TestSiEndpointClass * klass)
|
|
|
|
|
{
|
2020-05-29 09:30:36 +03:00
|
|
|
WpSessionItemClass *item_class = (WpSessionItemClass *) klass;
|
|
|
|
|
|
2021-03-17 14:52:41 -04:00
|
|
|
item_class->reset = si_endpoint_reset;
|
|
|
|
|
item_class->get_associated_proxy = si_endpoint_get_associated_proxy;
|
|
|
|
|
item_class->disable_active = si_endpoint_disable_active;
|
|
|
|
|
item_class->disable_exported = si_endpoint_disable_exported;
|
|
|
|
|
item_class->enable_active = si_endpoint_enable_active;
|
|
|
|
|
item_class->enable_exported = si_endpoint_enable_exported;
|
2020-03-20 14:45:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*******************/
|
|
|
|
|
|
2019-12-09 16:35:15 +02:00
|
|
|
typedef struct {
|
2020-04-22 18:29:40 +03:00
|
|
|
WpBaseTestFixture base;
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
WpObjectManager *export_om;
|
|
|
|
|
WpObjectManager *proxy_om;
|
|
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
WpProxy *impl_endpoint;
|
2019-12-09 16:35:15 +02:00
|
|
|
WpProxy *proxy_endpoint;
|
|
|
|
|
|
|
|
|
|
gint n_events;
|
|
|
|
|
|
|
|
|
|
} TestEndpointFixture;
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_endpoint_setup (TestEndpointFixture *self, gconstpointer user_data)
|
|
|
|
|
{
|
2020-04-22 18:29:40 +03:00
|
|
|
wp_base_test_fixture_setup (&self->base, WP_BASE_TEST_FLAG_CLIENT_CORE);
|
2019-12-09 16:35:15 +02:00
|
|
|
self->export_om = wp_object_manager_new ();
|
|
|
|
|
self->proxy_om = wp_object_manager_new ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
test_endpoint_teardown (TestEndpointFixture *self, gconstpointer user_data)
|
|
|
|
|
{
|
|
|
|
|
g_clear_object (&self->proxy_om);
|
|
|
|
|
g_clear_object (&self->export_om);
|
2020-04-22 18:29:40 +03:00
|
|
|
wp_base_test_fixture_teardown (&self->base);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_impl_object_added (WpObjectManager *om,
|
2019-12-09 16:35:15 +02:00
|
|
|
WpEndpoint *endpoint, TestEndpointFixture *fixture)
|
|
|
|
|
{
|
2020-02-12 11:28:07 +02:00
|
|
|
g_debug ("impl object added");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
|
|
|
|
g_assert_cmpstr (G_OBJECT_TYPE_NAME (endpoint), ==, "WpImplEndpoint");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-02-12 11:28:07 +02:00
|
|
|
g_assert_null (fixture->impl_endpoint);
|
2020-03-20 14:45:17 +02:00
|
|
|
fixture->impl_endpoint = WP_PROXY (endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
if (++fixture->n_events == 3)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_impl_object_removed (WpObjectManager *om,
|
2019-12-09 16:35:15 +02:00
|
|
|
WpEndpoint *endpoint, TestEndpointFixture *fixture)
|
|
|
|
|
{
|
2020-02-12 11:28:07 +02:00
|
|
|
g_debug ("impl object removed");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
|
|
|
|
g_assert_cmpstr (G_OBJECT_TYPE_NAME (endpoint), ==, "WpImplEndpoint");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-02-12 11:28:07 +02:00
|
|
|
g_assert_nonnull (fixture->impl_endpoint);
|
|
|
|
|
fixture->impl_endpoint = NULL;
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
if (++fixture->n_events == 2)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_proxy_object_added (WpObjectManager *om,
|
2019-12-09 16:35:15 +02:00
|
|
|
WpEndpoint *endpoint, TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_debug ("proxy object added");
|
|
|
|
|
|
|
|
|
|
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_cmpstr (G_OBJECT_TYPE_NAME (endpoint), ==, "WpEndpoint");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
g_assert_null (fixture->proxy_endpoint);
|
|
|
|
|
fixture->proxy_endpoint = WP_PROXY (endpoint);
|
|
|
|
|
|
|
|
|
|
if (++fixture->n_events == 3)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_proxy_object_removed (WpObjectManager *om,
|
2019-12-09 16:35:15 +02:00
|
|
|
WpEndpoint *endpoint, TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_debug ("proxy object removed");
|
|
|
|
|
|
|
|
|
|
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_cmpstr (G_OBJECT_TYPE_NAME (endpoint), ==, "WpEndpoint");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
g_assert_nonnull (fixture->proxy_endpoint);
|
|
|
|
|
fixture->proxy_endpoint = NULL;
|
|
|
|
|
|
|
|
|
|
if (++fixture->n_events == 2)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2021-03-17 14:52:41 -04:00
|
|
|
test_endpoint_activate_done (WpObject * object, GAsyncResult * res,
|
2019-12-09 16:35:15 +02:00
|
|
|
TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
g_debug ("activate done");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2021-03-17 14:52:41 -04:00
|
|
|
g_assert_true (wp_object_activate_finish (object, res, &error));
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_no_error (error);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
if (++fixture->n_events == 3)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
static void
|
2020-11-13 13:40:11 +02:00
|
|
|
test_endpoint_session_bound (WpObject * session, GAsyncResult * res,
|
2020-03-20 14:45:17 +02:00
|
|
|
TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (GError) error = NULL;
|
|
|
|
|
|
|
|
|
|
g_debug ("session export done");
|
|
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_true (wp_object_activate_finish (session, res, &error));
|
2020-03-20 14:45:17 +02:00
|
|
|
g_assert_no_error (error);
|
|
|
|
|
|
|
|
|
|
g_assert_true (WP_IS_IMPL_SESSION (session));
|
|
|
|
|
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2020-03-20 14:45:17 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-25 22:41:40 +02:00
|
|
|
static void
|
|
|
|
|
test_endpoint_params_changed (WpPipewireObject * proxy,
|
|
|
|
|
guint32 id, TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
wp_debug_object (proxy, "params changed: %u", id);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2021-02-23 12:30:08 +02:00
|
|
|
/* only count changes of id 2 (Props); PipeWire 0.3.22+git changed
|
|
|
|
|
behaviour and emits changes to PropInfo as well then the Props change */
|
|
|
|
|
if (id == 2 && ++fixture->n_events == 3)
|
2020-11-25 22:41:40 +02:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
|
|
|
|
}
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_notify_properties (WpEndpoint * endpoint, GParamSpec * param,
|
2019-12-09 16:35:15 +02:00
|
|
|
TestEndpointFixture *fixture)
|
|
|
|
|
{
|
|
|
|
|
g_debug ("properties changed: %s", G_OBJECT_TYPE_NAME (endpoint));
|
|
|
|
|
|
|
|
|
|
g_assert_true (WP_IS_ENDPOINT (endpoint));
|
|
|
|
|
|
|
|
|
|
if (++fixture->n_events == 2)
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_quit (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2020-05-29 09:30:36 +03:00
|
|
|
test_endpoint_no_props (TestEndpointFixture *fixture, gconstpointer data)
|
2019-12-09 16:35:15 +02:00
|
|
|
{
|
2020-03-20 14:45:17 +02:00
|
|
|
g_autoptr (TestSiEndpoint) endpoint = NULL;
|
|
|
|
|
g_autoptr (WpImplSession) session = NULL;
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
/* set up the export side */
|
|
|
|
|
g_signal_connect (fixture->export_om, "object-added",
|
2020-05-29 09:30:36 +03:00
|
|
|
(GCallback) test_endpoint_impl_object_added, fixture);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_signal_connect (fixture->export_om, "object-removed",
|
2020-05-29 09:30:36 +03:00
|
|
|
(GCallback) test_endpoint_impl_object_removed, fixture);
|
2020-05-14 16:24:34 +03:00
|
|
|
wp_object_manager_add_interest (fixture->export_om, WP_TYPE_ENDPOINT, NULL);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_manager_request_object_features (fixture->export_om,
|
|
|
|
|
WP_TYPE_ENDPOINT, WP_OBJECT_FEATURES_ALL);
|
2020-04-22 18:29:40 +03:00
|
|
|
wp_core_install_object_manager (fixture->base.core, fixture->export_om);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
/* set up the proxy side */
|
|
|
|
|
g_signal_connect (fixture->proxy_om, "object-added",
|
2020-05-29 09:30:36 +03:00
|
|
|
(GCallback) test_endpoint_proxy_object_added, fixture);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_signal_connect (fixture->proxy_om, "object-removed",
|
2020-05-29 09:30:36 +03:00
|
|
|
(GCallback) test_endpoint_proxy_object_removed, fixture);
|
2020-05-14 16:24:34 +03:00
|
|
|
wp_object_manager_add_interest (fixture->proxy_om, WP_TYPE_ENDPOINT, NULL);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_manager_request_object_features (fixture->proxy_om,
|
|
|
|
|
WP_TYPE_ENDPOINT, WP_OBJECT_FEATURES_ALL);
|
2020-04-22 18:29:40 +03:00
|
|
|
wp_core_install_object_manager (fixture->base.client_core, fixture->proxy_om);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
/* create session */
|
2020-04-22 18:29:40 +03:00
|
|
|
session = wp_impl_session_new (fixture->base.core);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_activate (WP_OBJECT (session), WP_PROXY_FEATURE_BOUND, NULL,
|
2020-05-29 09:30:36 +03:00
|
|
|
(GAsyncReadyCallback) test_endpoint_session_bound, fixture);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
/* run until session is bound */
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_cmpint (wp_object_get_active_features (WP_OBJECT (session)), &,
|
2020-03-20 14:45:17 +02:00
|
|
|
WP_PROXY_FEATURE_BOUND);
|
|
|
|
|
g_assert_cmpint (wp_proxy_get_bound_id (WP_PROXY (session)), >, 0);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-03-20 14:45:17 +02:00
|
|
|
/* create endpoint */
|
2021-03-17 14:52:41 -04:00
|
|
|
endpoint = g_object_new (test_si_endpoint_get_type (),
|
|
|
|
|
"core", fixture->base.core, NULL);
|
2020-03-20 14:45:17 +02:00
|
|
|
endpoint->name = "test-endpoint";
|
|
|
|
|
endpoint->media_class = "Audio/Source";
|
|
|
|
|
endpoint->direction = WP_DIRECTION_OUTPUT;
|
2021-03-17 14:52:41 -04:00
|
|
|
endpoint->session = WP_SESSION (g_object_ref (session));
|
|
|
|
|
wp_object_activate (WP_OBJECT (endpoint),
|
|
|
|
|
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED,
|
|
|
|
|
NULL, (GAsyncReadyCallback) test_endpoint_activate_done, fixture);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
/* run until objects are created and features are cached */
|
|
|
|
|
fixture->n_events = 0;
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2021-03-17 14:52:41 -04:00
|
|
|
g_assert_cmpint (wp_object_get_active_features (WP_OBJECT (endpoint)), ==,
|
|
|
|
|
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 3);
|
2020-02-12 11:28:07 +02:00
|
|
|
g_assert_nonnull (fixture->impl_endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_nonnull (fixture->proxy_endpoint);
|
|
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* verify the values on the proxy */
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_cmphex (
|
|
|
|
|
wp_object_get_active_features (WP_OBJECT (fixture->proxy_endpoint)), ==,
|
|
|
|
|
wp_object_get_supported_features (WP_OBJECT (fixture->proxy_endpoint)));
|
2020-01-23 18:50:01 +02:00
|
|
|
g_assert_cmpuint (wp_proxy_get_bound_id (fixture->proxy_endpoint), ==,
|
2020-03-20 14:45:17 +02:00
|
|
|
wp_proxy_get_bound_id (fixture->impl_endpoint));
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-11-13 13:40:11 +02:00
|
|
|
g_assert_cmpstr (wp_pipewire_object_get_property (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->proxy_endpoint), "test.property"),
|
|
|
|
|
==, "test-value");
|
2020-03-20 14:45:17 +02:00
|
|
|
|
|
|
|
|
{
|
2020-11-13 13:40:11 +02:00
|
|
|
g_autoptr (WpProperties) props = wp_global_proxy_get_global_properties (
|
|
|
|
|
WP_GLOBAL_PROXY (fixture->proxy_endpoint));
|
2020-03-20 14:45:17 +02:00
|
|
|
g_autofree gchar * session_id = g_strdup_printf ("%u",
|
|
|
|
|
wp_proxy_get_bound_id (WP_PROXY (session)));
|
|
|
|
|
|
|
|
|
|
g_assert_cmpstr (wp_properties_get (props, PW_KEY_ENDPOINT_NAME), ==,
|
|
|
|
|
"test-endpoint");
|
|
|
|
|
g_assert_cmpstr (wp_properties_get (props, PW_KEY_MEDIA_CLASS), ==,
|
|
|
|
|
"Audio/Source");
|
|
|
|
|
g_assert_cmpstr (wp_properties_get (props, PW_KEY_SESSION_ID), ==,
|
|
|
|
|
session_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
g_assert_cmpstr ("test-endpoint", ==,
|
|
|
|
|
wp_endpoint_get_name (WP_ENDPOINT (fixture->proxy_endpoint)));
|
|
|
|
|
g_assert_cmpstr ("Audio/Source", ==,
|
|
|
|
|
wp_endpoint_get_media_class (WP_ENDPOINT (fixture->proxy_endpoint)));
|
|
|
|
|
g_assert_cmpint (WP_DIRECTION_OUTPUT, ==,
|
|
|
|
|
wp_endpoint_get_direction (WP_ENDPOINT (fixture->proxy_endpoint)));
|
|
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* test property changes */
|
2019-12-09 16:35:15 +02:00
|
|
|
g_signal_connect (fixture->proxy_endpoint, "notify::properties",
|
2020-05-29 09:30:36 +03:00
|
|
|
(GCallback) test_endpoint_notify_properties, fixture);
|
|
|
|
|
g_signal_connect (fixture->impl_endpoint, "notify::properties",
|
|
|
|
|
(GCallback) test_endpoint_notify_properties, fixture);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* change a property on the impl */
|
|
|
|
|
fixture->n_events = 0;
|
|
|
|
|
endpoint->changed_properties = TRUE;
|
|
|
|
|
g_signal_emit_by_name (endpoint, "endpoint-properties-changed");
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
/* run until the change is on both sides */
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 2);
|
|
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* verify the property change on both sides */
|
|
|
|
|
{
|
2020-11-13 13:40:11 +02:00
|
|
|
g_autoptr (WpProperties) props = wp_pipewire_object_get_properties (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->impl_endpoint));
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpstr (wp_properties_get (props, "test.property"), ==,
|
|
|
|
|
"changed-value");
|
|
|
|
|
}
|
|
|
|
|
{
|
2020-11-13 13:40:11 +02:00
|
|
|
g_autoptr (WpProperties) props = wp_pipewire_object_get_properties (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->proxy_endpoint));
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpstr (wp_properties_get (props, "test.property"), ==,
|
|
|
|
|
"changed-value");
|
|
|
|
|
}
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* destroy impl endpoint */
|
2019-12-09 16:35:15 +02:00
|
|
|
fixture->n_events = 0;
|
2020-05-29 09:30:36 +03:00
|
|
|
g_clear_object (&endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* run until objects are destroyed */
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 2);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_null (fixture->impl_endpoint);
|
|
|
|
|
g_assert_null (fixture->proxy_endpoint);
|
|
|
|
|
}
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
static void
|
|
|
|
|
test_endpoint_with_props (TestEndpointFixture *fixture, gconstpointer data)
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (TestSiEndpoint) endpoint = NULL;
|
|
|
|
|
g_autoptr (WpImplSession) session = NULL;
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* load modules */
|
|
|
|
|
{
|
|
|
|
|
g_autoptr (WpTestServerLocker) lock =
|
|
|
|
|
wp_test_server_locker_new (&fixture->base.server);
|
|
|
|
|
|
|
|
|
|
g_assert_cmpint (pw_context_add_spa_lib (fixture->base.server.context,
|
|
|
|
|
"audiotestsrc", "audiotestsrc/libspa-audiotestsrc"), ==, 0);
|
|
|
|
|
g_assert_nonnull (pw_context_load_module (fixture->base.server.context,
|
|
|
|
|
"libpipewire-module-adapter", NULL, NULL));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* set up the export side */
|
|
|
|
|
g_signal_connect (fixture->export_om, "object-added",
|
|
|
|
|
(GCallback) test_endpoint_impl_object_added, fixture);
|
|
|
|
|
g_signal_connect (fixture->export_om, "object-removed",
|
|
|
|
|
(GCallback) test_endpoint_impl_object_removed, fixture);
|
|
|
|
|
wp_object_manager_add_interest (fixture->export_om, WP_TYPE_ENDPOINT, NULL);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_manager_request_object_features (fixture->export_om,
|
|
|
|
|
WP_TYPE_ENDPOINT, WP_OBJECT_FEATURES_ALL);
|
2020-05-29 09:30:36 +03:00
|
|
|
wp_core_install_object_manager (fixture->base.core, fixture->export_om);
|
|
|
|
|
|
|
|
|
|
/* set up the proxy side */
|
|
|
|
|
g_signal_connect (fixture->proxy_om, "object-added",
|
|
|
|
|
(GCallback) test_endpoint_proxy_object_added, fixture);
|
|
|
|
|
g_signal_connect (fixture->proxy_om, "object-removed",
|
|
|
|
|
(GCallback) test_endpoint_proxy_object_removed, fixture);
|
|
|
|
|
wp_object_manager_add_interest (fixture->proxy_om, WP_TYPE_ENDPOINT, NULL);
|
2020-11-13 13:40:11 +02:00
|
|
|
wp_object_manager_request_object_features (fixture->proxy_om,
|
|
|
|
|
WP_TYPE_ENDPOINT, WP_OBJECT_FEATURES_ALL);
|
2020-05-29 09:30:36 +03:00
|
|
|
wp_core_install_object_manager (fixture->base.client_core, fixture->proxy_om);
|
|
|
|
|
|
|
|
|
|
/* create session */
|
|
|
|
|
session = wp_impl_session_new (fixture->base.core);
|
2020-11-25 22:41:40 +02:00
|
|
|
wp_object_activate (WP_OBJECT (session), WP_PROXY_FEATURE_BOUND, NULL,
|
2020-05-29 09:30:36 +03:00
|
|
|
(GAsyncReadyCallback) test_endpoint_session_bound, fixture);
|
|
|
|
|
|
|
|
|
|
/* run until session is bound */
|
|
|
|
|
g_main_loop_run (fixture->base.loop);
|
2020-11-25 22:41:40 +02:00
|
|
|
g_assert_cmpint (wp_object_get_active_features (WP_OBJECT (session)), &,
|
2020-05-29 09:30:36 +03:00
|
|
|
WP_PROXY_FEATURE_BOUND);
|
|
|
|
|
g_assert_cmpint (wp_proxy_get_bound_id (WP_PROXY (session)), >, 0);
|
|
|
|
|
|
|
|
|
|
/* create endpoint */
|
2021-03-17 14:52:41 -04:00
|
|
|
endpoint = g_object_new (test_si_endpoint_get_type (),
|
|
|
|
|
"core", fixture->base.core, NULL);
|
2020-05-29 09:30:36 +03:00
|
|
|
endpoint->name = "test-endpoint";
|
|
|
|
|
endpoint->media_class = "Audio/Source";
|
|
|
|
|
endpoint->direction = WP_DIRECTION_OUTPUT;
|
2021-03-17 14:52:41 -04:00
|
|
|
endpoint->session = WP_SESSION (g_object_ref (session));
|
2020-05-29 09:30:36 +03:00
|
|
|
|
|
|
|
|
/* associate a node that has props */
|
|
|
|
|
endpoint->node = wp_node_new_from_factory (fixture->base.core,
|
|
|
|
|
"adapter",
|
|
|
|
|
wp_properties_new (
|
|
|
|
|
"factory.name", "audiotestsrc",
|
|
|
|
|
"node.name", "audiotestsrc.adapter",
|
|
|
|
|
NULL));
|
|
|
|
|
g_assert_nonnull (endpoint->node);
|
2020-11-25 22:41:40 +02:00
|
|
|
wp_object_activate (WP_OBJECT (endpoint->node),
|
|
|
|
|
WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL, NULL,
|
2020-11-13 13:40:11 +02:00
|
|
|
(GAsyncReadyCallback) test_object_activate_finish_cb, fixture);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
|
|
|
|
|
2020-11-25 22:41:40 +02:00
|
|
|
g_assert_cmpint (wp_object_get_active_features (WP_OBJECT (endpoint->node)),
|
|
|
|
|
==, WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL);
|
2020-05-29 09:30:36 +03:00
|
|
|
|
|
|
|
|
/* activate & export the endpoint */
|
2021-03-17 14:52:41 -04:00
|
|
|
wp_object_activate (WP_OBJECT (endpoint),
|
|
|
|
|
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED,
|
|
|
|
|
NULL, (GAsyncReadyCallback) test_endpoint_activate_done, fixture);
|
2020-05-29 09:30:36 +03:00
|
|
|
|
|
|
|
|
/* run until objects are created and features are cached */
|
2019-12-09 16:35:15 +02:00
|
|
|
fixture->n_events = 0;
|
2020-05-29 09:30:36 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2021-03-17 14:52:41 -04:00
|
|
|
g_assert_cmpint (wp_object_get_active_features (WP_OBJECT (endpoint)), ==,
|
|
|
|
|
WP_SESSION_ITEM_FEATURE_ACTIVE | WP_SESSION_ITEM_FEATURE_EXPORTED);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 3);
|
|
|
|
|
g_assert_nonnull (fixture->impl_endpoint);
|
|
|
|
|
g_assert_nonnull (fixture->proxy_endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* verify features; the endpoint must have also augmented the node */
|
2020-11-25 22:41:40 +02:00
|
|
|
g_assert_cmpint (
|
|
|
|
|
wp_object_get_active_features (WP_OBJECT (endpoint->node)), &,
|
|
|
|
|
WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL | WP_PIPEWIRE_OBJECT_FEATURE_PARAM_PROPS);
|
|
|
|
|
g_assert_cmphex (
|
|
|
|
|
wp_object_get_active_features (WP_OBJECT (fixture->proxy_endpoint)), &,
|
|
|
|
|
WP_PIPEWIRE_OBJECT_FEATURES_MINIMAL | WP_PIPEWIRE_OBJECT_FEATURE_PARAM_PROPS);
|
2020-05-29 09:30:36 +03:00
|
|
|
|
|
|
|
|
/* verify props */
|
|
|
|
|
{
|
2020-11-25 22:41:40 +02:00
|
|
|
g_autoptr (WpIterator) iterator = NULL;
|
|
|
|
|
g_auto (GValue) item = G_VALUE_INIT;
|
|
|
|
|
g_autoptr (WpSpaPod) pod = NULL;
|
2020-05-29 09:30:36 +03:00
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
gboolean boolean_value = TRUE;
|
2020-11-25 22:41:40 +02:00
|
|
|
|
|
|
|
|
iterator = wp_pipewire_object_enum_params_sync (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->proxy_endpoint), "Props", NULL);
|
|
|
|
|
g_assert_nonnull (iterator);
|
|
|
|
|
|
|
|
|
|
g_assert_true (wp_iterator_next (iterator, &item));
|
|
|
|
|
g_assert_nonnull ((pod = g_value_dup_boxed (&item)));
|
|
|
|
|
|
2021-01-13 20:11:41 +02:00
|
|
|
g_assert_true (wp_spa_pod_get_object (pod, NULL,
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", &float_value,
|
|
|
|
|
"mute", "b", &boolean_value,
|
|
|
|
|
NULL));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 1.0f, 0.001);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpint (boolean_value, ==, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* setup change signals */
|
2020-11-25 22:41:40 +02:00
|
|
|
g_signal_connect (fixture->proxy_endpoint, "params-changed",
|
|
|
|
|
(GCallback) test_endpoint_params_changed, fixture);
|
|
|
|
|
g_signal_connect (fixture->impl_endpoint, "params-changed",
|
|
|
|
|
(GCallback) test_endpoint_params_changed, fixture);
|
|
|
|
|
g_signal_connect (endpoint->node, "params-changed",
|
|
|
|
|
(GCallback) test_endpoint_params_changed, fixture);
|
2020-05-29 09:30:36 +03:00
|
|
|
|
|
|
|
|
/* change control on the proxy */
|
|
|
|
|
fixture->n_events = 0;
|
2020-11-25 22:41:40 +02:00
|
|
|
wp_pipewire_object_set_param (WP_PIPEWIRE_OBJECT (fixture->proxy_endpoint),
|
|
|
|
|
"Props", 0,
|
2021-01-13 20:11:41 +02:00
|
|
|
wp_spa_pod_new_object ("Spa:Pod:Object:Param:Props", "Props",
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", 0.7f, NULL));
|
2020-05-29 09:30:36 +03:00
|
|
|
|
|
|
|
|
/* run until the change is on all sides */
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 3);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* verify the value change on all sides */
|
|
|
|
|
{
|
2020-11-25 22:41:40 +02:00
|
|
|
g_autoptr (WpIterator) iterator = NULL;
|
|
|
|
|
g_auto (GValue) item = G_VALUE_INIT;
|
|
|
|
|
g_autoptr (WpSpaPod) pod = NULL;
|
2020-05-29 09:30:36 +03:00
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
gboolean boolean_value = TRUE;
|
2020-11-25 22:41:40 +02:00
|
|
|
|
|
|
|
|
iterator = wp_pipewire_object_enum_params_sync (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->proxy_endpoint), "Props", NULL);
|
|
|
|
|
g_assert_nonnull (iterator);
|
|
|
|
|
|
|
|
|
|
g_assert_true (wp_iterator_next (iterator, &item));
|
|
|
|
|
g_assert_nonnull ((pod = g_value_dup_boxed (&item)));
|
|
|
|
|
|
2021-01-13 20:11:41 +02:00
|
|
|
g_assert_true (wp_spa_pod_get_object (pod, NULL,
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", &float_value,
|
|
|
|
|
"mute", "b", &boolean_value,
|
|
|
|
|
NULL));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpint (boolean_value, ==, FALSE);
|
|
|
|
|
}
|
|
|
|
|
{
|
2020-11-25 22:41:40 +02:00
|
|
|
g_autoptr (WpIterator) iterator = NULL;
|
|
|
|
|
g_auto (GValue) item = G_VALUE_INIT;
|
|
|
|
|
g_autoptr (WpSpaPod) pod = NULL;
|
2020-05-29 09:30:36 +03:00
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
gboolean boolean_value = TRUE;
|
2020-11-25 22:41:40 +02:00
|
|
|
|
|
|
|
|
iterator = wp_pipewire_object_enum_params_sync (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->impl_endpoint), "Props", NULL);
|
|
|
|
|
g_assert_nonnull (iterator);
|
|
|
|
|
|
|
|
|
|
g_assert_true (wp_iterator_next (iterator, &item));
|
|
|
|
|
g_assert_nonnull ((pod = g_value_dup_boxed (&item)));
|
|
|
|
|
|
2021-01-13 20:11:41 +02:00
|
|
|
g_assert_true (wp_spa_pod_get_object (pod, NULL,
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", &float_value,
|
|
|
|
|
"mute", "b", &boolean_value,
|
|
|
|
|
NULL));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpint (boolean_value, ==, FALSE);
|
|
|
|
|
}
|
|
|
|
|
{
|
2020-11-25 22:41:40 +02:00
|
|
|
g_autoptr (WpIterator) iterator = NULL;
|
|
|
|
|
g_auto (GValue) item = G_VALUE_INIT;
|
|
|
|
|
g_autoptr (WpSpaPod) pod = NULL;
|
2020-05-29 09:30:36 +03:00
|
|
|
gfloat float_value = 0.0f;
|
|
|
|
|
gboolean boolean_value = TRUE;
|
2020-11-25 22:41:40 +02:00
|
|
|
|
|
|
|
|
iterator = wp_pipewire_object_enum_params_sync (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (endpoint->node), "Props", NULL);
|
|
|
|
|
g_assert_nonnull (iterator);
|
|
|
|
|
|
|
|
|
|
g_assert_true (wp_iterator_next (iterator, &item));
|
|
|
|
|
g_assert_nonnull ((pod = g_value_dup_boxed (&item)));
|
|
|
|
|
|
2021-01-13 20:11:41 +02:00
|
|
|
g_assert_true (wp_spa_pod_get_object (pod, NULL,
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", &float_value,
|
|
|
|
|
"mute", "b", &boolean_value,
|
|
|
|
|
NULL));
|
|
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpint (boolean_value, ==, FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* change control on the impl */
|
|
|
|
|
fixture->n_events = 0;
|
2020-11-25 22:41:40 +02:00
|
|
|
wp_pipewire_object_set_param (WP_PIPEWIRE_OBJECT (fixture->impl_endpoint),
|
|
|
|
|
"Props", 0,
|
2021-01-13 20:11:41 +02:00
|
|
|
wp_spa_pod_new_object ("Spa:Pod:Object:Param:Props", "Props",
|
2020-11-25 22:41:40 +02:00
|
|
|
"mute", "b", TRUE, NULL));
|
2020-05-29 09:30:36 +03:00
|
|
|
|
|
|
|
|
/* run until the change is on all sides */
|
|
|
|
|
g_main_loop_run (fixture->base.loop);
|
|
|
|
|
g_assert_cmpint (fixture->n_events, ==, 3);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
/* verify the value change on all sides */
|
2019-12-09 16:35:15 +02:00
|
|
|
{
|
2020-11-25 22:41:40 +02:00
|
|
|
g_autoptr (WpIterator) iterator = NULL;
|
|
|
|
|
g_auto (GValue) item = G_VALUE_INIT;
|
|
|
|
|
g_autoptr (WpSpaPod) pod = NULL;
|
2020-05-29 09:30:36 +03:00
|
|
|
gfloat float_value = 0.0f;
|
2020-11-25 22:41:40 +02:00
|
|
|
gboolean boolean_value = TRUE;
|
|
|
|
|
|
|
|
|
|
iterator = wp_pipewire_object_enum_params_sync (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->proxy_endpoint), "Props", NULL);
|
|
|
|
|
g_assert_nonnull (iterator);
|
|
|
|
|
|
|
|
|
|
g_assert_true (wp_iterator_next (iterator, &item));
|
|
|
|
|
g_assert_nonnull ((pod = g_value_dup_boxed (&item)));
|
|
|
|
|
|
2021-01-13 20:11:41 +02:00
|
|
|
g_assert_true (wp_spa_pod_get_object (pod, NULL,
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", &float_value,
|
|
|
|
|
"mute", "b", &boolean_value,
|
|
|
|
|
NULL));
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
|
|
|
|
}
|
|
|
|
|
{
|
2020-11-25 22:41:40 +02:00
|
|
|
g_autoptr (WpIterator) iterator = NULL;
|
|
|
|
|
g_auto (GValue) item = G_VALUE_INIT;
|
|
|
|
|
g_autoptr (WpSpaPod) pod = NULL;
|
2020-05-29 09:30:36 +03:00
|
|
|
gfloat float_value = 0.0f;
|
2020-11-25 22:41:40 +02:00
|
|
|
gboolean boolean_value = TRUE;
|
|
|
|
|
|
|
|
|
|
iterator = wp_pipewire_object_enum_params_sync (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->impl_endpoint), "Props", NULL);
|
|
|
|
|
g_assert_nonnull (iterator);
|
|
|
|
|
|
|
|
|
|
g_assert_true (wp_iterator_next (iterator, &item));
|
|
|
|
|
g_assert_nonnull ((pod = g_value_dup_boxed (&item)));
|
|
|
|
|
|
2021-01-13 20:11:41 +02:00
|
|
|
g_assert_true (wp_spa_pod_get_object (pod, NULL,
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", &float_value,
|
|
|
|
|
"mute", "b", &boolean_value,
|
|
|
|
|
NULL));
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
|
|
|
|
}
|
|
|
|
|
{
|
2020-11-25 22:41:40 +02:00
|
|
|
g_autoptr (WpIterator) iterator = NULL;
|
|
|
|
|
g_auto (GValue) item = G_VALUE_INIT;
|
|
|
|
|
g_autoptr (WpSpaPod) pod = NULL;
|
2020-05-29 09:30:36 +03:00
|
|
|
gfloat float_value = 0.0f;
|
2020-11-25 22:41:40 +02:00
|
|
|
gboolean boolean_value = TRUE;
|
|
|
|
|
|
|
|
|
|
iterator = wp_pipewire_object_enum_params_sync (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (endpoint->node), "Props", NULL);
|
|
|
|
|
g_assert_nonnull (iterator);
|
|
|
|
|
|
|
|
|
|
g_assert_true (wp_iterator_next (iterator, &item));
|
|
|
|
|
g_assert_nonnull ((pod = g_value_dup_boxed (&item)));
|
|
|
|
|
|
2021-01-13 20:11:41 +02:00
|
|
|
g_assert_true (wp_spa_pod_get_object (pod, NULL,
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", &float_value,
|
|
|
|
|
"mute", "b", &boolean_value,
|
|
|
|
|
NULL));
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.7f, 0.001);
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* change control on the node */
|
|
|
|
|
fixture->n_events = 0;
|
2020-11-25 22:41:40 +02:00
|
|
|
wp_pipewire_object_set_param (WP_PIPEWIRE_OBJECT (endpoint->node),
|
|
|
|
|
"Props", 0,
|
2021-01-13 20:11:41 +02:00
|
|
|
wp_spa_pod_new_object ("Spa:Pod:Object:Param:Props", "Props",
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", 0.2f, NULL));
|
2020-05-29 09:30:36 +03:00
|
|
|
|
|
|
|
|
/* run until the change is on all sides */
|
|
|
|
|
g_main_loop_run (fixture->base.loop);
|
|
|
|
|
g_assert_cmpint (fixture->n_events, ==, 3);
|
|
|
|
|
|
|
|
|
|
/* verify the value change on all sides */
|
|
|
|
|
{
|
2020-11-25 22:41:40 +02:00
|
|
|
g_autoptr (WpIterator) iterator = NULL;
|
|
|
|
|
g_auto (GValue) item = G_VALUE_INIT;
|
|
|
|
|
g_autoptr (WpSpaPod) pod = NULL;
|
2020-05-29 09:30:36 +03:00
|
|
|
gfloat float_value = 0.0f;
|
2020-11-25 22:41:40 +02:00
|
|
|
gboolean boolean_value = TRUE;
|
|
|
|
|
|
|
|
|
|
iterator = wp_pipewire_object_enum_params_sync (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->proxy_endpoint), "Props", NULL);
|
|
|
|
|
g_assert_nonnull (iterator);
|
|
|
|
|
|
|
|
|
|
g_assert_true (wp_iterator_next (iterator, &item));
|
|
|
|
|
g_assert_nonnull ((pod = g_value_dup_boxed (&item)));
|
|
|
|
|
|
2021-01-13 20:11:41 +02:00
|
|
|
g_assert_true (wp_spa_pod_get_object (pod, NULL,
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", &float_value,
|
|
|
|
|
"mute", "b", &boolean_value,
|
|
|
|
|
NULL));
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.2f, 0.001);
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
|
|
|
|
}
|
|
|
|
|
{
|
2020-11-25 22:41:40 +02:00
|
|
|
g_autoptr (WpIterator) iterator = NULL;
|
|
|
|
|
g_auto (GValue) item = G_VALUE_INIT;
|
|
|
|
|
g_autoptr (WpSpaPod) pod = NULL;
|
2020-05-29 09:30:36 +03:00
|
|
|
gfloat float_value = 0.0f;
|
2020-11-25 22:41:40 +02:00
|
|
|
gboolean boolean_value = TRUE;
|
|
|
|
|
|
|
|
|
|
iterator = wp_pipewire_object_enum_params_sync (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (fixture->impl_endpoint), "Props", NULL);
|
|
|
|
|
g_assert_nonnull (iterator);
|
|
|
|
|
|
|
|
|
|
g_assert_true (wp_iterator_next (iterator, &item));
|
|
|
|
|
g_assert_nonnull ((pod = g_value_dup_boxed (&item)));
|
|
|
|
|
|
2021-01-13 20:11:41 +02:00
|
|
|
g_assert_true (wp_spa_pod_get_object (pod, NULL,
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", &float_value,
|
|
|
|
|
"mute", "b", &boolean_value,
|
|
|
|
|
NULL));
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.2f, 0.001);
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
|
|
|
|
}
|
|
|
|
|
{
|
2020-11-25 22:41:40 +02:00
|
|
|
g_autoptr (WpIterator) iterator = NULL;
|
|
|
|
|
g_auto (GValue) item = G_VALUE_INIT;
|
|
|
|
|
g_autoptr (WpSpaPod) pod = NULL;
|
2020-05-29 09:30:36 +03:00
|
|
|
gfloat float_value = 0.0f;
|
2020-11-25 22:41:40 +02:00
|
|
|
gboolean boolean_value = TRUE;
|
|
|
|
|
|
|
|
|
|
iterator = wp_pipewire_object_enum_params_sync (
|
|
|
|
|
WP_PIPEWIRE_OBJECT (endpoint->node), "Props", NULL);
|
|
|
|
|
g_assert_nonnull (iterator);
|
|
|
|
|
|
|
|
|
|
g_assert_true (wp_iterator_next (iterator, &item));
|
|
|
|
|
g_assert_nonnull ((pod = g_value_dup_boxed (&item)));
|
|
|
|
|
|
2021-01-13 20:11:41 +02:00
|
|
|
g_assert_true (wp_spa_pod_get_object (pod, NULL,
|
2020-11-25 22:41:40 +02:00
|
|
|
"volume", "f", &float_value,
|
|
|
|
|
"mute", "b", &boolean_value,
|
|
|
|
|
NULL));
|
2020-05-29 09:30:36 +03:00
|
|
|
g_assert_cmpfloat_with_epsilon (float_value, 0.2f, 0.001);
|
|
|
|
|
g_assert_cmpint (boolean_value, ==, TRUE);
|
2019-12-09 16:35:15 +02:00
|
|
|
}
|
|
|
|
|
|
2020-02-12 11:28:07 +02:00
|
|
|
/* destroy impl endpoint */
|
2019-12-09 16:35:15 +02:00
|
|
|
fixture->n_events = 0;
|
2020-02-12 11:28:07 +02:00
|
|
|
g_clear_object (&endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
/* run until objects are destroyed */
|
2020-04-22 18:29:40 +03:00
|
|
|
g_main_loop_run (fixture->base.loop);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_cmpint (fixture->n_events, ==, 2);
|
2020-02-12 11:28:07 +02:00
|
|
|
g_assert_null (fixture->impl_endpoint);
|
2019-12-09 16:35:15 +02:00
|
|
|
g_assert_null (fixture->proxy_endpoint);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gint
|
|
|
|
|
main (gint argc, gchar *argv[])
|
|
|
|
|
{
|
|
|
|
|
g_test_init (&argc, &argv, NULL);
|
2020-05-11 15:45:09 +03:00
|
|
|
wp_init (WP_INIT_ALL);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
2020-05-29 09:30:36 +03:00
|
|
|
g_test_add ("/wp/endpoint/no-props", TestEndpointFixture, NULL,
|
|
|
|
|
test_endpoint_setup, test_endpoint_no_props, test_endpoint_teardown);
|
2020-11-25 22:41:40 +02:00
|
|
|
g_test_add ("/wp/endpoint/with-props", TestEndpointFixture, NULL,
|
|
|
|
|
test_endpoint_setup, test_endpoint_with_props, test_endpoint_teardown);
|
2019-12-09 16:35:15 +02:00
|
|
|
|
|
|
|
|
return g_test_run ();
|
|
|
|
|
}
|