78 const uint8_t * buf,
int len,
int flags)
81 int ident, fragmented, tdt, num_pkts, pkt_len;
113 fragmented = buf[3] >> 6;
114 tdt = (buf[3] >> 4) & 3;
115 num_pkts = buf[3] & 0xf;
118 if (pkt_len > len - 6) {
120 "Invalid packet length %d in %d byte packet\n", pkt_len,
125 if (ident != data->
ident) {
127 "Unimplemented Xiph SDP configuration change detected\n");
133 "Unimplemented RTP Xiph packet settings (%d,%d,%d)\n",
134 fragmented, tdt, num_pkts);
141 if (fragmented == 0) {
147 memcpy(pkt->
data, buf, pkt_len);
172 }
else if (fragmented == 1) {
186 assert(fragmented < 4);
196 "Received packet without a start fragment; dropping.\n");
203 if (fragmented == 3) {
210 "Error occurred when getting fragment buffer.");
229 static int get_base128(
const uint8_t ** buf,
const uint8_t * buf_end)
232 for (; *buf < buf_end; ++*buf) {
235 if (!(**buf & 0x80)) {
248 const uint8_t * packed_headers_end,
252 unsigned num_packed, num_headers, length, length1, length2, extradata_alloc;
255 if (packed_headers_end - packed_headers < 9) {
257 "Invalid %td byte packed header.",
258 packed_headers_end - packed_headers);
262 num_packed = bytestream_get_be32(&packed_headers);
263 xiph_data->
ident = bytestream_get_be24(&packed_headers);
264 length = bytestream_get_be16(&packed_headers);
265 num_headers =
get_base128(&packed_headers, packed_headers_end);
266 length1 =
get_base128(&packed_headers, packed_headers_end);
267 length2 =
get_base128(&packed_headers, packed_headers_end);
269 if (num_packed != 1 || num_headers > 3) {
271 "Unimplemented number of headers: %d packed headers, %d headers\n",
272 num_packed, num_headers);
276 if (packed_headers_end - packed_headers != length ||
277 length1 > length || length2 > length - length1) {
279 "Bad packed header lengths (%d,%d,%td,%d)\n", length1,
280 length2, packed_headers_end - packed_headers, length);
298 memcpy(ptr, packed_headers, length);
309 char *attr,
char *value)
314 if (!strcmp(attr,
"sampling")) {
315 if (!strcmp(value,
"YCbCr-4:2:0")) {
317 }
else if (!strcmp(value,
"YCbCr-4:4:2")) {
319 }
else if (!strcmp(value,
"YCbCr-4:4:4")) {
323 "Unsupported pixel format %s\n", attr);
326 }
else if (!strcmp(attr,
"width")) {
329 codec->
width = atoi(value);
331 }
else if (!strcmp(attr,
"height")) {
334 codec->
height = atoi(value);
336 }
else if (!strcmp(attr,
"delivery-method")) {
339 }
else if (!strcmp(attr,
"configuration-uri")) {
344 }
else if (!strcmp(attr,
"configuration")) {
347 uint8_t *decoded_packet =
NULL;
349 size_t decoded_alloc = strlen(value) / 4 * 3 + 4;
351 if (decoded_alloc <= INT_MAX) {
352 decoded_packet =
av_malloc(decoded_alloc);
353 if (decoded_packet) {
358 (decoded_packet, decoded_packet + packet_size, codec,
362 "Out of memory while decoding SDP configuration.\n");
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
enum PixelFormat pix_fmt
Pixel format, see PIX_FMT_xxx.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static PayloadContext * xiph_new_context(void)
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_WB24 AV_RB16
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_WARNING
Something somehow does not look correct.
RTP/H264 specific private data.
int index
stream index in AVFormatContext
RTPDynamicProtocolHandler ff_theora_dynamic_handler
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
static void free_fragment_if_needed(PayloadContext *data)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
static int xiph_parse_sdp_line(AVFormatContext *s, int st_index, PayloadContext *data, const char *line)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
void av_free_packet(AVPacket *pkt)
Free a packet.
void av_destruct_packet(AVPacket *pkt)
Default packet destructor.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
AVIOContext * fragment
buffer for split payloads
void(* destruct)(struct AVPacket *)
unsigned ident
24-bit stream configuration identifier
uint32_t timestamp
timestamp of next-to-be-returned packet
static void xiph_free_context(PayloadContext *data)
void av_free(void *ptr)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc(). ...
void av_log(void *avcl, int level, const char *fmt,...)
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
AVCodecContext * codec
codec context
int width
picture width / height.
static unsigned int parse_packed_headers(const uint8_t *packed_headers, const uint8_t *packed_headers_end, AVCodecContext *codec, PayloadContext *xiph_data)
Based off parse_packed_headers in Vorbis RTP.
static int get_base128(const uint8_t **buf, const uint8_t *buf_end)
Length encoding described in RFC5215 section 3.1.1.
static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, int flags)
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
main external API structure.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
AV_WL32 AV_WL24 AV_WL16 AV_WB32 AV_RB24
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
RTPDynamicProtocolHandler ff_vorbis_dynamic_handler
int av_base64_decode(uint8_t *out, const char *in, int out_size)
Decode a base64-encoded string.
int ff_parse_fmtp(AVStream *stream, PayloadContext *data, const char *p, int(*parse_fmtp)(AVStream *stream, PayloadContext *data, char *attr, char *value))
static int xiph_parse_fmtp_pair(AVStream *stream, PayloadContext *xiph_data, char *attr, char *value)