libwebsockets
Lightweight C library for HTML5 websockets
Loading...
Searching...
No Matches
lws-rtp.h File Reference

Go to the source code of this file.

Data Structures

struct  lws_rtp_ctx
 

Macros

#define LWS_RTP_VIDEO_WIDTH_1080P   1920
 
#define LWS_RTP_VIDEO_HEIGHT_1080P   1080
 
#define LWS_RTP_VIDEO_WIDTH_720P   1280
 
#define LWS_RTP_VIDEO_HEIGHT_720P   720
 
#define LWS_RTP_VIDEO_WIDTH_360P   640
 
#define LWS_RTP_VIDEO_HEIGHT_360P   360
 
#define LWS_RTP_MTU_DEFAULT   1200
 
#define LWS_RTP_AUDIO_SAMPLE_RATE   48000
 
#define LWS_RTP_AUDIO_CHANNELS   2
 
#define LWS_RTP_PT_OPUS   111
 
#define LWS_RTP_PT_H264   126
 
#define LWS_RTP_HEADER_LEN   12
 

Typedefs

typedef void(* lws_rtp_cb_t) (void *priv, const uint8_t *pkt, size_t len, int marker)
 

Functions

LWS_VISIBLE LWS_EXTERN void lws_rtp_init (struct lws_rtp_ctx *ctx, uint32_t ssrc, uint8_t pt)
 
LWS_VISIBLE LWS_EXTERN void lws_rtp_write_header (struct lws_rtp_ctx *ctx, uint8_t *buf, int marker)
 
LWS_VISIBLE LWS_EXTERN int lws_rtp_h264_packetize (struct lws_rtp_ctx *ctx, const uint8_t *nal, size_t len, int last_nal, size_t mtu, lws_rtp_cb_t cb, void *priv)
 
LWS_VISIBLE LWS_EXTERN int lws_rtp_av1_packetize (struct lws_rtp_ctx *ctx, const uint8_t *obu, size_t len, int last_obu, size_t mtu, lws_rtp_cb_t cb, void *priv)
 

Data Structure Documentation

◆ lws_rtp_ctx

struct lws_rtp_ctx

Definition at line 49 of file lws-rtp.h.

+ Collaboration diagram for lws_rtp_ctx:
Data Fields
uint32_t ssrc
uint32_t ts
uint32_t last_ts
uint16_t seq
uint8_t pt
uint8_t new_frame

Macro Definition Documentation

◆ LWS_RTP_VIDEO_WIDTH_1080P

#define LWS_RTP_VIDEO_WIDTH_1080P   1920

Definition at line 29 of file lws-rtp.h.

◆ LWS_RTP_VIDEO_HEIGHT_1080P

#define LWS_RTP_VIDEO_HEIGHT_1080P   1080

Definition at line 30 of file lws-rtp.h.

◆ LWS_RTP_VIDEO_WIDTH_720P

#define LWS_RTP_VIDEO_WIDTH_720P   1280

Definition at line 31 of file lws-rtp.h.

◆ LWS_RTP_VIDEO_HEIGHT_720P

#define LWS_RTP_VIDEO_HEIGHT_720P   720

Definition at line 32 of file lws-rtp.h.

◆ LWS_RTP_VIDEO_WIDTH_360P

#define LWS_RTP_VIDEO_WIDTH_360P   640

Definition at line 33 of file lws-rtp.h.

◆ LWS_RTP_VIDEO_HEIGHT_360P

#define LWS_RTP_VIDEO_HEIGHT_360P   360

Definition at line 34 of file lws-rtp.h.

◆ LWS_RTP_MTU_DEFAULT

#define LWS_RTP_MTU_DEFAULT   1200

Definition at line 36 of file lws-rtp.h.

◆ LWS_RTP_AUDIO_SAMPLE_RATE

#define LWS_RTP_AUDIO_SAMPLE_RATE   48000

Definition at line 39 of file lws-rtp.h.

◆ LWS_RTP_AUDIO_CHANNELS

#define LWS_RTP_AUDIO_CHANNELS   2

Definition at line 40 of file lws-rtp.h.

◆ LWS_RTP_PT_OPUS

#define LWS_RTP_PT_OPUS   111

Definition at line 43 of file lws-rtp.h.

◆ LWS_RTP_PT_H264

#define LWS_RTP_PT_H264   126

Definition at line 44 of file lws-rtp.h.

◆ LWS_RTP_HEADER_LEN

#define LWS_RTP_HEADER_LEN   12

Definition at line 47 of file lws-rtp.h.

Typedef Documentation

◆ lws_rtp_cb_t

typedef void(* lws_rtp_cb_t) (void *priv, const uint8_t *pkt, size_t len, int marker)

Definition at line 58 of file lws-rtp.h.

Function Documentation

◆ lws_rtp_init()

LWS_VISIBLE LWS_EXTERN void lws_rtp_init ( struct lws_rtp_ctx * ctx,
uint32_t ssrc,
uint8_t pt )

lws_rtp_init() - Initialize RTP context

Parameters
ctxRTP context to initialize
ssrcSSRC for this stream
ptPayload type

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_rtp_write_header()

LWS_VISIBLE LWS_EXTERN void lws_rtp_write_header ( struct lws_rtp_ctx * ctx,
uint8_t * buf,
int marker )

lws_rtp_write_header() - Write RTP header to buffer

Parameters
ctxRTP context
bufBuffer to write header to (must be at least LWS_RTP_HEADER_LEN)
markerMarker bit

Updates sequence number in context.

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_rtp_h264_packetize()

LWS_VISIBLE LWS_EXTERN int lws_rtp_h264_packetize ( struct lws_rtp_ctx * ctx,
const uint8_t * nal,
size_t len,
int last_nal,
size_t mtu,
lws_rtp_cb_t cb,
void * priv )

lws_rtp_h264_packetize() - Fragment H.264 NALU into RTP packets

Parameters
ctxRTP context
nalNALU data (excluding start code)
lenNALU length
last_naltrue if this is the last NALU of the frame
mtuMTU for the transport
cbCallback for each generated packet
privPrivate pointer for callback

Handles FU-A fragmentation if NALU exceeds MTU.

References LWS_EXTERN, and LWS_VISIBLE.

◆ lws_rtp_av1_packetize()

LWS_VISIBLE LWS_EXTERN int lws_rtp_av1_packetize ( struct lws_rtp_ctx * ctx,
const uint8_t * obu,
size_t len,
int last_obu,
size_t mtu,
lws_rtp_cb_t cb,
void * priv )