PipeWire  0.1.4
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/hook.h>
31 
57 struct pw_resource;
58 
59 #include <pipewire/client.h>
60 
62 #define PW_VERSION_RESOURCE_EVENTS 0
63  uint32_t version;
64 
65  void (*destroy) (void *data);
66 };
67 
69 struct pw_resource *
71  uint32_t id,
72  uint32_t permissions,
73  uint32_t type,
74  uint32_t version,
75  size_t user_data_size );
76 
77 void pw_resource_destroy(struct pw_resource *resource);
78 
79 struct pw_client *pw_resource_get_client(struct pw_resource *resource);
80 
81 uint32_t pw_resource_get_id(struct pw_resource *resource);
82 
83 uint32_t pw_resource_get_permissions(struct pw_resource *resource);
84 
85 uint32_t pw_resource_get_type(struct pw_resource *resource);
86 
87 struct pw_protocol *pw_resource_get_protocol(struct pw_resource *resource);
88 
89 void *pw_resource_get_user_data(struct pw_resource *resource);
90 
91 void pw_resource_add_listener(struct pw_resource *resource,
92  struct spa_hook *listener,
93  const struct pw_resource_events *events,
94  void *data);
95 
96 void pw_resource_set_implementation(struct pw_resource *resource,
97  const void *implementation,
98  void *data);
99 
100 void pw_resource_add_override(struct pw_resource *resource,
101  struct spa_hook *listener,
102  const void *implementation,
103  void *data);
104 
105 void pw_resource_error(struct pw_resource *resource, int result, const char *error);
106 
107 struct spa_hook_list *pw_resource_get_implementation(struct pw_resource *resource);
108 
109 const struct pw_protocol_marshal *pw_resource_get_marshal(struct pw_resource *resource);
110 
111 #define pw_resource_do(r,type,method,...) \
112  spa_hook_list_call_once(pw_resource_get_implementation(r),type,method,## __VA_ARGS__)
113 
114 #define pw_resource_do_parent(r,l,type,method,...) \
115  spa_hook_list_call_once_start(pw_resource_get_implementation(r),l,type,method,## __VA_ARGS__)
116 
117 #define pw_resource_notify(r,type,event,...) \
118  ((type*) pw_resource_get_marshal(r)->event_marshal)->event(r, ## __VA_ARGS__)
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 
124 #endif /* __PIPEWIRE_RESOURCE_H__ */
void pw_resource_error(struct pw_resource *resource, int result, const char *error)
Definition: resource.c:149
const struct pw_protocol_marshal * pw_resource_get_marshal(struct pw_resource *resource)
Definition: resource.c:144
void pw_resource_set_implementation(struct pw_resource *resource, const void *implementation, void *data)
Definition: resource.c:119
void(* destroy)(void *data)
Definition: resource.h:65
uint32_t pw_resource_get_id(struct pw_resource *resource)
Definition: resource.c:86
Definition: protocol.h:66
void pw_resource_destroy(struct pw_resource *resource)
Definition: resource.c:155
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
uint32_t pw_resource_get_type(struct pw_resource *resource)
Definition: resource.c:96
uint32_t version
Definition: resource.h:63
void pw_resource_add_override(struct pw_resource *resource, struct spa_hook *listener, const void *implementation, void *data)
Definition: resource.c:131
struct spa_hook_list * pw_resource_get_implementation(struct pw_resource *resource)
Definition: resource.c:139
uint32_t permissions
resource permissions
Definition: private.h:291
Client owned objects.
Definition: private.h:284
struct pw_client * client
owner client
Definition: private.h:288
struct pw_client * pw_resource_get_client(struct pw_resource *resource)
Definition: resource.c:81
struct pw_protocol * pw_resource_get_protocol(struct pw_resource *resource)
Definition: resource.c:101
PipeWire client object class.
Definition: private.h:58
Manages protocols and their implementation.
Definition: private.h:40
uint32_t pw_resource_get_permissions(struct pw_resource *resource)
Definition: resource.c:91
void pw_resource_add_listener(struct pw_resource *resource, struct spa_hook *listener, const struct pw_resource_events *events, void *data)
Definition: resource.c:111
uint32_t type
type of the client interface
Definition: private.h:292
const struct pw_protocol_implementaton * implementation
implementation of the protocol
Definition: private.h:51
void * pw_resource_get_user_data(struct pw_resource *resource)
Definition: resource.c:106
Definition: resource.h:61