55 int packet_types_received[32];
60 #define COUNT_NAL_TYPE(data, nal) data->packet_types_received[(nal) & 0x1f]++
62 #define COUNT_NAL_TYPE(data, nal) do { } while (0)
70 char *attr,
char *value)
74 assert(h264_data !=
NULL);
76 if (!strcmp(attr,
"packetization-mode")) {
88 "Interleaved RTP mode is not supported yet.\n");
89 }
else if (!strcmp(attr,
"profile-level-id")) {
90 if (strlen(value) == 6) {
100 profile_idc = strtol(buffer,
NULL, 16);
101 buffer[0] = value[2];
102 buffer[1] = value[3];
103 profile_iop = strtol(buffer,
NULL, 16);
104 buffer[0] = value[4];
105 buffer[1] = value[5];
106 level_idc = strtol(buffer,
NULL, 16);
109 "RTP Profile IDC: %x Profile IOP: %x Level: %x\n",
110 profile_idc, profile_iop, level_idc);
115 }
else if (!strcmp(attr,
"sprop-parameter-sets")) {
119 if (*value == 0 || value[strlen(value) - 1] ==
',') {
125 char base64packet[1024];
128 char *dst = base64packet;
130 while (*value && *value !=
','
131 && (dst - base64packet) <
sizeof(base64packet) - 1) {
140 sizeof(decoded_packet));
141 if (packet_size > 0) {
147 "Unable to allocate memory for extradata!\n");
158 decoded_packet, packet_size);
194 if (type >= 1 && type <= 23)
213 int total_length = 0;
216 for (pass = 0; pass < 2; pass++) {
220 while (src_len > 2) {
221 uint16_t nal_size =
AV_RB16(src);
227 if (nal_size <= src_len) {
236 memcpy(dst, src, nal_size);
242 "nal size exceeds length: %d %d\n", nal_size, src_len);
251 "Consumed more bytes than we got! (%d)\n", src_len);
261 assert(dst - pkt->
data == total_length);
272 "Unhandled type (%d) (See RFC for implementation details\n",
284 uint8_t start_bit = fu_header >> 7;
286 uint8_t nal_type = fu_header & 0x1f;
292 reconstructed_nal = fu_indicator & 0xe0;
293 reconstructed_nal |= nal_type;
311 memcpy(pkt->
data, buf, len);
342 for (ii = 0; ii < 32; ii++) {
343 if (data->packet_types_received[ii])
345 data->packet_types_received[ii], ii);
366 const char *p = line;
372 codec = stream->
codec;
379 while (*p && *p ==
' ')
381 while (*p && *p !=
' ')
383 while (*p && *p ==
' ')
385 while (*p && *p !=
'-' && (dst - buf1) <
sizeof(buf1) - 1)
391 codec->
width = atoi(buf1);
392 codec->
height = atoi(p + 1);
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.
int ff_parse_fmtp(AVFormatContext *s, AVStream *stream, PayloadContext *data, const char *p, int(*parse_fmtp)(AVFormatContext *s, AVStream *stream, PayloadContext *data, char *attr, char *value))
#define AV_LOG_WARNING
Something somehow does not look correct.
RTP/JPEG specific private data.
int index
stream index in AVFormatContext
RTPDynamicProtocolHandler ff_h264_dynamic_handler
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 void h264_free_context(PayloadContext *data)
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.
static av_cold int h264_init(AVFormatContext *s, int st_index, PayloadContext *data)
bitstream reader API header.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
static PayloadContext * h264_new_context(void)
#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(). ...
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
static int parse_h264_sdp_line(AVFormatContext *s, int st_index, PayloadContext *h264_data, const char *line)
void av_log(void *avcl, int level, const char *fmt,...)
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.
#define COUNT_NAL_TYPE(data, nal)
static int sdp_parse_fmtp_config_h264(AVFormatContext *s, AVStream *stream, PayloadContext *h264_data, char *attr, char *value)
main external API structure.
int av_strstart(const char *str, const char *pfx, const char **ptr)
Return non-zero if pfx is a prefix of str.
static int h264_handle_packet(AVFormatContext *ctx, PayloadContext *data, AVStream *st, AVPacket *pkt, uint32_t *timestamp, const uint8_t *buf, int len, uint16_t seq, int flags)
static const uint8_t start_sequence[]
int av_base64_decode(uint8_t *out, const char *in, int out_size)
Decode a base64-encoded string.
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 ...