PipeWire  0.3.15
impl-factory.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_FACTORY_H
26 #define PIPEWIRE_IMPL_FACTORY_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
38 struct pw_impl_factory;
39 
40 #include <pipewire/context.h>
41 #include <pipewire/impl-client.h>
42 #include <pipewire/global.h>
43 #include <pipewire/properties.h>
44 #include <pipewire/resource.h>
45 
48 #define PW_VERSION_IMPL_FACTORY_EVENTS 0
49  uint32_t version;
50 
52  void (*destroy) (void *data);
54  void (*free) (void *data);
56  void (*initialized) (void *data);
57 };
58 
60 #define PW_VERSION_IMPL_FACTORY_IMPLEMENTATION 0
61  uint32_t version;
62 
64  void *(*create_object) (void *data,
65  struct pw_resource *resource,
66  const char *type,
67  uint32_t version,
68  struct pw_properties *properties,
69  uint32_t new_id);
70 };
71 
73  const char *name,
74  const char *type,
75  uint32_t version,
76  struct pw_properties *properties,
77  size_t user_data_size);
78 
80 const struct pw_properties *pw_impl_factory_get_properties(struct pw_impl_factory *factory);
81 
83 const struct pw_factory_info *pw_impl_factory_get_info(struct pw_impl_factory *factory);
84 
86 int pw_impl_factory_update_properties(struct pw_impl_factory *factory, const struct spa_dict *dict);
87 
88 int pw_impl_factory_register(struct pw_impl_factory *factory,
89  struct pw_properties *properties);
90 
91 void pw_impl_factory_destroy(struct pw_impl_factory *factory);
92 
93 void *pw_impl_factory_get_user_data(struct pw_impl_factory *factory);
94 
97 
100  struct spa_hook *listener,
101  const struct pw_impl_factory_events *events,
102  void *data);
103 
105  const struct pw_impl_factory_implementation *implementation,
106  void *data);
107 
108 void *pw_impl_factory_create_object(struct pw_impl_factory *factory,
109  struct pw_resource *resource,
110  const char *type,
111  uint32_t version,
112  struct pw_properties *properties,
113  uint32_t new_id);
114 
116 struct pw_impl_factory *
117 pw_context_find_factory(struct pw_context *context ,
118  const char *name );
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif /* PIPEWIRE_IMPL_FACTORY_H */
res
static uint32_t int int res
Definition: core.h:326
PW_VERSION_FACTORY
#define PW_VERSION_FACTORY
Definition: factory.h:42
global.h
pw_log::pw_log_error
#define pw_log_error(...)
pw_global::pw_global_destroy
SPA_EXPORT void pw_global_destroy(struct pw_global *global)
Destroy a global.
Definition: global.c:377
pw_impl_factory_create_object
SPA_EXPORT 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_impl_factory_events::initialized
void(* initialized)(void *data)
the factory is initialized
Definition: impl-factory.h:56
PW_KEY_OBJECT_ID
#define PW_KEY_OBJECT_ID
a global object id
Definition: keys.h:60
data
Definition: filter.c:71
pw_impl_factory_update_properties
SPA_EXPORT int pw_impl_factory_update_properties(struct pw_impl_factory *factory, const struct spa_dict *dict)
Update the factory properties.
Definition: impl-factory.c:153
pw_impl_factory_get_properties
const struct pw_properties * pw_impl_factory_get_properties(struct pw_impl_factory *factory)
Get the factory properties.
Definition: impl-factory.c:147
pw_context_create_factory
SPA_EXPORT struct pw_impl_factory * pw_context_create_factory(struct pw_context *context, const char *name, const char *type, uint32_t version, struct pw_properties *properties, size_t user_data_size)
Definition: impl-factory.c:37
pw_global_events
Global events, use pw_global_add_listener.
Definition: global.h:65
pw_impl_client
PipeWire client object class.
pw_impl_factory_events
Factory events, listen to them with pw_impl_factory_add_listener.
Definition: impl-factory.h:47
pw_impl_factory_get_global
struct pw_global * pw_impl_factory_get_global(struct pw_impl_factory *factory)
Get the global of this factory.
Definition: impl-factory.c:238
pw_impl_factory_get_info
const struct pw_factory_info * pw_impl_factory_get_info(struct pw_impl_factory *factory)
Get the factory info.
Definition: impl-factory.c:232
PW_KEY_MODULE_ID
#define PW_KEY_MODULE_ID
module properties
Definition: keys.h:207
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:262
pw_impl_factory_events::destroy
void(* destroy)(void *data)
the factory is destroyed
Definition: impl-factory.h:52
PW_KEY_FACTORY_TYPE_NAME
#define PW_KEY_FACTORY_TYPE_NAME
the name of the type created by a factory
Definition: keys.h:220
pw_global
A global object visible to remote clients.
pw_impl_factory_implementation::version
uint32_t version
Definition: impl-factory.h:61
impl.h
pw_properties::dict
struct spa_dict dict
dictionary of key/values
Definition: properties.h:46
impl-client.h
pw_impl_factory_add_listener
void pw_impl_factory_add_listener(struct pw_impl_factory *factory, struct spa_hook *listener, const struct pw_impl_factory_events *events, void *data)
Add an event listener.
Definition: impl-factory.c:244
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:433
pw_context_create_factory
struct pw_impl_factory * pw_context_create_factory(struct pw_context *context, const char *name, const char *type, uint32_t version, struct pw_properties *properties, size_t user_data_size)
Definition: impl-factory.c:37
pw_impl_factory_get_user_data
void * pw_impl_factory_get_user_data(struct pw_impl_factory *factory)
Definition: impl-factory.c:226
pw_impl_factory_get_user_data
SPA_EXPORT void * pw_impl_factory_get_user_data(struct pw_impl_factory *factory)
Definition: impl-factory.c:226
pw_impl_factory_set_implementation
SPA_EXPORT void pw_impl_factory_set_implementation(struct pw_impl_factory *factory, const struct pw_impl_factory_implementation *implementation, void *data)
Definition: impl-factory.c:253
pw_global_update_keys
int pw_global_update_keys(struct pw_global *global, const struct spa_dict *dict, const char *keys[])
Update the global properties, must be done when unregistered.
Definition: global.c:215
pw_log::pw_log_debug
#define pw_log_debug(...)
resource.h
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:263
pw_impl_factory_get_global
SPA_EXPORT struct pw_global * pw_impl_factory_get_global(struct pw_impl_factory *factory)
Get the global of this factory.
Definition: impl-factory.c:238
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:237
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_impl_factory_destroy
SPA_EXPORT void pw_impl_factory_destroy(struct pw_impl_factory *factory)
Definition: impl-factory.c:82
pw_context
the PipeWire context
pw_impl_factory_set_implementation
void pw_impl_factory_set_implementation(struct pw_impl_factory *factory, const struct pw_impl_factory_implementation *implementation, void *data)
Definition: impl-factory.c:253
pw_impl_factory_register
SPA_EXPORT int pw_impl_factory_register(struct pw_impl_factory *factory, struct pw_properties *properties)
Definition: impl-factory.c:176
pw_properties::pw_properties_set
SPA_EXPORT int pw_properties_set(struct pw_properties *properties, const char *key, const char *value)
Set a property value.
Definition: properties.c:400
pw_resource
Client owned objects.
pw_impl_factory_get_info
SPA_EXPORT const struct pw_factory_info * pw_impl_factory_get_info(struct pw_impl_factory *factory)
Get the factory info.
Definition: impl-factory.c:232
PW_VERSION_GLOBAL_EVENTS
#define PW_VERSION_GLOBAL_EVENTS
Definition: global.h:66
pw_context::pw_context_find_factory
SPA_EXPORT 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
pw_impl_factory_destroy
void pw_impl_factory_destroy(struct pw_impl_factory *factory)
Definition: impl-factory.c:82
pw_impl_factory_events::free
void(* free)(void *data)
the factory is freed
Definition: impl-factory.h:54
pw_factory_info
The factory information.
Definition: factory.h:46
pw_impl_factory_implementation
Definition: impl-factory.h:59
pw_impl_factory_register
int pw_impl_factory_register(struct pw_impl_factory *factory, struct pw_properties *properties)
Definition: impl-factory.c:176
pw_factory_resource_info
#define pw_factory_resource_info(r,...)
Definition: impl-factory.c:34
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_KEY_FACTORY_NAME
#define PW_KEY_FACTORY_NAME
the name of the factory
Definition: keys.h:218
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
PW_TYPE_INTERFACE_Factory
#define PW_TYPE_INTERFACE_Factory
Definition: factory.h:40
pw_properties::pw_properties_new
SPA_EXPORT struct pw_properties * pw_properties_new(const char *key,...)
Make a new properties object.
Definition: properties.c:98
properties.h
NAME
#define NAME
Definition: impl-factory.c:32
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
pw_impl_factory_get_properties
SPA_EXPORT const struct pw_properties * pw_impl_factory_get_properties(struct pw_impl_factory *factory)
Get the factory properties.
Definition: impl-factory.c:147
pw_impl_factory
PipeWire factory interface.
PW_FACTORY_CHANGE_MASK_ALL
#define PW_FACTORY_CHANGE_MASK_ALL
Definition: factory.h:52
PW_KEY_FACTORY_TYPE_VERSION
#define PW_KEY_FACTORY_TYPE_VERSION
the version of the type created by a factory
Definition: keys.h:221
pw_impl_factory_update_properties
int pw_impl_factory_update_properties(struct pw_impl_factory *factory, const struct spa_dict *dict)
Update the factory properties.
Definition: impl-factory.c:153
PW_FACTORY_CHANGE_MASK_PROPS
#define PW_FACTORY_CHANGE_MASK_PROPS
Definition: factory.h:51
pw_properties
A collection of key/value pairs.
Definition: properties.h:45
pw_properties::pw_properties_free
SPA_EXPORT void pw_properties_free(struct pw_properties *properties)
Free a properties object.
Definition: properties.c:335
pw_impl_factory_events::version
uint32_t version
Definition: impl-factory.h:49
pw_impl_factory_add_listener
SPA_EXPORT void pw_impl_factory_add_listener(struct pw_impl_factory *factory, struct spa_hook *listener, const struct pw_impl_factory_events *events, void *data)
Add an event listener.
Definition: impl-factory.c:244