pub struct SendAdvertiser { /* private fields */ }Expand description
Advertises senders to a Discovery Server so they can be monitored.
This is separate from the discovery every sender already performs: a
registration here makes a sender visible to SendListeners, not to
finders or receivers.
§Connection
An advertiser connects in the background and keeps trying for as long as
it lives. It is created, and accepts registrations, whether or not its
server can be reached, and delivers them once the server answers, which
can take several seconds after the server appears. It has no way to report
whether it is connected. To find out, use a SendListener on the same
server: is_connected reports the
connection, and a snapshot shows whether
the registration arrived.
§Ownership
The advertiser owns its registrations. Registering a sender keeps the native
sender alive until the registration is removed or the
advertiser is dropped, even if every Sender handle is dropped first.
Dropping the advertiser removes every registration, destroys the native
advertiser, and then releases the senders it was keeping alive.
§Threading
An advertiser is Send but not Sync: it may be moved to another
thread, and is used by one thread at a time. Every method takes it
exclusively, so Sync would give a shared reference nothing to do today.
It is withheld, as from the listeners, because the SDK does not say
whether calls on one advertiser may overlap, so that a shared query such
as the listeners’ connection state can be added without that guarantee.
Implementations§
Source§impl SendAdvertiser
impl SendAdvertiser
Sourcepub fn new(ndi: &Ndi, options: &AdvertiserOptions) -> Result<Self>
pub fn new(ndi: &Ndi, options: &AdvertiserOptions) -> Result<Self>
Create an advertiser for the Discovery Server options name, without
registering any sender.
Success does not mean the server was reached; see Connection.
§Errors
Returns Error::UnsupportedCapability when the selected runtime
cannot provide sender advertising, which needs NDI 6.4.0 or later, or
the options carry an Advanced configuration that the runtime or this
build cannot take; Error::InvalidInput when the server list is empty,
a server element is empty or contains a comma or NUL, or the SDK
creates no advertiser. Without an explicit server the SDK uses its configuration;
creation fails when it names no server or one the SDK cannot use. An
explicit address the SDK cannot parse is also refused.
Sourcepub fn register(
&mut self,
sender: &Sender,
options: &SendAdvertisement,
) -> Result<SendRegistration>
pub fn register( &mut self, sender: &Sender, options: &SendAdvertisement, ) -> Result<SendRegistration>
Advertise sender, keeping the native sender alive for as long as the
registration exists.
The sender is not borrowed: it stays fully usable, and may even be dropped, while it is registered.
Only an ordinary sender, in the RawSend mode, can
be registered. The Advanced CompressedSender and QueuedSender lend
their sender in another SenderMode, which this
method does not take: they free the frames or completion state the SDK
uses as soon as their native sender is destroyed, and a registration
would keep it alive past that.
Registering a sender within a few tens of milliseconds of removing it from another advertiser on the same server can crash a listener on that server, through an SDK defect of NDI 6.3.2 and 6.4.0.2. Wait a second, or drop the other advertiser first. See the module documentation.
§Errors
Returns Error::InvalidInput when this advertiser already
advertises the sender, and Error::NativeOperationFailed when the SDK
refuses the registration.
Sourcepub fn unregister(
&mut self,
registration: SendRegistration,
) -> Result<(), Rejected<SendRegistration>>
pub fn unregister( &mut self, registration: SendRegistration, ) -> Result<(), Rejected<SendRegistration>>
Stop advertising a sender and release this advertiser’s hold on it.
§Errors
A failure changes nothing and hands the registration back inside
Rejected. Only the advertiser that issued a registration can end
it: another one fails with Error::InvalidInput, and the
registration can still be given to the advertiser it belongs to. The
call fails with Error::NativeOperationFailed when the SDK removes
nothing because it does not know the sender; the registration then
stays in effect, and keeps the sender alive, until it is removed or
the advertiser is dropped.