#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 "libavcodec/bitstream.h"
Go to the source code of this file.
Data Structures | |
struct | RDTDemuxContext |
struct | PayloadContext |
RTP/H264 specific private data. More... | |
Defines | |
#define | XOR_TABLE_SIZE 37 |
#define | RDT_HANDLER(n, s, t) |
Functions | |
RDTDemuxContext * | ff_rdt_parse_open (AVFormatContext *ic, int first_stream_of_set_idx, void *priv_data, RTPDynamicProtocolHandler *handler) |
Allocate and init the RDT parsing context. | |
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. | |
static int | rdt_load_mdpr (PayloadContext *rdt, AVStream *st, int rule_nr) |
int | ff_rdt_parse_header (const uint8_t *buf, int len, int *pset_id, int *pseq_no, int *pstream_id, int *pis_keyframe, uint32_t *ptimestamp) |
Actual data handling. | |
static int | rdt_parse_packet (AVFormatContext *ctx, PayloadContext *rdt, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, int flags) |
int | ff_rdt_parse_packet (RDTDemuxContext *s, AVPacket *pkt, const uint8_t *buf, int len) |
Parse RDT-style packet data (header + media data). | |
void | ff_rdt_subscribe_rule (char *cmd, int size, int stream_nr, int rule_nr) |
Add subscription information to Subscribe parameter string. | |
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 AVStream * | add_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. | |
static PayloadContext * | rdt_new_extradata (void) |
static void | rdt_free_extradata (PayloadContext *rdt) |
RDT_HANDLER (live_video,"x-pn-multirate-realvideo-live", CODEC_TYPE_VIDEO) | |
RDT_HANDLER (live_audio,"x-pn-multirate-realaudio-live", CODEC_TYPE_AUDIO) | |
RDT_HANDLER (video,"x-pn-realvideo", CODEC_TYPE_VIDEO) | |
RDT_HANDLER (audio,"x-pn-realaudio", CODEC_TYPE_AUDIO) | |
void | av_register_rdt_dynamic_payload_handlers (void) |
Register RDT-related dynamic payload handlers with our cache. |
Definition in file rdt.c.
#define RDT_HANDLER | ( | n, | |||
s, | |||||
t | ) |
Value:
static RTPDynamicProtocolHandler ff_rdt_ ## n ## _handler = { \ s, \ t, \ CODEC_ID_NONE, \ rdt_parse_sdp_line, \ rdt_new_extradata, \ rdt_free_extradata, \ rdt_parse_packet \ };
#define XOR_TABLE_SIZE 37 |
Referenced by ff_rdt_calc_response_and_checksum().
static AVStream* add_dstream | ( | AVFormatContext * | s, | |
AVStream * | orig_st | |||
) | [static] |
void av_register_rdt_dynamic_payload_handlers | ( | void | ) |
Register RDT-related dynamic payload handlers with our cache.
Definition at line 553 of file rdt.c.
Referenced by av_register_all().
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.
response | pointer to response buffer, it should be at least 41 bytes (40 data + 1 zero) bytes long. | |
chksum | pointer to buffer containing a checksum of the response, it should be at least 9 (8 data + 1 zero) bytes long. | |
challenge | pointer to the RealChallenge1 value provided by the server. |
Definition at line 97 of file rdt.c.
Referenced by make_setup_request().
void ff_rdt_parse_close | ( | RDTDemuxContext * | s | ) |
int ff_rdt_parse_header | ( | const uint8_t * | buf, | |
int | len, | |||
int * | pset_id, | |||
int * | pseq_no, | |||
int * | pstream_id, | |||
int * | pis_keyframe, | |||
uint32_t * | ptimestamp | |||
) |
Actual data handling.
Parse RDT-style packet header.
return 0 on packet, no more left, 1 on packet, 1 on partial packet...
Layout of the header (in bits): 1: len_included Flag indicating whether this header includes a length field; this can be used to concatenate multiple RDT packets in a single UDP/TCP data frame and is used to precede RDT data by stream status packets 1: need_reliable Flag indicating whether this header includes a "reliable sequence number"; these are apparently sequence numbers of data packets alone. For data packets, this flag is always set, according to the Real documentation [1] 5: set_id ID of a set of streams of identical content, possibly with different codecs or bitrates 1: is_reliable Flag set for certain streams deemed less tolerable for packet loss 16: seq_no Packet sequence number; if >=0xFF00, this is a non-data packet containing stream status info, the second byte indicates the type of status packet (see wireshark docs / source code [2]) if (len_included) { 16: packet_len } else { packet_len = remainder of UDP/TCP frame } 1: is_back_to_back Back-to-Back flag; used for timing, set for one in every 10 packets, according to the Real documentation [1] 1: is_slow_data Slow-data flag; currently unused, according to Real docs [1] 5: stream_id ID of the stream within this particular set of streams 1: is_no_keyframe Non-keyframe flag (unset if packet belongs to a keyframe) 32: timestamp (PTS) if (set_id == 0x1F) { 16: set_id (extended set-of-streams ID; see set_id) } if (need_reliable) { 16: reliable_seq_no Reliable sequence number (see need_reliable) } if (stream_id == 0x3F) { 16: stream_id (extended stream ID; see stream_id) } [1] https://protocol.helixcommunity.org/files/2005/devdocs/RDT_Feature_Level_20.txt [2] http://www.wireshark.org/docs/dfref/r/rdt.html and http://anonsvn.wireshark.org/viewvc/trunk/epan/dissectors/packet-rdt.c
Definition at line 194 of file rdt.c.
Referenced by ff_rdt_parse_packet(), and tcp_read_packet().
RDTDemuxContext* ff_rdt_parse_open | ( | AVFormatContext * | ic, | |
int | first_stream_of_set_idx, | |||
void * | priv_data, | |||
RTPDynamicProtocolHandler * | handler | |||
) |
Allocate and init the RDT parsing context.
ic | the containing RTSP demuxer context | |
first_stream_of_set_idx | index 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_data | private data of the payload data handler context | |
handler | pointer to the parse_packet() payload parsing function |
Definition at line 54 of file rdt.c.
Referenced by rtsp_open_transport_ctx().
int ff_rdt_parse_packet | ( | RDTDemuxContext * | s, | |
AVPacket * | pkt, | |||
const 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 337 of file rdt.c.
Referenced by rtsp_read_packet().
void ff_rdt_subscribe_rule | ( | char * | cmd, | |
int | size, | |||
int | stream_nr, | |||
int | rule_nr | |||
) |
Add subscription information to Subscribe parameter string.
cmd | string to write the subscription information into. | |
size | size of cmd. | |
stream_nr | stream number. | |
rule_nr | rule number to conform to. |
Definition at line 385 of file rdt.c.
Referenced by rtsp_read_packet().
void ff_real_parse_sdp_a_line | ( | AVFormatContext * | s, | |
int | stream_index, | |||
const char * | buf | |||
) |
Parse a server-related SDP line.
s | the RTSP AVFormatContext | |
stream_index | the index of the first stream in the set represented by the SDP m= line (in s->streams) | |
buf | the SDP line |
Definition at line 502 of file rdt.c.
Referenced by sdp_parse_line().
static void rdt_free_extradata | ( | PayloadContext * | rdt | ) | [static] |
RDT_HANDLER | ( | audio | , | |
"x-pn-realaudio" | , | |||
CODEC_TYPE_AUDIO | ||||
) |
RDT_HANDLER | ( | video | , | |
"x-pn-realvideo" | , | |||
CODEC_TYPE_VIDEO | ||||
) |
RDT_HANDLER | ( | live_audio | , | |
"x-pn-multirate-realaudio-live" | , | |||
CODEC_TYPE_AUDIO | ||||
) |
RDT_HANDLER | ( | live_video | , | |
"x-pn-multirate-realvideo-live" | , | |||
CODEC_TYPE_VIDEO | ||||
) |
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> [size]:<data> 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 136 of file rdt.c.
Referenced by rdt_parse_sdp_line().
static PayloadContext* rdt_new_extradata | ( | void | ) | [static] |
static unsigned char* rdt_parse_b64buf | ( | unsigned int * | target_len, | |
const char * | p | |||
) | [static] |
static int rdt_parse_packet | ( | AVFormatContext * | ctx, | |
PayloadContext * | rdt, | |||
AVStream * | st, | |||
AVPacket * | pkt, | |||
uint32_t * | timestamp, | |||
const uint8_t * | buf, | |||
int | len, | |||
int | flags | |||
) | [static] |
static int rdt_parse_sdp_line | ( | AVFormatContext * | s, | |
int | st_index, | |||
PayloadContext * | rdt, | |||
const char * | line | |||
) | [static] |
static void real_parse_asm_rule | ( | AVStream * | st, | |
const char * | p, | |||
const char * | end | |||
) | [static] |
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 preceeded 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 463 of file rdt.c.
Referenced by ff_real_parse_sdp_a_line().