ifm3dpy.rtsp.RtspClient

class ifm3dpy.rtsp.RtspClient

Bases: None

RTSP/1.0 client that streams H.264 video from an ifm device and, optionally, decodes it into buffers using a compiled-in video decoder.

__init__(*args, **kwargs)

Overloaded function.

  1. __init__(self: ifm3dpy.rtsp.RtspClient, device: ifm3dpy.device.Device, url: str | None = None, port: typing.SupportsInt = 8554, stream_path: str = ‘port1’, transport: ifm3dpy.rtsp.RtspClient.Transport = <Transport.INTERLEAVED: 0>, decoder: str | None = None) -> None

    Constructs a client that streams from the given device.

    deviceifm3dpy.device.Device

    Device used to discover the stream IP (unless url is set).

    urlstr, optional

    Full RTSP URL override (e.g. rtsp://192.168.0.69:8554/port1). When unset the URL is built from the device IP, port and stream_path.

    portint, optional

    RTSP server port, used when url is unset.

    stream_pathstr, optional

    Stream path appended to the device IP, used when url is unset.

    transportifm3dpy.rtsp.RtspClient.Transport, optional

    RTP transport selection.

    decoderstr, optional

    Override the decoder name used for decoding h264 video into buffers. When unset the decoder is chosen automatically.

  2. __init__(self: ifm3dpy.rtsp.RtspClient, device: ifm3dpy.device.Device, port: ifm3dpy.device.PortInfo, url: str | None = None, transport: ifm3dpy.rtsp.RtspClient.Transport = <Transport.INTERLEAVED: 0>, decoder: str | None = None) -> None

    Constructs a client for a specific port, deriving the RTSP port and stream path from the port’s advertised RtspInfo when available.

    deviceifm3dpy.device.Device

    Device used to discover the stream IP (unless url is set).

    portifm3dpy.device.PortInfo

    Port whose RTSP endpoint should be streamed.

    urlstr, optional

    Full RTSP URL override. When unset the URL is built from the device IP and the port’s RtspInfo.

    transportifm3dpy.rtsp.RtspClient.Transport, optional

    RTP transport selection.

    decoderstr, optional

    Override the decoder name used for decoding h264 video into buffers. When unset the decoder is chosen automatically.

Methods

__init__(*args, **kwargs)

Overloaded function.

_pybind11_conduit_v1_

get_state(self)

Returns the current session state.

is_running(self)

Returns true while the worker thread is running.

on_error(self[, callback])

Registers a callback invoked on terminal errors.

on_nal_unit(self[, callback])

Registers a callback invoked for each reassembled NAL unit.

on_new_frame(self[, callback])

Registers a callback invoked for each received frame.

on_state_change(self[, callback])

Registers a callback invoked on every session state transition.

start(self[, buffers])

Performs the RTSP handshake and starts streaming.

stop(self)

Sends TEARDOWN, stops the worker thread and closes the socket.

class State(value)

Bases: IntEnum

Lifecycle state of the RTSP session.

class Transport(value)

Bases: IntEnum

RTP transport used for the media stream.

get_state(self: ifm3dpy.rtsp.RtspClient) ifm3dpy.rtsp.RtspClient.State

Returns the current session state.

is_running(self: ifm3dpy.rtsp.RtspClient) bool

Returns true while the worker thread is running.

on_error(self: ifm3dpy.rtsp.RtspClient, callback: Callable[[ifm3dpy.device.Error], None] = None) None

Registers a callback invoked on terminal errors.

on_nal_unit(self: ifm3dpy.rtsp.RtspClient, callback: collections.abc.Callable[[ifm3dpy.rtsp.NalUnit], None] = None) None

Registers a callback invoked for each reassembled NAL unit.

on_new_frame(self: ifm3dpy.rtsp.RtspClient, callback: collections.abc.Callable[[ifm3dpy.framegrabber.Frame], None] = None) None

Registers a callback invoked for each received frame.

on_state_change(self: ifm3dpy.rtsp.RtspClient, callback: collections.abc.Callable[[ifm3dpy.rtsp.RtspClient.State], None] = None) None

Registers a callback invoked on every session state transition.

start(self: ifm3dpy.rtsp.RtspClient, buffers: collections.abc.Sequence[ifm3dpy.framegrabber.buffer_id] = []) ifm3dpy.Awaitable

Performs the RTSP handshake and starts streaming.

Parameters

buffers (list[ifm3dpy.framegrabber.buffer_id], optional) – Buffers to make available on each received frame. Supported ids are COMPRESSED_H264_FRAME, RGB_IMAGE, YUV420_IMAGE and RGB_INFO. An empty list, the default, requests all four; each one costs additional per-frame work, so pass only what you consume.

Returns

Resolves once the stream is playing, or raises on failure.

Return type

Awaitable

stop(self: ifm3dpy.rtsp.RtspClient) ifm3dpy.Awaitable

Sends TEARDOWN, stops the worker thread and closes the socket.

Returns

Resolves once the client has stopped.

Return type

Awaitable