session: make the media_class a normal GObject property
This commit is contained in:
@@ -11,12 +11,14 @@
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_DIRECTION
|
||||
PROP_DIRECTION,
|
||||
PROP_MEDIA_CLASS,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
WpSessionDirection direction;
|
||||
gchar media_class[41];
|
||||
} WpSessionPrivate;
|
||||
|
||||
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:
|
||||
priv->direction = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_MEDIA_CLASS:
|
||||
strncpy (priv->media_class, g_value_get_string (value), 40);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@@ -52,6 +57,9 @@ wp_session_get_property (GObject * object, guint property_id, GValue * value,
|
||||
case PROP_DIRECTION:
|
||||
g_value_set_enum (value, priv->direction);
|
||||
break;
|
||||
case PROP_MEDIA_CLASS:
|
||||
g_value_set_string (value, priv->media_class);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
@@ -71,12 +79,23 @@ wp_session_class_init (WpSessionClass * klass)
|
||||
"The media flow direction of the session",
|
||||
WP_TYPE_SESSION_DIRECTION, 0,
|
||||
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
|
||||
wp_session_get_direction (WpSession * self)
|
||||
{
|
||||
WpSessionDirection dir;
|
||||
g_object_get (self, "direction", &dir, NULL);
|
||||
return dir;
|
||||
WpSessionPrivate *priv = wp_session_get_instance_private (self);
|
||||
return priv->direction;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
#define WP_SESSION_PW_PROP_MEDIA_CLASS "media.class"
|
||||
const gchar *wp_session_get_media_class (WpSession * session);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@@ -54,10 +54,13 @@ session_class_init (DefaultSessionClass * klass)
|
||||
}
|
||||
|
||||
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 =
|
||||
g_object_new (session_get_type (), "direction", dir, NULL);
|
||||
DefaultSession *sess = g_object_new (session_get_type (),
|
||||
"direction", dir,
|
||||
"media-class", media_class,
|
||||
NULL);
|
||||
|
||||
sess->device_node = device_node;
|
||||
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),
|
||||
media_class);
|
||||
|
||||
session = session_new (proxy, media_type, direction);
|
||||
session = session_new (proxy, media_type, direction, media_class);
|
||||
|
||||
core = wp_plugin_get_core (self);
|
||||
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);
|
||||
WpPluginRegistry *plugin_registry = NULL;
|
||||
WpPipewireProperties *pw_props = NULL;
|
||||
const gchar *media_class = NULL;
|
||||
SessionData data;
|
||||
|
||||
@@ -114,16 +113,7 @@ register_session (WpSessionRegistry * sr,
|
||||
wp_plugin_registry_impl_invoke (plugin_registry,
|
||||
wp_plugin_provide_interfaces, WP_OBJECT (session));
|
||||
|
||||
pw_props = wp_object_get_interface (WP_OBJECT (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);
|
||||
media_class = wp_session_get_media_class (session);
|
||||
if (!media_class) {
|
||||
g_set_error (error, WP_DOMAIN_CORE, WP_CODE_INVALID_ARGUMENT,
|
||||
"session media_class is NULL");
|
||||
|
Reference in New Issue
Block a user