| 1 |
/* PipeWire */ |
| 2 |
/* SPDX-FileCopyrightText: Copyright © 2018 Wim Taymans */ |
| 3 |
/* SPDX-License-Identifier: MIT */ |
| 4 |
|
| 5 |
#ifndef PIPEWIRE_EXT_PROTOCOL_NATIVE_H |
| 6 |
#define PIPEWIRE_EXT_PROTOCOL_NATIVE_H |
| 7 |
|
| 8 |
#include <pw-headers/spa/utils/defs.h> |
| 9 |
|
| 10 |
#include <pw-headers/pipewire/proxy.h> |
| 11 |
#include <pw-headers/pipewire/resource.h> |
| 12 |
|
| 13 |
#ifdef __cplusplus |
| 14 |
extern "C" { |
| 15 |
#endif |
| 16 |
|
| 17 |
/** \defgroup pw_protocol_native Native Protocol |
| 18 |
* PipeWire native protocol interface |
| 19 |
*/ |
| 20 |
|
| 21 |
/** |
| 22 |
* \addtogroup pw_protocol_native |
| 23 |
* \{ |
| 24 |
*/ |
| 25 |
#define PW_TYPE_INFO_PROTOCOL_Native PW_TYPE_INFO_PROTOCOL_BASE "Native" |
| 26 |
|
| 27 |
struct pw_protocol_native_message { |
| 28 |
uint32_t id; |
| 29 |
uint32_t opcode; |
| 30 |
void *data; |
| 31 |
uint32_t size; |
| 32 |
uint32_t n_fds; |
| 33 |
int *fds; |
| 34 |
int seq; |
| 35 |
}; |
| 36 |
|
| 37 |
struct pw_protocol_native_demarshal { |
| 38 |
int (*func) (void *object, const struct pw_protocol_native_message *msg); |
| 39 |
uint32_t permissions; |
| 40 |
uint32_t flags; |
| 41 |
}; |
| 42 |
|
| 43 |
/** \ref pw_protocol_native_ext methods */ |
| 44 |
struct pw_protocol_native_ext { |
| 45 |
#define PW_VERSION_PROTOCOL_NATIVE_EXT 0 |
| 46 |
uint32_t version; |
| 47 |
|
| 48 |
struct spa_pod_builder * (*begin_proxy) (struct pw_proxy *proxy, |
| 49 |
uint8_t opcode, struct pw_protocol_native_message **msg); |
| 50 |
|
| 51 |
uint32_t (*add_proxy_fd) (struct pw_proxy *proxy, int fd); |
| 52 |
int (*get_proxy_fd) (struct pw_proxy *proxy, uint32_t index); |
| 53 |
|
| 54 |
int (*end_proxy) (struct pw_proxy *proxy, |
| 55 |
struct spa_pod_builder *builder); |
| 56 |
|
| 57 |
struct spa_pod_builder * (*begin_resource) (struct pw_resource *resource, |
| 58 |
uint8_t opcode, struct pw_protocol_native_message **msg); |
| 59 |
|
| 60 |
uint32_t (*add_resource_fd) (struct pw_resource *resource, int fd); |
| 61 |
int (*get_resource_fd) (struct pw_resource *resource, uint32_t index); |
| 62 |
|
| 63 |
int (*end_resource) (struct pw_resource *resource, |
| 64 |
struct spa_pod_builder *builder); |
| 65 |
}; |
| 66 |
|
| 67 |
#define pw_protocol_native_begin_proxy(p,...) pw_protocol_ext(pw_proxy_get_protocol(p),struct pw_protocol_native_ext,begin_proxy,p,__VA_ARGS__) |
| 68 |
#define pw_protocol_native_add_proxy_fd(p,...) pw_protocol_ext(pw_proxy_get_protocol(p),struct pw_protocol_native_ext,add_proxy_fd,p,__VA_ARGS__) |
| 69 |
#define pw_protocol_native_get_proxy_fd(p,...) pw_protocol_ext(pw_proxy_get_protocol(p),struct pw_protocol_native_ext,get_proxy_fd,p,__VA_ARGS__) |
| 70 |
#define pw_protocol_native_end_proxy(p,...) pw_protocol_ext(pw_proxy_get_protocol(p),struct pw_protocol_native_ext,end_proxy,p,__VA_ARGS__) |
| 71 |
|
| 72 |
#define pw_protocol_native_begin_resource(r,...) pw_protocol_ext(pw_resource_get_protocol(r),struct pw_protocol_native_ext,begin_resource,r,__VA_ARGS__) |
| 73 |
#define pw_protocol_native_add_resource_fd(r,...) pw_protocol_ext(pw_resource_get_protocol(r),struct pw_protocol_native_ext,add_resource_fd,r,__VA_ARGS__) |
| 74 |
#define pw_protocol_native_get_resource_fd(r,...) pw_protocol_ext(pw_resource_get_protocol(r),struct pw_protocol_native_ext,get_resource_fd,r,__VA_ARGS__) |
| 75 |
#define pw_protocol_native_end_resource(r,...) pw_protocol_ext(pw_resource_get_protocol(r),struct pw_protocol_native_ext,end_resource,r,__VA_ARGS__) |
| 76 |
|
| 77 |
/** |
| 78 |
* \} |
| 79 |
*/ |
| 80 |
|
| 81 |
#ifdef __cplusplus |
| 82 |
} /* extern "C" */ |
| 83 |
#endif |
| 84 |
|
| 85 |
#endif /* PIPEWIRE_EXT_PROTOCOL_NATIVE_H */ |