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_DEVICE_H 26 #define PIPEWIRE_IMPL_DEVICE_H 27 28 #ifdef __cplusplus 29 extern "C" { 30 #endif 31 32 /** \class pw_impl_device 33 * 34 * \brief PipeWire device interface. 35 * 36 * The device is an object that manages nodes. It typically 37 * corresponds to a physical hardware device but it does not 38 * have to be. 39 * 40 * The purpose of the device is to provide an interface to 41 * dynamically create/remove/configure the nodes it manages. 42 */ 43 struct pw_impl_device; 44 45 #include <spa/monitor/device.h> 46 47 #include <pipewire/context.h> 48 #include <pipewire/global.h> 49 #include <pipewire/properties.h> 50 #include <pipewire/resource.h> 51 52 /** Device events, listen to them with \ref pw_impl_device_add_listener */ 53 struct pw_impl_device_events { 54 #define PW_VERSION_IMPL_DEVICE_EVENTS 0 55 uint32_t version; 56 57 /** the device is destroyed */ 58 void (*destroy) (void *data); 59 /** the device is freed */ 60 void (*free) (void *data); 61 /** the device is initialized */ 62 void (*initialized) (void *data); 63 64 /** the device info changed */ 65 void (*info_changed) (void *data, const struct pw_device_info *info); 66 }; 67 68 struct pw_impl_device *pw_context_create_device(struct pw_context *context, 69 struct pw_properties *properties, 70 size_t user_data_size); 71 72 int pw_impl_device_register(struct pw_impl_device *device, 73 struct pw_properties *properties); 74 75 void pw_impl_device_destroy(struct pw_impl_device *device); 76 77 void *pw_impl_device_get_user_data(struct pw_impl_device *device); 78 79 /** Set the device implementation */ 80 int pw_impl_device_set_implementation(struct pw_impl_device *device, struct spa_device *spa_device); 81 /** Get the device implementation */ 82 struct spa_device *pw_impl_device_get_implementation(struct pw_impl_device *device); 83 84 /** Get the global of this device */ 85 struct pw_global *pw_impl_device_get_global(struct pw_impl_device *device); 86 87 /** Add an event listener */ 88 void pw_impl_device_add_listener(struct pw_impl_device *device, 89 struct spa_hook *listener, 90 const struct pw_impl_device_events *events, 91 void *data); 92 93 int pw_impl_device_update_properties(struct pw_impl_device *device, const struct spa_dict *dict); 94 95 const struct pw_properties *pw_impl_device_get_properties(struct pw_impl_device *device); 96 97 int pw_impl_device_for_each_param(struct pw_impl_device *device, 98 int seq, uint32_t param_id, 99 uint32_t index, uint32_t max, 100 const struct spa_pod *filter, 101 int (*callback) (void *data, int seq, 102 uint32_t id, uint32_t index, uint32_t next, 103 struct spa_pod *param), 104 void *data); 105 #ifdef __cplusplus 106 } 107 #endif 108 109 #endif /* PIPEWIRE_IMPL_DEVICE_H */ 110