*/
/**
-* @file libavformat/rtpdec_h264.c
+* @file
* @brief H.264 / RTP Code (RFC3984)
* @author Ryan Martell <rdm4@martellventures.com>
*
#include <assert.h>
#include "rtpdec.h"
-#include "rtpdec_h264.h"
+#include "rtpdec_formats.h"
/**
RTP/H264 specific private data.
#define DEAD_COOKIE (0xdeaddead) ///< Cookie for the extradata; once it is freed.
/* ---------------- private code */
-static void sdp_parse_fmtp_config_h264(AVStream * stream,
- PayloadContext * h264_data,
- char *attr, char *value)
+static int sdp_parse_fmtp_config_h264(AVStream * stream,
+ PayloadContext * h264_data,
+ char *attr, char *value)
{
AVCodecContext *codec = stream->codec;
assert(codec->codec_id == CODEC_ID_H264);
while (*value) {
char base64packet[1024];
uint8_t decoded_packet[1024];
- uint32_t packet_size;
+ int packet_size;
char *dst = base64packet;
while (*value && *value != ','
value++;
packet_size= av_base64_decode(decoded_packet, base64packet, sizeof(decoded_packet));
- if (packet_size) {
- uint8_t *dest= av_malloc(packet_size+sizeof(start_sequence)+codec->extradata_size);
+ if (packet_size > 0) {
+ uint8_t *dest = av_malloc(packet_size + sizeof(start_sequence) +
+ codec->extradata_size +
+ FF_INPUT_BUFFER_PADDING_SIZE);
if(dest)
{
if(codec->extradata_size)
memcpy(dest+codec->extradata_size, start_sequence, sizeof(start_sequence));
memcpy(dest+codec->extradata_size+sizeof(start_sequence), decoded_packet, packet_size);
+ memset(dest+codec->extradata_size+sizeof(start_sequence)+
+ packet_size, 0, FF_INPUT_BUFFER_PADDING_SIZE);
codec->extradata= dest;
codec->extradata_size+= sizeof(start_sequence)+packet_size;
} else {
av_log(codec, AV_LOG_ERROR, "Unable to allocate memory for extradata!");
+ return AVERROR(ENOMEM);
}
}
}
av_log(codec, AV_LOG_DEBUG, "Extradata set to %p (size: %d)!", codec->extradata, codec->extradata_size);
}
+ return 0;
}
// return 0 on packet, no more left, 1 on packet, 1 on partial packet...
codec->height = atoi(p + 1); // skip the -
codec->pix_fmt = PIX_FMT_YUV420P;
} else if (av_strstart(p, "fmtp:", &p)) {
- char attr[256];
- char value[4096];
-
- // remove the protocol identifier..
- while (*p && *p == ' ') p++; // strip spaces.
- while (*p && *p != ' ') p++; // eat protocol identifier
- while (*p && *p == ' ') p++; // strip trailing spaces.
-
- /* loop on each attribute */
- while (ff_rtsp_next_attr_and_value
- (&p, attr, sizeof(attr), value, sizeof(value))) {
- /* grab the codec extra_data from the config parameter of the fmtp line */
- sdp_parse_fmtp_config_h264(stream, h264_data, attr, value);
- }
+ return ff_parse_fmtp(stream, h264_data, p, sdp_parse_fmtp_config_h264);
} else if (av_strstart(p, "cliprect:", &p)) {
// could use this if we wanted.
}
- av_set_pts_info(stream, 33, 1, 90000); // 33 should be right, because the pts is 64 bit? (done elsewhere; this is a one time thing)
-
return 0; // keep processing it the normal way...
}
*/
RTPDynamicProtocolHandler ff_h264_dynamic_handler = {
.enc_name = "H264",
- .codec_type = CODEC_TYPE_VIDEO,
+ .codec_type = AVMEDIA_TYPE_VIDEO,
.codec_id = CODEC_ID_H264,
.parse_sdp_a_line = parse_h264_sdp_line,
.open = h264_new_context,