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 
32 /** \class pw_impl_core
33  *
34  * \brief PipeWire core interface.
35  *
36  * The core is used to make objects on demand.
37  */
38 struct pw_impl_core;
39 
40 #include <pipewire/context.h>
41 #include <pipewire/global.h>
42 #include <pipewire/properties.h>
43 #include <pipewire/resource.h>
44 
45 /** Factory events, listen to them with \ref pw_impl_core_add_listener */
46 struct pw_impl_core_events {
47 #define PW_VERSION_IMPL_CORE_EVENTS	0
48 	uint32_t version;
49 
50 	/** the core is destroyed */
51         void (*destroy) (void *data);
52 	/** the core is freed */
53         void (*free) (void *data);
54 	/** the core is initialized */
55         void (*initialized) (void *data);
56 };
57 
58 struct pw_impl_core *pw_context_create_core(struct pw_context *context,
59 				  struct pw_properties *properties,
60 				  size_t user_data_size);
61 
62 /* get the default core in a context */
63 struct pw_impl_core *pw_context_get_default_core(struct pw_context *context);
64 
65 /** Get the core properties */
66 const struct pw_properties *pw_impl_core_get_properties(struct pw_impl_core *core);
67 
68 /** Get the core information */
69 const struct pw_core_info *pw_impl_core_get_info(struct pw_impl_core *core);
70 
71 /** Update the core properties */
72 int pw_impl_core_update_properties(struct pw_impl_core *core, const struct spa_dict *dict);
73 
74 int pw_impl_core_register(struct pw_impl_core *core,
75 			struct pw_properties *properties);
76 
77 void pw_impl_core_destroy(struct pw_impl_core *core);
78 
79 void *pw_impl_core_get_user_data(struct pw_impl_core *core);
80 
81 /** Get the global of this core */
82 struct pw_global *pw_impl_core_get_global(struct pw_impl_core *core);
83 
84 /** Add an event listener */
85 void pw_impl_core_add_listener(struct pw_impl_core *core,
86 			     struct spa_hook *listener,
87 			     const struct pw_impl_core_events *events,
88 			     void *data);
89 
90 #ifdef __cplusplus
91 }
92 #endif
93 
94 #endif /* PIPEWIRE_IMPL_CORE_H */
95