FFmpeg
Data Structures | Macros | Functions
rdt.c File Reference

Realmedia RTSP protocol (RDT) support. More...

#include "avformat.h"
#include "libavutil/avstring.h"
#include "rtpdec.h"
#include "rdt.h"
#include "libavutil/base64.h"
#include "libavutil/md5.h"
#include "rm.h"
#include "internal.h"
#include "avio_internal.h"
#include "libavcodec/get_bits.h"

Go to the source code of this file.

Data Structures

struct  RDTDemuxContext
 
struct  PayloadContext
 RTP/JPEG specific private data. More...
 

Macros

#define XOR_TABLE_SIZE   37
 
#define RDT_HANDLER(n, s, t)
 

Functions

RDTDemuxContextff_rdt_parse_open (AVFormatContext *ic, int first_stream_of_set_idx, void *priv_data, const RTPDynamicProtocolHandler *handler)
 Allocate and init the RDT parsing context. More...
 
void ff_rdt_parse_close (RDTDemuxContext *s)
 
void ff_rdt_calc_response_and_checksum (char response[41], char chksum[9], const char *challenge)
 Calculate the response (RealChallenge2 in the RTSP header) to the challenge (RealChallenge1 in the RTSP header from the Real/Helix server), which is used as some sort of client validation. More...
 
static int rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr)
 
static int rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t rtp_seq, int flags)
 
int ff_rdt_parse_packet (RDTDemuxContext *s, AVPacket *pkt, uint8_t **bufptr, int len)
 Parse RDT-style packet data (header + media data). More...
 
void ff_rdt_subscribe_rule (char *cmd, int size, int stream_nr, int rule_nr)
 Add subscription information to Subscribe parameter string. More...
 
static unsigned char * rdt_parse_b64buf (unsigned int *target_len, const char *p)
 
static int rdt_parse_sdp_line (AVFormatContext *s, int st_index, PayloadContext *rdt, const char *line)
 
static void real_parse_asm_rule (AVStream *st, const char *p, const char *end)
 
static AVStreamadd_dstream (AVFormatContext *s, AVStream *orig_st)
 
static void real_parse_asm_rulebook (AVFormatContext *s, AVStream *orig_st, const char *p)
 
void ff_real_parse_sdp_a_line (AVFormatContext *s, int stream_index, const char *line)
 Parse a server-related SDP line. More...
 
static av_cold int rdt_init (AVFormatContext *s, int st_index, PayloadContext *rdt)
 
static void rdt_close_context (PayloadContext *rdt)
 
 RDT_HANDLER (live_video, "x-pn-multirate-realvideo-live", AVMEDIA_TYPE_VIDEO)
 
 RDT_HANDLER (live_audio, "x-pn-multirate-realaudio-live", AVMEDIA_TYPE_AUDIO)
 
 RDT_HANDLER (video, "x-pn-realvideo", AVMEDIA_TYPE_VIDEO)
 
 RDT_HANDLER (audio, "x-pn-realaudio", AVMEDIA_TYPE_AUDIO)
 

Detailed Description

Realmedia RTSP protocol (RDT) support.

Author
Ronald S. Bultje rbult.nosp@m.je@r.nosp@m.onald.nosp@m..bit.nosp@m.freak.nosp@m..net

Definition in file rdt.c.

Macro Definition Documentation

◆ XOR_TABLE_SIZE

#define XOR_TABLE_SIZE   37

◆ RDT_HANDLER

#define RDT_HANDLER (   n,
  s,
 
)
Value:
const RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \
.enc_name = s, \
.codec_type = t, \
.codec_id = AV_CODEC_ID_NONE, \
.priv_data_size = sizeof(PayloadContext), \
.init = rdt_init, \
.parse_sdp_a_line = rdt_parse_sdp_line, \
.close = rdt_close_context, \
}

Definition at line 556 of file rdt.c.

Function Documentation

◆ ff_rdt_parse_open()

RDTDemuxContext* ff_rdt_parse_open ( AVFormatContext ic,
int  first_stream_of_set_idx,
void *  priv_data,
const RTPDynamicProtocolHandler handler 
)

Allocate and init the RDT parsing context.

Parameters
icthe containing RTSP demuxer context
first_stream_of_set_idxindex to the first AVStream in the RTSP demuxer context's ic->streams array that is part of this particular stream's set of streams (with identical content)
priv_dataprivate data of the payload data handler context
handlerpointer to the parse_packet() payload parsing function
Returns
a newly allocated RDTDemuxContext. Free with ff_rdt_parse_close().

Definition at line 55 of file rdt.c.

Referenced by ff_rtsp_open_transport_ctx().

◆ ff_rdt_parse_close()

void ff_rdt_parse_close ( RDTDemuxContext s)

Definition at line 78 of file rdt.c.

Referenced by ff_rtsp_undo_setup(), and rtsp_read_setup().

◆ ff_rdt_calc_response_and_checksum()

void ff_rdt_calc_response_and_checksum ( char  response[41],
char  chksum[9],
const char *  challenge 
)

Calculate the response (RealChallenge2 in the RTSP header) to the challenge (RealChallenge1 in the RTSP header from the Real/Helix server), which is used as some sort of client validation.

Parameters
responsepointer to response buffer, it should be at least 41 bytes (40 data + 1 zero) bytes long.
chksumpointer to buffer containing a checksum of the response, it should be at least 9 (8 data + 1 zero) bytes long.
challengepointer to the RealChallenge1 value provided by the server.

Definition at line 94 of file rdt.c.

◆ rdt_load_mdpr()

static int rdt_load_mdpr ( PayloadContext rdt,
AVStream st,
int  rule_nr 
)
static

Layout of the MLTI chunk: 4: MLTI 2: number of streams Then for each stream ([number_of_streams] times): 2: mdpr index 2: number of mdpr chunks Then for each mdpr chunk ([number_of_mdpr_chunks] times): 4: size

we skip MDPR chunks until we reach the one of the stream we're interested in, and forward that ([size]+[data]) to the RM demuxer to parse the stream-specific header data.

Definition at line 132 of file rdt.c.

Referenced by rdt_parse_sdp_line().

◆ rdt_parse_packet()

static int rdt_parse_packet ( AVFormatContext ctx,
PayloadContext rdt,
AVStream st,
AVPacket pkt,
uint32_t *  timestamp,
const uint8_t *  buf,
int  len,
uint16_t  rtp_seq,
int  flags 
)
static

Definition at line 294 of file rdt.c.

◆ ff_rdt_parse_packet()

int ff_rdt_parse_packet ( RDTDemuxContext s,
AVPacket pkt,
uint8_t **  buf,
int  len 
)

Parse RDT-style packet data (header + media data).

Usage similar to rtp_parse_packet().

< Should not be used if buf is NULL, but should be set to the timestamp of the packet returned....

Definition at line 335 of file rdt.c.

◆ ff_rdt_subscribe_rule()

void ff_rdt_subscribe_rule ( char *  cmd,
int  size,
int  stream_nr,
int  rule_nr 
)

Add subscription information to Subscribe parameter string.

Parameters
cmdstring to write the subscription information into.
sizesize of cmd.
stream_nrstream number.
rule_nrrule number to conform to.

Definition at line 384 of file rdt.c.

Referenced by rtsp_read_packet().

◆ rdt_parse_b64buf()

static unsigned char* rdt_parse_b64buf ( unsigned int target_len,
const char *  p 
)
static

Definition at line 392 of file rdt.c.

Referenced by rdt_parse_sdp_line().

◆ rdt_parse_sdp_line()

static int rdt_parse_sdp_line ( AVFormatContext s,
int  st_index,
PayloadContext rdt,
const char *  line 
)
static

Definition at line 409 of file rdt.c.

◆ real_parse_asm_rule()

static void real_parse_asm_rule ( AVStream st,
const char *  p,
const char *  end 
)
static

Definition at line 447 of file rdt.c.

Referenced by real_parse_asm_rulebook().

◆ add_dstream()

static AVStream* add_dstream ( AVFormatContext s,
AVStream orig_st 
)
static

Definition at line 460 of file rdt.c.

Referenced by real_parse_asm_rulebook().

◆ real_parse_asm_rulebook()

static void real_parse_asm_rulebook ( AVFormatContext s,
AVStream orig_st,
const char *  p 
)
static

The ASMRuleBook contains a list of comma-separated strings per rule, and each rule is separated by a ;. The last one also has a ; at the end so we can use it as delimiter. Every rule occurs twice, once for when the RTSP packet header marker is set and once for if it isn't. We only read the first because we don't care much (that's what the "odd" variable is for). Each rule contains a set of one or more statements, optionally preceded by a single condition. If there's a condition, the rule starts with a '#'. Multiple conditions are merged between brackets, so there are never multiple conditions spread out over separate statements. Generally, these conditions are bitrate limits (min/max) for multi-bitrate streams.

Definition at line 474 of file rdt.c.

Referenced by ff_real_parse_sdp_a_line().

◆ ff_real_parse_sdp_a_line()

void ff_real_parse_sdp_a_line ( AVFormatContext s,
int  stream_index,
const char *  buf 
)

Parse a server-related SDP line.

Parameters
sthe RTSP AVFormatContext
stream_indexthe index of the first stream in the set represented by the SDP m= line (in s->streams)
bufthe SDP line

Definition at line 515 of file rdt.c.

◆ rdt_init()

static av_cold int rdt_init ( AVFormatContext s,
int  st_index,
PayloadContext rdt 
)
static

Definition at line 526 of file rdt.c.

◆ rdt_close_context()

static void rdt_close_context ( PayloadContext rdt)
static

Definition at line 541 of file rdt.c.

◆ RDT_HANDLER() [1/4]

RDT_HANDLER ( live_video  ,
"x-pn-multirate-realvideo-live"  ,
AVMEDIA_TYPE_VIDEO   
)

◆ RDT_HANDLER() [2/4]

RDT_HANDLER ( live_audio  ,
"x-pn-multirate-realaudio-live"  ,
AVMEDIA_TYPE_AUDIO   
)

◆ RDT_HANDLER() [3/4]

RDT_HANDLER ( video  ,
"x-pn-realvideo"  ,
AVMEDIA_TYPE_VIDEO   
)

◆ RDT_HANDLER() [4/4]

RDT_HANDLER ( audio  ,
"x-pn-realaudio"  ,
AVMEDIA_TYPE_AUDIO   
)
RTPDynamicProtocolHandler::enc_name
const char * enc_name
Definition: rtpdec.h:117
rdt_parse_sdp_line
static int rdt_parse_sdp_line(AVFormatContext *s, int st_index, PayloadContext *rdt, const char *line)
Definition: rdt.c:409
s
#define s(width, name)
Definition: cbs_vp9.c:198
init
int(* init)(AVBSFContext *ctx)
Definition: dts2pts_bsf.c:365
rdt_close_context
static void rdt_close_context(PayloadContext *rdt)
Definition: rdt.c:541
AV_CODEC_ID_NONE
@ AV_CODEC_ID_NONE
Definition: codec_id.h:50
rdt_parse_packet
static int rdt_parse_packet(AVFormatContext *ctx, PayloadContext *rdt, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t rtp_seq, int flags)
Definition: rdt.c:294
rdt_init
static av_cold int rdt_init(AVFormatContext *s, int st_index, PayloadContext *rdt)
Definition: rdt.c:526
parse_packet
static int parse_packet(AVFormatContext *s, AVPacket *pkt, int stream_index, int flush)
Parse a packet, add all split parts to parse_queue.
Definition: demux.c:1133
PayloadContext
RTP/JPEG specific private data.
Definition: rdt.c:83
RTPDynamicProtocolHandler
Definition: rtpdec.h:116