X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fsdp.c;h=11b50a0d071e32e6811dbde73dd1714aa99c3d00;hb=482ee63641f4fa50f017538af384aadbceee7a18;hp=5f3ed1c4b16ba81182170a856bb3638299da6ce7;hpb=23c1db9b83b5928a312b8d7cd753d04d49c252b6;p=ffmpeg diff --git a/libavformat/sdp.c b/libavformat/sdp.c index 5f3ed1c4b16..11b50a0d071 100644 --- a/libavformat/sdp.c +++ b/libavformat/sdp.c @@ -156,6 +156,8 @@ static char *extradata2psets(AVCodecContext *c) char *psets, *p; const uint8_t *r; const char *pset_string = "; sprop-parameter-sets="; + uint8_t *orig_extradata = NULL; + int orig_extradata_size = 0; if (c->extradata_size > MAX_EXTRADATA_SIZE) { av_log(c, AV_LOG_ERROR, "Too much extradata!\n"); @@ -172,6 +174,15 @@ static char *extradata2psets(AVCodecContext *c) return NULL; } + + orig_extradata_size = c->extradata_size; + orig_extradata = av_mallocz(orig_extradata_size + + FF_INPUT_BUFFER_PADDING_SIZE); + if (!orig_extradata) { + av_bitstream_filter_close(bsfc); + return NULL; + } + memcpy(orig_extradata, c->extradata, orig_extradata_size); av_bitstream_filter_filter(bsfc, c, NULL, &dummy_p, &dummy_int, NULL, 0, 0); av_bitstream_filter_close(bsfc); } @@ -179,6 +190,7 @@ static char *extradata2psets(AVCodecContext *c) psets = av_mallocz(MAX_PSET_SIZE); if (psets == NULL) { av_log(c, AV_LOG_ERROR, "Cannot allocate memory for the parameter sets.\n"); + av_free(orig_extradata); return NULL; } memcpy(psets, pset_string, strlen(pset_string)); @@ -208,6 +220,11 @@ static char *extradata2psets(AVCodecContext *c) p += strlen(p); r = r1; } + if (orig_extradata) { + av_free(c->extradata); + c->extradata = orig_extradata; + c->extradata_size = orig_extradata_size; + } return psets; } @@ -252,7 +269,7 @@ static char *xiph_extradata2config(AVCodecContext *c) return NULL; } - if (ff_split_xiph_headers(c->extradata, c->extradata_size, + if (avpriv_split_xiph_headers(c->extradata, c->extradata_size, first_header_size, header_start, header_len) < 0) { av_log(c, AV_LOG_ERROR, "Extradata corrupt.\n"); @@ -342,7 +359,7 @@ static char *latm_context2config(AVCodecContext *c) char *config; for (rate_index = 0; rate_index < 16; rate_index++) - if (ff_mpeg4audio_sample_rates[rate_index] == c->sample_rate) + if (avpriv_mpeg4audio_sample_rates[rate_index] == c->sample_rate) break; if (rate_index == 16) { av_log(c, AV_LOG_ERROR, "Unsupported sample rate\n"); @@ -402,7 +419,7 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, payload_type, config ? config : ""); break; case CODEC_ID_AAC: - if (fmt && fmt->oformat->priv_class && + if (fmt && fmt->oformat && fmt->oformat->priv_class && av_opt_flag_is_set(fmt->priv_data, "rtpflags", "latm")) { config = latm_context2config(c); if (!config) @@ -517,6 +534,14 @@ static char *sdp_write_media_attributes(char *buff, int size, AVCodecContext *c, payload_type, 8000, c->channels); break; + case CODEC_ID_ADPCM_G726: { + if (payload_type >= RTP_PT_PRIVATE) + av_strlcatf(buff, size, "a=rtpmap:%d G726-%d/%d\r\n", + payload_type, + c->bits_per_coded_sample*8, + c->sample_rate); + break; + } default: /* Nothing special to do here... */ break;