resource.h
Go to the documentation of this file.
/* PipeWire
* Copyright (C) 2015 Wim Taymans <wim.taymans@gmail.com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __PIPEWIRE_RESOURCE_H__
#define __PIPEWIRE_RESOURCE_H__
#ifdef __cplusplus
extern "C" {
#endif
#define PW_TYPE__Resource "PipeWire:Object:Resource"
#define PW_TYPE_RESOURCE_BASE PW_TYPE__Resource ":"
#include <spa/utils/hook.h>
struct pw_resource;
#include <pipewire/client.h>
struct pw_resource_events {
#define PW_VERSION_RESOURCE_EVENTS 0
uint32_t version;
void (*destroy) (void *data);
};
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 );
void pw_resource_destroy(struct pw_resource *resource);
struct pw_client *pw_resource_get_client(struct pw_resource *resource);
uint32_t pw_resource_get_id(struct pw_resource *resource);
uint32_t pw_resource_get_permissions(struct pw_resource *resource);
uint32_t pw_resource_get_type(struct pw_resource *resource);
struct pw_protocol *pw_resource_get_protocol(struct pw_resource *resource);
void *pw_resource_get_user_data(struct pw_resource *resource);
void pw_resource_add_listener(struct pw_resource *resource,
struct spa_hook *listener,
const struct pw_resource_events *events,
void *data);
void pw_resource_set_implementation(struct pw_resource *resource,
const void *implementation,
void *data);
void pw_resource_add_override(struct pw_resource *resource,
struct spa_hook *listener,
const void *implementation,
void *data);
void pw_resource_error(struct pw_resource *resource, int result, const char *error);
struct spa_hook_list *pw_resource_get_implementation(struct pw_resource *resource);
const struct pw_protocol_marshal *pw_resource_get_marshal(struct pw_resource *resource);
#define pw_resource_do(r,type,method,v,...) \
spa_hook_list_call_once(pw_resource_get_implementation(r),type,method,v,## __VA_ARGS__)
#define pw_resource_do_parent(r,l,type,method,...) \
spa_hook_list_call_once_start(pw_resource_get_implementation(r),l,type,method,v,## __VA_ARGS__)
#define pw_resource_notify(r,type,event,...) \
((type*) pw_resource_get_marshal(r)->event_marshal)->event(r, ## __VA_ARGS__)
#ifdef __cplusplus
}
#endif
#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:162
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:156
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:128
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:89
pw_protocol_marshal
Definition: protocol.h:70
pw_resource_destroy
void pw_resource_destroy(struct pw_resource *resource)
Destroy a resource.
Definition: resource.c:169
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:34
pw_resource_get_type
uint32_t pw_resource_get_type(struct pw_resource *resource)
Get the type of this resource.
Definition: resource.c:101
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:141
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:150
pw_resource_get_client
struct pw_client * pw_resource_get_client(struct pw_resource *resource)
Get the client owning this resource.
Definition: resource.c:83
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:107
pw_resource_get_permissions
uint32_t pw_resource_get_permissions(struct pw_resource *resource)
Get the permissions of this resource.
Definition: resource.c:95
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:119
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:113
pw_resource_events
Resource events.
Definition: resource.h:62