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

An RTP/JPEG (Motion JPEG) data transport. More...

#include <smolrtsp/droppable.h>
#include <smolrtsp/jpeg.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 jpeg_transport.h:

Go to the source code of this file.

Data Structures

struct  SmolRTSP_JpegTransportConfig
 The configuration structure for SmolRTSP_JpegTransport. More...
 
struct  SmolRTSP_JpegFrame
 One Motion-JPEG frame, ready to packetize per RFC 2435. More...
 

Typedefs

typedef struct SmolRTSP_JpegTransport SmolRTSP_JpegTransport
 An RTP/JPEG data transport.
 

Functions

SmolRTSP_JpegTransportConfig SmolRTSP_JpegTransportConfig_default (void) SMOLRTSP_PRIV_MUST_USE
 Returns the default SmolRTSP_JpegTransportConfig (SMOLRTSP_MAX_JPEG_PACKET_SIZE).
 
SmolRTSP_JpegTransportSmolRTSP_JpegTransport_new (SmolRTSP_RtpTransport *t) SMOLRTSP_PRIV_MUST_USE
 Creates a new RTP/JPEG transport with the default configuration.
 
SmolRTSP_JpegTransportSmolRTSP_JpegTransport_new_with_config (SmolRTSP_RtpTransport *t, SmolRTSP_JpegTransportConfig config) SMOLRTSP_PRIV_MUST_USE
 Creates a new RTP/JPEG transport with a custom configuration.
 
int SmolRTSP_JpegTransport_send_frame (SmolRTSP_JpegTransport *self, SmolRTSP_RtpTimestamp ts, SmolRTSP_JpegFrame frame) SMOLRTSP_PRIV_MUST_USE
 Sends one Motion-JPEG frame as a sequence of RTP packets.
 
 declImplExtern99 (SmolRTSP_Droppable, SmolRTSP_JpegTransport)
 Implements SmolRTSP_Droppable_IFACE for SmolRTSP_JpegTransport.
 
bool SmolRTSP_JpegTransport_is_full (SmolRTSP_JpegTransport *self)
 

Detailed Description

An RTP/JPEG (Motion JPEG) data transport.

See also
RTP Payload Format for JPEG-compressed Video: https://datatracker.ietf.org/doc/html/rfc2435

Function Documentation

◆ declImplExtern99()

declImplExtern99 ( SmolRTSP_Droppable  ,
SmolRTSP_JpegTransport   
)

Implements SmolRTSP_Droppable_IFACE for SmolRTSP_JpegTransport.

See Interface99 for the macro usage.

◆ SmolRTSP_JpegTransport_new()

SmolRTSP_JpegTransport * SmolRTSP_JpegTransport_new ( SmolRTSP_RtpTransport t)

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

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

◆ SmolRTSP_JpegTransport_new_with_config()

SmolRTSP_JpegTransport * SmolRTSP_JpegTransport_new_with_config ( SmolRTSP_RtpTransport t,
SmolRTSP_JpegTransportConfig  config 
)

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

Parameters
[in]tThe underlying RTP transport.
[in]configThe transmission configuration structure.
Precondition
t != NULL.
config.max_packet_size > SMOLRTSP_JPEG_MAIN_HEADER_SIZE.

◆ SmolRTSP_JpegTransport_send_frame()

int SmolRTSP_JpegTransport_send_frame ( SmolRTSP_JpegTransport self,
SmolRTSP_RtpTimestamp  ts,
SmolRTSP_JpegFrame  frame 
)

Sends one Motion-JPEG frame as a sequence of RTP packets.

The library splits SmolRTSP_JpegFrame::scan_data across as many RTP packets as needed and builds the RFC 2435 ยง3.1 main header per packet, stamping SmolRTSP_JpegPayloadHeader.fragment_offset with the byte offset inside the scan data carried by each packet. The first packet of the frame also carries the quantization-table block (when SmolRTSP_JpegFrame::qt0 / SmolRTSP_JpegFrame::qt1 are non-empty). The RTP marker bit is set on the final packet of the frame.

Parameters
[in]selfThe transport.
[in]tsThe RTP timestamp shared by every packet of the frame.
[in]frameThe Motion-JPEG frame to send.
Precondition
self != NULL.
frame.qt0.len + frame.qt1.len <= 0xFFFF (fits the QT header Length field).
config.max_packet_size is large enough to carry one main JPEG header plus the QT block (when present) plus at least one byte of scan data on the first packet – a single-byte first packet is otherwise unrepresentable.
Returns
0 on success; -1 on I/O error (with errno set by the underlying transport's send).