session: make the media_class a normal GObject property

This commit is contained in:
George Kiagiadakis
2019-04-28 14:18:44 +03:00
parent bd1c233f43
commit ac65d44bbf
4 changed files with 32 additions and 21 deletions

View File

@@ -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;
}

View File

@@ -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