PipeWire 0.1.9

resource.h
Go to the documentation of this file.
1 /* PipeWire
2 * Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifndef __PIPEWIRE_RESOURCE_H__
21 #define __PIPEWIRE_RESOURCE_H__
22
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26
27 #define PW_TYPE__Resource "PipeWire:Object:Resource"
28 #define PW_TYPE_RESOURCE_BASE PW_TYPE__Resource ":"
29
30 #include <spa/utils/hook.h>
31
57 struct pw_resource;
58
59 #include <pipewire/client.h>
60
62 struct pw_resource_events {
63 #define PW_VERSION_RESOURCE_EVENTS 0
64 uint32_t version;
65
67 void (*destroy) (void *data);
68 };
69
71 struct pw_resource *
72 pw_resource_new(struct pw_client *client,
73 uint32_t id,
74 uint32_t permissions,
75 uint32_t type,
76 uint32_t version,
77 size_t user_data_size );
78
80 void pw_resource_destroy(struct pw_resource *resource);
81
83 struct pw_client *pw_resource_get_client(struct pw_resource *resource);
84
86 uint32_t pw_resource_get_id(struct pw_resource *resource);
87
89 uint32_t pw_resource_get_permissions(struct pw_resource *resource);
90
92 uint32_t pw_resource_get_type(struct pw_resource *resource);
93
95 struct pw_protocol *pw_resource_get_protocol(struct pw_resource *resource);
96
98 void *pw_resource_get_user_data(struct pw_resource *resource);
99
101 void pw_resource_add_listener(struct pw_resource *resource,
102 struct spa_hook *listener,
103 const struct pw_resource_events *events,
104 void *data);
105
107 void pw_resource_set_implementation(struct pw_resource *resource,
108 const void *implementation,
109 void *data);
110
112 void pw_resource_add_override(struct pw_resource *resource,
113 struct spa_hook *listener,
114 const void *implementation,
115 void *data);
116
118 void pw_resource_error(struct pw_resource *resource, int result, const char *error);
119
121 struct spa_hook_list *pw_resource_get_implementation(struct pw_resource *resource);
122
124 const struct pw_protocol_marshal *pw_resource_get_marshal(struct pw_resource *resource);
125
126 #define pw_resource_do(r,type,method,...) \
127 spa_hook_list_call_once(pw_resource_get_implementation(r),type,method,## __VA_ARGS__)
128
129 #define pw_resource_do_parent(r,l,type,method,...) \
130 spa_hook_list_call_once_start(pw_resource_get_implementation(r),l,type,method,## __VA_ARGS__)
131
132 #define pw_resource_notify(r,type,event,...) \
133 ((type*) pw_resource_get_marshal(r)->event_marshal)->event(r, ## __VA_ARGS__)
134
135 #ifdef __cplusplus
136 }
137 #endif
138
139 #endif /* __PIPEWIRE_RESOURCE_H__ */
pw_resource_error
void pw_resource_error(struct pw_resource *resource, int result, const char *error)
Generate an error for a resource.
Definition: resource.c:149
pw_resource_get_marshal
const struct pw_protocol_marshal * pw_resource_get_marshal(struct pw_resource *resource)
Get the marshal functions for the resource.
Definition: resource.c:144
pw_protocol
Manages protocols and their implementation.
pw_resource_set_implementation
void pw_resource_set_implementation(struct pw_resource *resource, const void *implementation, void *data)
Set the resource implementation.
Definition: resource.c:119
pw_resource_events::destroy
void(* destroy)(void *data)
The resource is destroyed.
Definition: resource.h:67
pw_resource_get_id
uint32_t pw_resource_get_id(struct pw_resource *resource)
Get the unique id of this resource.
Definition: resource.c:86
pw_protocol_marshal
Definition: protocol.h:70
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:155
pw_resource_new
struct pw_resource * pw_resource_new(struct pw_client *client, uint32_t id, uint32_t permissions, uint32_t type, uint32_t version, size_t user_data_size)
Make a new resource for client.
Definition: resource.c:33
pw_resource_get_type
uint32_t pw_resource_get_type(struct pw_resource *resource)
Get the type of this resource.
Definition: resource.c:96
pw_resource_events::version
uint32_t version
Definition: resource.h:64
pw_resource_add_override
void pw_resource_add_override(struct pw_resource *resource, struct spa_hook *listener, const void *implementation, void *data)
Override the implementation of a resource.
Definition: resource.c:131
pw_resource_get_implementation
struct spa_hook_list * pw_resource_get_implementation(struct pw_resource *resource)
Get the implementation list of a resource.
Definition: resource.c:139
pw_resource_get_client
struct pw_client * pw_resource_get_client(struct pw_resource *resource)
Get the client owning this resource.
Definition: resource.c:81
pw_resource_get_protocol
struct pw_protocol * pw_resource_get_protocol(struct pw_resource *resource)
Get the protocol used for this resource.
Definition: resource.c:101
pw_resource_get_permissions
uint32_t pw_resource_get_permissions(struct pw_resource *resource)
Get the permissions of this resource.
Definition: resource.c:91
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:111
pw_client
PipeWire client object class.
pw_resource
Client owned objects.
client.h
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:106
pw_resource_events
Resource events.
Definition: resource.h:62