Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wireplumber
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pkg
wireplumber
Commits
ca1453fe
Commit
ca1453fe
authored
5 years ago
by
George Kiagiadakis
Browse files
Options
Downloads
Patches
Plain Diff
endpoint: add some useful API for querying info about streams & controls
parent
ecad76d9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/wp/endpoint.c
+110
-3
110 additions, 3 deletions
lib/wp/endpoint.c
lib/wp/endpoint.h
+8
-0
8 additions, 0 deletions
lib/wp/endpoint.h
with
118 additions
and
3 deletions
lib/wp/endpoint.c
+
110
−
3
View file @
ca1453fe
...
...
@@ -425,6 +425,26 @@ wp_endpoint_register_stream (WpEndpoint * self, GVariant * stream)
g_ptr_array_add
(
priv
->
streams
,
g_variant_ref_sink
(
stream
));
}
GVariant
*
wp_endpoint_get_stream
(
WpEndpoint
*
self
,
guint32
stream_id
)
{
WpEndpointPrivate
*
priv
;
guint32
id
;
gint
i
;
g_return_val_if_fail
(
WP_IS_ENDPOINT
(
self
),
NULL
);
priv
=
wp_endpoint_get_instance_private
(
self
);
for
(
i
=
0
;
i
<
priv
->
streams
->
len
;
i
++
)
{
GVariant
*
v
=
g_ptr_array_index
(
priv
->
streams
,
i
);
if
(
g_variant_lookup
(
v
,
"id"
,
"u"
,
&
id
)
&&
id
==
stream_id
)
{
return
g_variant_ref
(
v
);
}
}
return
NULL
;
}
/**
* wp_endpoint_list_streams:
* @self: the endpoint
...
...
@@ -445,6 +465,30 @@ wp_endpoint_list_streams (WpEndpoint * self)
(
GVariant
*
const
*
)
priv
->
streams
->
pdata
,
priv
->
streams
->
len
);
}
guint32
wp_endpoint_find_stream
(
WpEndpoint
*
self
,
const
gchar
*
name
)
{
WpEndpointPrivate
*
priv
;
const
gchar
*
tmp
=
NULL
;
guint32
id
=
WP_STREAM_ID_NONE
;
gint
i
;
g_return_val_if_fail
(
WP_IS_ENDPOINT
(
self
),
WP_STREAM_ID_NONE
);
g_return_val_if_fail
(
name
!=
NULL
,
WP_STREAM_ID_NONE
);
priv
=
wp_endpoint_get_instance_private
(
self
);
for
(
i
=
0
;
i
<
priv
->
streams
->
len
;
i
++
)
{
GVariant
*
v
=
g_ptr_array_index
(
priv
->
streams
,
i
);
if
(
g_variant_lookup
(
v
,
"name"
,
"&s"
,
&
tmp
)
&&
!
g_strcmp0
(
tmp
,
name
))
{
/* found, return the id */
g_variant_lookup
(
v
,
"id"
,
"u"
,
&
id
);
break
;
}
}
return
id
;
}
/**
* wp_endpoint_register_control:
* @self: the endpoint
...
...
@@ -462,6 +506,26 @@ wp_endpoint_register_control (WpEndpoint * self, GVariant * control)
g_ptr_array_add
(
priv
->
controls
,
g_variant_ref_sink
(
control
));
}
GVariant
*
wp_endpoint_get_control
(
WpEndpoint
*
self
,
guint32
control_id
)
{
WpEndpointPrivate
*
priv
;
guint32
id
;
gint
i
;
g_return_val_if_fail
(
WP_IS_ENDPOINT
(
self
),
NULL
);
priv
=
wp_endpoint_get_instance_private
(
self
);
for
(
i
=
0
;
i
<
priv
->
controls
->
len
;
i
++
)
{
GVariant
*
v
=
g_ptr_array_index
(
priv
->
controls
,
i
);
if
(
g_variant_lookup
(
v
,
"id"
,
"u"
,
&
id
)
&&
id
==
control_id
)
{
return
g_variant_ref
(
v
);
}
}
return
NULL
;
}
/**
* wp_endpoint_list_controls:
* @self: the endpoint
...
...
@@ -482,6 +546,44 @@ wp_endpoint_list_controls (WpEndpoint * self)
(
GVariant
*
const
*
)
priv
->
controls
->
pdata
,
priv
->
controls
->
len
);
}
guint32
wp_endpoint_find_control
(
WpEndpoint
*
self
,
guint32
stream_id
,
const
gchar
*
name
)
{
WpEndpointPrivate
*
priv
;
const
gchar
*
tmp
=
NULL
;
guint32
tmp_id
=
WP_STREAM_ID_NONE
;
guint32
id
=
WP_CONTROL_ID_NONE
;
gint
i
;
g_return_val_if_fail
(
WP_IS_ENDPOINT
(
self
),
WP_CONTROL_ID_NONE
);
g_return_val_if_fail
(
name
!=
NULL
,
WP_CONTROL_ID_NONE
);
priv
=
wp_endpoint_get_instance_private
(
self
);
for
(
i
=
0
;
i
<
priv
->
controls
->
len
;
i
++
)
{
GVariant
*
v
=
g_ptr_array_index
(
priv
->
controls
,
i
);
/*
* if the stream-id exists, it must match @stream_id
* if it doesn't exist, then @stream_id must be NONE
*/
if
(
g_variant_lookup
(
v
,
"stream-id"
,
"u"
,
&
tmp_id
))
{
if
(
stream_id
!=
tmp_id
)
continue
;
}
else
if
(
stream_id
!=
WP_STREAM_ID_NONE
)
{
continue
;
}
if
(
g_variant_lookup
(
v
,
"name"
,
"&s"
,
&
tmp
)
&&
!
g_strcmp0
(
tmp
,
name
))
{
/* found, return the id */
g_variant_lookup
(
v
,
"id"
,
"u"
,
&
id
);
break
;
}
}
return
id
;
}
/**
* wp_endpoint_get_control_value: (virtual get_control_value)
* @self: the endpoint
...
...
@@ -522,13 +624,18 @@ gboolean
wp_endpoint_set_control_value
(
WpEndpoint
*
self
,
guint32
control_id
,
GVariant
*
value
)
{
gboolean
ret
=
FALSE
;
g_return_val_if_fail
(
WP_IS_ENDPOINT
(
self
),
FALSE
);
if
(
WP_ENDPOINT_GET_CLASS
(
self
)
->
set_control_value
)
ret
urn
WP_ENDPOINT_GET_CLASS
(
self
)
->
set_control_value
(
self
,
control_id
,
ret
=
WP_ENDPOINT_GET_CLASS
(
self
)
->
set_control_value
(
self
,
control_id
,
value
);
else
return
FALSE
;
if
(
g_variant_is_floating
(
value
))
g_variant_unref
(
value
);
return
ret
;
}
/**
...
...
This diff is collapsed.
Click to expand it.
lib/wp/endpoint.h
+
8
−
0
View file @
ca1453fe
...
...
@@ -13,6 +13,9 @@
G_BEGIN_DECLS
static
const
guint32
WP_STREAM_ID_NONE
=
0xffffffff
;
static
const
guint32
WP_CONTROL_ID_NONE
=
0xffffffff
;
#define WP_TYPE_ENDPOINT (wp_endpoint_get_type ())
G_DECLARE_DERIVABLE_TYPE
(
WpEndpoint
,
wp_endpoint
,
WP
,
ENDPOINT
,
GObject
)
...
...
@@ -43,10 +46,15 @@ const gchar * wp_endpoint_get_name (WpEndpoint * self);
const
gchar
*
wp_endpoint_get_media_class
(
WpEndpoint
*
self
);
void
wp_endpoint_register_stream
(
WpEndpoint
*
self
,
GVariant
*
stream
);
GVariant
*
wp_endpoint_get_stream
(
WpEndpoint
*
self
,
guint32
stream_id
);
GVariant
*
wp_endpoint_list_streams
(
WpEndpoint
*
self
);
guint32
wp_endpoint_find_stream
(
WpEndpoint
*
self
,
const
gchar
*
name
);
void
wp_endpoint_register_control
(
WpEndpoint
*
self
,
GVariant
*
control
);
GVariant
*
wp_endpoint_get_control
(
WpEndpoint
*
self
,
guint32
control_id
);
GVariant
*
wp_endpoint_list_controls
(
WpEndpoint
*
self
);
guint32
wp_endpoint_find_control
(
WpEndpoint
*
self
,
guint32
stream_id
,
const
gchar
*
name
);
GVariant
*
wp_endpoint_get_control_value
(
WpEndpoint
*
self
,
guint32
control_id
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment