pub struct StreamBuilder<'a> { /* private fields */ }Expand description
Builder for configuring a GVSP stream.
Implementations§
Source§impl<'a> StreamBuilder<'a>
impl<'a> StreamBuilder<'a>
Sourcepub fn new(device: &'a mut GigeDevice) -> Self
pub fn new(device: &'a mut GigeDevice) -> Self
Create a new builder bound to an opened GigeDevice.
Default packet-size policy is preserve: the camera’s current
GevSCPSPacketSize is used as-is. Call StreamBuilder::auto_packet_size
to set from the NIC MTU and path-probe, or StreamBuilder::packet_size
for an explicit ceiling (ADR-0021).
Sourcepub fn probe(self, enable: bool) -> Self
pub fn probe(self, enable: bool) -> Self
Whether to path-probe with a GVSP test packet before streaming (default: on, under every packet-size policy).
It applies under the default preserve policy too, which is not a contradiction: the probe never raises a size, so it cannot override the value an operator set. It can only decline to stream at a size the path demonstrably drops — something no register read can discover, because both endpoints accept it. Turning it off is what makes preserve literal.
Turning it off restores the pre-0.4.2 behaviour: whatever
GevSCPSPacketSize holds is assumed to reach the host.
That is wrong on any path narrower than both endpoints
(#112), so
the only good reason to disable it is a device that misbehaves when
asked for a test packet — in which case please open an issue, because
the probe is written to tolerate a device that simply ignores it.
Sourcepub fn dest(self, dest: StreamDest) -> Self
pub fn dest(self, dest: StreamDest) -> Self
Configure the stream destination.
Sourcepub fn target_mtu(self, mtu: u32) -> Self
pub fn target_mtu(self, mtu: u32) -> Self
Cap the MTU used when computing the GVSP packet size in
StreamBuilder::auto_packet_size mode.
The interface’s own MTU is still read; this only lowers the request.
Sourcepub fn auto_packet_size(self) -> Self
pub fn auto_packet_size(self) -> Self
Set GevSCPSPacketSize from the host NIC MTU, then path-probe (SR-13).
This is the explicit opt-in that replaces the old always-write-MTU
default (ADR-0021). It is not the pre-0.4 --auto false ⇒ 1500
behaviour.
Sourcepub fn packet_size(self, size: u32) -> Self
pub fn packet_size(self, size: u32) -> Self
Write this GVSP packet size (a ceiling for the path probe).
Sourcepub fn packet_delay(self, delay: Duration) -> Self
pub fn packet_delay(self, delay: Duration) -> Self
Have the camera wait delay between stream packets: GevSCPD,
written in timestamp ticks at the frequency the camera reports
(0x093C/0x0940), rounded to the nearest tick.
Without it GevSCPD is left as it is. A camera that reports no tick
frequency cannot be given a delay in time, and the build fails rather
than guess a unit.
Sourcepub fn resend(self, policy: ResendPolicy) -> Self
pub fn resend(self, policy: ResendPolicy) -> Self
Whether to ask the camera for lost packets (default
ResendPolicy::Auto).
Sourcepub fn destination_port(self, port: u16) -> Self
pub fn destination_port(self, port: u16) -> Self
Receive on this UDP port, for a firewall that admits only it.
By default the operating system picks a free port; either way the
port is written to the camera’s GevSCPHostPort. The port is the
stream’s alone: it is bound without SO_REUSEPORT, so a second
stream asking for the same one fails to open.
Sourcepub fn multicast(self, group: Option<Ipv4Addr>) -> Self
pub fn multicast(self, group: Option<Ipv4Addr>) -> Self
Configure multicast reception when the device is set to multicast mode.
Sourcepub fn rcvbuf_bytes(self, size: usize) -> Self
pub fn rcvbuf_bytes(self, size: usize) -> Self
Custom receive buffer size for the UDP socket.
Sourcepub fn channel(self, channel: u32) -> Self
pub fn channel(self, channel: u32) -> Self
Select the GigE Vision stream channel to configure (defaults to 0).
The build fails for a channel at or beyond the camera’s
GevNumberOfStreamChannels (0x0904), before anything is written.
Sourcepub async fn build(self) -> Result<Stream, GenicamError>
pub async fn build(self) -> Result<Stream, GenicamError>
Finalise the builder and return a configured Stream.
In order: check the channel exists and that a requested packet delay
can be converted, bind the socket (port 0 unless one was asked for),
point the stream channel at it, negotiate the packet size, write
GevSCPD if asked, and read whether the camera supports resend.