mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-15 08:56:38 -05:00
Make extensions
Make the protocol-native and client-node extensions
This commit is contained in:
parent
8a4c816d2f
commit
849e0599b6
21 changed files with 1625 additions and 1231 deletions
1
Makefile
1
Makefile
|
|
@ -15,6 +15,7 @@ run:
|
||||||
|
|
||||||
monitor:
|
monitor:
|
||||||
SPA_PLUGIN_DIR=build/spa/plugins \
|
SPA_PLUGIN_DIR=build/spa/plugins \
|
||||||
|
PIPEWIRE_MODULE_DIR=build/pipewire/modules/ \
|
||||||
build/pipewire/tools/pipewire-monitor
|
build/pipewire/tools/pipewire-monitor
|
||||||
|
|
||||||
dist:
|
dist:
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
#include "pipewire/client/pipewire.h"
|
#include "pipewire/client/pipewire.h"
|
||||||
|
|
||||||
#include "pipewire/client/context.h"
|
#include "pipewire/client/context.h"
|
||||||
|
#include "pipewire/client/extension.h"
|
||||||
#include "pipewire/client/introspect.h"
|
#include "pipewire/client/introspect.h"
|
||||||
#include "pipewire/client/interfaces.h"
|
#include "pipewire/client/interfaces.h"
|
||||||
#include "pipewire/client/protocol-native.h"
|
#include "pipewire/client/protocol-native.h"
|
||||||
|
|
@ -443,8 +444,6 @@ struct pw_context *pw_context_new(struct pw_loop *loop,
|
||||||
|
|
||||||
this->loop = loop;
|
this->loop = loop;
|
||||||
|
|
||||||
this->protocol = pw_protocol_native_client_init();
|
|
||||||
|
|
||||||
pw_type_init(&this->type);
|
pw_type_init(&this->type);
|
||||||
|
|
||||||
spa_debug_set_type_map(this->type.map);
|
spa_debug_set_type_map(this->type.map);
|
||||||
|
|
@ -462,6 +461,7 @@ struct pw_context *pw_context_new(struct pw_loop *loop,
|
||||||
pw_map_init(&this->objects, 64, 32);
|
pw_map_init(&this->objects, 64, 32);
|
||||||
pw_map_init(&this->types, 64, 32);
|
pw_map_init(&this->types, 64, 32);
|
||||||
|
|
||||||
|
spa_list_init(&this->extension_list);
|
||||||
spa_list_init(&this->stream_list);
|
spa_list_init(&this->stream_list);
|
||||||
spa_list_init(&this->proxy_list);
|
spa_list_init(&this->proxy_list);
|
||||||
|
|
||||||
|
|
@ -469,6 +469,11 @@ struct pw_context *pw_context_new(struct pw_loop *loop,
|
||||||
pw_signal_init(&this->subscription);
|
pw_signal_init(&this->subscription);
|
||||||
pw_signal_init(&this->destroy_signal);
|
pw_signal_init(&this->destroy_signal);
|
||||||
|
|
||||||
|
pw_extension_load(this, "libpipewire-module-protocol-native", NULL);
|
||||||
|
pw_extension_load(this, "libpipewire-module-client-node", NULL);
|
||||||
|
|
||||||
|
this->protocol = pw_protocol_get(PW_TYPE_PROTOCOL__Native);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
|
||||||
no_mem:
|
no_mem:
|
||||||
|
|
@ -482,6 +487,7 @@ void pw_context_destroy(struct pw_context *context)
|
||||||
struct context *impl = SPA_CONTAINER_OF(context, struct context, this);
|
struct context *impl = SPA_CONTAINER_OF(context, struct context, this);
|
||||||
struct pw_stream *stream, *t1;
|
struct pw_stream *stream, *t1;
|
||||||
struct pw_proxy *proxy, *t2;
|
struct pw_proxy *proxy, *t2;
|
||||||
|
struct pw_extension *ext, *t3;
|
||||||
|
|
||||||
pw_log_debug("context %p: destroy", context);
|
pw_log_debug("context %p: destroy", context);
|
||||||
pw_signal_emit(&context->destroy_signal, context);
|
pw_signal_emit(&context->destroy_signal, context);
|
||||||
|
|
@ -495,6 +501,8 @@ void pw_context_destroy(struct pw_context *context)
|
||||||
pw_stream_destroy(stream);
|
pw_stream_destroy(stream);
|
||||||
spa_list_for_each_safe(proxy, t2, &context->proxy_list, link)
|
spa_list_for_each_safe(proxy, t2, &context->proxy_list, link)
|
||||||
pw_proxy_destroy(proxy);
|
pw_proxy_destroy(proxy);
|
||||||
|
spa_list_for_each_safe(ext, t3, &context->extension_list, link)
|
||||||
|
pw_extension_destroy(ext);
|
||||||
|
|
||||||
pw_map_clear(&context->objects);
|
pw_map_clear(&context->objects);
|
||||||
pw_map_clear(&context->types);
|
pw_map_clear(&context->types);
|
||||||
|
|
|
||||||
|
|
@ -157,6 +157,7 @@ struct pw_context {
|
||||||
uint32_t n_types; /**< number of client types */
|
uint32_t n_types; /**< number of client types */
|
||||||
struct pw_map types; /**< client types */
|
struct pw_map types; /**< client types */
|
||||||
|
|
||||||
|
struct spa_list extension_list; /**< list of \ref pw_extension objects */
|
||||||
struct spa_list stream_list; /**< list of \ref pw_stream objects */
|
struct spa_list stream_list; /**< list of \ref pw_stream objects */
|
||||||
struct spa_list proxy_list; /**< list of \ref pw_proxy objects */
|
struct spa_list proxy_list; /**< list of \ref pw_proxy objects */
|
||||||
|
|
||||||
|
|
|
||||||
140
pipewire/client/extension.c
Normal file
140
pipewire/client/extension.c
Normal file
|
|
@ -0,0 +1,140 @@
|
||||||
|
/* PipeWire
|
||||||
|
* Copyright (C) 2016 Axis Communications <dev-gstreamer@axis.com>
|
||||||
|
* @author Linus Svensson <linus.svensson@axis.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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifdef HAVE_CONFIG_H
|
||||||
|
#include "config.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "pipewire/client/pipewire.h"
|
||||||
|
#include "pipewire/client/interfaces.h"
|
||||||
|
#include "pipewire/client/utils.h"
|
||||||
|
#include "pipewire/client/extension.h"
|
||||||
|
|
||||||
|
/** \cond */
|
||||||
|
struct impl {
|
||||||
|
struct pw_extension this;
|
||||||
|
void *hnd;
|
||||||
|
};
|
||||||
|
/** \endcond */
|
||||||
|
|
||||||
|
/** Load an extension \memberof pw_extension
|
||||||
|
*
|
||||||
|
* \param context a \ref pw_context
|
||||||
|
* \param name name of the extension to load
|
||||||
|
* \param args A string with arguments for the extension
|
||||||
|
* \param[out] err Return location for an error string, or NULL
|
||||||
|
* \return A \ref pw_extension if the extension could be loaded, or NULL on failure.
|
||||||
|
*/
|
||||||
|
struct pw_extension *pw_extension_load(struct pw_context *context,
|
||||||
|
const char *name, const char *args)
|
||||||
|
{
|
||||||
|
struct pw_extension *this;
|
||||||
|
struct impl *impl;
|
||||||
|
void *hnd;
|
||||||
|
char *filename = NULL;
|
||||||
|
const char *module_dir;
|
||||||
|
pw_extension_init_func_t init_func;
|
||||||
|
|
||||||
|
module_dir = getenv("PIPEWIRE_MODULE_DIR");
|
||||||
|
if (module_dir == NULL)
|
||||||
|
module_dir = MODULEDIR;
|
||||||
|
|
||||||
|
pw_log_debug("PIPEWIRE_MODULE_DIR set to: %s", module_dir);
|
||||||
|
|
||||||
|
asprintf(&filename, "%s/%s.so", module_dir, name);
|
||||||
|
if (filename == NULL)
|
||||||
|
goto no_filename;
|
||||||
|
|
||||||
|
pw_log_debug("trying to load extension: %s (%s)", name, filename);
|
||||||
|
|
||||||
|
hnd = dlopen(filename, RTLD_NOW | RTLD_LOCAL);
|
||||||
|
|
||||||
|
if (hnd == NULL)
|
||||||
|
goto open_failed;
|
||||||
|
|
||||||
|
if ((init_func = dlsym(hnd, PIPEWIRE_SYMBOL_EXTENSION_INIT)) == NULL)
|
||||||
|
goto no_pw_extension;
|
||||||
|
|
||||||
|
impl = calloc(1, sizeof(struct impl));
|
||||||
|
if (impl == NULL)
|
||||||
|
goto no_mem;
|
||||||
|
|
||||||
|
impl->hnd = hnd;
|
||||||
|
|
||||||
|
this = &impl->this;
|
||||||
|
this->context = context;
|
||||||
|
this->filename = filename;
|
||||||
|
this->args = args ? strdup(args) : NULL;
|
||||||
|
this->props = NULL;
|
||||||
|
|
||||||
|
pw_signal_init(&this->destroy_signal);
|
||||||
|
|
||||||
|
if (!init_func(this, (char *) args))
|
||||||
|
goto init_failed;
|
||||||
|
|
||||||
|
spa_list_insert(&context->extension_list, &this->link);
|
||||||
|
|
||||||
|
pw_log_debug("loaded extension: %s", filename);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
|
||||||
|
no_filename:
|
||||||
|
pw_log_error("No memory");
|
||||||
|
return NULL;
|
||||||
|
open_failed:
|
||||||
|
pw_log_error("Failed to open module: \"%s\" %s", filename, dlerror());
|
||||||
|
free(filename);
|
||||||
|
return NULL;
|
||||||
|
no_mem:
|
||||||
|
no_pw_extension:
|
||||||
|
pw_log_error("\"%s\" is not a pipewire extension", name);
|
||||||
|
dlclose(hnd);
|
||||||
|
free(filename);
|
||||||
|
return NULL;
|
||||||
|
init_failed:
|
||||||
|
pw_log_error("\"%s\" failed to initialize", name);
|
||||||
|
pw_extension_destroy(this);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Destroy a extension
|
||||||
|
* \param extension the extension to destroy
|
||||||
|
* \memberof pw_extension
|
||||||
|
*/
|
||||||
|
void pw_extension_destroy(struct pw_extension *extension)
|
||||||
|
{
|
||||||
|
struct impl *impl = SPA_CONTAINER_OF(extension, struct impl, this);
|
||||||
|
|
||||||
|
pw_signal_emit(&extension->destroy_signal, extension);
|
||||||
|
|
||||||
|
if (extension->filename)
|
||||||
|
free((char *) extension->filename);
|
||||||
|
if (extension->args)
|
||||||
|
free((char *) extension->args);
|
||||||
|
if (extension->props)
|
||||||
|
pw_properties_free(extension->props);
|
||||||
|
dlclose(impl->hnd);
|
||||||
|
free(impl);
|
||||||
|
}
|
||||||
72
pipewire/client/extension.h
Normal file
72
pipewire/client/extension.h
Normal file
|
|
@ -0,0 +1,72 @@
|
||||||
|
/* PipeWire
|
||||||
|
* Copyright (C) 2016 Axis Communications <dev-gstreamer@axis.com>
|
||||||
|
* @author Linus Svensson <linus.svensson@axis.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_EXTENSION_H__
|
||||||
|
#define __PIPEWIRE_EXTENSION_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <pipewire/client/context.h>
|
||||||
|
|
||||||
|
#define PIPEWIRE_SYMBOL_EXTENSION_INIT "pipewire__extension_init"
|
||||||
|
|
||||||
|
/** \class pw_extension
|
||||||
|
*
|
||||||
|
* A dynamically loadable extension
|
||||||
|
*/
|
||||||
|
struct pw_extension {
|
||||||
|
struct pw_context *context; /**< the client context */
|
||||||
|
struct spa_list link; /**< link in the context extension_list */
|
||||||
|
|
||||||
|
const char *filename; /**< filename of extension */
|
||||||
|
const char *args; /**< argument for the extension */
|
||||||
|
struct pw_properties *props; /**< extra properties */
|
||||||
|
|
||||||
|
void *user_data; /**< extension user_data */
|
||||||
|
|
||||||
|
/** Emited when the extension is destroyed */
|
||||||
|
PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_extension *extension));
|
||||||
|
};
|
||||||
|
|
||||||
|
/** Module init function signature \memberof pw_extension
|
||||||
|
*
|
||||||
|
* \param extension A \ref pw_extension
|
||||||
|
* \param args Arguments to the extension
|
||||||
|
* \return true on success, false otherwise
|
||||||
|
*
|
||||||
|
* A extension should provide an init function with this signature. This function
|
||||||
|
* will be called when a extension is loaded.
|
||||||
|
*/
|
||||||
|
typedef bool (*pw_extension_init_func_t) (struct pw_extension *extension, char *args);
|
||||||
|
|
||||||
|
struct pw_extension *
|
||||||
|
pw_extension_load(struct pw_context *context,
|
||||||
|
const char *name, const char *args);
|
||||||
|
|
||||||
|
void
|
||||||
|
pw_extension_destroy(struct pw_extension *extension);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __PIPEWIRE_EXTENSION_H__ */
|
||||||
|
|
@ -306,263 +306,6 @@ struct pw_node_events {
|
||||||
|
|
||||||
#define pw_node_notify_info(r,...) ((struct pw_node_events*)r->iface->events)->info(r,__VA_ARGS__)
|
#define pw_node_notify_info(r,...) ((struct pw_node_events*)r->iface->events)->info(r,__VA_ARGS__)
|
||||||
|
|
||||||
/** information about a buffer */
|
|
||||||
struct pw_client_node_buffer {
|
|
||||||
uint32_t mem_id; /**< the memory id for the metadata */
|
|
||||||
uint32_t offset; /**< offset in memory */
|
|
||||||
uint32_t size; /**< size in memory */
|
|
||||||
struct spa_buffer *buffer; /**< buffer describing metadata and buffer memory */
|
|
||||||
};
|
|
||||||
|
|
||||||
#define PW_VERSION_CLIENT_NODE 0
|
|
||||||
|
|
||||||
#define PW_CLIENT_NODE_METHOD_DONE 0
|
|
||||||
#define PW_CLIENT_NODE_METHOD_UPDATE 1
|
|
||||||
#define PW_CLIENT_NODE_METHOD_PORT_UPDATE 2
|
|
||||||
#define PW_CLIENT_NODE_METHOD_EVENT 3
|
|
||||||
#define PW_CLIENT_NODE_METHOD_DESTROY 4
|
|
||||||
#define PW_CLIENT_NODE_METHOD_NUM 5
|
|
||||||
|
|
||||||
/** \ref pw_client_node methods */
|
|
||||||
struct pw_client_node_methods {
|
|
||||||
/** Complete an async operation */
|
|
||||||
void (*done) (void *object, int seq, int res);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update the node ports and properties
|
|
||||||
*
|
|
||||||
* Update the maximum number of ports and the properties of the
|
|
||||||
* client node.
|
|
||||||
* \param change_mask bitfield with changed parameters
|
|
||||||
* \param max_input_ports new max input ports
|
|
||||||
* \param max_output_ports new max output ports
|
|
||||||
* \param props new properties
|
|
||||||
*/
|
|
||||||
void (*update) (void *object,
|
|
||||||
#define PW_CLIENT_NODE_UPDATE_MAX_INPUTS (1 << 0)
|
|
||||||
#define PW_CLIENT_NODE_UPDATE_MAX_OUTPUTS (1 << 1)
|
|
||||||
#define PW_CLIENT_NODE_UPDATE_PROPS (1 << 2)
|
|
||||||
uint32_t change_mask,
|
|
||||||
uint32_t max_input_ports,
|
|
||||||
uint32_t max_output_ports,
|
|
||||||
const struct spa_props *props);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Update a node port
|
|
||||||
*
|
|
||||||
* Update the information of one port of a node.
|
|
||||||
* \param direction the direction of the port
|
|
||||||
* \param port_id the port id to update
|
|
||||||
* \param change_mask a bitfield of changed items
|
|
||||||
* \param n_possible_formats number of possible formats
|
|
||||||
* \param possible_formats array of possible formats on the port
|
|
||||||
* \param format the current format on the port
|
|
||||||
* \param n_params number of port parameters
|
|
||||||
* \param params array of port parameters
|
|
||||||
* \param info port information
|
|
||||||
*/
|
|
||||||
void (*port_update) (void *object,
|
|
||||||
enum spa_direction direction,
|
|
||||||
uint32_t port_id,
|
|
||||||
#define PW_CLIENT_NODE_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
|
|
||||||
#define PW_CLIENT_NODE_PORT_UPDATE_FORMAT (1 << 1)
|
|
||||||
#define PW_CLIENT_NODE_PORT_UPDATE_PARAMS (1 << 2)
|
|
||||||
#define PW_CLIENT_NODE_PORT_UPDATE_INFO (1 << 3)
|
|
||||||
uint32_t change_mask,
|
|
||||||
uint32_t n_possible_formats,
|
|
||||||
const struct spa_format **possible_formats,
|
|
||||||
const struct spa_format *format,
|
|
||||||
uint32_t n_params,
|
|
||||||
const struct spa_param **params,
|
|
||||||
const struct spa_port_info *info);
|
|
||||||
/**
|
|
||||||
* Send an event to the node
|
|
||||||
* \param event the event to send
|
|
||||||
*/
|
|
||||||
void (*event) (void *object, struct spa_event *event);
|
|
||||||
/**
|
|
||||||
* Destroy the client_node
|
|
||||||
*/
|
|
||||||
void (*destroy) (void *object);
|
|
||||||
};
|
|
||||||
|
|
||||||
#define pw_client_node_do_done(r,...) ((struct pw_client_node_methods*)r->iface->methods)->done(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_do_update(r,...) ((struct pw_client_node_methods*)r->iface->methods)->update(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_do_port_update(r,...) ((struct pw_client_node_methods*)r->iface->methods)->port_update(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_do_event(r,...) ((struct pw_client_node_methods*)r->iface->methods)->event(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_do_destroy(r) ((struct pw_client_node_methods*)r->iface->methods)->destroy(r)
|
|
||||||
|
|
||||||
#define PW_CLIENT_NODE_EVENT_SET_PROPS 0
|
|
||||||
#define PW_CLIENT_NODE_EVENT_EVENT 1
|
|
||||||
#define PW_CLIENT_NODE_EVENT_ADD_PORT 2
|
|
||||||
#define PW_CLIENT_NODE_EVENT_REMOVE_PORT 3
|
|
||||||
#define PW_CLIENT_NODE_EVENT_SET_FORMAT 4
|
|
||||||
#define PW_CLIENT_NODE_EVENT_SET_PARAM 5
|
|
||||||
#define PW_CLIENT_NODE_EVENT_ADD_MEM 6
|
|
||||||
#define PW_CLIENT_NODE_EVENT_USE_BUFFERS 7
|
|
||||||
#define PW_CLIENT_NODE_EVENT_NODE_COMMAND 8
|
|
||||||
#define PW_CLIENT_NODE_EVENT_PORT_COMMAND 9
|
|
||||||
#define PW_CLIENT_NODE_EVENT_TRANSPORT 10
|
|
||||||
#define PW_CLIENT_NODE_EVENT_NUM 11
|
|
||||||
|
|
||||||
/** \ref pw_client_node events */
|
|
||||||
struct pw_client_node_events {
|
|
||||||
/**
|
|
||||||
* Notify of a property change
|
|
||||||
*
|
|
||||||
* When the server configures the properties on the node
|
|
||||||
* this event is sent
|
|
||||||
*
|
|
||||||
* \param seq a sequence number
|
|
||||||
* \param props the props to set
|
|
||||||
*/
|
|
||||||
void (*set_props) (void *object,
|
|
||||||
uint32_t seq,
|
|
||||||
const struct spa_props *props);
|
|
||||||
/**
|
|
||||||
* Receive an event from the client node
|
|
||||||
* \param event the received event */
|
|
||||||
void (*event) (void *object, const struct spa_event *event);
|
|
||||||
/**
|
|
||||||
* A new port was added to the node
|
|
||||||
*
|
|
||||||
* The server can at any time add a port to the node when there
|
|
||||||
* are free ports available.
|
|
||||||
*
|
|
||||||
* \param seq a sequence number
|
|
||||||
* \param direction the direction of the port
|
|
||||||
* \param port_id the new port id
|
|
||||||
*/
|
|
||||||
void (*add_port) (void *object,
|
|
||||||
uint32_t seq,
|
|
||||||
enum spa_direction direction,
|
|
||||||
uint32_t port_id);
|
|
||||||
/**
|
|
||||||
* A port was removed from the node
|
|
||||||
*
|
|
||||||
* \param seq a sequence number
|
|
||||||
* \param direction a port direction
|
|
||||||
* \param port_id the remove port id
|
|
||||||
*/
|
|
||||||
void (*remove_port) (void *object,
|
|
||||||
uint32_t seq,
|
|
||||||
enum spa_direction direction,
|
|
||||||
uint32_t port_id);
|
|
||||||
/**
|
|
||||||
* A format was configured on the port
|
|
||||||
*
|
|
||||||
* \param seq a sequence number
|
|
||||||
* \param direction a port direction
|
|
||||||
* \param port_id the port id
|
|
||||||
* \param flags flags used when setting the format
|
|
||||||
* \param format the new format
|
|
||||||
*/
|
|
||||||
void (*set_format) (void *object,
|
|
||||||
uint32_t seq,
|
|
||||||
enum spa_direction direction,
|
|
||||||
uint32_t port_id,
|
|
||||||
uint32_t flags,
|
|
||||||
const struct spa_format *format);
|
|
||||||
/**
|
|
||||||
* A parameter was configured on the port
|
|
||||||
*
|
|
||||||
* \param seq a sequence number
|
|
||||||
* \param direction a port direction
|
|
||||||
* \param port_id the port id
|
|
||||||
* \param param the new param
|
|
||||||
*/
|
|
||||||
void (*set_param) (void *object,
|
|
||||||
uint32_t seq,
|
|
||||||
enum spa_direction direction,
|
|
||||||
uint32_t port_id,
|
|
||||||
const struct spa_param *param);
|
|
||||||
/**
|
|
||||||
* Memory was added for a port
|
|
||||||
*
|
|
||||||
* \param direction a port direction
|
|
||||||
* \param port_id the port id
|
|
||||||
* \param mem_id the id of the memory
|
|
||||||
* \param type the memory type
|
|
||||||
* \param memfd the fd of the memory
|
|
||||||
* \param flags flags for the \a memfd
|
|
||||||
* \param offset valid offset of mapped memory from \a memfd
|
|
||||||
* \param size valid size of mapped memory from \a memfd
|
|
||||||
*/
|
|
||||||
void (*add_mem) (void *object,
|
|
||||||
enum spa_direction direction,
|
|
||||||
uint32_t port_id,
|
|
||||||
uint32_t mem_id,
|
|
||||||
uint32_t type,
|
|
||||||
int memfd,
|
|
||||||
uint32_t flags,
|
|
||||||
uint32_t offset,
|
|
||||||
uint32_t size);
|
|
||||||
/**
|
|
||||||
* Notify the port of buffers
|
|
||||||
*
|
|
||||||
* \param seq a sequence number
|
|
||||||
* \param direction a port direction
|
|
||||||
* \param port_id the port id
|
|
||||||
* \param n_buffer the number of buffers
|
|
||||||
* \param buffers and array of buffer descriptions
|
|
||||||
*/
|
|
||||||
void (*use_buffers) (void *object,
|
|
||||||
uint32_t seq,
|
|
||||||
enum spa_direction direction,
|
|
||||||
uint32_t port_id,
|
|
||||||
uint32_t n_buffers,
|
|
||||||
struct pw_client_node_buffer *buffers);
|
|
||||||
/**
|
|
||||||
* Notify of a new node command
|
|
||||||
*
|
|
||||||
* \param seq a sequence number
|
|
||||||
* \param command the command
|
|
||||||
*/
|
|
||||||
void (*node_command) (void *object, uint32_t seq, const struct spa_command *command);
|
|
||||||
/**
|
|
||||||
* Notify of a new port command
|
|
||||||
*
|
|
||||||
* \param direction a port direction
|
|
||||||
* \param port_id the port id
|
|
||||||
* \param command the command
|
|
||||||
*/
|
|
||||||
void (*port_command) (void *object,
|
|
||||||
enum spa_direction direction,
|
|
||||||
uint32_t port_id,
|
|
||||||
const struct spa_command *command);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Notify of a new transport area
|
|
||||||
*
|
|
||||||
* The transport area is used to exchange real-time commands between
|
|
||||||
* the client and the server.
|
|
||||||
*
|
|
||||||
* \param readfd fd for signal data can be read
|
|
||||||
* \param writefd fd for signal data can be written
|
|
||||||
* \param memfd the memory fd of the area
|
|
||||||
* \param offset the offset to map
|
|
||||||
* \param size the size to map
|
|
||||||
*/
|
|
||||||
void (*transport) (void *object,
|
|
||||||
int readfd,
|
|
||||||
int writefd,
|
|
||||||
int memfd,
|
|
||||||
uint32_t offset,
|
|
||||||
uint32_t size);
|
|
||||||
};
|
|
||||||
|
|
||||||
#define pw_client_node_notify_set_props(r,...) ((struct pw_client_node_events*)r->iface->events)->props(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_notify_event(r,...) ((struct pw_client_node_events*)r->iface->events)->event(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_notify_add_port(r,...) ((struct pw_client_node_events*)r->iface->events)->add_port(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_notify_remove_port(r,...) ((struct pw_client_node_events*)r->iface->events)->remove_port(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_notify_set_format(r,...) ((struct pw_client_node_events*)r->iface->events)->set_format(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_notify_set_param(r,...) ((struct pw_client_node_events*)r->iface->events)->set_param(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_notify_add_mem(r,...) ((struct pw_client_node_events*)r->iface->events)->add_mem(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_notify_use_buffers(r,...) ((struct pw_client_node_events*)r->iface->events)->use_buffers(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_notify_node_command(r,...) ((struct pw_client_node_events*)r->iface->events)->node_command(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_notify_port_command(r,...) ((struct pw_client_node_events*)r->iface->events)->port_command(r,__VA_ARGS__)
|
|
||||||
#define pw_client_node_notify_transport(r,...) ((struct pw_client_node_events*)r->iface->events)->transport(r,__VA_ARGS__)
|
|
||||||
|
|
||||||
#define PW_VERSION_CLIENT 0
|
#define PW_VERSION_CLIENT 0
|
||||||
|
|
||||||
#define PW_CLIENT_EVENT_INFO 0
|
#define PW_CLIENT_EVENT_INFO 0
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ pipewire_headers = [
|
||||||
'array.h',
|
'array.h',
|
||||||
'connection.h',
|
'connection.h',
|
||||||
'context.h',
|
'context.h',
|
||||||
|
'extension.h',
|
||||||
'interfaces.h',
|
'interfaces.h',
|
||||||
'introspect.h',
|
'introspect.h',
|
||||||
'log.h',
|
'log.h',
|
||||||
|
|
@ -11,7 +12,6 @@ pipewire_headers = [
|
||||||
'pipewire.h',
|
'pipewire.h',
|
||||||
'properties.h',
|
'properties.h',
|
||||||
'protocol.h',
|
'protocol.h',
|
||||||
'protocol-native.h',
|
|
||||||
'proxy.h',
|
'proxy.h',
|
||||||
'rtkit.h',
|
'rtkit.h',
|
||||||
'sig.h',
|
'sig.h',
|
||||||
|
|
@ -26,6 +26,7 @@ pipewire_headers = [
|
||||||
pipewire_sources = [
|
pipewire_sources = [
|
||||||
'connection.c',
|
'connection.c',
|
||||||
'context.c',
|
'context.c',
|
||||||
|
'extension.c',
|
||||||
'introspect.c',
|
'introspect.c',
|
||||||
'log.c',
|
'log.c',
|
||||||
'loop.c',
|
'loop.c',
|
||||||
|
|
@ -33,7 +34,6 @@ pipewire_sources = [
|
||||||
'pipewire.c',
|
'pipewire.c',
|
||||||
'properties.c',
|
'properties.c',
|
||||||
'protocol.c',
|
'protocol.c',
|
||||||
'protocol-native.c',
|
|
||||||
'proxy.c',
|
'proxy.c',
|
||||||
'stream.c',
|
'stream.c',
|
||||||
'rtkit.c',
|
'rtkit.c',
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
/* PipeWire
|
|
||||||
* Copyright (C) 2017 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <pipewire/client/protocol.h>
|
|
||||||
|
|
||||||
struct pw_protocol *pw_protocol_native_client_init(void);
|
|
||||||
|
|
@ -48,6 +48,8 @@ struct pw_protocol *pw_protocol_get(const char *name)
|
||||||
spa_list_init(&protocol->iface_list);
|
spa_list_init(&protocol->iface_list);
|
||||||
spa_list_insert(impl->protocol_list.prev, &protocol->link);
|
spa_list_insert(impl->protocol_list.prev, &protocol->link);
|
||||||
|
|
||||||
|
pw_log_info("Created protocol %s", name);
|
||||||
|
|
||||||
return protocol;
|
return protocol;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,12 +59,19 @@ pw_protocol_add_interfaces(struct pw_protocol *protocol,
|
||||||
const struct pw_interface *server_iface)
|
const struct pw_interface *server_iface)
|
||||||
{
|
{
|
||||||
struct pw_protocol_iface *iface;
|
struct pw_protocol_iface *iface;
|
||||||
|
const char *type;
|
||||||
|
uint32_t version;
|
||||||
|
|
||||||
iface = calloc(1, sizeof(struct pw_protocol_iface));
|
iface = calloc(1, sizeof(struct pw_protocol_iface));
|
||||||
iface->client_iface = client_iface;
|
iface->client_iface = client_iface;
|
||||||
iface->server_iface = server_iface;
|
iface->server_iface = server_iface;
|
||||||
|
|
||||||
spa_list_insert(protocol->iface_list.prev, &iface->link);
|
spa_list_insert(protocol->iface_list.prev, &iface->link);
|
||||||
|
|
||||||
|
type = client_iface ? client_iface->type : server_iface->type;
|
||||||
|
version = client_iface ? client_iface->version : server_iface->version;
|
||||||
|
|
||||||
|
pw_log_info("Add iface %s:%d to protocol %s", type, version, protocol->name);
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct pw_interface *
|
const struct pw_interface *
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@
|
||||||
#include "pipewire/client/stream.h"
|
#include "pipewire/client/stream.h"
|
||||||
#include "pipewire/client/transport.h"
|
#include "pipewire/client/transport.h"
|
||||||
#include "pipewire/client/utils.h"
|
#include "pipewire/client/utils.h"
|
||||||
|
#include "pipewire/extensions/client-node.h"
|
||||||
|
|
||||||
/** \cond */
|
/** \cond */
|
||||||
|
|
||||||
|
|
|
||||||
297
pipewire/extensions/client-node.h
Normal file
297
pipewire/extensions/client-node.h
Normal file
|
|
@ -0,0 +1,297 @@
|
||||||
|
/* PipeWire
|
||||||
|
* Copyright (C) 2016 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_EXT_CLIENT_NODE_H__
|
||||||
|
#define __PIPEWIRE_EXT_CLIENT_NODE_H__
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <spa/defs.h>
|
||||||
|
#include <spa/props.h>
|
||||||
|
#include <spa/format.h>
|
||||||
|
#include <spa/param-alloc.h>
|
||||||
|
#include <spa/node.h>
|
||||||
|
|
||||||
|
#define PIPEWIRE_TYPE__ClientNode PIPEWIRE_TYPE_NODE_BASE "Client"
|
||||||
|
#define PIPEWIRE_TYPE_CLIENT_NODE_BASE PIPEWIRE_TYPE__ClientNode ":"
|
||||||
|
|
||||||
|
/** information about a buffer */
|
||||||
|
struct pw_client_node_buffer {
|
||||||
|
uint32_t mem_id; /**< the memory id for the metadata */
|
||||||
|
uint32_t offset; /**< offset in memory */
|
||||||
|
uint32_t size; /**< size in memory */
|
||||||
|
struct spa_buffer *buffer; /**< buffer describing metadata and buffer memory */
|
||||||
|
};
|
||||||
|
|
||||||
|
#define PW_VERSION_CLIENT_NODE 0
|
||||||
|
|
||||||
|
#define PW_CLIENT_NODE_METHOD_DONE 0
|
||||||
|
#define PW_CLIENT_NODE_METHOD_UPDATE 1
|
||||||
|
#define PW_CLIENT_NODE_METHOD_PORT_UPDATE 2
|
||||||
|
#define PW_CLIENT_NODE_METHOD_EVENT 3
|
||||||
|
#define PW_CLIENT_NODE_METHOD_DESTROY 4
|
||||||
|
#define PW_CLIENT_NODE_METHOD_NUM 5
|
||||||
|
|
||||||
|
/** \ref pw_client_node methods */
|
||||||
|
struct pw_client_node_methods {
|
||||||
|
/** Complete an async operation */
|
||||||
|
void (*done) (void *object, int seq, int res);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the node ports and properties
|
||||||
|
*
|
||||||
|
* Update the maximum number of ports and the properties of the
|
||||||
|
* client node.
|
||||||
|
* \param change_mask bitfield with changed parameters
|
||||||
|
* \param max_input_ports new max input ports
|
||||||
|
* \param max_output_ports new max output ports
|
||||||
|
* \param props new properties
|
||||||
|
*/
|
||||||
|
void (*update) (void *object,
|
||||||
|
#define PW_CLIENT_NODE_UPDATE_MAX_INPUTS (1 << 0)
|
||||||
|
#define PW_CLIENT_NODE_UPDATE_MAX_OUTPUTS (1 << 1)
|
||||||
|
#define PW_CLIENT_NODE_UPDATE_PROPS (1 << 2)
|
||||||
|
uint32_t change_mask,
|
||||||
|
uint32_t max_input_ports,
|
||||||
|
uint32_t max_output_ports,
|
||||||
|
const struct spa_props *props);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update a node port
|
||||||
|
*
|
||||||
|
* Update the information of one port of a node.
|
||||||
|
* \param direction the direction of the port
|
||||||
|
* \param port_id the port id to update
|
||||||
|
* \param change_mask a bitfield of changed items
|
||||||
|
* \param n_possible_formats number of possible formats
|
||||||
|
* \param possible_formats array of possible formats on the port
|
||||||
|
* \param format the current format on the port
|
||||||
|
* \param n_params number of port parameters
|
||||||
|
* \param params array of port parameters
|
||||||
|
* \param info port information
|
||||||
|
*/
|
||||||
|
void (*port_update) (void *object,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id,
|
||||||
|
#define PW_CLIENT_NODE_PORT_UPDATE_POSSIBLE_FORMATS (1 << 0)
|
||||||
|
#define PW_CLIENT_NODE_PORT_UPDATE_FORMAT (1 << 1)
|
||||||
|
#define PW_CLIENT_NODE_PORT_UPDATE_PARAMS (1 << 2)
|
||||||
|
#define PW_CLIENT_NODE_PORT_UPDATE_INFO (1 << 3)
|
||||||
|
uint32_t change_mask,
|
||||||
|
uint32_t n_possible_formats,
|
||||||
|
const struct spa_format **possible_formats,
|
||||||
|
const struct spa_format *format,
|
||||||
|
uint32_t n_params,
|
||||||
|
const struct spa_param **params,
|
||||||
|
const struct spa_port_info *info);
|
||||||
|
/**
|
||||||
|
* Send an event to the node
|
||||||
|
* \param event the event to send
|
||||||
|
*/
|
||||||
|
void (*event) (void *object, struct spa_event *event);
|
||||||
|
/**
|
||||||
|
* Destroy the client_node
|
||||||
|
*/
|
||||||
|
void (*destroy) (void *object);
|
||||||
|
};
|
||||||
|
|
||||||
|
#define pw_client_node_do_done(r,...) ((struct pw_client_node_methods*)r->iface->methods)->done(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_do_update(r,...) ((struct pw_client_node_methods*)r->iface->methods)->update(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_do_port_update(r,...) ((struct pw_client_node_methods*)r->iface->methods)->port_update(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_do_event(r,...) ((struct pw_client_node_methods*)r->iface->methods)->event(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_do_destroy(r) ((struct pw_client_node_methods*)r->iface->methods)->destroy(r)
|
||||||
|
|
||||||
|
#define PW_CLIENT_NODE_EVENT_SET_PROPS 0
|
||||||
|
#define PW_CLIENT_NODE_EVENT_EVENT 1
|
||||||
|
#define PW_CLIENT_NODE_EVENT_ADD_PORT 2
|
||||||
|
#define PW_CLIENT_NODE_EVENT_REMOVE_PORT 3
|
||||||
|
#define PW_CLIENT_NODE_EVENT_SET_FORMAT 4
|
||||||
|
#define PW_CLIENT_NODE_EVENT_SET_PARAM 5
|
||||||
|
#define PW_CLIENT_NODE_EVENT_ADD_MEM 6
|
||||||
|
#define PW_CLIENT_NODE_EVENT_USE_BUFFERS 7
|
||||||
|
#define PW_CLIENT_NODE_EVENT_NODE_COMMAND 8
|
||||||
|
#define PW_CLIENT_NODE_EVENT_PORT_COMMAND 9
|
||||||
|
#define PW_CLIENT_NODE_EVENT_TRANSPORT 10
|
||||||
|
#define PW_CLIENT_NODE_EVENT_NUM 11
|
||||||
|
|
||||||
|
/** \ref pw_client_node events */
|
||||||
|
struct pw_client_node_events {
|
||||||
|
/**
|
||||||
|
* Notify of a property change
|
||||||
|
*
|
||||||
|
* When the server configures the properties on the node
|
||||||
|
* this event is sent
|
||||||
|
*
|
||||||
|
* \param seq a sequence number
|
||||||
|
* \param props the props to set
|
||||||
|
*/
|
||||||
|
void (*set_props) (void *object,
|
||||||
|
uint32_t seq,
|
||||||
|
const struct spa_props *props);
|
||||||
|
/**
|
||||||
|
* Receive an event from the client node
|
||||||
|
* \param event the received event */
|
||||||
|
void (*event) (void *object, const struct spa_event *event);
|
||||||
|
/**
|
||||||
|
* A new port was added to the node
|
||||||
|
*
|
||||||
|
* The server can at any time add a port to the node when there
|
||||||
|
* are free ports available.
|
||||||
|
*
|
||||||
|
* \param seq a sequence number
|
||||||
|
* \param direction the direction of the port
|
||||||
|
* \param port_id the new port id
|
||||||
|
*/
|
||||||
|
void (*add_port) (void *object,
|
||||||
|
uint32_t seq,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id);
|
||||||
|
/**
|
||||||
|
* A port was removed from the node
|
||||||
|
*
|
||||||
|
* \param seq a sequence number
|
||||||
|
* \param direction a port direction
|
||||||
|
* \param port_id the remove port id
|
||||||
|
*/
|
||||||
|
void (*remove_port) (void *object,
|
||||||
|
uint32_t seq,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id);
|
||||||
|
/**
|
||||||
|
* A format was configured on the port
|
||||||
|
*
|
||||||
|
* \param seq a sequence number
|
||||||
|
* \param direction a port direction
|
||||||
|
* \param port_id the port id
|
||||||
|
* \param flags flags used when setting the format
|
||||||
|
* \param format the new format
|
||||||
|
*/
|
||||||
|
void (*set_format) (void *object,
|
||||||
|
uint32_t seq,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id,
|
||||||
|
uint32_t flags,
|
||||||
|
const struct spa_format *format);
|
||||||
|
/**
|
||||||
|
* A parameter was configured on the port
|
||||||
|
*
|
||||||
|
* \param seq a sequence number
|
||||||
|
* \param direction a port direction
|
||||||
|
* \param port_id the port id
|
||||||
|
* \param param the new param
|
||||||
|
*/
|
||||||
|
void (*set_param) (void *object,
|
||||||
|
uint32_t seq,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id,
|
||||||
|
const struct spa_param *param);
|
||||||
|
/**
|
||||||
|
* Memory was added for a port
|
||||||
|
*
|
||||||
|
* \param direction a port direction
|
||||||
|
* \param port_id the port id
|
||||||
|
* \param mem_id the id of the memory
|
||||||
|
* \param type the memory type
|
||||||
|
* \param memfd the fd of the memory
|
||||||
|
* \param flags flags for the \a memfd
|
||||||
|
* \param offset valid offset of mapped memory from \a memfd
|
||||||
|
* \param size valid size of mapped memory from \a memfd
|
||||||
|
*/
|
||||||
|
void (*add_mem) (void *object,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id,
|
||||||
|
uint32_t mem_id,
|
||||||
|
uint32_t type,
|
||||||
|
int memfd,
|
||||||
|
uint32_t flags,
|
||||||
|
uint32_t offset,
|
||||||
|
uint32_t size);
|
||||||
|
/**
|
||||||
|
* Notify the port of buffers
|
||||||
|
*
|
||||||
|
* \param seq a sequence number
|
||||||
|
* \param direction a port direction
|
||||||
|
* \param port_id the port id
|
||||||
|
* \param n_buffer the number of buffers
|
||||||
|
* \param buffers and array of buffer descriptions
|
||||||
|
*/
|
||||||
|
void (*use_buffers) (void *object,
|
||||||
|
uint32_t seq,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id,
|
||||||
|
uint32_t n_buffers,
|
||||||
|
struct pw_client_node_buffer *buffers);
|
||||||
|
/**
|
||||||
|
* Notify of a new node command
|
||||||
|
*
|
||||||
|
* \param seq a sequence number
|
||||||
|
* \param command the command
|
||||||
|
*/
|
||||||
|
void (*node_command) (void *object, uint32_t seq, const struct spa_command *command);
|
||||||
|
/**
|
||||||
|
* Notify of a new port command
|
||||||
|
*
|
||||||
|
* \param direction a port direction
|
||||||
|
* \param port_id the port id
|
||||||
|
* \param command the command
|
||||||
|
*/
|
||||||
|
void (*port_command) (void *object,
|
||||||
|
enum spa_direction direction,
|
||||||
|
uint32_t port_id,
|
||||||
|
const struct spa_command *command);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Notify of a new transport area
|
||||||
|
*
|
||||||
|
* The transport area is used to exchange real-time commands between
|
||||||
|
* the client and the server.
|
||||||
|
*
|
||||||
|
* \param readfd fd for signal data can be read
|
||||||
|
* \param writefd fd for signal data can be written
|
||||||
|
* \param memfd the memory fd of the area
|
||||||
|
* \param offset the offset to map
|
||||||
|
* \param size the size to map
|
||||||
|
*/
|
||||||
|
void (*transport) (void *object,
|
||||||
|
int readfd,
|
||||||
|
int writefd,
|
||||||
|
int memfd,
|
||||||
|
uint32_t offset,
|
||||||
|
uint32_t size);
|
||||||
|
};
|
||||||
|
|
||||||
|
#define pw_client_node_notify_set_props(r,...) ((struct pw_client_node_events*)r->iface->events)->props(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_notify_event(r,...) ((struct pw_client_node_events*)r->iface->events)->event(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_notify_add_port(r,...) ((struct pw_client_node_events*)r->iface->events)->add_port(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_notify_remove_port(r,...) ((struct pw_client_node_events*)r->iface->events)->remove_port(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_notify_set_format(r,...) ((struct pw_client_node_events*)r->iface->events)->set_format(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_notify_set_param(r,...) ((struct pw_client_node_events*)r->iface->events)->set_param(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_notify_add_mem(r,...) ((struct pw_client_node_events*)r->iface->events)->add_mem(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_notify_use_buffers(r,...) ((struct pw_client_node_events*)r->iface->events)->use_buffers(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_notify_node_command(r,...) ((struct pw_client_node_events*)r->iface->events)->node_command(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_notify_port_command(r,...) ((struct pw_client_node_events*)r->iface->events)->port_command(r,__VA_ARGS__)
|
||||||
|
#define pw_client_node_notify_transport(r,...) ((struct pw_client_node_events*)r->iface->events)->transport(r,__VA_ARGS__)
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
} /* extern "C" */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __PIPEWIRE_EXT_CLIENT_NODE_H__ */
|
||||||
66
pipewire/modules/extension-client-node.c
Normal file
66
pipewire/modules/extension-client-node.c
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
/* PipeWire
|
||||||
|
* Copyright (C) 2017 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "pipewire/client/interfaces.h"
|
||||||
|
#include "pipewire/client/context.h"
|
||||||
|
#include "pipewire/client/extension.h"
|
||||||
|
|
||||||
|
struct pw_protocol *pw_protocol_native_ext_client_node_init(void);
|
||||||
|
|
||||||
|
struct impl {
|
||||||
|
struct pw_context *context;
|
||||||
|
struct pw_properties *properties;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct impl *extension_new(struct pw_context *context, struct pw_properties *properties)
|
||||||
|
{
|
||||||
|
struct impl *impl;
|
||||||
|
|
||||||
|
impl = calloc(1, sizeof(struct impl));
|
||||||
|
pw_log_debug("extension %p: new", impl);
|
||||||
|
|
||||||
|
impl->context = context;
|
||||||
|
impl->properties = properties;
|
||||||
|
|
||||||
|
pw_protocol_native_ext_client_node_init();
|
||||||
|
|
||||||
|
return impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static void extension_destroy(struct impl *impl)
|
||||||
|
{
|
||||||
|
pw_log_debug("extension %p: destroy", impl);
|
||||||
|
|
||||||
|
free(impl);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool pipewire__extension_init(struct pw_extension *extension, const char *args)
|
||||||
|
{
|
||||||
|
extension_new(extension->context, NULL);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
66
pipewire/modules/extension-protocol-native.c
Normal file
66
pipewire/modules/extension-protocol-native.c
Normal file
|
|
@ -0,0 +1,66 @@
|
||||||
|
/* PipeWire
|
||||||
|
* Copyright (C) 2017 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include "pipewire/client/interfaces.h"
|
||||||
|
#include "pipewire/client/context.h"
|
||||||
|
#include "pipewire/client/extension.h"
|
||||||
|
|
||||||
|
struct pw_protocol *pw_protocol_native_init(void);
|
||||||
|
|
||||||
|
struct impl {
|
||||||
|
struct pw_context *context;
|
||||||
|
struct pw_properties *properties;
|
||||||
|
};
|
||||||
|
|
||||||
|
static struct impl *extension_new(struct pw_context *context, struct pw_properties *properties)
|
||||||
|
{
|
||||||
|
struct impl *impl;
|
||||||
|
|
||||||
|
impl = calloc(1, sizeof(struct impl));
|
||||||
|
pw_log_debug("extension %p: new", impl);
|
||||||
|
|
||||||
|
impl->context = context;
|
||||||
|
impl->properties = properties;
|
||||||
|
|
||||||
|
pw_protocol_native_init();
|
||||||
|
|
||||||
|
return impl;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
static void extension_destroy(struct impl *impl)
|
||||||
|
{
|
||||||
|
pw_log_debug("extension %p: destroy", impl);
|
||||||
|
|
||||||
|
free(impl);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool pipewire__extension_init(struct pw_extension *extension, const char *args)
|
||||||
|
{
|
||||||
|
extension_new(extension->context, NULL);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
@ -33,7 +33,10 @@ pipewire_module_mixer = shared_library('pipewire-module-mixer', [ 'module-mixer.
|
||||||
)
|
)
|
||||||
|
|
||||||
pipewire_module_client_node = shared_library('pipewire-module-client-node',
|
pipewire_module_client_node = shared_library('pipewire-module-client-node',
|
||||||
[ 'module-client-node.c', 'module-client-node/client-node.c' ],
|
[ 'module-client-node.c',
|
||||||
|
'module-client-node/client-node.c',
|
||||||
|
'module-client-node/protocol-native.c',
|
||||||
|
'extension-client-node.c', ],
|
||||||
c_args : pipewire_module_c_args,
|
c_args : pipewire_module_c_args,
|
||||||
include_directories : [configinc, spa_inc],
|
include_directories : [configinc, spa_inc],
|
||||||
link_with : spalib,
|
link_with : spalib,
|
||||||
|
|
@ -51,7 +54,10 @@ pipewire_module_client_node = shared_library('pipewire-module-client-node',
|
||||||
# dependencies : [glib_dep, gio_dep, mathlib, dl_lib, pipewire_dep, pipewirecore_dep],
|
# dependencies : [glib_dep, gio_dep, mathlib, dl_lib, pipewire_dep, pipewirecore_dep],
|
||||||
#)
|
#)
|
||||||
|
|
||||||
pipewire_module_protocol_native = shared_library('pipewire-module-protocol-native', [ 'module-protocol-native.c' ],
|
pipewire_module_protocol_native = shared_library('pipewire-module-protocol-native',
|
||||||
|
[ 'module-protocol-native.c',
|
||||||
|
'module-protocol-native/protocol-native.c',
|
||||||
|
'extension-protocol-native.c' ],
|
||||||
c_args : pipewire_module_c_args,
|
c_args : pipewire_module_c_args,
|
||||||
include_directories : [configinc, spa_inc],
|
include_directories : [configinc, spa_inc],
|
||||||
link_with : spalib,
|
link_with : spalib,
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,8 @@
|
||||||
#include "pipewire/server/module.h"
|
#include "pipewire/server/module.h"
|
||||||
#include "module-client-node/client-node.h"
|
#include "module-client-node/client-node.h"
|
||||||
|
|
||||||
|
struct pw_protocol *pw_protocol_native_ext_client_node_init(void);
|
||||||
|
|
||||||
struct impl {
|
struct impl {
|
||||||
struct pw_node_factory this;
|
struct pw_node_factory this;
|
||||||
struct pw_properties *properties;
|
struct pw_properties *properties;
|
||||||
|
|
@ -69,6 +71,8 @@ static struct impl *module_new(struct pw_core *core, struct pw_properties *prope
|
||||||
pw_signal_init(&impl->this.destroy_signal);
|
pw_signal_init(&impl->this.destroy_signal);
|
||||||
impl->this.create_node = create_node;
|
impl->this.create_node = create_node;
|
||||||
|
|
||||||
|
pw_protocol_native_ext_client_node_init();
|
||||||
|
|
||||||
spa_list_insert(core->node_factory_list.prev, &impl->this.link);
|
spa_list_insert(core->node_factory_list.prev, &impl->this.link);
|
||||||
|
|
||||||
pw_core_add_global(core, NULL, core->type.node_factory, 0, impl, NULL, &impl->this.global);
|
pw_core_add_global(core, NULL, core->type.node_factory, 0, impl, NULL, &impl->this.global);
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,12 @@
|
||||||
#define __PIPEWIRE_CLIENT_NODE_H__
|
#define __PIPEWIRE_CLIENT_NODE_H__
|
||||||
|
|
||||||
#include <pipewire/server/node.h>
|
#include <pipewire/server/node.h>
|
||||||
|
#include <pipewire/extensions/client-node.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define PIPEWIRE_TYPE__ClientNode PIPEWIRE_TYPE_NODE_BASE "Client"
|
|
||||||
#define PIPEWIRE_TYPE_CLIENT_NODE_BASE PIPEWIRE_TYPE__ClientNode ":"
|
|
||||||
|
|
||||||
/** \class pw_client_node
|
/** \class pw_client_node
|
||||||
*
|
*
|
||||||
* PipeWire client node interface
|
* PipeWire client node interface
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -34,7 +34,6 @@
|
||||||
#include "pipewire/client/interfaces.h"
|
#include "pipewire/client/interfaces.h"
|
||||||
|
|
||||||
#include "pipewire/server/core.h"
|
#include "pipewire/server/core.h"
|
||||||
#include "pipewire/server/protocol-native.h"
|
|
||||||
#include "pipewire/server/node.h"
|
#include "pipewire/server/node.h"
|
||||||
#include "pipewire/server/module.h"
|
#include "pipewire/server/module.h"
|
||||||
#include "pipewire/server/client.h"
|
#include "pipewire/server/client.h"
|
||||||
|
|
@ -51,6 +50,8 @@
|
||||||
#define LOCK_SUFFIX ".lock"
|
#define LOCK_SUFFIX ".lock"
|
||||||
#define LOCK_SUFFIXLEN 5
|
#define LOCK_SUFFIXLEN 5
|
||||||
|
|
||||||
|
struct pw_protocol *pw_protocol_native_init(void);
|
||||||
|
|
||||||
typedef bool(*demarshal_func_t) (void *object, void *data, size_t size);
|
typedef bool(*demarshal_func_t) (void *object, void *data, size_t size);
|
||||||
|
|
||||||
struct socket {
|
struct socket {
|
||||||
|
|
@ -69,6 +70,7 @@ struct impl {
|
||||||
struct pw_core *core;
|
struct pw_core *core;
|
||||||
struct spa_list link;
|
struct spa_list link;
|
||||||
|
|
||||||
|
struct pw_protocol *protocol;
|
||||||
struct pw_properties *properties;
|
struct pw_properties *properties;
|
||||||
|
|
||||||
struct spa_list socket_list;
|
struct spa_list socket_list;
|
||||||
|
|
@ -217,7 +219,7 @@ static struct native_client *client_new(struct impl *impl, int fd)
|
||||||
if (this->connection == NULL)
|
if (this->connection == NULL)
|
||||||
goto no_connection;
|
goto no_connection;
|
||||||
|
|
||||||
client->protocol = pw_protocol_native_server_init();
|
client->protocol = impl->protocol;
|
||||||
client->protocol_private = this->connection;
|
client->protocol_private = this->connection;
|
||||||
|
|
||||||
this->client = client;
|
this->client = client;
|
||||||
|
|
@ -397,6 +399,7 @@ static struct impl *pw_protocol_native_new(struct pw_core *core, struct pw_prope
|
||||||
|
|
||||||
impl->core = core;
|
impl->core = core;
|
||||||
impl->properties = properties;
|
impl->properties = properties;
|
||||||
|
impl->protocol = pw_protocol_native_init();
|
||||||
|
|
||||||
name = NULL;
|
name = NULL;
|
||||||
if (impl->properties)
|
if (impl->properties)
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -9,7 +9,6 @@ pipewirecore_headers = [
|
||||||
'node.h',
|
'node.h',
|
||||||
'node-factory.h',
|
'node-factory.h',
|
||||||
'port.h',
|
'port.h',
|
||||||
'protocol-native.h',
|
|
||||||
'resource.h',
|
'resource.h',
|
||||||
'work-queue.h',
|
'work-queue.h',
|
||||||
]
|
]
|
||||||
|
|
@ -25,7 +24,6 @@ pipewirecore_sources = [
|
||||||
'node.c',
|
'node.c',
|
||||||
'node-factory.c',
|
'node-factory.c',
|
||||||
'port.c',
|
'port.c',
|
||||||
'protocol-native.c',
|
|
||||||
'resource.c',
|
'resource.c',
|
||||||
'work-queue.c',
|
'work-queue.c',
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -1,22 +0,0 @@
|
||||||
/* PipeWire
|
|
||||||
* Copyright (C) 2017 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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "pipewire/client/pipewire.h"
|
|
||||||
|
|
||||||
struct pw_protocol *pw_protocol_native_server_init(void);
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue