|
| 1 | +#pragma once |
| 2 | + |
| 3 | +// NOTE : The following MIT license applies to this file ONLY and not to the SDK as a whole. Please review |
| 4 | +// the SDK documentation for the description of the full license terms, which are also provided in the file |
| 5 | +// "NDI License Agreement.pdf" within the SDK or online at http://ndi.link/ndisdk_license. Your use of any |
| 6 | +// part of this SDK is acknowledgment that you agree to the SDK license terms. The full NDI SDK may be |
| 7 | +// downloaded at http://ndi.video/ |
| 8 | +// |
| 9 | +//*********************************************************************************************************** |
| 10 | +// |
| 11 | +// Copyright (C) 2023-2024 Vizrt NDI AB. All rights reserved. |
| 12 | +// |
| 13 | +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and |
| 14 | +// associated documentation files(the "Software"), to deal in the Software without restriction, including |
| 15 | +// without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and / or sell |
| 16 | +// copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the |
| 17 | +// following conditions : |
| 18 | +// |
| 19 | +// The above copyright notice and this permission notice shall be included in all copies or substantial |
| 20 | +// portions of the Software. |
| 21 | +// |
| 22 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT |
| 23 | +// LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO |
| 24 | +// EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER |
| 25 | +// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR |
| 26 | +// THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 27 | +// |
| 28 | +//*********************************************************************************************************** |
| 29 | + |
| 30 | +// The type instance for a receiver listener. |
| 31 | +struct NDIlib_recv_listener_instance_type; |
| 32 | +typedef struct NDIlib_recv_listener_instance_type* NDIlib_recv_listener_instance_t; |
| 33 | + |
| 34 | +typedef struct NDIlib_recv_listener_create_t { |
| 35 | + // The URL address of the NDI Discovery Server to connect to. If NULL, then the default NDI discovery |
| 36 | + // server will be used. If there is no discovery server available, then the receiver listener will not |
| 37 | + // be able to be instantiated and the create function will return NULL. The format of this field is |
| 38 | + // expected to be the hostname or IP address, optionally followed by a colon and a port number. If the |
| 39 | + // port number is not specified, then port 5959 will be used. For example, |
| 40 | + // 127.0.0.1:5959 |
| 41 | + // or |
| 42 | + // 127.0.0.1 |
| 43 | + // or |
| 44 | + // hostname:5959 |
| 45 | + // If this field is a comma-separated list, then only the first address will be used. |
| 46 | + const char* p_url_address; |
| 47 | + |
| 48 | +#if NDILIB_CPP_DEFAULT_CONSTRUCTORS |
| 49 | + NDIlib_recv_listener_create_t( |
| 50 | + const char* p_url_address = NULL |
| 51 | + ); |
| 52 | +#endif // NDILIB_CPP_DEFAULT_CONSTRUCTORS |
| 53 | +} NDIlib_recv_listener_create_t; |
| 54 | + |
| 55 | +// Create an instance of the receiver listener. This will return NULL if it fails to create the listener. |
| 56 | +PROCESSINGNDILIB_API |
| 57 | +NDIlib_recv_listener_instance_t NDIlib_recv_listener_create(const NDIlib_recv_listener_create_t* p_create_settings NDILIB_CPP_DEFAULT_VALUE(NULL)); |
| 58 | + |
| 59 | +// Destroy an instance of the receiver listener. |
| 60 | +PROCESSINGNDILIB_API |
| 61 | +void NDIlib_recv_listener_destroy(NDIlib_recv_listener_instance_t p_instance); |
| 62 | + |
| 63 | +// Returns true if the receiver listener is actively connected to the configured NDI Discovery Server. |
| 64 | +PROCESSINGNDILIB_API |
| 65 | +bool NDIlib_recv_listener_is_connected(NDIlib_recv_listener_instance_t p_instance); |
| 66 | + |
| 67 | +// Retrieve the URL address of the NDI Discovery Server that the receiver listener is connected to. This can |
| 68 | +// return NULL if the instance pointer is invalid. |
| 69 | +PROCESSINGNDILIB_API |
| 70 | +const char* NDIlib_recv_listener_get_server_url(NDIlib_recv_listener_instance_t p_instance); |
| 71 | + |
| 72 | +// The types of streams that a receiver can receive from the source it's connected to. |
| 73 | +typedef enum NDIlib_receiver_type_e { |
| 74 | + NDIlib_receiver_type_none = 0, |
| 75 | + NDIlib_receiver_type_metadata = 1, |
| 76 | + NDIlib_receiver_type_video = 2, |
| 77 | + NDIlib_receiver_type_audio = 3, |
| 78 | + |
| 79 | + // Make sure this is a 32-bit enumeration. |
| 80 | + NDIlib_receiver_type_max = 0x7fffffff |
| 81 | +} NDIlib_receiver_type_e; |
| 82 | + |
| 83 | +// The types of commands that a receiver can process. |
| 84 | +typedef enum NDIlib_receiver_command_e { |
| 85 | + NDIlib_receiver_command_none = 0, |
| 86 | + |
| 87 | + // A receiver can be told to connect to a specific source. |
| 88 | + NDIlib_receiver_command_connect = 1, |
| 89 | + |
| 90 | + // Make sure this is a 32-bit enumeration. |
| 91 | + NDIlib_receiver_command_max = 0x7fffffff |
| 92 | +} NDIlib_receiver_command_e; |
| 93 | + |
| 94 | +// Describes a receiver that has been discovered. |
| 95 | +typedef struct NDIlib_receiver_t { |
| 96 | + // The unique identifier for the receiver on the network. |
| 97 | + const char* p_uuid; |
| 98 | + |
| 99 | + // The human-readable name of the receiver. |
| 100 | + const char* p_name; |
| 101 | + |
| 102 | + // The unique identifier for the input group that the receiver belongs to. |
| 103 | + const char* p_input_uuid; |
| 104 | + |
| 105 | + // The human-readable name of the input group that the receiver belongs to. |
| 106 | + const char* p_input_name; |
| 107 | + |
| 108 | + // The known IP address of the receiver. |
| 109 | + const char* p_address; |
| 110 | + |
| 111 | + // An array of streams that the receiver is set to receive. The last entry in this list will be |
| 112 | + // NDIlib_receiver_type_none. |
| 113 | + NDIlib_receiver_type_e* p_streams; |
| 114 | + |
| 115 | + // How many elements are in the p_streams array, excluding the NDIlib_receiver_type_none entry. |
| 116 | + uint32_t num_streams; |
| 117 | + |
| 118 | + // An array of commands that the receiver can process. The last entry in this list will be |
| 119 | + // NDIlib_receiver_command_none. |
| 120 | + NDIlib_receiver_command_e* p_commands; |
| 121 | + |
| 122 | + // How many elements are in the p_commands array, excluding the NDIlib_receiver_command_none entry. |
| 123 | + uint32_t num_commands; |
| 124 | + |
| 125 | + // Are we currently subscribed for receiver events? |
| 126 | + bool events_subscribed; |
| 127 | + |
| 128 | +#if NDILIB_CPP_DEFAULT_CONSTRUCTORS |
| 129 | + NDIlib_receiver_t(void); |
| 130 | +#endif // NDILIB_CPP_DEFAULT_CONSTRUCTORS |
| 131 | +} NDIlib_receiver_t; |
| 132 | + |
| 133 | +// Retrieves the current list of advertised receivers. The memory for the returned structure is only valid |
| 134 | +// until the next call or when destroy is called. For a given NDIlib_recv_listener_instance_t, do not call |
| 135 | +// NDIlib_recv_listener_get_receivers asynchronously. |
| 136 | +PROCESSINGNDILIB_API |
| 137 | +const NDIlib_receiver_t* NDIlib_recv_listener_get_receivers(NDIlib_recv_listener_instance_t p_instance, uint32_t* p_num_receivers); |
| 138 | + |
| 139 | +// This will allow you to wait until the number of online receivers has changed. |
| 140 | +PROCESSINGNDILIB_API |
| 141 | +bool NDIlib_recv_listener_wait_for_receivers(NDIlib_recv_listener_instance_t p_instance, uint32_t timeout_in_ms); |
| 142 | + |
| 143 | +// This will subscribe this listener instance to begin receiving events from the specified receiver. |
| 144 | +PROCESSINGNDILIB_API |
| 145 | +void NDIlib_recv_listener_subscribe_events(NDIlib_recv_listener_instance_t p_instance, const char* p_receiver_uuid); |
| 146 | + |
| 147 | +// This will unsubscribe this listener instance from receiving events from the specified receiver. |
| 148 | +PROCESSINGNDILIB_API |
| 149 | +void NDIlib_recv_listener_unsubscribe_events(NDIlib_recv_listener_instance_t p_instance, const char* p_receiver_uuid); |
| 150 | + |
| 151 | +// For backwards compatibility. |
| 152 | +typedef NDIlib_listener_event NDIlib_recv_listener_event; |
| 153 | + |
| 154 | +// Returns a list of the currently pending events for the listener. The events are returned in the order that |
| 155 | +// they were received. The timeout value is the amount of time in milliseconds that the function will wait |
| 156 | +// for events to be received. If the timeout is 0, then the function will return immediately with any events |
| 157 | +// that are currently pending. If the timeout is -1, then the function will wait indefinitely for events to |
| 158 | +// be received. The function will return NULL if no events were received within the timeout period. The |
| 159 | +// returned events should be freed using NDIlib_recv_listener_free_events(). |
| 160 | +PROCESSINGNDILIB_API |
| 161 | +const NDIlib_recv_listener_event* NDIlib_recv_listener_get_events(NDIlib_recv_listener_instance_t p_instance, uint32_t* p_num_events, uint32_t timeout_in_ms); |
| 162 | + |
| 163 | +// Frees the memory allocated for the events returned by NDIlib_recv_listener_get_events(). |
| 164 | +PROCESSINGNDILIB_API |
| 165 | +void NDIlib_recv_listener_free_events(NDIlib_recv_listener_instance_t p_instance, const NDIlib_recv_listener_event* p_events); |
| 166 | + |
| 167 | +// Trigger the "connect" command to be sent from the listener to the receiver. This will return false if the |
| 168 | +// command could not be sent, receiver is unknown, or some other error occurred. If p_source_name is NULL, |
| 169 | +// then this would indicate that the receiver should disconnect from its current source. Note that this |
| 170 | +// should only be called for a receiver that has NDIlib_receiver_command_connect in its list of commands that |
| 171 | +// it can respond to. |
| 172 | +PROCESSINGNDILIB_API |
| 173 | +bool NDIlib_recv_listener_send_connect(NDIlib_recv_listener_instance_t p_instance, const char* p_receiver_uuid, const char* p_source_name); |
0 commit comments