doc updates

This commit is contained in:
Wim Taymans 2017-06-20 18:01:20 +02:00
parent 423d40f494
commit b608599220
13 changed files with 173 additions and 290 deletions

View file

@ -416,16 +416,6 @@ on_context_data(struct spa_loop_utils *utils,
} }
} }
/** Create a new unconnected context
*
* \param loop a \ref pw_loop to use as event loop
* \param name an application name
* \param properties optional properties, ownership of the properties is
* taken.
* \return a new unconnected context
*
* \memberof pw_context
*/
struct pw_context *pw_context_new(struct pw_loop *loop, struct pw_context *pw_context_new(struct pw_loop *loop,
const char *name, struct pw_properties *properties) const char *name, struct pw_properties *properties)
{ {
@ -487,12 +477,6 @@ struct pw_context *pw_context_new(struct pw_loop *loop,
return NULL; return NULL;
} }
/** Destroy a context
*
* \param context a \ref pw_context to destroy to destroy
*
* \memberof pw_context
*/
void pw_context_destroy(struct pw_context *context) 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);
@ -522,14 +506,6 @@ void pw_context_destroy(struct pw_context *context)
free(impl); free(impl);
} }
/** Connect to the PipeWire daemon
*
* \param context a \ref pw_context
* \param flags flags to use
* \return true on success.
*
* \memberof pw_context
*/
bool pw_context_connect(struct pw_context *context, enum pw_context_flags flags) bool pw_context_connect(struct pw_context *context, enum pw_context_flags flags)
{ {
struct sockaddr_un addr; struct sockaddr_un addr;
@ -577,15 +553,6 @@ bool pw_context_connect(struct pw_context *context, enum pw_context_flags flags)
return false; return false;
} }
/** Connect to the PipeWire daemon on the given socket
*
* \param context a \ref pw_context
* \param flags flags to use
* \param fd the connected socket to use
* \return true on success.
*
* \memberof pw_context
*/
bool pw_context_connect_fd(struct pw_context *context, enum pw_context_flags flags, int fd) bool pw_context_connect_fd(struct pw_context *context, enum pw_context_flags flags, int fd)
{ {
struct context *impl = SPA_CONTAINER_OF(context, struct context, this); struct context *impl = SPA_CONTAINER_OF(context, struct context, this);
@ -644,14 +611,7 @@ bool pw_context_connect_fd(struct pw_context *context, enum pw_context_flags fla
return false; return false;
} }
/** Disconnect from the daemon. void pw_context_disconnect(struct pw_context *context)
*
* \param context a \ref pw_context
* \return true on success.
*
* \memberof pw_context
*/
bool pw_context_disconnect(struct pw_context *context)
{ {
struct context *impl = SPA_CONTAINER_OF(context, struct context, this); struct context *impl = SPA_CONTAINER_OF(context, struct context, this);
@ -679,8 +639,6 @@ bool pw_context_disconnect(struct pw_context *context)
impl->fd = -1; impl->fd = -1;
context_set_state(context, PW_CONTEXT_STATE_UNCONNECTED, NULL); context_set_state(context, PW_CONTEXT_STATE_UNCONNECTED, NULL);
return true;
} }
/** Get core information /** Get core information

View file

@ -177,17 +177,28 @@ struct pw_context {
PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_context *context)); PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_context *context));
}; };
/** Create a new unconnected context \memberof pw_context
* \return a new unconnected context */
struct pw_context * struct pw_context *
pw_context_new(struct pw_loop *loop, pw_context_new(struct pw_loop *loop, /**< a \ref pw_loop to use as event loop */
const char *name, struct pw_properties *properties); const char *name, /**< an application name */
struct pw_properties *properties /**< optional properties, ownership of
* the properties is taken.*/ );
/** Destroy a context \memberof pw_context */
void pw_context_destroy(struct pw_context *context); void pw_context_destroy(struct pw_context *context);
/** Connect to the PipeWire daemon \memberof pw_context
* \return true on success. */
bool pw_context_connect(struct pw_context *context, enum pw_context_flags flags); bool pw_context_connect(struct pw_context *context, enum pw_context_flags flags);
/** Connect to the PipeWire daemon on the given socket \memberof pw_context
* \param fd the connected socket to use
* \return true on success. */
bool pw_context_connect_fd(struct pw_context *context, enum pw_context_flags flags, int fd); bool pw_context_connect_fd(struct pw_context *context, enum pw_context_flags flags, int fd);
bool pw_context_disconnect(struct pw_context *context); /** Disconnect from the daemon. \memberof pw_context */
void pw_context_disconnect(struct pw_context *context);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -178,15 +178,6 @@ const char *pw_stream_state_as_string(enum pw_stream_state state)
return "invalid-state"; return "invalid-state";
} }
/** Create a new unconneced \ref pw_stream
*
* \param context a \ref pw_context
* \param name a stream name
* \param props stream properties, ownership is taken
* \return a newly allocated \ref pw_stream
*
* \memberof pw_stream
*/
struct pw_stream *pw_stream_new(struct pw_context *context, struct pw_stream *pw_stream_new(struct pw_context *context,
const char *name, struct pw_properties *props) const char *name, struct pw_properties *props)
{ {
@ -293,10 +284,6 @@ static void set_params(struct pw_stream *stream, int n_params, struct spa_param
} }
} }
/** Destroy a stream
* \param stream the stream to destroy
* \memberof pw_stream
*/
void pw_stream_destroy(struct pw_stream *stream) void pw_stream_destroy(struct pw_stream *stream)
{ {
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
@ -889,22 +876,6 @@ static void on_node_proxy_destroy(struct pw_listener *listener, struct pw_proxy
stream_set_state(this, PW_STREAM_STATE_UNCONNECTED, NULL); stream_set_state(this, PW_STREAM_STATE_UNCONNECTED, NULL);
} }
/** Connect a stream for input or output on \a port_path.
* \param stream a \ref pw_stream
* \param direction the stream direction
* \param mode a \ref pw_stream_mode
* \param port_path the port path to connect to or NULL to let the server choose a port
* \param flags a \ref pw_stream
* \param n_possible_formats number of items in \a possible_formats
* \param possible_formats an array with possible accepted formats
* \return true on success.
*
* When \a mode is \ref PW_STREAM_MODE_BUFFER, you should connect to the new-buffer
* signal and use pw_stream_peek_buffer() to get the latest metadata and
* data.
*
* \memberof pw_stream
*/
bool bool
pw_stream_connect(struct pw_stream *stream, pw_stream_connect(struct pw_stream *stream,
enum pw_direction direction, enum pw_direction direction,
@ -954,24 +925,7 @@ pw_stream_connect(struct pw_stream *stream,
return true; return true;
} }
/** Complete the negotiation process with result code \a res void
* \param stream a \ref pw_stream
* \param res a result code
* \param params an array of pointers to \ref spa_param
* \param n_params number of elements in \a params
*
* Complete the negotiation process with result code \a res.
*
* This function should be called after notification of the format.
* When \a res indicates success, \a params contain the parameters for the
* allocation state.
*
* Returns: %true on success
*
* \memberof pw_stream
*/
bool
pw_stream_finish_format(struct pw_stream *stream, pw_stream_finish_format(struct pw_stream *stream,
int res, struct spa_param **params, uint32_t n_params) int res, struct spa_param **params, uint32_t n_params)
{ {
@ -991,17 +945,9 @@ pw_stream_finish_format(struct pw_stream *stream,
add_async_complete(stream, impl->pending_seq, res); add_async_complete(stream, impl->pending_seq, res);
impl->pending_seq = SPA_ID_INVALID; impl->pending_seq = SPA_ID_INVALID;
return true;
} }
/** Disconnect \a stream void pw_stream_disconnect(struct pw_stream *stream)
* \param stream: a \ref pw_stream
* \return true on success
*
* \memberof pw_stream
*/
bool pw_stream_disconnect(struct pw_stream *stream)
{ {
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
@ -1013,8 +959,6 @@ bool pw_stream_disconnect(struct pw_stream *stream)
pw_client_node_do_destroy(impl->node_proxy); pw_client_node_do_destroy(impl->node_proxy);
impl->node_proxy = NULL; impl->node_proxy = NULL;
} }
return true;
} }
bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time) bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
@ -1033,14 +977,6 @@ bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time)
return true; return true;
} }
/** Get the id of an empty buffer that can be filled
*
* \param stream: a \ref pw_stream
* \return the id of an empty buffer or \ref SPA_ID_INVALID when no buffer is
* available.
*
* \memberof pw_stream
*/
uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream) uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream)
{ {
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
@ -1054,15 +990,6 @@ uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream)
return bid->id; return bid->id;
} }
/** Recycle the buffer with \a id
* \param stream: a \ref pw_stream
* \param id: a buffer id
* \return true on success
*
* Let the PipeWire server know that it can reuse the buffer with \a id.
*
* \memberof pw_stream
*/
bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id) bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id)
{ {
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);
@ -1083,15 +1010,6 @@ bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id)
return true; return true;
} }
/** Get the buffer with \a id from \a stream
* \param stream: a \ref pw_stream
* \param id: the buffer id
* \return a \ref spa_buffer or NULL when there is no buffer
*
* This function should be called from the new-buffer signal callback.
*
* \memberof pw_stream
*/
struct spa_buffer *pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id) struct spa_buffer *pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id)
{ {
struct buffer_id *bid; struct buffer_id *bid;
@ -1102,16 +1020,6 @@ struct spa_buffer *pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id)
return NULL; return NULL;
} }
/** Send a buffer with \a id to \a stream
* \param stream a \ref pw_stream
* \param id a buffer id
* \return true when \a id was handled
*
* For provider or playback streams, this function should be called whenever
* there is a new frame available.
*
* \memberof pw_stream
*/
bool pw_stream_send_buffer(struct pw_stream *stream, uint32_t id) bool pw_stream_send_buffer(struct pw_stream *stream, uint32_t id)
{ {
struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this);

View file

@ -238,42 +238,73 @@ struct pw_stream {
PW_SIGNAL(need_buffer, (struct pw_listener *listener, struct pw_stream *stream)); PW_SIGNAL(need_buffer, (struct pw_listener *listener, struct pw_stream *stream));
}; };
/** Create a new unconneced \ref pw_stream \memberof pw_stream
* \return a newly allocated \ref pw_stream */
struct pw_stream * struct pw_stream *
pw_stream_new(struct pw_context *context, pw_stream_new(struct pw_context *context, /**< a \ref pw_context */
const char *name, const char *name, /**< a stream name */
struct pw_properties *props); struct pw_properties *props /**< stream properties, ownership is taken */);
/** Destroy a stream \memberof pw_stream */
void pw_stream_destroy(struct pw_stream *stream);
/** Connect a stream for input or output on \a port_path. \memberof pw_stream
* \return true on success.
*
* When \a mode is \ref PW_STREAM_MODE_BUFFER, you should connect to the new-buffer
* signal and use pw_stream_peek_buffer() to get the latest metadata and
* data. */
bool
pw_stream_connect(struct pw_stream *stream, /**< a \ref pw_stream */
enum pw_direction direction, /**< the stream direction */
enum pw_stream_mode mode, /**< a \ref pw_stream_mode */
const char *port_path, /**< the port path to connect to or NULL
* to let the server choose a port */
enum pw_stream_flags flags, /**< stream flags */
uint32_t n_possible_formats, /**< number of items in \a possible_formats */
struct spa_format **possible_formats /**< an array with possible accepted formats */);
/** Disconnect \a stream \memberof pw_stream */
void pw_stream_disconnect(struct pw_stream *stream);
/** Complete the negotiation process with result code \a res \memberof pw_stream
*
* This function should be called after notification of the format.
* When \a res indicates success, \a params contain the parameters for the
* allocation state. */
void void
pw_stream_destroy(struct pw_stream *stream); pw_stream_finish_format(struct pw_stream *stream, /**< a \ref pw_stream */
int res, /**< a result code */
struct spa_param **params, /**< an array of pointers to \ref spa_param */
uint32_t n_params /**< number of elements in \a params */);
bool /** Query the time on the stream \memberof pw_stream */
pw_stream_connect(struct pw_stream *stream, bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time);
enum pw_direction direction,
enum pw_stream_mode mode,
const char *port_path,
enum pw_stream_flags flags,
uint32_t n_possible_formats,
struct spa_format **possible_formats);
bool
pw_stream_disconnect(struct pw_stream *stream);
bool /** Get the id of an empty buffer that can be filled \memberof pw_stream
pw_stream_finish_format(struct pw_stream *stream, * \return the id of an empty buffer or \ref SPA_ID_INVALID when no buffer is
int res, struct spa_param **params, uint32_t n_params); * available. */
uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream);
bool /** Recycle the buffer with \a id \memberof pw_stream
pw_stream_get_time(struct pw_stream *stream, struct pw_time *time); * \return true on success, false when \a id is invalid or not a used buffer
* Let the PipeWire server know that it can reuse the buffer with \a id. */
uint32_t bool pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id);
pw_stream_get_empty_buffer(struct pw_stream *stream);
bool
pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id);
/** Get the buffer with \a id from \a stream \memberof pw_stream
* \return a \ref spa_buffer or NULL when there is no buffer
*
* This function should be called from the new-buffer signal callback. */
struct spa_buffer * struct spa_buffer *
pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id); pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id);
bool /** Send a buffer with \a id to \a stream \memberof pw_stream
pw_stream_send_buffer(struct pw_stream *stream, uint32_t id); * \return true when \a id was handled, false on error
*
* For provider or playback streams, this function should be called whenever
* there is a new buffer available. */
bool pw_stream_send_buffer(struct pw_stream *stream, uint32_t id);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -1,7 +1,7 @@
#load-module libpipewire-module-protocol-dbus #load-module libpipewire-module-protocol-dbus
load-module libpipewire-module-protocol-native load-module libpipewire-module-protocol-native
load-module libpipewire-module-suspend-on-idle load-module libpipewire-module-suspend-on-idle
#load-module libpipewire-module-spa-monitor alsa/libspa-alsa alsa-monitor alsa load-module libpipewire-module-spa-monitor alsa/libspa-alsa alsa-monitor alsa
load-module libpipewire-module-spa-monitor v4l2/libspa-v4l2 v4l2-monitor v4l2 load-module libpipewire-module-spa-monitor v4l2/libspa-v4l2 v4l2-monitor v4l2
#load-module libpipewire-module-spa-node videotestsrc/libspa-videotestsrc videotestsrc videotestsrc media.class=Video/Source Spa:POD:Object:Props:patternType=Spa:POD:Object:Props:patternType:snow #load-module libpipewire-module-spa-node videotestsrc/libspa-videotestsrc videotestsrc videotestsrc media.class=Video/Source Spa:POD:Object:Props:patternType=Spa:POD:Object:Props:patternType:snow
load-module libpipewire-module-autolink load-module libpipewire-module-autolink

View file

@ -125,7 +125,6 @@ struct impl {
struct pw_listener node_free; struct pw_listener node_free;
struct pw_listener initialized; struct pw_listener initialized;
struct pw_listener loop_changed;
struct pw_listener global_added; struct pw_listener global_added;
int fds[2]; int fds[2];
@ -1059,12 +1058,6 @@ static void on_initialized(struct pw_listener *listener, struct pw_node *node)
pw_client_node_notify_transport(this->resource, readfd, writefd, info.memfd, info.offset, info.size); pw_client_node_notify_transport(this->resource, readfd, writefd, info.memfd, info.offset, info.size);
} }
static void on_loop_changed(struct pw_listener *listener, struct pw_node *node)
{
struct impl *impl = SPA_CONTAINER_OF(listener, struct impl, loop_changed);
impl->proxy.data_loop = node->data_loop->loop->loop;
}
static void static void
on_global_added(struct pw_listener *listener, struct pw_core *core, struct pw_global *global) on_global_added(struct pw_listener *listener, struct pw_core *core, struct pw_global *global)
{ {
@ -1102,7 +1095,6 @@ static void client_node_resource_destroy(struct pw_resource *resource)
impl->proxy.resource = this->resource = NULL; impl->proxy.resource = this->resource = NULL;
pw_signal_remove(&impl->global_added); pw_signal_remove(&impl->global_added);
pw_signal_remove(&impl->loop_changed);
pw_signal_remove(&impl->initialized); pw_signal_remove(&impl->initialized);
if (proxy->data_source.fd != -1) if (proxy->data_source.fd != -1)
@ -1188,7 +1180,6 @@ struct pw_client_node *pw_client_node_new(struct pw_client *client,
pw_signal_add(&this->node->free_signal, &impl->node_free, on_node_free); pw_signal_add(&this->node->free_signal, &impl->node_free, on_node_free);
pw_signal_add(&this->node->initialized, &impl->initialized, on_initialized); pw_signal_add(&this->node->initialized, &impl->initialized, on_initialized);
pw_signal_add(&this->node->loop_changed, &impl->loop_changed, on_loop_changed);
pw_signal_add(&impl->core->global_added, &impl->global_added, on_global_added); pw_signal_add(&impl->core->global_added, &impl->global_added, on_global_added);
return this; return this;

View file

@ -53,6 +53,8 @@ struct pw_global;
* *
* \subpage page_node * \subpage page_node
* *
* \subpage page_port
*
* \subpage page_link * \subpage page_link
*/ */

View file

@ -892,17 +892,6 @@ link_bind_func(struct pw_global *global, struct pw_client *client, uint32_t vers
return SPA_RESULT_NO_MEMORY; return SPA_RESULT_NO_MEMORY;
} }
/** Create a new link
* \param core the core class
* \param output an output port
* \param input an input port
* \param format_filter a format filter
* \param properties extra properties
*
* Make a link between \a output and \a input
*
* \memberof pw_link
*/
struct pw_link *pw_link_new(struct pw_core *core, struct pw_link *pw_link_new(struct pw_core *core,
struct pw_port *output, struct pw_port *output,
struct pw_port *input, struct pw_port *input,
@ -1041,13 +1030,6 @@ do_link_remove(struct spa_loop *loop,
return res; return res;
} }
/** Destroy a link
* \param link the link to destroy
*
* Trigger removal of \a link
*
* \memberof pw_link
*/
void pw_link_destroy(struct pw_link *link) void pw_link_destroy(struct pw_link *link)
{ {
struct impl *impl = SPA_CONTAINER_OF(link, struct impl, this); struct impl *impl = SPA_CONTAINER_OF(link, struct impl, this);

View file

@ -87,21 +87,25 @@ struct pw_link {
}; };
/** Make a new link between two ports \memberof pw_link
* \return a newly allocated link */
struct pw_link * struct pw_link *
pw_link_new(struct pw_core *core, pw_link_new(struct pw_core *core, /**< the core object */
struct pw_port *output, struct pw_port *output, /**< an output port */
struct pw_port *input, struct pw_port *input, /**< an input port */
struct spa_format *format_filter, struct spa_format *format_filter, /**< an optional format filter */
struct pw_properties *properties); struct pw_properties *properties /**< extra properties */);
void /** Destroy a link \memberof pw_link */
pw_link_destroy(struct pw_link *link); void pw_link_destroy(struct pw_link *link);
bool /** Activate a link \memberof pw_link
pw_link_activate(struct pw_link *link); * Starts the negotiation of formats and buffers on \a link and then
* starts data streaming */
bool pw_link_activate(struct pw_link *link);
bool /** Deactivate a link \memberof pw_link */
pw_link_deactivate(struct pw_link *link); bool pw_link_deactivate(struct pw_link *link);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -509,12 +509,6 @@ static void init_complete(struct pw_node *this)
pw_node_update_state(this, PW_NODE_STATE_SUSPENDED, NULL); pw_node_update_state(this, PW_NODE_STATE_SUSPENDED, NULL);
} }
void pw_node_set_data_loop(struct pw_node *node, struct pw_data_loop *loop)
{
node->data_loop = loop;
pw_signal_emit(&node->loop_changed, node);
}
static const struct spa_node_callbacks node_callbacks = { static const struct spa_node_callbacks node_callbacks = {
SPA_VERSION_NODE_CALLBACKS, SPA_VERSION_NODE_CALLBACKS,
&on_node_done, &on_node_done,
@ -565,7 +559,6 @@ struct pw_node *pw_node_new(struct pw_core *core,
pw_signal_init(&this->free_signal); pw_signal_init(&this->free_signal);
pw_signal_init(&this->async_complete); pw_signal_init(&this->async_complete);
pw_signal_init(&this->initialized); pw_signal_init(&this->initialized);
pw_signal_init(&this->loop_changed);
this->info.state = PW_NODE_STATE_CREATING; this->info.state = PW_NODE_STATE_CREATING;

View file

@ -54,77 +54,82 @@ extern "C" {
* PipeWire node class. * PipeWire node class.
*/ */
struct pw_node { struct pw_node {
struct pw_core *core; struct pw_core *core; /**< core object */
struct spa_list link; struct spa_list link; /**< link in core node_list */
struct pw_global *global; struct pw_global *global; /**< global for this node */
struct pw_client *owner; struct pw_client *owner; /**< owner client if any */
struct pw_properties *properties; struct pw_properties *properties; /**< properties of the node */
struct pw_node_info info; struct pw_node_info info; /**< introspectable node info */
/** Emited when a state change is started */
PW_SIGNAL(state_request, (struct pw_listener *listener, PW_SIGNAL(state_request, (struct pw_listener *listener,
struct pw_node *object, enum pw_node_state state)); struct pw_node *object, enum pw_node_state state));
/** Emited when a stat change is completed */
PW_SIGNAL(state_changed, (struct pw_listener *listener, PW_SIGNAL(state_changed, (struct pw_listener *listener,
struct pw_node *object, struct pw_node *object,
enum pw_node_state old, enum pw_node_state state)); enum pw_node_state old, enum pw_node_state state));
struct spa_handle *handle; struct spa_handle *handle; /**< handle to SPA factory */
struct spa_node *node; struct spa_node *node; /**< handle to SPA node */
bool live; bool live; /**< if the node is live */
struct spa_clock *clock; struct spa_clock *clock; /**< handle to SPA clock if any */
struct spa_list resource_list; struct spa_list resource_list; /**< list of resources for this node */
/** Emited when the node is initialized */
PW_SIGNAL(initialized, (struct pw_listener *listener, struct pw_node *object)); PW_SIGNAL(initialized, (struct pw_listener *listener, struct pw_node *object));
struct spa_list input_ports; struct spa_list input_ports; /**< list of input ports */
struct pw_port **input_port_map; struct pw_port **input_port_map; /**< map from port_id to port */
uint32_t n_used_input_links; uint32_t n_used_input_links; /**< number of active input links */
struct spa_list output_ports; struct spa_list output_ports; /**< list of output ports */
struct pw_port **output_port_map; struct pw_port **output_port_map; /**< map from port_id to port */
uint32_t n_used_output_links; uint32_t n_used_output_links; /**< number of active output links */
/** Emited when a new port is added */
PW_SIGNAL(port_added, (struct pw_listener *listener, PW_SIGNAL(port_added, (struct pw_listener *listener,
struct pw_node *node, struct pw_port *port)); struct pw_node *node, struct pw_port *port));
/** Emited when a port is removed */
PW_SIGNAL(port_removed, (struct pw_listener *listener, PW_SIGNAL(port_removed, (struct pw_listener *listener,
struct pw_node *node, struct pw_port *port)); struct pw_node *node, struct pw_port *port));
/** Emited when the node is destroyed */
PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_node *object)); PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_node *object));
/** Emited when the node is free */
PW_SIGNAL(free_signal, (struct pw_listener *listener, struct pw_node *object)); PW_SIGNAL(free_signal, (struct pw_listener *listener, struct pw_node *object));
/** an async operation on the node completed */
PW_SIGNAL(async_complete, (struct pw_listener *listener, PW_SIGNAL(async_complete, (struct pw_listener *listener,
struct pw_node *node, uint32_t seq, int res)); struct pw_node *node, uint32_t seq, int res));
struct pw_data_loop *data_loop; struct pw_data_loop *data_loop; /**< the data loop for this node */
PW_SIGNAL(loop_changed, (struct pw_listener *listener, struct pw_node *object));
}; };
/** Create a new node \memberof pw_node */
struct pw_node * struct pw_node *
pw_node_new(struct pw_core *core, pw_node_new(struct pw_core *core, /**< the core */
struct pw_client *owner, struct pw_client *owner, /**< optional owner */
const char *name, const char *name, /**< node name */
bool async, bool async, /**< if the node will initialize async */
struct spa_node *node, struct spa_node *node, /**< the node */
struct spa_clock *clock, struct spa_clock *clock, /**< optional clock */
struct pw_properties *properties); struct pw_properties *properties /**< extra properties */);
void /** Destroy a node */
pw_node_destroy(struct pw_node *node); void pw_node_destroy(struct pw_node *node);
void
pw_node_set_data_loop(struct pw_node *node, struct pw_data_loop *loop);
/** Get a free unused port from the node */
struct pw_port * struct pw_port *
pw_node_get_free_port(struct pw_node *node, enum pw_direction direction); pw_node_get_free_port(struct pw_node *node, enum pw_direction direction);
int /** Change the state of the node */
pw_node_set_state(struct pw_node *node, enum pw_node_state state); int pw_node_set_state(struct pw_node *node, enum pw_node_state state);
void /** Update the state of the node, mostly used by node implementations */
pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *error); void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *error);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -97,20 +97,6 @@ static struct pw_link *find_link(struct pw_port *output_port, struct pw_port *in
return NULL; return NULL;
} }
/** Link two ports
* \param output_port an output port
* \param input_port an input port
* \param format_filter a format filter
* \param properties extra properties
* \param error an error or NULL
* \return a newly allocated \ref pw_link or NULL and \a error is set.
*
* Make a link between \a output_port and \a input_port
*
* If the ports were already linked, the existing link will be returned.
*
* \memberof pw_port
*/
struct pw_link *pw_port_link(struct pw_port *output_port, struct pw_link *pw_port_link(struct pw_port *output_port,
struct pw_port *input_port, struct pw_port *input_port,
struct spa_format *format_filter, struct spa_format *format_filter,

View file

@ -44,55 +44,67 @@ enum pw_port_state {
PW_PORT_STATE_STREAMING = 4, PW_PORT_STATE_STREAMING = 4,
}; };
/** \page page_port Port
*
* \section page_node_overview Overview
*
* A port can be used to link two nodes.
*/
/** \class pw_port /** \class pw_port
* *
* The port object * The port object
*/ */
struct pw_port { struct pw_port {
struct spa_list link; struct spa_list link; /**< link in node port_list */
PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_port *)); PW_SIGNAL(destroy_signal, (struct pw_listener *listener, struct pw_port *));
struct pw_node *node; struct pw_node *node; /**< owner node */
enum pw_direction direction; enum pw_direction direction; /**< port direction */
uint32_t port_id; uint32_t port_id; /**< port id */
enum pw_port_state state; enum pw_port_state state; /**< state of the port */
struct spa_port_io io; struct spa_port_io io; /**< io area of the port */
bool allocated; bool allocated; /**< if buffers are allocated */
struct pw_memblock buffer_mem; struct pw_memblock buffer_mem; /**< allocated buffer memory */
struct spa_buffer **buffers; struct spa_buffer **buffers; /**< port buffers */
uint32_t n_buffers; uint32_t n_buffers; /**< number of port buffers */
struct spa_list links; struct spa_list links; /**< list of \ref pw_link */
struct { struct {
struct spa_list links; struct spa_list links; /**< list of \ref pw_link only accessed from the
} rt; * data thread */
} rt; /**< data only accessed from the data thread */
}; };
/** Create a new port \memberof pw_port
* \return a newly allocated port */
struct pw_port * struct pw_port *
pw_port_new(struct pw_node *node, enum pw_direction direction, uint32_t port_id); pw_port_new(struct pw_node *node, enum pw_direction direction, uint32_t port_id);
void /** Destroy a port \memberof pw_port */
pw_port_destroy(struct pw_port *port); void pw_port_destroy(struct pw_port *port);
/** Link two ports with an optional filter \memberof pw_port
* \return a newly allocated \ref pw_link or NULL and \a error is set.
*
* If the ports were already linked, the existing link will be returned. */
struct pw_link * struct pw_link *
pw_port_link(struct pw_port *output_port, pw_port_link(struct pw_port *output_port, /**< output port */
struct pw_port *input_port, struct pw_port *input_port, /**< input port */
struct spa_format *format_filter, struct spa_format *format_filter, /**< optional filter */
struct pw_properties *properties, struct pw_properties *properties, /**< extra properties */
char **error); char **error /**< result error message or NULL */);
int /** Unlink a port \memberof pw_port */
pw_port_unlink(struct pw_port *port, struct pw_link *link); int pw_port_unlink(struct pw_port *port, struct pw_link *link);
int /** Pause a port, should be called from data thread \memberof pw_port */
pw_port_pause_rt(struct pw_port *port); int pw_port_pause_rt(struct pw_port *port);
int /** Clear the buffers on a port \memberof pw_port */
pw_port_clear_buffers(struct pw_port *port); int pw_port_clear_buffers(struct pw_port *port);
#ifdef __cplusplus #ifdef __cplusplus
} }