X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavformat%2Fsmoothstreamingenc.c;h=193c360db1f077a77d758881049b56423fc6488a;hb=6372c9dc9972318e75a5889ad6c52500b8294099;hp=f36e5fee7b2253328815f5089c051969d0de217b;hpb=79127dbbeffa87243c92af2befc09ad63bcbd1a1;p=ffmpeg diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index f36e5fee7b2..193c360db1f 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -122,8 +122,8 @@ static int64_t ism_seek(void *opaque, int64_t offset, int whence) AVDictionary *opts = NULL; os->tail_out = os->out; av_dict_set(&opts, "truncate", "0", 0); - ret = ffurl_open_whitelist(&os->out, frag->file, AVIO_FLAG_READ_WRITE, - &os->ctx->interrupt_callback, &opts, os->ctx->protocol_whitelist); + ret = ffurl_open_whitelist(&os->out, frag->file, AVIO_FLAG_WRITE, + &os->ctx->interrupt_callback, &opts, os->ctx->protocol_whitelist, os->ctx->protocol_blacklist); av_dict_free(&opts); if (ret < 0) { os->out = os->tail_out; @@ -131,8 +131,8 @@ static int64_t ism_seek(void *opaque, int64_t offset, int whence) return ret; } av_dict_set(&opts, "truncate", "0", 0); - ffurl_open_whitelist(&os->out2, frag->infofile, AVIO_FLAG_READ_WRITE, - &os->ctx->interrupt_callback, &opts, os->ctx->protocol_whitelist); + ffurl_open_whitelist(&os->out2, frag->infofile, AVIO_FLAG_WRITE, + &os->ctx->interrupt_callback, &opts, os->ctx->protocol_whitelist, os->ctx->protocol_blacklist); av_dict_free(&opts); ffurl_seek(os->out, offset - frag->start_pos, SEEK_SET); if (os->out2) @@ -146,14 +146,14 @@ static int64_t ism_seek(void *opaque, int64_t offset, int whence) static void get_private_data(OutputStream *os) { - AVCodecContext *codec = os->ctx->streams[0]->codec; - uint8_t *ptr = codec->extradata; - int size = codec->extradata_size; + AVCodecParameters *par = os->ctx->streams[0]->codecpar; + uint8_t *ptr = par->extradata; + int size = par->extradata_size; int i; - if (codec->codec_id == AV_CODEC_ID_H264) { + if (par->codec_id == AV_CODEC_ID_H264) { ff_avc_write_annexb_extradata(ptr, &ptr, &size); if (!ptr) - ptr = codec->extradata; + ptr = par->extradata; } if (!ptr) return; @@ -163,7 +163,7 @@ static void get_private_data(OutputStream *os) for (i = 0; i < size; i++) snprintf(&os->private_str[2*i], 3, "%02x", ptr[i]); fail: - if (ptr != codec->extradata) + if (ptr != par->extradata) av_free(ptr); } @@ -235,7 +235,7 @@ static int write_manifest(AVFormatContext *s, int final) Fragment *last = os->fragments[os->nb_fragments - 1]; duration = last->start_time + last->duration; } - if (s->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + if (s->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { video_chunks = os->nb_fragments; video_streams++; } else { @@ -260,10 +260,10 @@ static int write_manifest(AVFormatContext *s, int final) avio_printf(out, "\n", video_streams, video_chunks); for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[i]; - if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_VIDEO) + if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_VIDEO) continue; last = i; - avio_printf(out, "\n", index, (int64_t)s->streams[i]->codec->bit_rate, os->fourcc, s->streams[i]->codec->width, s->streams[i]->codec->height, os->private_str); + avio_printf(out, "\n", index, (int64_t)s->streams[i]->codecpar->bit_rate, os->fourcc, s->streams[i]->codecpar->width, s->streams[i]->codecpar->height, os->private_str); index++; } output_chunk_list(&c->streams[last], out, final, c->lookahead_count, c->window_size); @@ -274,10 +274,10 @@ static int write_manifest(AVFormatContext *s, int final) avio_printf(out, "\n", audio_streams, audio_chunks); for (i = 0; i < s->nb_streams; i++) { OutputStream *os = &c->streams[i]; - if (s->streams[i]->codec->codec_type != AVMEDIA_TYPE_AUDIO) + if (s->streams[i]->codecpar->codec_type != AVMEDIA_TYPE_AUDIO) continue; last = i; - avio_printf(out, "\n", index, (int64_t)s->streams[i]->codec->bit_rate, os->fourcc, s->streams[i]->codec->sample_rate, s->streams[i]->codec->channels, os->packet_size, os->audio_tag, os->private_str); + avio_printf(out, "\n", index, (int64_t)s->streams[i]->codecpar->bit_rate, os->fourcc, s->streams[i]->codecpar->sample_rate, s->streams[i]->codecpar->channels, os->packet_size, os->audio_tag, os->private_str); index++; } output_chunk_list(&c->streams[last], out, final, c->lookahead_count, c->window_size); @@ -319,12 +319,12 @@ static int ism_write_header(AVFormatContext *s) AVStream *st; AVDictionary *opts = NULL; - if (!s->streams[i]->codec->bit_rate) { + if (!s->streams[i]->codecpar->bit_rate) { av_log(s, AV_LOG_ERROR, "No bit rate set for stream %d\n", i); ret = AVERROR(EINVAL); goto fail; } - snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%"PRId64")", s->filename, (int64_t)s->streams[i]->codec->bit_rate); + snprintf(os->dirname, sizeof(os->dirname), "%s/QualityLevels(%"PRId64")", s->filename, (int64_t)s->streams[i]->codecpar->bit_rate); if (mkdir(os->dirname, 0777) == -1 && errno != EEXIST) { ret = AVERROR(errno); av_log(s, AV_LOG_ERROR, "mkdir failed\n"); @@ -332,7 +332,7 @@ static int ism_write_header(AVFormatContext *s) } ctx = avformat_alloc_context(); - if (!ctx || ff_copy_whitelists(ctx, s) < 0) { + if (!ctx || ff_copy_whiteblacklists(ctx, s) < 0) { ret = AVERROR(ENOMEM); goto fail; } @@ -344,7 +344,7 @@ static int ism_write_header(AVFormatContext *s) ret = AVERROR(ENOMEM); goto fail; } - avcodec_copy_context(st->codec, s->streams[i]->codec); + avcodec_parameters_copy(st->codecpar, s->streams[i]->codecpar); st->sample_aspect_ratio = s->streams[i]->sample_aspect_ratio; st->time_base = s->streams[i]->time_base; @@ -363,12 +363,12 @@ static int ism_write_header(AVFormatContext *s) avio_flush(ctx->pb); av_dict_free(&opts); s->streams[i]->time_base = st->time_base; - if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { c->has_video = 1; os->stream_type_tag = "video"; - if (st->codec->codec_id == AV_CODEC_ID_H264) { + if (st->codecpar->codec_id == AV_CODEC_ID_H264) { os->fourcc = "H264"; - } else if (st->codec->codec_id == AV_CODEC_ID_VC1) { + } else if (st->codecpar->codec_id == AV_CODEC_ID_VC1) { os->fourcc = "WVC1"; } else { av_log(s, AV_LOG_ERROR, "Unsupported video codec\n"); @@ -378,10 +378,10 @@ static int ism_write_header(AVFormatContext *s) } else { c->has_audio = 1; os->stream_type_tag = "audio"; - if (st->codec->codec_id == AV_CODEC_ID_AAC) { + if (st->codecpar->codec_id == AV_CODEC_ID_AAC) { os->fourcc = "AACL"; os->audio_tag = 0xff; - } else if (st->codec->codec_id == AV_CODEC_ID_WMAPRO) { + } else if (st->codecpar->codec_id == AV_CODEC_ID_WMAPRO) { os->fourcc = "WMAP"; os->audio_tag = 0x0162; } else { @@ -389,7 +389,7 @@ static int ism_write_header(AVFormatContext *s) ret = AVERROR(EINVAL); goto fail; } - os->packet_size = st->codec->block_align ? st->codec->block_align : 4; + os->packet_size = st->codecpar->block_align ? st->codecpar->block_align : 4; } get_private_data(os); } @@ -526,7 +526,7 @@ static int ism_flush(AVFormatContext *s, int final) continue; snprintf(filename, sizeof(filename), "%s/temp", os->dirname); - ret = ffurl_open_whitelist(&os->out, filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL, s->protocol_whitelist); + ret = ffurl_open_whitelist(&os->out, filename, AVIO_FLAG_WRITE, &s->interrupt_callback, NULL, s->protocol_whitelist, s->protocol_blacklist); if (ret < 0) break; os->cur_start_pos = os->tail_pos; @@ -588,7 +588,7 @@ static int ism_write_packet(AVFormatContext *s, AVPacket *pkt) if (st->first_dts == AV_NOPTS_VALUE) st->first_dts = pkt->dts; - if ((!c->has_video || st->codec->codec_type == AVMEDIA_TYPE_VIDEO) && + if ((!c->has_video || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) && av_compare_ts(pkt->dts - st->first_dts, st->time_base, end_dts, AV_TIME_BASE_Q) >= 0 && pkt->flags & AV_PKT_FLAG_KEY && os->packets_written) {