52 int packet_types_received[32];
57 #define COUNT_NAL_TYPE(data, nal) data->packet_types_received[(nal) & 0x1f]++
58 #define NAL_COUNTERS data->packet_types_received
60 #define COUNT_NAL_TYPE(data, nal) do { } while (0)
61 #define NAL_COUNTERS NULL
80 profile_idc = strtol(buffer,
NULL, 16);
83 profile_iop = strtol(buffer,
NULL, 16);
86 level_idc = strtol(buffer,
NULL, 16);
89 "RTP Profile IDC: %x Profile IOP: %x Level: %x\n",
90 profile_idc, profile_iop, level_idc);
97 uint8_t **data_ptr,
int *size_ptr,
100 char base64packet[1024];
105 char *dst = base64packet;
107 while (*value && *value !=
','
108 && (dst - base64packet) <
sizeof(base64packet) - 1) {
117 sizeof(decoded_packet));
118 if (packet_size > 0) {
125 "Unable to allocate memory for extradata!\n");
133 decoded_packet, packet_size);
147 const char *attr,
const char *
value)
151 if (!strcmp(attr,
"packetization-mode")) {
163 "Interleaved RTP mode is not supported yet.\n");
164 }
else if (!strcmp(attr,
"profile-level-id")) {
165 if (strlen(value) == 6)
167 }
else if (!strcmp(attr,
"sprop-parameter-sets")) {
186 while (*p && *p ==
' ')
188 while (*p && *p !=
' ')
190 while (*p && *p ==
' ')
192 while (*p && *p !=
'-' && (dst - buf1) <
sizeof(buf1) - 1)
198 codec->
width = atoi(buf1);
199 codec->
height = atoi(p + 1);
204 int skip_between,
int *nal_counters,
208 int total_length = 0;
213 for (pass = 0; pass < 2; pass++) {
217 while (src_len > 2) {
218 uint16_t nal_size =
AV_RB16(src);
224 if (nal_size <= src_len) {
232 memcpy(dst, src, nal_size);
234 nal_counters[(*src) & nal_mask]++;
239 "nal size exceeds length: %d %d\n", nal_size, src_len);
244 src += nal_size + skip_between;
245 src_len -= nal_size + skip_between;
261 int start_bit,
const uint8_t *nal_header,
274 memcpy(pkt->
data + pos, nal_header, nal_header_len);
275 pos += nal_header_len;
277 memcpy(pkt->
data + pos, buf, len);
283 int *nal_counters,
int nal_mask)
285 uint8_t fu_indicator, fu_header, start_bit, nal_type, nal;
292 fu_indicator = buf[0];
294 start_bit = fu_header >> 7;
295 nal_type = fu_header & 0x1f;
296 nal = fu_indicator & 0xe0 | nal_type;
302 if (start_bit && nal_counters)
303 nal_counters[nal_type & nal_mask]++;
326 if (type >= 1 && type <= 23)
351 "Unhandled type (%d) (See RFC for implementation details)\n",
379 for (ii = 0; ii < 32; ii++) {
380 if (data->packet_types_received[ii])
382 data->packet_types_received[ii], ii);
391 const char *p = line;
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
ptrdiff_t const GLvoid * data
RTP/JPEG specific private data.
int index
stream index in AVFormatContext
static int h264_handle_packet_fu_a(AVFormatContext *ctx, PayloadContext *data, AVPacket *pkt, const uint8_t *buf, int len, int *nal_counters, int nal_mask)
void ff_h264_parse_framesize(AVCodecContext *codec, const char *p)
RTPDynamicProtocolHandler ff_h264_dynamic_handler
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
Macro definitions for various function/variable attributes.
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVStream ** streams
A list of all streams in the file.
int ff_h264_handle_frag_packet(AVPacket *pkt, const uint8_t *buf, int len, int start_bit, const uint8_t *nal_header, int nal_header_len)
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static void h264_close_context(PayloadContext *data)
static int sdp_parse_fmtp_config_h264(AVFormatContext *s, AVStream *stream, PayloadContext *h264_data, const char *attr, const char *value)
#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)
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.
GLsizei GLboolean const GLfloat * value
#define COUNT_NAL_TYPE(data, nal)
main external API structure.
static void parse_profile_level_id(AVFormatContext *s, PayloadContext *h264_data, const char *value)
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.
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)
void * av_realloc(void *ptr, size_t size)
Allocate or reallocate a block of memory.
int ff_h264_parse_sprop_parameter_sets(AVFormatContext *s, uint8_t **data_ptr, int *size_ptr, const char *value)
int ff_h264_handle_aggregated_packet(AVFormatContext *ctx, PayloadContext *data, AVPacket *pkt, const uint8_t *buf, int len, int skip_between, int *nal_counters, int nal_mask)
static const uint8_t start_sequence[]
int av_base64_decode(uint8_t *out, const char *in_str, int out_size)
Decode a base64-encoded string.
This structure stores compressed data.