ifm3dpy.rtsp.RtspClient
- class ifm3dpy.rtsp.RtspClient
Bases:
NoneRTSP/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.
__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, output_format: ifm3dpy.rtsp.RtspClient.OutputFormat = <OutputFormat.RGB: 0>) -> None
Constructs a client that streams from the given device.
- deviceifm3dpy.device.Device
Device used to discover the stream IP (unless
urlis 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,portandstream_path.- portint, optional
RTSP server port, used when
urlis unset.- stream_pathstr, optional
Stream path appended to the device IP, used when
urlis unset.- transportifm3dpy.rtsp.RtspClient.Transport, optional
RTP transport selection.
- decoderstr, optional
Decoder selection. When unset, the first available decoder is used. Set to a decoder name substring (e.g.
"ffmpeg") to prefer a specific decoder, or to"null"to disable decoding (NAL-only mode).- output_formatifm3dpy.rtsp.RtspClient.OutputFormat, optional
Pixel layout of decoded frames.
RGB(default) delivers a 3-channel RGB numpy array;YUV420delivers raw planar I420 (YUV420P) as a single-channel array of shape (height * 3 / 2, width).
__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, output_format: ifm3dpy.rtsp.RtspClient.OutputFormat = <OutputFormat.RGB: 0>) -> 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
urlis 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
Decoder selection. When unset, the first available decoder is used. Set to a decoder name substring (e.g.
"ffmpeg") to prefer a specific decoder, or to"null"to disable decoding (NAL-only mode).- output_formatifm3dpy.rtsp.RtspClient.OutputFormat, optional
Pixel layout of decoded frames.
RGB(default) delivers a 3-channel RGB numpy array;YUV420delivers raw planar I420 (YUV420P) as a single-channel array of shape (height * 3 / 2, width).
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 decoded frame.
on_state_change(self[, callback])Registers a callback invoked on every session state transition.
start(self)Performs the RTSP handshake and starts streaming.
stop(self)Sends TEARDOWN, stops the worker thread and closes the socket.
- class OutputFormat(value)
Bases:
IntEnumPixel layout of decoded frames delivered to on_new_frame.
- class State(value)
Bases:
IntEnumLifecycle state of the RTSP session.
- class Transport(value)
Bases:
IntEnumRTP 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: object = None) None
Registers a callback invoked for each decoded frame. The callback receives a numpy.ndarray buffer whose .metadata attribute holds any RGB_INFO SEI metadata.
- 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) ifm3dpy.Awaitable
Performs the RTSP handshake and starts streaming.
- Returns
Resolves once the stream is playing, or raises on failure.
- Return type
- 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