PipeWire: impl-device.h Source File

PipeWire 0.3.5

impl-device.h
Go to the documentation of this file.
1 /* PipeWire
2 *
3 * Copyright © 2018 Wim Taymans
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
14 * Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
23 */
24
25 #ifndef PIPEWIRE_IMPL_DEVICE_H
26 #define PIPEWIRE_IMPL_DEVICE_H
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
43 struct pw_impl_device;
44
45 #include <spa/monitor/device.h>
46
47 #include <pipewire/context.h>
48 #include <pipewire/global.h>
49 #include <pipewire/properties.h>
50 #include <pipewire/resource.h>
51
53 struct pw_impl_device_events {
54 #define PW_VERSION_IMPL_DEVICE_EVENTS 0
55 uint32_t version;
56
58 void (*destroy) (void *data);
60 void (*free) (void *data);
62 void (*initialized) (void *data);
63
65 void (*info_changed) (void *data, const struct pw_device_info *info);
66 };
67
68 struct pw_impl_device *pw_context_create_device(struct pw_context *context,
69 struct pw_properties *properties,
70 size_t user_data_size);
71
72 int pw_impl_device_register(struct pw_impl_device *device,
73 struct pw_properties *properties);
74
75 void pw_impl_device_destroy(struct pw_impl_device *device);
76
77 void *pw_impl_device_get_user_data(struct pw_impl_device *device);
78
80 int pw_impl_device_set_implementation(struct pw_impl_device *device, struct spa_device *spa_device);
82 struct spa_device *pw_impl_device_get_implementation(struct pw_impl_device *device);
83
85 struct pw_global *pw_impl_device_get_global(struct pw_impl_device *device);
86
88 void pw_impl_device_add_listener(struct pw_impl_device *device,
89 struct spa_hook *listener,
90 const struct pw_impl_device_events *events,
91 void *data);
92
93 int pw_impl_device_update_properties(struct pw_impl_device *device, const struct spa_dict *dict);
94
95 const struct pw_properties *pw_impl_device_get_properties(struct pw_impl_device *device);
96
97 int pw_impl_device_for_each_param(struct pw_impl_device *device,
98 int seq, uint32_t param_id,
99 uint32_t index, uint32_t max,
100 const struct spa_pod *filter,
101 int (*callback) (void *data, int seq,
102 uint32_t id, uint32_t index, uint32_t next,
103 struct spa_pod *param),
104 void *data);
105 #ifdef __cplusplus
106 }
107 #endif
108
109 #endif /* PIPEWIRE_IMPL_DEVICE_H */
res
static uint32_t int int res
Definition: core.h:323
PW_VERSION_IMPL_DEVICE_EVENTS
#define PW_VERSION_IMPL_DEVICE_EVENTS
Definition: impl-device.h:54
global.h
id
static uint32_t id
Definition: core.h:322
pw_impl_device_add_listener
SPA_EXPORT void pw_impl_device_add_listener(struct pw_impl_device *device, struct spa_hook *listener, const struct pw_impl_device_events *events, void *data)
Add an event listener.
Definition: impl-device.c:810
resource_data::resource
struct pw_resource * resource
Definition: impl-device.c:52
PW_KEY_DEVICE_API
#define PW_KEY_DEVICE_API
API this device is accessed with.
Definition: keys.h:174
resource_data::subscribe_ids
uint32_t subscribe_ids[MAX_PARAMS]
Definition: impl-device.c:57
pw_log::pw_log_error
#define pw_log_error(...)
resource_data::device
struct pw_impl_device * device
Definition: impl-device.c:51
pw_global::pw_global_destroy
SPA_EXPORT void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:367
pw_impl_device_get_global
SPA_EXPORT struct pw_global * pw_impl_device_get_global(struct pw_impl_device *device)
Get the global of this device.
Definition: impl-device.c:804
OBJECT_DEVICE
#define OBJECT_DEVICE
Definition: impl-device.c:71
resource_data
Definition: impl-core.c:37
resource_data::seq
int seq
Definition: impl-device.c:61
PW_KEY_OBJECT_ID
#define PW_KEY_OBJECT_ID
a global object id
Definition: keys.h:70
data
Definition: filter.c:70
pw_impl_device_for_each_param
SPA_EXPORT int pw_impl_device_for_each_param(struct pw_impl_device *device, int seq, uint32_t param_id, uint32_t index, uint32_t max, const struct spa_pod *filter, int(*callback)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param), void *data)
Definition: impl-device.c:234
object_data::type
uint32_t type
Definition: impl-device.c:72
resource_data::resource_listener
struct spa_hook resource_listener
Definition: impl-core.c:38
pw_impl_device_add_listener
void pw_impl_device_add_listener(struct pw_impl_device *device, struct spa_hook *listener, const struct pw_impl_device_events *events, void *data)
Add an event listener.
Definition: impl-device.c:810
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:65
pw_impl_client
PipeWire client object class.
pw_impl_device_events::version
uint32_t version
Definition: impl-device.h:55
pw_impl_node::pw_impl_node_destroy
SPA_EXPORT void pw_impl_node_destroy(struct pw_impl_node *node)
Destroy a node.
Definition: impl-node.c:1530
pw_resource_errorf
void pw_resource_errorf(struct pw_resource *resource, int res, const char *error,...) SPA_PRINTF_FUNC(3
NAME
#define NAME
Definition: impl-device.c:33
impl
Definition: control.c:33
pw_impl_device_set_implementation
int pw_impl_device_set_implementation(struct pw_impl_device *device, struct spa_device *spa_device)
Set the device implementation.
Definition: impl-device.c:761
pw_impl_device_get_user_data
void * pw_impl_device_get_user_data(struct pw_impl_device *device)
Definition: impl-device.c:798
PW_KEY_FACTORY_ID
#define PW_KEY_FACTORY_ID
Factory properties.
Definition: keys.h:215
PW_KEY_MODULE_ID
#define PW_KEY_MODULE_ID
module properties
Definition: keys.h:205
pw_global_add_listener
void pw_global_add_listener(struct pw_global *global, struct spa_hook *listener, const struct pw_global_events *events, void *data)
Add an event listener on the global.
Definition: global.c:252
r
static uint32_t int int const char int r
Definition: core.h:335
pw_impl_device_events::free
void(* free)(void *data)
the device is freed
Definition: impl-device.h:60
pw_context_load_spa_handle
struct spa_handle * pw_context_load_spa_handle(struct pw_context *context, const char *factory_name, const struct spa_dict *info)
handle
Definition: pipewire.c:58
pw_global
A global object visible to remote clients.
pw_impl_device_set_implementation
SPA_EXPORT int pw_impl_device_set_implementation(struct pw_impl_device *device, struct spa_device *spa_device)
Set the device implementation.
Definition: impl-device.c:761
pw_impl_device_get_implementation
SPA_EXPORT struct spa_device * pw_impl_device_get_implementation(struct pw_impl_device *device)
Get the device implementation.
Definition: impl-device.c:778
pw_impl_node_set_active
int pw_impl_node_set_active(struct pw_impl_node *node, bool active)
Set a node active.
Definition: impl-node.c:1867
pw_device_methods
Device methods.
Definition: device.h:100
pw_impl_node_set_implementation
int pw_impl_node_set_implementation(struct pw_impl_node *node, struct spa_node *spa_node)
Set the node implementation.
Definition: impl-node.c:1471
impl.h
pw_impl_node::pw_context_create_node
struct pw_impl_node * pw_context_create_node(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Create a new node.
Definition: impl-node.c:969
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
PW_KEY_CLIENT_ID
#define PW_KEY_CLIENT_ID
Client properties.
Definition: keys.h:118
pw_impl_device_destroy
void pw_impl_device_destroy(struct pw_impl_device *device)
Definition: impl-device.c:179
object_data::id
uint32_t id
Definition: impl-device.c:69
pw_impl_device_get_implementation
struct spa_device * pw_impl_device_get_implementation(struct pw_impl_device *device)
Get the device implementation.
Definition: impl-device.c:778
pw_impl_node
pw_impl_node_add_listener
void pw_impl_node_add_listener(struct pw_impl_node *node, struct spa_hook *listener, const struct pw_impl_node_events *events, void *data)
Add an event listener.
Definition: impl-node.c:1513
pw_impl_device_events::destroy
void(* destroy)(void *data)
the device is destroyed
Definition: impl-device.h:58
pw_properties::pw_properties_setf
SPA_EXPORT int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format,...)
Set a property value by format.
Definition: properties.c:428
pw_impl_node_register
int pw_impl_node_register(struct pw_impl_node *node, struct pw_properties *properties)
Complete initialization of the node and register.
Definition: impl-node.c:548
pw_impl_device_register
SPA_EXPORT int pw_impl_device_register(struct pw_impl_device *device, struct pw_properties *properties)
Definition: impl-device.c:449
pw_impl_device_get_properties
const struct pw_properties * pw_impl_device_get_properties(struct pw_impl_device *device)
Definition: impl-device.c:784
PW_KEY_OBJECT_PATH
#define PW_KEY_OBJECT_PATH
unique path to construct the object
Definition: keys.h:69
PW_DEVICE_CHANGE_MASK_PROPS
#define PW_DEVICE_CHANGE_MASK_PROPS
Definition: device.h:45
PW_KEY_MEDIA_CLASS
#define PW_KEY_MEDIA_CLASS
class Ex: "Video/Source"
Definition: keys.h:242
pw_device_resource_info
#define pw_device_resource_info(r,...)
Definition: impl-device.c:40
pw_device_methods::version
uint32_t version
Definition: device.h:102
resource_data::object_listener
struct spa_hook object_listener
Definition: impl-core.c:39
pw_impl_device_get_user_data
SPA_EXPORT void * pw_impl_device_get_user_data(struct pw_impl_device *device)
Definition: impl-device.c:798
pw_impl_device_events::info_changed
void(* info_changed)(void *data, const struct pw_device_info *info)
the device info changed
Definition: impl-device.h:65
pw_device_resource_param
#define pw_device_resource_param(r,...)
Definition: impl-device.c:41
filter
Definition: filter.c:112
result_device_params_data::callback
int(* callback)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param)
Definition: impl-device.c:45
PW_VERSION_IMPL_NODE_EVENTS
#define PW_VERSION_IMPL_NODE_EVENTS
Definition: impl-node.h:54
pw_log::pw_log_debug
#define pw_log_debug(...)
pw_log::pw_log_warn
#define pw_log_warn(...)
PW_VERSION_RESOURCE_EVENTS
#define PW_VERSION_RESOURCE_EVENTS
Definition: resource.h:65
object_data
Definition: impl-device.c:67
object_data::listener
struct spa_hook listener
Definition: impl-device.c:75
PW_KEY_DEVICE_DESCRIPTION
#define PW_KEY_DEVICE_DESCRIPTION
localized human readable device one-line description.
Definition: keys.h:176
resource.h
pw_impl_device_register
int pw_impl_device_register(struct pw_impl_device *device, struct pw_properties *properties)
Definition: impl-device.c:449
pw_properties::pw_properties_update
SPA_EXPORT int pw_properties_update(struct pw_properties *props, const struct spa_dict *dict)
Update properties.
Definition: properties.c:258
PW_DEVICE_CHANGE_MASK_PARAMS
#define PW_DEVICE_CHANGE_MASK_PARAMS
Definition: device.h:46
pw_impl_node_events
Node events, listen to them with pw_impl_node_add_listener.
Definition: impl-node.h:53
pw_resource_get_user_data
void * pw_resource_get_user_data(struct pw_resource *resource)
Get the user data for the resource, the size was given in pw_resource_new.
Definition: resource.c:160
PW_VERSION_DEVICE
#define PW_VERSION_DEVICE
Definition: device.h:39
object_data::object
void * object
Definition: impl-device.c:74
pw_impl_device_update_properties
SPA_EXPORT int pw_impl_device_update_properties(struct pw_impl_device *device, const struct spa_dict *dict)
Definition: impl-device.c:790
pw_global_add_resource
int pw_global_add_resource(struct pw_global *global, struct pw_resource *resource)
Add a resource to a global.
Definition: global.c:227
pw_impl_device_get_properties
SPA_EXPORT const struct pw_properties * pw_impl_device_get_properties(struct pw_impl_device *device)
Definition: impl-device.c:784
pw_context
the PipeWire context
pw_context_create_device
struct pw_impl_device * pw_context_create_device(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Definition: impl-device.c:128
pw_device_info
The device information.
Definition: device.h:43
object_data::handle
struct spa_handle * handle
Definition: impl-device.c:73
resource_data::end
int end
Definition: impl-device.c:62
pw_properties::pw_properties_copy
SPA_EXPORT struct pw_properties * pw_properties_copy(const struct pw_properties *properties)
Copy a properties object.
Definition: properties.c:200
param
Definition: filter.c:75
pw_resource
Client owned objects.
result_device_params_data::data
void * data
Definition: impl-device.c:44
pw_impl_device_for_each_param
int pw_impl_device_for_each_param(struct pw_impl_device *device, int seq, uint32_t param_id, uint32_t index, uint32_t max, const struct spa_pod *filter, int(*callback)(void *data, int seq, uint32_t id, uint32_t index, uint32_t next, struct spa_pod *param), void *data)
Definition: impl-device.c:234
pw_resource_add_object_listener
void pw_resource_add_object_listener(struct pw_resource *resource, struct spa_hook *listener, const void *funcs, void *data)
Set the resource implementation.
Definition: resource.c:175
PW_DEVICE_CHANGE_MASK_ALL
#define PW_DEVICE_CHANGE_MASK_ALL
Definition: device.h:47
resource_data::n_subscribe_ids
uint32_t n_subscribe_ids
Definition: impl-device.c:58
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:66
resource_data::data
struct result_device_params_data data
Definition: impl-device.c:63
PW_KEY_DEVICE_NICK
#define PW_KEY_DEVICE_NICK
a short device nickname
Definition: keys.h:171
pw_properties::pw_properties_get
SPA_EXPORT const char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:451
pw_impl_node_update_properties
int pw_impl_node_update_properties(struct pw_impl_node *node, const struct spa_dict *dict)
Update the node properties.
Definition: impl-node.c:1131
pw_impl_device_destroy
SPA_EXPORT void pw_impl_device_destroy(struct pw_impl_device *device)
Definition: impl-device.c:179
pw_resource_new
struct pw_resource * pw_resource_new(struct pw_impl_client *client, uint32_t id, uint32_t permissions, const char *type, uint32_t version, size_t user_data_size)
Make a new resource for client.
Definition: resource.c:43
context.h
pw_global::pw_global_new
SPA_EXPORT struct pw_global * pw_global_new(struct pw_context *context, const char *type, uint32_t version, struct pw_properties *properties, pw_global_bind_func_t func, void *object)
Create a new global.
Definition: global.c:67
impl::this
struct pw_control this
Definition: control.c:34
pw_impl_device_events::initialized
void(* initialized)(void *data)
the device is initialized
Definition: impl-device.h:62
result_device_params_data
Definition: impl-device.c:43
pw_context_create_device
SPA_EXPORT struct pw_impl_device * pw_context_create_device(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Definition: impl-device.c:128
pw_properties::pw_properties_new
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:95
PW_TYPE_INTERFACE_Device
#define PW_TYPE_INTERFACE_Device
Definition: device.h:37
seq
static uint32_t int seq
Definition: core.h:322
properties.h
pw_global::pw_global_register
SPA_EXPORT int pw_global_register(struct pw_global *global)
register a global to the context registry
Definition: global.c:128
OBJECT_NODE
#define OBJECT_NODE
Definition: impl-device.c:70
resource_data::listener
struct spa_hook listener
Definition: impl-device.c:64
pw_impl_device_events
Device events, listen to them with pw_impl_device_add_listener.
Definition: impl-device.h:53
pw_resource_events
Resource events.
Definition: resource.h:64
PW_VERSION_DEVICE_METHODS
#define PW_VERSION_DEVICE_METHODS
Definition: device.h:101
pw_impl_device_get_global
struct pw_global * pw_impl_device_get_global(struct pw_impl_device *device)
Get the global of this device.
Definition: impl-device.c:804
pw_impl_device_update_properties
int pw_impl_device_update_properties(struct pw_impl_device *device, const struct spa_dict *dict)
Definition: impl-device.c:790
pw_resource_add_listener
void pw_resource_add_listener(struct pw_resource *resource, struct spa_hook *listener, const struct pw_resource_events *events, void *data)
Add an event listener.
Definition: resource.c:166
pw_impl_client_set_busy
void pw_impl_client_set_busy(struct pw_impl_client *client, bool busy)
Mark the client busy.
Definition: impl-client.c:636
pw_unload_spa_handle
int pw_unload_spa_handle(struct spa_handle *handle)
Definition: pipewire.c:308
PW_KEY_DEVICE_NAME
#define PW_KEY_DEVICE_NAME
device name
Definition: keys.h:168
object_data::link
struct spa_list link
Definition: impl-device.c:68
pw_properties::pw_properties_update_keys
SPA_EXPORT int pw_properties_update_keys(struct pw_properties *props, const struct spa_dict *dict, const char *keys[])
Copy multiple keys from one property to another.
Definition: properties.c:215
pw_properties
A collection of key/value pairs.
Definition: properties.h:45
pw_impl_node_get_user_data
void * pw_impl_node_get_user_data(struct pw_impl_node *node)
Get node user_data.
Definition: impl-node.c:1091
pw_properties::pw_properties_free
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:330
pw_impl_device
PipeWire device interface.