pub struct RecvAdvertiser { /* private fields */ }Expand description
Advertises receivers to a Discovery Server so they can be monitored and, when permitted, told which source to connect to.
§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 RecvListener 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 receiver keeps the
native receiver alive until the registration is removed
or the advertiser is dropped, even if every Receiver handle is dropped
first. Dropping the advertiser removes every registration, destroys the
native advertiser, and then releases the receivers 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 RecvAdvertiser
impl RecvAdvertiser
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 receiver.
Success does not mean the server was reached; see Connection.
§Errors
Returns Error::UnsupportedCapability when the selected runtime
cannot provide receiver 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<M: ReceiverMode>(
&mut self,
receiver: &Receiver<M>,
options: &RecvAdvertisement,
) -> Result<RecvRegistration>
pub fn register<M: ReceiverMode>( &mut self, receiver: &Receiver<M>, options: &RecvAdvertisement, ) -> Result<RecvRegistration>
Advertise receiver, in any mode, keeping the native receiver alive for
as long as the registration exists.
The receiver is not borrowed: it stays fully usable, and may even be dropped, while it is registered.
Two SDK defects of NDI 6.3.2 and 6.4.0.2 concern a registered receiver. Registering it within a few tens of milliseconds of removing it from another advertiser on the same server can crash a listener on that server; wait a second, or drop the other advertiser first. And a listener anywhere that unsubscribes from it while it connects can block that connect for good. See the module documentation.
§Errors
Returns Error::InvalidCString when the input-group name contains a
NUL byte, Error::InvalidInput when this advertiser already
advertises the receiver, and Error::NativeOperationFailed when the
SDK refuses the registration. Returns Error::UnsupportedCapability
when the options request remote control and the selected runtime
lacks remote receiver control.
Sourcepub fn unregister(
&mut self,
registration: RecvRegistration,
) -> Result<(), Rejected<RecvRegistration>>
pub fn unregister( &mut self, registration: RecvRegistration, ) -> Result<(), Rejected<RecvRegistration>>
Stop advertising a receiver 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 receiver; the registration then
stays in effect, and keeps the receiver alive, until it is removed or
the advertiser is dropped.