PipeWire  0.3.33
impl-core.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_CORE_H
26 #define PIPEWIRE_IMPL_CORE_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
44 struct pw_impl_core;
45 
46 #include <pipewire/context.h>
47 #include <pipewire/global.h>
48 #include <pipewire/properties.h>
49 #include <pipewire/resource.h>
50 
53 #define PW_VERSION_IMPL_CORE_EVENTS 0
54  uint32_t version;
55 
57  void (*destroy) (void *data);
59  void (*free) (void *data);
61  void (*initialized) (void *data);
62 };
63 
64 struct pw_impl_core *pw_context_create_core(struct pw_context *context,
65  struct pw_properties *properties,
66  size_t user_data_size);
67 
68 /* get the default core in a context */
69 struct pw_impl_core *pw_context_get_default_core(struct pw_context *context);
70 
72 const struct pw_properties *pw_impl_core_get_properties(struct pw_impl_core *core);
73 
75 const struct pw_core_info *pw_impl_core_get_info(struct pw_impl_core *core);
76 
78 int pw_impl_core_update_properties(struct pw_impl_core *core, const struct spa_dict *dict);
79 
80 int pw_impl_core_register(struct pw_impl_core *core,
81  struct pw_properties *properties);
82 
83 void pw_impl_core_destroy(struct pw_impl_core *core);
84 
85 void *pw_impl_core_get_user_data(struct pw_impl_core *core);
86 
88 struct pw_global *pw_impl_core_get_global(struct pw_impl_core *core);
89 
91 void pw_impl_core_add_listener(struct pw_impl_core *core,
92  struct spa_hook *listener,
93  const struct pw_impl_core_events *events,
94  void *data);
95 
100 #ifdef __cplusplus
101 }
102 #endif
103 
104 #endif /* PIPEWIRE_IMPL_CORE_H */
PW_KEY_USER_NAME
#define PW_KEY_USER_NAME
The user name that runs pipewire.
Definition: src/pipewire/keys.h:78
PW_PERM_IS_R
#define PW_PERM_IS_R(p)
Definition: permission.h:56
pw_properties_get
int int const char * pw_properties_get(const struct pw_properties *properties, const char *key)
Get a property.
Definition: properties.c:487
global.h
pw_impl_core_add_listener
void pw_impl_core_add_listener(struct pw_impl_core *core, struct spa_hook *listener, const struct pw_impl_core_events *events, void *data)
Add an event listener.
Definition: impl-core.c:672
PW_TYPE_INTERFACE_Registry
#define PW_TYPE_INTERFACE_Registry
Definition: core.h:55
pw_resource_remove
void pw_resource_remove(struct pw_resource *resource)
Remove a resource, like pw_resource_destroy but without sending a remove_id message to the client.
Definition: resource.c:291
pw_impl_core_events
Factory events, listen to them with pw_impl_core_add_listener.
Definition: impl-core.h:52
pw_context_create_core
struct pw_impl_core * pw_context_create_core(struct pw_context *context, struct pw_properties *properties, size_t user_data_size)
Definition: impl-core.c:412
pw_impl_core_update_properties
int pw_impl_core_update_properties(struct pw_impl_core *core, const struct spa_dict *dict)
Update the core properties.
Definition: impl-core.c:586
pw_properties_update
int pw_properties_update(struct pw_properties *props, const struct spa_dict *dict)
Update properties.
Definition: properties.c:298
PW_CORE_CHANGE_MASK_ALL
#define PW_CORE_CHANGE_MASK_ALL
Definition: core.h:81
PW_KEY_OBJECT_ID
#define PW_KEY_OBJECT_ID
a global object id
Definition: src/pipewire/keys.h:66
pw_core_info
The core information.
Definition: core.h:73
pw_global_register
int pw_global_register(struct pw_global *global)
Register a global object to the context registry.
Definition: global.c:125
types.h
pw_impl_core_get_info
const struct pw_core_info * pw_impl_core_get_info(struct pw_impl_core *core)
Get the core information.
NAME
#define NAME
Definition: impl-core.c:72
resource_data
Definition: impl-core.c:74
name
const char * name
Definition: media-session.c:2379
string.h
data
user data to add to an object
Definition: filter.c:75
pw_resource_errorf_id
void void pw_resource_errorf_id(struct pw_resource *resource, uint32_t id, int res, const char *error,...) 1(4
pw_global_new
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 object.
Definition: global.c:66
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:230
spa_streq
bool spa_streq(const char *s1, const char *s2)
Definition: string.h:50
resource_data::resource_listener
struct spa_hook resource_listener
Definition: impl-core.c:76
spa_list_for_each
#define spa_list_for_each(pos, head, member)
Definition: list.h:111
pw_global_get_permissions
uint32_t pw_global_get_permissions(struct pw_global *global, struct pw_impl_client *client)
Get the permissions of the global for a given client.
Definition: global.c:45
pw_impl_core_events::version
uint32_t version
Definition: impl-core.h:54
PW_VERSION_CORE
#define PW_VERSION_CORE
Definition: core.h:57
SPA_EXPORT
#define SPA_EXPORT
Definition: defs.h:208
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:68
pw_log_trace
#define pw_log_trace(...)
Definition: src/pipewire/log.h:90
PW_KEY_HOST_NAME
#define PW_KEY_HOST_NAME
The host name of the machine.
Definition: src/pipewire/keys.h:79
pw_get_user_name
const char * pw_get_user_name(void)
Get the user name.
Definition: pipewire.c:663
pw_impl_core_destroy
void pw_impl_core_destroy(struct pw_impl_core *core)
Definition: impl-core.c:479
pw_impl_core_get_global
struct pw_global * pw_impl_core_get_global(struct pw_impl_core *core)
Get the global of this core.
Definition: impl-core.c:666
spa_hook_list_append
void spa_hook_list_append(struct spa_hook_list *list, struct spa_hook *hook, const void *funcs, void *data)
Append a hook.
Definition: hook.h:316
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:264
SPA_PTROFF
#define SPA_PTROFF(ptr_, offset_, type_)
Return the address (buffer + offset) as pointer of type.
Definition: defs.h:159
pw_properties_new_dict
struct pw_properties * pw_properties_new_dict(const struct spa_dict *dict)
Make a new properties object from the given dictionary.
Definition: properties.c:126
PW_TYPE_INTERFACE_Core
#define PW_TYPE_INTERFACE_Core
Definition: core.h:54
pw_impl_core_get_user_data
void * pw_impl_core_get_user_data(struct pw_impl_core *core)
Definition: impl-core.c:660
props
const char * props
Definition: media-session.c:2382
impl.h
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:50
pw_impl_core_events::free
void(* free)(void *data)
the core is freed
Definition: impl-core.h:59
pw_mempool_clear
void pw_mempool_clear(struct pw_mempool *pool)
Clear a pool.
Definition: mem.c:156
PW_KEY_CORE_NAME
#define PW_KEY_CORE_NAME
The name of the core.
Definition: src/pipewire/keys.h:82
pw_impl_core_register
int pw_impl_core_register(struct pw_impl_core *core, struct pw_properties *properties)
Definition: impl-core.c:609
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:255
spa_list_remove
void spa_list_remove(struct spa_list *elem)
Definition: list.h:69
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:174
pw_global_bind
int pw_global_bind(struct pw_global *global, struct pw_impl_client *client, uint32_t permissions, uint32_t version, uint32_t id)
Let a client bind to a global.
Definition: global.c:277
pw_context_find_global
struct pw_global * pw_context_find_global(struct pw_context *context, uint32_t id)
Find a context global by id.
Definition: context.c:636
resource_data::object_listener
struct spa_hook object_listener
Definition: impl-core.c:77
PW_PERM_ALL
#define PW_PERM_ALL
Definition: permission.h:61
spa_hook
A hook, contains the structure with functions and the data passed to the functions.
Definition: hook.h:295
pw_get_host_name
const char * pw_get_host_name(void)
Get the host name.
Definition: pipewire.c:675
pw_resource_errorf
void pw_resource_errorf(struct pw_resource *resource, int res, const char *error,...) 1(3
PW_VERSION_RESOURCE_EVENTS
#define PW_VERSION_RESOURCE_EVENTS
Definition: resource.h:61
PW_PERM_IS_X
#define PW_PERM_IS_X(p)
Definition: permission.h:58
resource.h
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:165
client::context
struct pw_context * context
Definition: module-protocol-native.c:105
pw_core_methods
Core methods.
Definition: core.h:229
spa_dict
Definition: utils/dict.h:48
pw_global_update_keys
int pw_global_update_keys(struct pw_global *global, const struct spa_dict *dict, const char *const keys[])
Update the global properties, must be done when unregistered.
Definition: global.c:209
spa_strerror
#define spa_strerror(err)
Definition: result.h:51
PW_VERSION_CORE_METHODS
#define PW_VERSION_CORE_METHODS
Definition: core.h:230
PW_ID_CORE
#define PW_ID_CORE
default ID for the core object after connect
Definition: core.h:66
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
pw_log_debug
#define pw_log_debug(...)
Definition: src/pipewire/log.h:89
PW_KEY_CORE_VERSION
#define PW_KEY_CORE_VERSION
The version of the core.
Definition: src/pipewire/keys.h:85
client
Definition: module-protocol-native.c:103
pw_global_destroy
void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:369
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:69
pw_context_find_factory
struct pw_impl_factory * pw_context_find_factory(struct pw_context *context, const char *name)
Find a factory by name.
Definition: impl-factory.c:287
resource_data::data
struct result_device_params_data data
Definition: impl-device.c:76
PW_CORE_CHANGE_MASK_PROPS
#define PW_CORE_CHANGE_MASK_PROPS
Definition: core.h:80
context.h
client::core
struct pw_core * core
Definition: module-protocol-simple.c:107
pw_registry_methods
Registry methods.
Definition: core.h:464
spa_hook_remove
void spa_hook_remove(struct spa_hook *hook)
Remove a hook.
Definition: hook.h:336
pw_impl_core_events::initialized
void(* initialized)(void *data)
the core is initialized
Definition: impl-core.h:61
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:159
pw_context_get_default_core
struct pw_impl_core * pw_context_get_default_core(struct pw_context *context)
Definition: impl-core.c:473
resource_data::resource
struct pw_resource * resource
Definition: impl-core.c:75
spa_hook_list_init
void spa_hook_list_init(struct spa_hook_list *list)
Initialize a hook list to the empty list.
Definition: hook.h:305
properties.h
PW_VERSION_REGISTRY_METHODS
#define PW_VERSION_REGISTRY_METHODS
Definition: core.h:465
PW_VERSION_CLIENT
#define PW_VERSION_CLIENT
Definition: client.h:48
pw_impl_factory_create_object
void * pw_impl_factory_create_object(struct pw_impl_factory *factory, struct pw_resource *resource, const char *type, uint32_t version, struct pw_properties *properties, uint32_t new_id)
Definition: impl-factory.c:261
pw_properties_new
struct pw_properties * pw_properties_new(const char *key,...) 1
Make a new properties object.
Definition: properties.c:98
pw_resource_events
Resource events.
Definition: resource.h:60
pw_properties_setf
int pw_properties_setf(struct pw_properties *properties, const char *key, const char *format,...) 1(3
pw_impl_core_events::destroy
void(* destroy)(void *data)
the core is destroyed
Definition: impl-core.h:57
pw_impl_client_find_resource
struct pw_resource * pw_impl_client_find_resource(struct pw_impl_client *client, uint32_t id)
Get a resource with the given id.
Definition: impl-client.c:540
pw_resource_events::version
uint32_t version
Definition: resource.h:62
pw_get_library_version
const char * pw_get_library_version(void)
Get the currently running version.
Definition: pipewire.c:740
pw_impl_core_get_properties
const struct pw_properties * pw_impl_core_get_properties(struct pw_impl_core *core)
Get the core properties.
Definition: impl-core.c:580
pw_properties
Definition: properties.h:49
spa_hook_list_clean
void spa_hook_list_clean(struct spa_hook_list *list)
Remove all hooks from the list.
Definition: hook.h:344
pw_properties_free
void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:364
ENODATA
#define ENODATA
Definition: impl-core.c:31
pw_log_error
#define pw_log_error(...)
Definition: src/pipewire/log.h:86
spa_list_append
#define spa_list_append(list, item)
Definition: list.h:81