1 /* PipeWire 2 * 3 * Copyright © 2018 Wim Taymans 4 * 5 * Permission is hereby granted, free of charge, to any person obtaining a 6 * copy of this software and associated documentation files (the "Software"), 7 * to deal in the Software without restriction, including without limitation 8 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9 * and/or sell copies of the Software, and to permit persons to whom the 10 * Software is furnished to do so, subject to the following conditions: 11 * 12 * The above copyright notice and this permission notice (including the next 13 * paragraph) shall be included in all copies or substantial portions of the 14 * Software. 15 * 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 * DEALINGS IN THE SOFTWARE. 23 */ 24 25 #ifndef PIPEWIRE_IMPL_LINK_H 26 #define PIPEWIRE_IMPL_LINK_H 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 /** \class pw_impl_link 33 * 34 * PipeWire link object. 35 */ 36 struct pw_impl_link; 37 struct pw_impl_port; 38 39 #include <pipewire/impl.h> 40 41 /** \page page_link Link 42 * 43 * \section page_link_overview Overview 44 * 45 * A link is the connection between 2 nodes (\ref page_node). Nodes are 46 * linked together on ports. 47 * 48 * The link is responsible for negotiating the format and buffers for 49 * the nodes. 50 */ 51 52 /** link events added with \ref pw_impl_link_add_listener */ 53 struct pw_impl_link_events { 54 #define PW_VERSION_IMPL_LINK_EVENTS 0 55 uint32_t version; 56 57 /** A link is destroyed */ 58 void (*destroy) (void *data); 59 60 /** A link is freed */ 61 void (*free) (void *data); 62 63 /** a Link is initialized */ 64 void (*initialized) (void *data); 65 66 /** The info changed on a link */ 67 void (*info_changed) (void *data, const struct pw_link_info *info); 68 69 /** The link state changed, \a error is only valid when the state is 70 * in error. */ 71 void (*state_changed) (void *data, enum pw_link_state old, 72 enum pw_link_state state, const char *error); 73 74 /** A port is unlinked */ 75 void (*port_unlinked) (void *data, struct pw_impl_port *port); 76 }; 77 78 79 /** Make a new link between two ports \memberof pw_impl_link 80 * \return a newly allocated link */ 81 struct pw_impl_link * 82 pw_context_create_link(struct pw_context *context, /**< the context object */ 83 struct pw_impl_port *output, /**< an output port */ 84 struct pw_impl_port *input, /**< an input port */ 85 struct spa_pod *format_filter, /**< an optional format filter */ 86 struct pw_properties *properties /**< extra properties */, 87 size_t user_data_size /**< extra user data size */); 88 89 /** Destroy a link \memberof pw_impl_link */ 90 void pw_impl_link_destroy(struct pw_impl_link *link); 91 92 /** Add an event listener to \a link */ 93 void pw_impl_link_add_listener(struct pw_impl_link *link, 94 struct spa_hook *listener, 95 const struct pw_impl_link_events *events, 96 void *data); 97 98 /** Finish link configuration and register */ 99 int pw_impl_link_register(struct pw_impl_link *link, /**< the link to register */ 100 struct pw_properties *properties /**< extra properties */); 101 102 /** Get the context of a link */ 103 struct pw_context *pw_impl_link_get_context(struct pw_impl_link *link); 104 105 /** Get the user_data of a link, the size of the memory is given when 106 * constructing the link */ 107 void *pw_impl_link_get_user_data(struct pw_impl_link *link); 108 109 /** Get the link info */ 110 const struct pw_link_info *pw_impl_link_get_info(struct pw_impl_link *link); 111 112 /** Get the global of the link */ 113 struct pw_global *pw_impl_link_get_global(struct pw_impl_link *link); 114 115 /** Get the output port of the link */ 116 struct pw_impl_port *pw_impl_link_get_output(struct pw_impl_link *link); 117 118 /** Get the input port of the link */ 119 struct pw_impl_port *pw_impl_link_get_input(struct pw_impl_link *link); 120 121 /** Find the link between 2 ports \memberof pw_impl_link */ 122 struct pw_impl_link *pw_impl_link_find(struct pw_impl_port *output, struct pw_impl_port *input); 123 124 #ifdef __cplusplus 125 } 126 #endif 127 128 #endif /* PIPEWIRE_IMPL_LINK_H */ 129