diff --git a/pipewire/client/context.c b/pipewire/client/context.c index 5dd250fad..509664f52 100644 --- a/pipewire/client/context.c +++ b/pipewire/client/context.c @@ -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, const char *name, struct pw_properties *properties) { @@ -487,12 +477,6 @@ struct pw_context *pw_context_new(struct pw_loop *loop, 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) { struct context *impl = SPA_CONTAINER_OF(context, struct context, this); @@ -522,14 +506,6 @@ void pw_context_destroy(struct pw_context *context) 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) { struct sockaddr_un addr; @@ -577,15 +553,6 @@ bool pw_context_connect(struct pw_context *context, enum pw_context_flags flags) 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) { 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; } -/** Disconnect from the daemon. - * - * \param context a \ref pw_context - * \return true on success. - * - * \memberof pw_context - */ -bool pw_context_disconnect(struct pw_context *context) +void pw_context_disconnect(struct pw_context *context) { 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; context_set_state(context, PW_CONTEXT_STATE_UNCONNECTED, NULL); - - return true; } /** Get core information diff --git a/pipewire/client/context.h b/pipewire/client/context.h index 9b8df2041..fe251f6d1 100644 --- a/pipewire/client/context.h +++ b/pipewire/client/context.h @@ -177,17 +177,28 @@ struct pw_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 * -pw_context_new(struct pw_loop *loop, - const char *name, struct pw_properties *properties); +pw_context_new(struct pw_loop *loop, /**< a \ref pw_loop to use as event loop */ + 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); +/** 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); +/** 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_disconnect(struct pw_context *context); +/** Disconnect from the daemon. \memberof pw_context */ +void pw_context_disconnect(struct pw_context *context); #ifdef __cplusplus } diff --git a/pipewire/client/stream.c b/pipewire/client/stream.c index f84eeb767..cdd968a8e 100644 --- a/pipewire/client/stream.c +++ b/pipewire/client/stream.c @@ -178,15 +178,6 @@ const char *pw_stream_state_as_string(enum pw_stream_state 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, 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) { 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); } -/** 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 pw_stream_connect(struct pw_stream *stream, enum pw_direction direction, @@ -954,24 +925,7 @@ pw_stream_connect(struct pw_stream *stream, return true; } -/** Complete the negotiation process with result code \a res - * \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 +void pw_stream_finish_format(struct pw_stream *stream, 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); impl->pending_seq = SPA_ID_INVALID; - - return true; } -/** Disconnect \a stream - * \param stream: a \ref pw_stream - * \return true on success - * - * \memberof pw_stream - */ -bool pw_stream_disconnect(struct pw_stream *stream) +void pw_stream_disconnect(struct pw_stream *stream) { 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); impl->node_proxy = NULL; } - - return true; } 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; } -/** 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) { 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; } -/** 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) { 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; } -/** 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 buffer_id *bid; @@ -1102,16 +1020,6 @@ struct spa_buffer *pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id) 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) { struct stream *impl = SPA_CONTAINER_OF(stream, struct stream, this); diff --git a/pipewire/client/stream.h b/pipewire/client/stream.h index 7293f9c2d..c34107236 100644 --- a/pipewire/client/stream.h +++ b/pipewire/client/stream.h @@ -238,42 +238,73 @@ struct pw_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 * -pw_stream_new(struct pw_context *context, - const char *name, - struct pw_properties *props); +pw_stream_new(struct pw_context *context, /**< a \ref pw_context */ + const char *name, /**< a stream name */ + 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 -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 -pw_stream_connect(struct pw_stream *stream, - 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); +/** Query the time on the stream \memberof pw_stream */ +bool pw_stream_get_time(struct pw_stream *stream, struct pw_time *time); -bool -pw_stream_finish_format(struct pw_stream *stream, - int res, struct spa_param **params, uint32_t n_params); +/** Get the id of an empty buffer that can be filled \memberof pw_stream + * \return the id of an empty buffer or \ref SPA_ID_INVALID when no buffer is + * available. */ +uint32_t pw_stream_get_empty_buffer(struct pw_stream *stream); -bool -pw_stream_get_time(struct pw_stream *stream, struct pw_time *time); - -uint32_t -pw_stream_get_empty_buffer(struct pw_stream *stream); - -bool -pw_stream_recycle_buffer(struct pw_stream *stream, uint32_t id); +/** Recycle the buffer with \a id \memberof pw_stream + * \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. */ +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 * pw_stream_peek_buffer(struct pw_stream *stream, uint32_t id); -bool -pw_stream_send_buffer(struct pw_stream *stream, uint32_t id); +/** Send a buffer with \a id to \a stream \memberof pw_stream + * \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 } diff --git a/pipewire/daemon/pipewire.conf.in b/pipewire/daemon/pipewire.conf.in index fd8810225..a6365c7d1 100644 --- a/pipewire/daemon/pipewire.conf.in +++ b/pipewire/daemon/pipewire.conf.in @@ -1,7 +1,7 @@ #load-module libpipewire-module-protocol-dbus load-module libpipewire-module-protocol-native 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-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 diff --git a/pipewire/server/client-node.c b/pipewire/server/client-node.c index dc3956a31..f6d4bdc88 100644 --- a/pipewire/server/client-node.c +++ b/pipewire/server/client-node.c @@ -125,7 +125,6 @@ struct impl { struct pw_listener node_free; struct pw_listener initialized; - struct pw_listener loop_changed; struct pw_listener global_added; 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); } -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 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; pw_signal_remove(&impl->global_added); - pw_signal_remove(&impl->loop_changed); pw_signal_remove(&impl->initialized); 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->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); return this; diff --git a/pipewire/server/core.h b/pipewire/server/core.h index d21b7efdc..304c3a723 100644 --- a/pipewire/server/core.h +++ b/pipewire/server/core.h @@ -53,6 +53,8 @@ struct pw_global; * * \subpage page_node * + * \subpage page_port + * * \subpage page_link */ diff --git a/pipewire/server/link.c b/pipewire/server/link.c index 6ae61fb44..e6ad52562 100644 --- a/pipewire/server/link.c +++ b/pipewire/server/link.c @@ -892,17 +892,6 @@ link_bind_func(struct pw_global *global, struct pw_client *client, uint32_t vers 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_port *output, struct pw_port *input, @@ -1041,13 +1030,6 @@ do_link_remove(struct spa_loop *loop, 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) { struct impl *impl = SPA_CONTAINER_OF(link, struct impl, this); diff --git a/pipewire/server/link.h b/pipewire/server/link.h index a1d98e667..a3a4411a3 100644 --- a/pipewire/server/link.h +++ b/pipewire/server/link.h @@ -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 * -pw_link_new(struct pw_core *core, - struct pw_port *output, - struct pw_port *input, - struct spa_format *format_filter, - struct pw_properties *properties); +pw_link_new(struct pw_core *core, /**< the core object */ + struct pw_port *output, /**< an output port */ + struct pw_port *input, /**< an input port */ + struct spa_format *format_filter, /**< an optional format filter */ + struct pw_properties *properties /**< extra properties */); -void -pw_link_destroy(struct pw_link *link); +/** Destroy a link \memberof pw_link */ +void pw_link_destroy(struct pw_link *link); -bool -pw_link_activate(struct pw_link *link); +/** Activate a link \memberof pw_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 -pw_link_deactivate(struct pw_link *link); +/** Deactivate a link \memberof pw_link */ +bool pw_link_deactivate(struct pw_link *link); #ifdef __cplusplus } diff --git a/pipewire/server/node.c b/pipewire/server/node.c index e535a4d4f..fb42d117a 100644 --- a/pipewire/server/node.c +++ b/pipewire/server/node.c @@ -509,12 +509,6 @@ static void init_complete(struct pw_node *this) 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 = { SPA_VERSION_NODE_CALLBACKS, &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->async_complete); pw_signal_init(&this->initialized); - pw_signal_init(&this->loop_changed); this->info.state = PW_NODE_STATE_CREATING; diff --git a/pipewire/server/node.h b/pipewire/server/node.h index 6b326ce74..f67747b91 100644 --- a/pipewire/server/node.h +++ b/pipewire/server/node.h @@ -54,77 +54,82 @@ extern "C" { * PipeWire node class. */ struct pw_node { - struct pw_core *core; - struct spa_list link; - struct pw_global *global; + struct pw_core *core; /**< core object */ + struct spa_list link; /**< link in core node_list */ + struct pw_global *global; /**< global for this node */ - struct pw_client *owner; - struct pw_properties *properties; + struct pw_client *owner; /**< owner client if any */ + 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, struct pw_node *object, enum pw_node_state state)); + /** Emited when a stat change is completed */ PW_SIGNAL(state_changed, (struct pw_listener *listener, struct pw_node *object, enum pw_node_state old, enum pw_node_state state)); - struct spa_handle *handle; - struct spa_node *node; - bool live; - struct spa_clock *clock; + struct spa_handle *handle; /**< handle to SPA factory */ + struct spa_node *node; /**< handle to SPA node */ + bool live; /**< if the node is live */ + 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)); - struct spa_list input_ports; - struct pw_port **input_port_map; - uint32_t n_used_input_links; + struct spa_list input_ports; /**< list of input ports */ + struct pw_port **input_port_map; /**< map from port_id to port */ + uint32_t n_used_input_links; /**< number of active input links */ - struct spa_list output_ports; - struct pw_port **output_port_map; - uint32_t n_used_output_links; + struct spa_list output_ports; /**< list of output ports */ + struct pw_port **output_port_map; /**< map from port_id to port */ + 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, struct pw_node *node, struct pw_port *port)); + /** Emited when a port is removed */ PW_SIGNAL(port_removed, (struct pw_listener *listener, 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)); + /** Emited when the node is free */ 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, struct pw_node *node, uint32_t seq, int res)); - struct pw_data_loop *data_loop; - PW_SIGNAL(loop_changed, (struct pw_listener *listener, struct pw_node *object)); + struct pw_data_loop *data_loop; /**< the data loop for this node */ }; +/** Create a new node \memberof pw_node */ struct pw_node * -pw_node_new(struct pw_core *core, - struct pw_client *owner, - const char *name, - bool async, - struct spa_node *node, - struct spa_clock *clock, - struct pw_properties *properties); +pw_node_new(struct pw_core *core, /**< the core */ + struct pw_client *owner, /**< optional owner */ + const char *name, /**< node name */ + bool async, /**< if the node will initialize async */ + struct spa_node *node, /**< the node */ + struct spa_clock *clock, /**< optional clock */ + struct pw_properties *properties /**< extra properties */); -void -pw_node_destroy(struct pw_node *node); - - -void -pw_node_set_data_loop(struct pw_node *node, struct pw_data_loop *loop); +/** Destroy a node */ +void pw_node_destroy(struct pw_node *node); +/** Get a free unused port from the node */ struct pw_port * pw_node_get_free_port(struct pw_node *node, enum pw_direction direction); -int -pw_node_set_state(struct pw_node *node, enum pw_node_state state); +/** Change the state of the node */ +int pw_node_set_state(struct pw_node *node, enum pw_node_state state); -void -pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *error); +/** Update the state of the node, mostly used by node implementations */ +void pw_node_update_state(struct pw_node *node, enum pw_node_state state, char *error); #ifdef __cplusplus } diff --git a/pipewire/server/port.c b/pipewire/server/port.c index ccea2bfff..83716a08b 100644 --- a/pipewire/server/port.c +++ b/pipewire/server/port.c @@ -97,20 +97,6 @@ static struct pw_link *find_link(struct pw_port *output_port, struct pw_port *in 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_port *input_port, struct spa_format *format_filter, diff --git a/pipewire/server/port.h b/pipewire/server/port.h index 0986316e4..4cb12843e 100644 --- a/pipewire/server/port.h +++ b/pipewire/server/port.h @@ -44,55 +44,67 @@ enum pw_port_state { 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 * * The port object */ 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 *)); - struct pw_node *node; - enum pw_direction direction; - uint32_t port_id; - enum pw_port_state state; - struct spa_port_io io; + struct pw_node *node; /**< owner node */ + enum pw_direction direction; /**< port direction */ + uint32_t port_id; /**< port id */ + enum pw_port_state state; /**< state of the port */ + struct spa_port_io io; /**< io area of the port */ - bool allocated; - struct pw_memblock buffer_mem; - struct spa_buffer **buffers; - uint32_t n_buffers; + bool allocated; /**< if buffers are allocated */ + struct pw_memblock buffer_mem; /**< allocated buffer memory */ + struct spa_buffer **buffers; /**< port buffers */ + uint32_t n_buffers; /**< number of port buffers */ - struct spa_list links; + struct spa_list links; /**< list of \ref pw_link */ struct { - struct spa_list links; - } rt; + struct spa_list links; /**< list of \ref pw_link only accessed from the + * 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 * pw_port_new(struct pw_node *node, enum pw_direction direction, uint32_t port_id); -void -pw_port_destroy(struct pw_port *port); - +/** Destroy a port \memberof pw_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 * -pw_port_link(struct pw_port *output_port, - struct pw_port *input_port, - struct spa_format *format_filter, - struct pw_properties *properties, - char **error); +pw_port_link(struct pw_port *output_port, /**< output port */ + struct pw_port *input_port, /**< input port */ + struct spa_format *format_filter, /**< optional filter */ + struct pw_properties *properties, /**< extra properties */ + char **error /**< result error message or NULL */); -int -pw_port_unlink(struct pw_port *port, struct pw_link *link); +/** Unlink a port \memberof pw_port */ +int pw_port_unlink(struct pw_port *port, struct pw_link *link); -int -pw_port_pause_rt(struct pw_port *port); +/** Pause a port, should be called from data thread \memberof pw_port */ +int pw_port_pause_rt(struct pw_port *port); -int -pw_port_clear_buffers(struct pw_port *port); +/** Clear the buffers on a port \memberof pw_port */ +int pw_port_clear_buffers(struct pw_port *port); #ifdef __cplusplus }