# 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:

<table><thead><tr><th valign="top">Parameter</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top">p_url_address (const char*)</td><td valign="top"><p>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.</p><p>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.</p></td></tr></tbody></table>

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 the `NDIlib_send_advertiser_create` call.
* `p_sender`: An already instantiated NDI sender instance from the `NDIlib_send_create` call.
* `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.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ndi.video/all/developing-with-ndi/sdk/ndi-sender-discovery-and-monitor/ndi-sender-advertiser.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
