session: make the media_class a normal GObject property
This commit is contained in:
@@ -11,12 +11,14 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_DIRECTION
|
PROP_DIRECTION,
|
||||||
|
PROP_MEDIA_CLASS,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
WpSessionDirection direction;
|
WpSessionDirection direction;
|
||||||
|
gchar media_class[41];
|
||||||
} WpSessionPrivate;
|
} WpSessionPrivate;
|
||||||
|
|
||||||
G_DEFINE_TYPE_WITH_PRIVATE (WpSession, wp_session, WP_TYPE_OBJECT)
|
G_DEFINE_TYPE_WITH_PRIVATE (WpSession, wp_session, WP_TYPE_OBJECT)
|
||||||
@@ -36,6 +38,9 @@ wp_session_set_property (GObject * object, guint property_id,
|
|||||||
case PROP_DIRECTION:
|
case PROP_DIRECTION:
|
||||||
priv->direction = g_value_get_enum (value);
|
priv->direction = g_value_get_enum (value);
|
||||||
break;
|
break;
|
||||||
|
case PROP_MEDIA_CLASS:
|
||||||
|
strncpy (priv->media_class, g_value_get_string (value), 40);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -52,6 +57,9 @@ wp_session_get_property (GObject * object, guint property_id, GValue * value,
|
|||||||
case PROP_DIRECTION:
|
case PROP_DIRECTION:
|
||||||
g_value_set_enum (value, priv->direction);
|
g_value_set_enum (value, priv->direction);
|
||||||
break;
|
break;
|
||||||
|
case PROP_MEDIA_CLASS:
|
||||||
|
g_value_set_string (value, priv->media_class);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||||
break;
|
break;
|
||||||
@@ -71,12 +79,23 @@ wp_session_class_init (WpSessionClass * klass)
|
|||||||
"The media flow direction of the session",
|
"The media flow direction of the session",
|
||||||
WP_TYPE_SESSION_DIRECTION, 0,
|
WP_TYPE_SESSION_DIRECTION, 0,
|
||||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||||
|
|
||||||
|
g_object_class_install_property (object_class, PROP_MEDIA_CLASS,
|
||||||
|
g_param_spec_string ("media-class", "media-class",
|
||||||
|
"The media class of the session", NULL,
|
||||||
|
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||||
}
|
}
|
||||||
|
|
||||||
WpSessionDirection
|
WpSessionDirection
|
||||||
wp_session_get_direction (WpSession * self)
|
wp_session_get_direction (WpSession * self)
|
||||||
{
|
{
|
||||||
WpSessionDirection dir;
|
WpSessionPrivate *priv = wp_session_get_instance_private (self);
|
||||||
g_object_get (self, "direction", &dir, NULL);
|
return priv->direction;
|
||||||
return dir;
|
}
|
||||||
|
|
||||||
|
const gchar *
|
||||||
|
wp_session_get_media_class (WpSession * self)
|
||||||
|
{
|
||||||
|
WpSessionPrivate *priv = wp_session_get_instance_private (self);
|
||||||
|
return priv->media_class;
|
||||||
}
|
}
|
||||||
|
@@ -27,8 +27,7 @@ struct _WpSessionClass
|
|||||||
};
|
};
|
||||||
|
|
||||||
WpSessionDirection wp_session_get_direction (WpSession * session);
|
WpSessionDirection wp_session_get_direction (WpSession * session);
|
||||||
|
const gchar *wp_session_get_media_class (WpSession * session);
|
||||||
#define WP_SESSION_PW_PROP_MEDIA_CLASS "media.class"
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
@@ -54,10 +54,13 @@ session_class_init (DefaultSessionClass * klass)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static DefaultSession *
|
static DefaultSession *
|
||||||
session_new (WpProxy * device_node, guint32 type, WpSessionDirection dir)
|
session_new (WpProxy * device_node, guint32 type, WpSessionDirection dir,
|
||||||
|
const gchar * media_class)
|
||||||
{
|
{
|
||||||
DefaultSession *sess =
|
DefaultSession *sess = g_object_new (session_get_type (),
|
||||||
g_object_new (session_get_type (), "direction", dir, NULL);
|
"direction", dir,
|
||||||
|
"media-class", media_class,
|
||||||
|
NULL);
|
||||||
|
|
||||||
sess->device_node = device_node;
|
sess->device_node = device_node;
|
||||||
sess->media_type = type;
|
sess->media_type = type;
|
||||||
@@ -126,7 +129,7 @@ handle_node (WpPlugin * self, WpProxy * proxy)
|
|||||||
wp_proxy_get_id (proxy), wp_proxy_get_spa_type_string (proxy),
|
wp_proxy_get_id (proxy), wp_proxy_get_spa_type_string (proxy),
|
||||||
media_class);
|
media_class);
|
||||||
|
|
||||||
session = session_new (proxy, media_type, direction);
|
session = session_new (proxy, media_type, direction, media_class);
|
||||||
|
|
||||||
core = wp_plugin_get_core (self);
|
core = wp_plugin_get_core (self);
|
||||||
sr = wp_object_get_interface (core, WP_TYPE_SESSION_REGISTRY);
|
sr = wp_object_get_interface (core, WP_TYPE_SESSION_REGISTRY);
|
||||||
|
@@ -105,7 +105,6 @@ register_session (WpSessionRegistry * sr,
|
|||||||
{
|
{
|
||||||
WpSessionRegistryImpl * self = WP_SESSION_REGISTRY_IMPL (sr);
|
WpSessionRegistryImpl * self = WP_SESSION_REGISTRY_IMPL (sr);
|
||||||
WpPluginRegistry *plugin_registry = NULL;
|
WpPluginRegistry *plugin_registry = NULL;
|
||||||
WpPipewireProperties *pw_props = NULL;
|
|
||||||
const gchar *media_class = NULL;
|
const gchar *media_class = NULL;
|
||||||
SessionData data;
|
SessionData data;
|
||||||
|
|
||||||
@@ -114,16 +113,7 @@ register_session (WpSessionRegistry * sr,
|
|||||||
wp_plugin_registry_impl_invoke (plugin_registry,
|
wp_plugin_registry_impl_invoke (plugin_registry,
|
||||||
wp_plugin_provide_interfaces, WP_OBJECT (session));
|
wp_plugin_provide_interfaces, WP_OBJECT (session));
|
||||||
|
|
||||||
pw_props = wp_object_get_interface (WP_OBJECT (session),
|
media_class = wp_session_get_media_class (session);
|
||||||
WP_TYPE_PIPEWIRE_PROPERTIES);
|
|
||||||
if (!pw_props) {
|
|
||||||
g_set_error (error, WP_DOMAIN_CORE, WP_CODE_INVALID_ARGUMENT,
|
|
||||||
"session object does not implement WpPipewirePropertiesInterface");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
media_class = wp_pipewire_properties_get (pw_props,
|
|
||||||
WP_SESSION_PW_PROP_MEDIA_CLASS);
|
|
||||||
if (!media_class) {
|
if (!media_class) {
|
||||||
g_set_error (error, WP_DOMAIN_CORE, WP_CODE_INVALID_ARGUMENT,
|
g_set_error (error, WP_DOMAIN_CORE, WP_CODE_INVALID_ARGUMENT,
|
||||||
"session media_class is NULL");
|
"session media_class is NULL");
|
||||||
|
Reference in New Issue
Block a user