Skip to main content

RecvAdvertiser

Struct RecvAdvertiser 

Source
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

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for RecvAdvertiser

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.