90 int ident, fragmented, tdt, num_pkts, pkt_len;
122 fragmented = buf[3] >> 6;
123 tdt = (buf[3] >> 4) & 3;
124 num_pkts = buf[3] & 0xf;
127 if (pkt_len > len - 6) {
129 "Invalid packet length %d in %d byte packet\n", pkt_len,
134 if (ident != data->
ident) {
136 "Unimplemented Xiph SDP configuration change detected\n");
142 "Unimplemented RTP Xiph packet settings (%d,%d,%d)\n",
143 fragmented, tdt, num_pkts);
150 if (fragmented == 0) {
156 memcpy(pkt->
data, buf, pkt_len);
181 }
else if (fragmented == 1) {
195 assert(fragmented < 4);
205 "Received packet without a start fragment; dropping.\n");
212 if (fragmented == 3) {
217 "Error occurred when getting fragment buffer.");
234 for (; *buf < buf_end; ++*buf) {
237 if (!(**buf & 0x80)) {
250 const uint8_t * packed_headers_end,
254 unsigned num_packed, num_headers, length, length1, length2, extradata_alloc;
257 if (packed_headers_end - packed_headers < 9) {
259 "Invalid %td byte packed header.",
260 packed_headers_end - packed_headers);
264 num_packed = bytestream_get_be32(&packed_headers);
265 xiph_data->
ident = bytestream_get_be24(&packed_headers);
266 length = bytestream_get_be16(&packed_headers);
267 num_headers =
get_base128(&packed_headers, packed_headers_end);
268 length1 =
get_base128(&packed_headers, packed_headers_end);
269 length2 =
get_base128(&packed_headers, packed_headers_end);
271 if (num_packed != 1 || num_headers > 3) {
273 "Unimplemented number of headers: %d packed headers, %d headers\n",
274 num_packed, num_headers);
278 if (packed_headers_end - packed_headers != length ||
279 length1 > length || length2 > length - length1) {
281 "Bad packed header lengths (%d,%d,%td,%d)\n", length1,
282 length2, packed_headers_end - packed_headers, length);
300 memcpy(ptr, packed_headers, length);
311 char *attr,
char *value)
316 if (!strcmp(attr,
"sampling")) {
317 if (!strcmp(value,
"YCbCr-4:2:0")) {
319 }
else if (!strcmp(value,
"YCbCr-4:4:2")) {
321 }
else if (!strcmp(value,
"YCbCr-4:4:4")) {
325 "Unsupported pixel format %s\n", attr);
328 }
else if (!strcmp(attr,
"width")) {
331 codec->
width = atoi(value);
333 }
else if (!strcmp(attr,
"height")) {
336 codec->
height = atoi(value);
338 }
else if (!strcmp(attr,
"delivery-method")) {
341 }
else if (!strcmp(attr,
"configuration-uri")) {
346 }
else if (!strcmp(attr,
"configuration")) {
351 size_t decoded_alloc = strlen(value) / 4 * 3 + 4;
353 if (decoded_alloc <= INT_MAX) {
354 decoded_packet =
av_malloc(decoded_alloc);
355 if (decoded_packet) {
360 (decoded_packet, decoded_packet + packet_size, codec,
364 "Out of memory while decoding SDP configuration.\n");
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static PayloadContext * xiph_new_context(void)
void av_free_packet(AVPacket *pkt)
Free a packet.
int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
Return the written size and a pointer to the buffer.
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
#define AV_LOG_WARNING
Something somehow does not look correct.
RTP/JPEG specific private data.
int index
stream index in AVFormatContext
RTPDynamicProtocolHandler ff_theora_dynamic_handler
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
static void free_fragment_if_needed(PayloadContext *data)
Macro definitions for various function/variable attributes.
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
static int xiph_parse_sdp_line(AVFormatContext *s, int st_index, PayloadContext *data, const char *line)
enum AVStreamParseType need_parsing
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVStream ** streams
A list of all streams in the file.
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
AVIOContext * fragment
buffer for split payloads
unsigned ident
24-bit stream configuration identifier
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
uint32_t timestamp
current frame timestamp
static void xiph_free_context(PayloadContext *data)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
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:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AVCodecContext * codec
Codec context associated with this stream.
#define FF_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int width
picture width / height.
static int get_base128(const uint8_t **buf, const uint8_t *buf_end)
Length encoding described in RFC5215 section 3.1.1.
#define AVERROR_PATCHWELCOME
Not yet implemented in Libav, patches welcome.
main external API structure.
static 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.
unsigned int av_xiphlacing(unsigned char *s, unsigned int v)
Encode extradata length to a buffer.
static av_cold int xiph_vorbis_init(AVFormatContext *ctx, int st_index, PayloadContext *data)
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
static int xiph_handle_packet(AVFormatContext *ctx, PayloadContext *data, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags)
RTPDynamicProtocolHandler ff_vorbis_dynamic_handler
int ff_rtp_finalize_packet(AVPacket *pkt, AVIOContext **dyn_buf, int stream_idx)
Close the dynamic buffer and make a packet from it.
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))
This structure stores compressed data.
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
static int xiph_parse_fmtp_pair(AVStream *stream, PayloadContext *xiph_data, char *attr, char *value)