SmolRTSP 0.2.0
A small, portable, extensible RTSP 1.0 implementation in C99
Loading...
Searching...
No Matches
jpegxs_transport.h File Reference

An RTP/JPEG XS data transport. More...

#include <smolrtsp/droppable.h>
#include <smolrtsp/jpegxs.h>
#include <smolrtsp/rtp_transport.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <slice99.h>
#include <smolrtsp/priv/compiler_attrs.h>
Include dependency graph for jpegxs_transport.h:

Go to the source code of this file.

Data Structures

struct  SmolRTSP_JpegXsTransportConfig
 The configuration structure for SmolRTSP_JpegXsTransport. More...
 

Macros

#define SMOLRTSP_MAX_JPEGXS_PACKET_SIZE   1200
 The default value for SmolRTSP_JpegXsTransportConfig.max_packet_size.
 

Typedefs

typedef struct SmolRTSP_JpegXsTransport SmolRTSP_JpegXsTransport
 An RTP/JPEG XS data transport.
 

Functions

SmolRTSP_JpegXsTransportConfig SmolRTSP_JpegXsTransportConfig_default (void) SMOLRTSP_PRIV_MUST_USE
 Returns the default SmolRTSP_JpegXsTransportConfig: codestream packetization mode, T=1, and SMOLRTSP_MAX_JPEGXS_PACKET_SIZE.
 
SmolRTSP_JpegXsTransportSmolRTSP_JpegXsTransport_new (SmolRTSP_RtpTransport *t) SMOLRTSP_PRIV_MUST_USE
 Creates a new RTP/JPEG XS transport with the default configuration.
 
SmolRTSP_JpegXsTransportSmolRTSP_JpegXsTransport_new_with_config (SmolRTSP_RtpTransport *t, SmolRTSP_JpegXsTransportConfig config) SMOLRTSP_PRIV_MUST_USE
 Creates a new RTP/JPEG XS transport with a custom configuration.
 
int SmolRTSP_JpegXsTransport_send_codestream (SmolRTSP_JpegXsTransport *self, SmolRTSP_RtpTimestamp ts, SmolRTSP_JpegXsInterlace interlace, bool is_frame_end, U8Slice99 codestream) SMOLRTSP_PRIV_MUST_USE
 Sends a JPEG XS packetization unit in codestream mode (K=0).
 
int SmolRTSP_JpegXsTransport_send_header_segment (SmolRTSP_JpegXsTransport *self, SmolRTSP_RtpTimestamp ts, SmolRTSP_JpegXsInterlace interlace, U8Slice99 header_segment) SMOLRTSP_PRIV_MUST_USE
 Sends the header-segment packetization unit in slice mode (K=1).
 
int SmolRTSP_JpegXsTransport_send_slice (SmolRTSP_JpegXsTransport *self, SmolRTSP_RtpTimestamp ts, SmolRTSP_JpegXsInterlace interlace, uint16_t slice_index, bool is_frame_end, U8Slice99 slice) SMOLRTSP_PRIV_MUST_USE
 Sends a single slice as its own packetization unit in slice mode (K=1).
 
 declImplExtern99 (SmolRTSP_Droppable, SmolRTSP_JpegXsTransport)
 Implements SmolRTSP_Droppable_IFACE for SmolRTSP_JpegXsTransport.
 
bool SmolRTSP_JpegXsTransport_is_full (SmolRTSP_JpegXsTransport *self)
 

Detailed Description

An RTP/JPEG XS data transport.

See also
RTP Payload Format for ISO/IEC 21122 (JPEG XS): https://datatracker.ietf.org/doc/html/rfc9134

Macro Definition Documentation

◆ SMOLRTSP_MAX_JPEGXS_PACKET_SIZE

#define SMOLRTSP_MAX_JPEGXS_PACKET_SIZE   1200

The default value for SmolRTSP_JpegXsTransportConfig.max_packet_size.

The limit includes the 4-byte JPEG XS payload header: the codestream chunk per RTP packet is at most max_packet_size - SMOLRTSP_JPEGXS_PAYLOAD_HEADER_SIZE bytes.

Function Documentation

◆ declImplExtern99()

declImplExtern99 ( SmolRTSP_Droppable  ,
SmolRTSP_JpegXsTransport   
)

Implements SmolRTSP_Droppable_IFACE for SmolRTSP_JpegXsTransport.

See Interface99 for the macro usage.

◆ SmolRTSP_JpegXsTransport_new()

SmolRTSP_JpegXsTransport * SmolRTSP_JpegXsTransport_new ( SmolRTSP_RtpTransport t)

Creates a new RTP/JPEG XS transport with the default configuration.

Parameters
[in]tThe underlying RTP transport.
Precondition
t != NULL.

◆ SmolRTSP_JpegXsTransport_new_with_config()

SmolRTSP_JpegXsTransport * SmolRTSP_JpegXsTransport_new_with_config ( SmolRTSP_RtpTransport t,
SmolRTSP_JpegXsTransportConfig  config 
)

Creates a new RTP/JPEG XS transport with a custom configuration.

Parameters
[in]tThe underlying RTP transport.
[in]configThe transmission configuration structure.
Precondition
t != NULL.
config.max_packet_size > SMOLRTSP_JPEGXS_PAYLOAD_HEADER_SIZE.
config.sequential is true when config.pack_mode is SMOLRTSP_JPEGXS_PACK_CODESTREAM (RFC 9134 §4.3).

◆ SmolRTSP_JpegXsTransport_send_codestream()

int SmolRTSP_JpegXsTransport_send_codestream ( SmolRTSP_JpegXsTransport self,
SmolRTSP_RtpTimestamp  ts,
SmolRTSP_JpegXsInterlace  interlace,
bool  is_frame_end,
U8Slice99  codestream 
)

Sends a JPEG XS packetization unit in codestream mode (K=0).

One call corresponds to one packetization unit: an entire progressive frame, or a single field of an interlaced frame. The library splits codestream across as many RTP packets as needed and builds the RFC 9134 §4.3 payload header per packet. The L bit is set on the final packet of the unit; the RTP marker bit is set only when is_frame_end is true and on that same final packet. The internal frame counter is post-incremented after a successful send with is_frame_end true.

Parameters
[in]selfThe transport.
[in]tsThe RTP timestamp shared by every packet of the unit.
[in]interlaceThe interlaced-information field.
[in]is_frame_endtrue iff this packetization unit ends the current frame – always true for a progressive frame, true only on SMOLRTSP_JPEGXS_INTERLACE_FIELD_2 for an interlaced frame.
[in]codestreamThe codestream bytes for this unit.
Precondition
self != NULL.
The configured pack mode is SMOLRTSP_JPEGXS_PACK_CODESTREAM.
Returns
0 on success; -1 on I/O error (with errno set).

◆ SmolRTSP_JpegXsTransport_send_header_segment()

int SmolRTSP_JpegXsTransport_send_header_segment ( SmolRTSP_JpegXsTransport self,
SmolRTSP_RtpTimestamp  ts,
SmolRTSP_JpegXsInterlace  interlace,
U8Slice99  header_segment 
)

Sends the header-segment packetization unit in slice mode (K=1).

The unit carries the VS box, CS box, and codestream-header segment; every packet emitted by this call has SEP set to SMOLRTSP_JPEGXS_SEP_HEADER_SEGMENT. The RTP marker bit is never set.

Parameters
[in]selfThe transport.
[in]tsThe RTP timestamp shared by every packet of the unit.
[in]interlaceThe interlaced-information field.
[in]header_segmentThe header-segment bytes.
Precondition
self != NULL.
The configured pack mode is SMOLRTSP_JPEGXS_PACK_SLICE.
Returns
0 on success; -1 on I/O error (with errno set).

◆ SmolRTSP_JpegXsTransport_send_slice()

int SmolRTSP_JpegXsTransport_send_slice ( SmolRTSP_JpegXsTransport self,
SmolRTSP_RtpTimestamp  ts,
SmolRTSP_JpegXsInterlace  interlace,
uint16_t  slice_index,
bool  is_frame_end,
U8Slice99  slice 
)

Sends a single slice as its own packetization unit in slice mode (K=1).

Parameters
[in]selfThe transport.
[in]tsThe RTP timestamp shared by every packet of the slice.
[in]interlaceThe interlaced-information field.
[in]slice_indexThe slice index in [0, 0x7FE]. (0x7FF is reserved for the header segment.) Placed in the SEP field.
[in]is_frame_endtrue iff this slice ends the current frame – the RTP marker bit fires on the slice's final packet. For interlaced frames this should be true only on the last slice of SMOLRTSP_JPEGXS_INTERLACE_FIELD_2.
[in]sliceThe slice bytes.
Precondition
self != NULL.
The configured pack mode is SMOLRTSP_JPEGXS_PACK_SLICE.
slice_index < SMOLRTSP_JPEGXS_SEP_HEADER_SEGMENT.
Returns
0 on success; -1 on I/O error (with errno set).