|
| 1 | +// NOTE : The following MIT license applies to this file ONLY and not to the SDK as a whole. Please review the SDK documentation |
| 2 | +// for the description of the full license terms, which are also provided in the file "NDI License Agreement.pdf" within the SDK or |
| 3 | +// online at http://ndi.link/ndisdk_license. Your use of any part of this SDK is acknowledgment that you agree to the SDK license |
| 4 | +// terms. The full NDI SDK may be downloaded at http://ndi.video/ |
| 5 | +// |
| 6 | +//************************************************************************************************************************************* |
| 7 | +// |
| 8 | +// Copyright (C) 2023-2026 Vizrt NDI AB. All rights reserved. |
| 9 | +// |
| 10 | +// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation |
| 11 | +// files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, |
| 12 | +// merge, publish, distribute, sublicense, and / or sell copies of the Software, and to permit persons to whom the Software is |
| 13 | +// furnished to do so, subject to the following conditions : |
| 14 | +// |
| 15 | +// The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. |
| 16 | +// |
| 17 | +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 18 | +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE |
| 19 | +// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 20 | +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 21 | + |
| 22 | +using System; |
| 23 | +using System.Runtime.InteropServices; |
| 24 | +using System.Security; |
| 25 | + |
| 26 | +namespace NewTek |
| 27 | +{ |
| 28 | + [SuppressUnmanagedCodeSecurity] |
| 29 | + public static partial class NDIlib |
| 30 | + { |
| 31 | + public struct recv_advertiser_create_t |
| 32 | + { |
| 33 | + // The URL address of the NDI Discovery Server to connect to. If NULL, then the default NDI discovery |
| 34 | + // server will be used. If there is no discovery server available, then the receiver advertiser will not |
| 35 | + // be able to be instantiated and the create function will return NULL. The format of this field is |
| 36 | + // expected to be the hostname or IP address, optionally followed by a colon and a port number. If the |
| 37 | + // port number is not specified, then port 5959 will be used. For example, |
| 38 | + // 127.0.0.1:5959 |
| 39 | + // or |
| 40 | + // 127.0.0.1 |
| 41 | + // or |
| 42 | + // hostname:5959 |
| 43 | + // This field can also specify multiple addresses separated by commas for redundancy support. |
| 44 | + public IntPtr p_url_address; |
| 45 | + } |
| 46 | + |
| 47 | + // Create a new Receiver Listener instance. This will return NULL if it fails. |
| 48 | + public static IntPtr recv_advertiser_create(ref recv_advertiser_create_t p_create_settings) |
| 49 | + { |
| 50 | + if (IntPtr.Size == 8) |
| 51 | + return UnsafeNativeMethods.recv_advertiser_create_64(ref p_create_settings); |
| 52 | + else |
| 53 | + return UnsafeNativeMethods.recv_advertiser_create_32(ref p_create_settings); |
| 54 | + } |
| 55 | + |
| 56 | + // This will destroy an existing Receiver Listener instance. |
| 57 | + public static bool recv_advertiser_add_receiver(IntPtr p_instance, IntPtr p_receiver, bool allow_controlling, bool allow_monitoring, IntPtr input_name) |
| 58 | + { |
| 59 | + if (IntPtr.Size == 8) |
| 60 | + return UnsafeNativeMethods.recv_advertiser_add_receiver_64(p_instance, p_receiver, allow_controlling, allow_monitoring, input_name); |
| 61 | + else |
| 62 | + return UnsafeNativeMethods.recv_advertiser_add_receiver_32(p_instance, p_receiver, allow_controlling, allow_monitoring, input_name); |
| 63 | + } |
| 64 | + |
| 65 | + // This will wait up till timeout_in_ms seconds to check for new receivers to be added or removed |
| 66 | + public static void recv_advertiser_del_receiver(IntPtr p_instance_recv_advertiser, IntPtr p_instance_recv) |
| 67 | + { |
| 68 | + if (IntPtr.Size == 8) |
| 69 | + UnsafeNativeMethods.recv_advertiser_del_receiver_64(p_instance_recv_advertiser, p_instance_recv); |
| 70 | + else |
| 71 | + UnsafeNativeMethods.recv_advertiser_del_receiver_32(p_instance_recv_advertiser, p_instance_recv); |
| 72 | + } |
| 73 | + |
| 74 | + // Get the updated list of receivers |
| 75 | + public static void recv_advertiser_destroy(IntPtr p_instance_recv_advertiser) |
| 76 | + { |
| 77 | + if (IntPtr.Size == 8) |
| 78 | + UnsafeNativeMethods.recv_advertiser_destroy_64(p_instance_recv_advertiser); |
| 79 | + else |
| 80 | + UnsafeNativeMethods.recv_advertiser_destroy_32(p_instance_recv_advertiser); |
| 81 | + } |
| 82 | + |
| 83 | + [SuppressUnmanagedCodeSecurity] |
| 84 | + internal static partial class UnsafeNativeMethods |
| 85 | + { |
| 86 | + // Create Receiver Listener |
| 87 | + [DllImport("Processing.NDI.Lib.x64.dll", EntryPoint = "NDIlib_recv_advertiser_create", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] |
| 88 | + internal static extern IntPtr recv_advertiser_create_64(ref recv_advertiser_create_t p_create_settings); |
| 89 | + [DllImport("Processing.NDI.Lib.x86.dll", EntryPoint = "NDIlib_recv_advertiser_create", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] |
| 90 | + internal static extern IntPtr recv_advertiser_create_32(ref recv_advertiser_create_t p_create_settings); |
| 91 | + |
| 92 | + // Destroy Receiver Listener |
| 93 | + [DllImport("Processing.NDI.Lib.x64.dll", EntryPoint = "NDIlib_recv_advertiser_destroy", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] |
| 94 | + internal static extern void recv_advertiser_destroy_64(IntPtr p_instance_recv_advertiser); |
| 95 | + [DllImport("Processing.NDI.Lib.x86.dll", EntryPoint = "NDIlib_recv_advertiser_destroy", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] |
| 96 | + internal static extern void recv_advertiser_destroy_32(IntPtr p_instance_recv_advertiser); |
| 97 | + |
| 98 | + // Check if Receiver Listener is Connected |
| 99 | + [DllImport("Processing.NDI.Lib.x64.dll", EntryPoint = "NDIlib_recv_advertiser_add_receiver", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] |
| 100 | + internal static extern bool recv_advertiser_add_receiver_64(IntPtr p_instance, IntPtr p_receiver, bool allow_controlling, bool allow_monitoring, IntPtr input_name); |
| 101 | + [DllImport("Processing.NDI.Lib.x86.dll", EntryPoint = "NDIlib_recv_advertiser_add_receiver", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] |
| 102 | + internal static extern bool recv_advertiser_add_receiver_32(IntPtr p_instance, IntPtr p_receiver, bool allow_controlling, bool allow_monitoring, IntPtr input_name); |
| 103 | + |
| 104 | + // Get Receivers |
| 105 | + [DllImport("Processing.NDI.Lib.x64.dll", EntryPoint = "NDIlib_recv_advertiser_del_receiver", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] |
| 106 | + internal static extern void recv_advertiser_del_receiver_64(IntPtr p_instance_recv_advertiser, IntPtr p_instance_recv); |
| 107 | + [DllImport("Processing.NDI.Lib.x86.dll", EntryPoint = "NDIlib_recv_advertiser_del_receiver", ExactSpelling = true, CallingConvention = CallingConvention.Cdecl)] |
| 108 | + internal static extern void recv_advertiser_del_receiver_32(IntPtr p_instance_recv_advertiser, IntPtr p_instance_recv); |
| 109 | + |
| 110 | + } // UnsafeNativeMethods |
| 111 | + |
| 112 | + } // class NDIlib |
| 113 | + |
| 114 | +} // namespace NewTek |
| 115 | + |
0 commit comments