66 int ident, fragmented, tdt, num_pkts, pkt_len;
91 if (len < 6 || len > INT_MAX/2) {
98 fragmented = buf[3] >> 6;
99 tdt = (buf[3] >> 4) & 3;
100 num_pkts = buf[3] & 0xf;
103 if (pkt_len > len - 6) {
105 "Invalid packet length %d in %d byte packet\n", pkt_len,
110 if (ident != data->
ident) {
112 "Unimplemented Xiph SDP configuration change detected\n");
118 "Unimplemented RTP Xiph packet settings (%d,%d,%d)\n",
119 fragmented, tdt, num_pkts);
126 if (fragmented == 0) {
132 memcpy(pkt->
data, buf, pkt_len);
157 }
else if (fragmented == 1) {
181 "Received packet without a start fragment; dropping.\n");
188 if (fragmented == 3) {
193 "Error occurred when getting fragment buffer.");
210 for (; *buf < buf_end; ++*
buf) {
213 if (!(**buf & 0x80)) {
226 const uint8_t * packed_headers_end,
230 unsigned num_packed, num_headers,
length, length1, length2, extradata_alloc;
233 if (packed_headers_end - packed_headers < 9) {
236 packed_headers_end - packed_headers);
240 num_packed = bytestream_get_be32(&packed_headers);
241 xiph_data->
ident = bytestream_get_be24(&packed_headers);
242 length = bytestream_get_be16(&packed_headers);
243 num_headers =
get_base128(&packed_headers, packed_headers_end);
244 length1 =
get_base128(&packed_headers, packed_headers_end);
245 length2 =
get_base128(&packed_headers, packed_headers_end);
247 if (num_packed != 1 || num_headers > 3) {
249 "Unimplemented number of headers: %d packed headers, %d headers\n",
250 num_packed, num_headers);
254 if (packed_headers_end - packed_headers != length ||
255 length1 > length || length2 > length - length1) {
258 length2, packed_headers_end - packed_headers, length);
276 memcpy(ptr, packed_headers, length);
288 const char *attr,
const char *
value)
293 if (!strcmp(attr,
"sampling")) {
294 if (!strcmp(value,
"YCbCr-4:2:0")) {
296 }
else if (!strcmp(value,
"YCbCr-4:4:2")) {
298 }
else if (!strcmp(value,
"YCbCr-4:4:4")) {
302 "Unsupported pixel format %s\n", attr);
305 }
else if (!strcmp(attr,
"width")) {
308 codec->
width = atoi(value);
310 }
else if (!strcmp(attr,
"height")) {
313 codec->
height = atoi(value);
315 }
else if (!strcmp(attr,
"delivery-method")) {
318 }
else if (!strcmp(attr,
"configuration-uri")) {
323 }
else if (!strcmp(attr,
"configuration")) {
328 size_t decoded_alloc = strlen(value) / 4 * 3 + 4;
330 if (decoded_alloc <= INT_MAX) {
331 decoded_packet =
av_malloc(decoded_alloc);
332 if (decoded_packet) {
337 (decoded_packet, decoded_packet + packet_size, codec,
341 "Out of memory while decoding SDP configuration.\n");
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
void av_free_packet(AVPacket *pkt)
Free a packet.
ptrdiff_t const GLvoid * data
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.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_WB24 unsigned int_TMPL AV_RB16
int avio_open_dyn_buf(AVIOContext **s)
Open a write only memory stream.
Macro definitions for various function/variable attributes.
static int xiph_parse_sdp_line(AVFormatContext *s, int st_index, PayloadContext *data, const char *line)
static int xiph_parse_fmtp_pair(AVFormatContext *s, AVStream *stream, PayloadContext *xiph_data, const char *attr, const char *value)
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVStream ** streams
A list of all streams in the file.
static void xiph_close_context(PayloadContext *data)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
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
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define PTRDIFF_SPECIFIER
simple assert() macros that are a bit more flexible than ISO C assert().
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
AVCodecContext * codec
Codec context associated with this stream.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int width
picture width / height.
GLsizei GLboolean const GLfloat * value
static int get_base128(const uint8_t **buf, const uint8_t *buf_end)
Length encoding described in RFC5215 section 3.1.1.
void ffio_free_dyn_buf(AVIOContext **s)
Free a dynamic buffer.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
AVIOContext * fragment
buffer for split payloads
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
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.
int ff_parse_fmtp(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *p, int(*parse_fmtp)(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *attr, const char *value))
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.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
Decode a base64-encoded string.
This structure stores compressed data.