NDI Sender Advertiser
The NDIlib_send_advertiser_create function creates an instance of the sender advertiser. This function returns an instance of type NDIlib_send_advertiser_create_t (or NULL if it fails), representing the sender advertiser instance.
The function takes parameters defined by NDIlib_send_advertiser_create_t, as follows:
p_url_address (const char*)
This parameter represents the URL address of the NDI Discovery Server to connect to. If NULL, the default NDI discovery server will be used. If no discovery server is available, the sender advertiser will not be instantiated, and the create function will return NULL. The format of this field is expected to be the hostname or IP address, optionally followed by a colon and a port number. If the port number is not specified, port 5959 will be used.
For example: 127.0.0.1:5959, 127.0.0.1, or hostname:5959. This field can also specify multiple addresses separated by commas for redundancy support.
Once the structure is filled out, NDIlib_send_advertiser_create will create an instance for you. The sender advertiser instance is destroyed by passing it into NDIlib_send_advertiser_destroy.
Adding a Sender for Advertising
To add your NDI sender for advertising, call the following function:
bool NDIlib_send_advertiser_add_sender(
NDIlib_send_advertiser_instance_t p_instance,
NDIlib_send_instance_t p_sender,
bool allow_monitoring
);This function adds the sender to the list of senders being advertised. It returns false if the sender has been previously registered.
Parameters:
p_instance: The sender advertiser instance from theNDIlib_send_advertiser_createcall.p_sender: An already instantiated NDI sender instance from theNDIlib_send_createcall.allow_monitoring: A flag to allow monitoring of the sender.
Removing a Sender from Advertising
To remove the sender from the list of senders being advertised, call the corresponding function:
bool NDIlib_send_advertiser_del_sender(
NDIlib_send_advertiser_instance_t p_instance,
NDIlib_send_instance_t p_sender
);This function returns false if the sender was not previously advertised.
Example Code:
The following code illustrates how to add/register a sender and remove it from the advertiser. Note: A full example is provided with the SDK that illustrates registering a sender for advertisement (we will not reproduce that code here).
// Create an unconnected sender that will be set up for advertising.
NDIlib_send_instance_t pNDI_sender = NDIlib_send_create();
if (!pNDI_sender) {
// Handle error
}
// Create an instance of the sender advertiser
NDIlib_send_advertiser_instance_t pNDI_send_advertiser = NDIlib_send_advertiser_create();
if (!pNDI_send_advertiser) {
// Handle error
}
// Register the sender with the advertiser
NDIlib_send_advertiser_add_sender(pNDI_send_advertiser, pNDI_sender, true);
// Do stuff
...
// Remove the sender from the advertiser before destroying it
NDIlib_send_advertiser_del_sender(pNDI_send_advertiser, pNDI_sender);
// Destroy the sender advertiser
NDIlib_send_advertiser_destroy(pNDI_send_advertiser);
// Destroy the sender
NDIlib_send_destroy(pNDI_sender);This example demonstrates the creation, registration, and destruction of an NDI sender and its associated advertiser.
Last updated
Was this helpful?

