From patchwork Sat Dec 30 21:16:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 7040 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.79.195 with SMTP id r64csp11989979jad; Sat, 30 Dec 2017 13:16:32 -0800 (PST) X-Google-Smtp-Source: ACJfBov+dD9DLpeQv/lOuQgDJzKWfcPbvg4moYONN56fTqvdjrhxSn052TYxSugULQc4Xux8UtYr X-Received: by 10.28.49.195 with SMTP id x186mr28854940wmx.116.1514668592570; Sat, 30 Dec 2017 13:16:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1514668592; cv=none; d=google.com; s=arc-20160816; b=H7eTUVIW5U20T2GAD5Oet5frFpMYk+jr6VbDy7Ya+zdP9OSqMtODbTY7LiNl+xv6kq CDGZm69O3EDeuyt40TVylH+WLjo42WRlx/PoY9QWUs/E2rtXirCzSP2cFt1EgJbYvqMk EM7zbuDIhsvbamKudp8RvraSPN4lNHRKusvvSGG2eGeHc6hjnNGGSwiZJbA72kE/w8ig OSP7mhglzvPqCazn4/ThywDFdqfXrUP5TGZtjZ5WM83MtCDoaYhcvMlCLlpcsBYzMcdr PE7sc1gdgeOgB7LzOHY+I5XMhK0TR6HYXj+L5fKebdhA42SusBET3Y/MZPTa4UCY+bF3 ecmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to:arc-authentication-results; bh=kJFEo7REXWpwI4/hptvtJNCPYqtYuop+YLaRrKJPXfA=; b=U3P7FcrZjWlxlGjZ6zfFKCGS9p6h7vcm1KvAc/1FKJHDst6m6ILlnopSKnI/ielqPj vewAySL7yTOkX/wpXOlmkSxCZgQF8m4qbpcntkgACv7AVROARom/qxXINZa5hAVGurEk +EDpSJjl56hgH+eIe6gs2yIXhrxomxASRnePY93vGKd8lrO52VdYMgzoWRKavn+xg73s k67WO/99wJ7BSszC42lpzdBv+68lpuA6E0LnJYc6HuNACj5fJcZgpNeXWYfxIA5ZNzBA mCleJAVshZ9LeK8pxMugFD+PgDJn6yXrJXd9b6J/5xyXpbev7N3T9LbW1OpeGUjARwI0 dYew== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id s82si18168592wmb.177.2017.12.30.13.16.32; Sat, 30 Dec 2017 13:16:32 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A7C04689F5D; Sat, 30 Dec 2017 23:16:09 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C9A10689F29 for ; Sat, 30 Dec 2017 23:16:02 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id EAF1BE149B; Sat, 30 Dec 2017 22:16:17 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2n_I-AYG1dT8; Sat, 30 Dec 2017 22:16:16 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 627AFE129E; Sat, 30 Dec 2017 22:16:16 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 30 Dec 2017 22:16:02 +0100 Message-Id: <20171230211606.16405-2-cus@passwd.hu> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171230211606.16405-1-cus@passwd.hu> References: <20171230211606.16405-1-cus@passwd.hu> Subject: [FFmpeg-devel] [PATCH 2/6] fftools, tools, examples: migrate to AVFormatContext->url X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Marton Balint MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Signed-off-by: Marton Balint --- doc/examples/transcode_aac.c | 7 +++++-- fftools/ffmpeg.c | 16 ++++++++-------- fftools/ffmpeg_opt.c | 8 ++++---- fftools/ffplay.c | 6 +++--- fftools/ffprobe.c | 2 +- tools/uncoded_frame.c | 2 +- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/doc/examples/transcode_aac.c b/doc/examples/transcode_aac.c index 9fd5c00d60..3c7688cd33 100644 --- a/doc/examples/transcode_aac.c +++ b/doc/examples/transcode_aac.c @@ -171,8 +171,11 @@ static int open_output_file(const char *filename, goto cleanup; } - av_strlcpy((*output_format_context)->filename, filename, - sizeof((*output_format_context)->filename)); + if (!((*output_format_context)->url = av_strdup(filename))) { + fprintf(stderr, "Could not allocate url.\n"); + error = AVERROR(ENOMEM); + goto cleanup; + } /* Find the encoder to be used by its name. */ if (!(output_codec = avcodec_find_encoder(AV_CODEC_ID_AAC))) { diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 6aff3366c5..56c077921c 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1563,7 +1563,7 @@ static void print_final_stats(int64_t total_size) uint64_t total_packets = 0, total_size = 0; av_log(NULL, AV_LOG_VERBOSE, "Input file #%d (%s):\n", - i, f->ctx->filename); + i, f->ctx->url); for (j = 0; j < f->nb_streams; j++) { InputStream *ist = input_streams[f->ist_index + j]; @@ -1597,7 +1597,7 @@ static void print_final_stats(int64_t total_size) uint64_t total_packets = 0, total_size = 0; av_log(NULL, AV_LOG_VERBOSE, "Output file #%d (%s):\n", - i, of->ctx->filename); + i, of->ctx->url); for (j = 0; j < of->ctx->nb_streams; j++) { OutputStream *ost = output_streams[of->ost_index + j]; @@ -2105,7 +2105,7 @@ static void check_decode_result(InputStream *ist, int *got_output, int ret) if (exit_on_error && *got_output && ist) { if (ist->decoded_frame->decode_error_flags || (ist->decoded_frame->flags & AV_FRAME_FLAG_CORRUPT)) { - av_log(NULL, AV_LOG_FATAL, "%s: corrupt decoded frame in stream %d\n", input_files[ist->file_index]->ctx->filename, ist->st->index); + av_log(NULL, AV_LOG_FATAL, "%s: corrupt decoded frame in stream %d\n", input_files[ist->file_index]->ctx->url, ist->st->index); exit_program(1); } } @@ -2989,7 +2989,7 @@ static int check_init_output_file(OutputFile *of, int file_index) //assert_avoptions(of->opts); of->header_written = 1; - av_dump_format(of->ctx, file_index, of->ctx->filename, 1); + av_dump_format(of->ctx, file_index, of->ctx->url, 1); if (sdp_filename || want_sdp) print_sdp(); @@ -4252,7 +4252,7 @@ static int process_input(int file_index) } if (ret < 0) { if (ret != AVERROR_EOF) { - print_error(is->filename, ret); + print_error(is->url, ret); if (exit_on_error) exit_program(1); } @@ -4301,7 +4301,7 @@ static int process_input(int file_index) goto discard_packet; if (exit_on_error && (pkt.flags & AV_PKT_FLAG_CORRUPT)) { - av_log(NULL, AV_LOG_FATAL, "%s: corrupt input packet in stream %d\n", is->filename, pkt.stream_index); + av_log(NULL, AV_LOG_FATAL, "%s: corrupt input packet in stream %d\n", is->url, pkt.stream_index); exit_program(1); } @@ -4668,11 +4668,11 @@ static int transcode(void) av_log(NULL, AV_LOG_ERROR, "Nothing was written into output file %d (%s), because " "at least one of its streams received no packets.\n", - i, os->filename); + i, os->url); continue; } if ((ret = av_write_trailer(os)) < 0) { - av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", os->filename, av_err2str(ret)); + av_log(NULL, AV_LOG_ERROR, "Error writing trailer of %s: %s\n", os->url, av_err2str(ret)); if (exit_on_error) exit_program(1); } diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index a6e36ac822..9ddeea18ff 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1272,7 +1272,7 @@ static int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *o if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO || type == AVMEDIA_TYPE_SUBTITLE) { MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); if (!codec_name) { - ost->st->codecpar->codec_id = av_guess_codec(s->oformat, NULL, s->filename, + ost->st->codecpar->codec_id = av_guess_codec(s->oformat, NULL, s->url, NULL, ost->st->codecpar->codec_type); ost->enc = avcodec_find_encoder(ost->st->codecpar->codec_id); if (!ost->enc) { @@ -2429,7 +2429,7 @@ loop_end: #endif if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) { - av_dump_format(oc, nb_output_files - 1, oc->filename, 1); + av_dump_format(oc, nb_output_files - 1, oc->url, 1); av_log(NULL, AV_LOG_ERROR, "Output file #%d does not contain any stream\n", nb_output_files - 1); exit_program(1); } @@ -2561,8 +2561,8 @@ loop_end: /* check filename in case of an image number is expected */ if (oc->oformat->flags & AVFMT_NEEDNUMBER) { - if (!av_filename_number_test(oc->filename)) { - print_error(oc->filename, AVERROR(EINVAL)); + if (!av_filename_number_test(oc->url)) { + print_error(oc->url, AVERROR(EINVAL)); exit_program(1); } } diff --git a/fftools/ffplay.c b/fftools/ffplay.c index 9bfa3e6cea..f2028d4b13 100644 --- a/fftools/ffplay.c +++ b/fftools/ffplay.c @@ -2712,8 +2712,8 @@ static int is_realtime(AVFormatContext *s) ) return 1; - if(s->pb && ( !strncmp(s->filename, "rtp:", 4) - || !strncmp(s->filename, "udp:", 4) + if(s->pb && ( !strncmp(s->url, "rtp:", 4) + || !strncmp(s->url, "udp:", 4) ) ) return 1; @@ -2928,7 +2928,7 @@ static int read_thread(void *arg) ret = avformat_seek_file(is->ic, -1, seek_min, seek_target, seek_max, is->seek_flags); if (ret < 0) { av_log(NULL, AV_LOG_ERROR, - "%s: error while seeking\n", is->ic->filename); + "%s: error while seeking\n", is->ic->url); } else { if (is->audio_stream >= 0) { packet_queue_flush(&is->audioq); diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c index 0e7a771517..acb403e3b1 100644 --- a/fftools/ffprobe.c +++ b/fftools/ffprobe.c @@ -2778,7 +2778,7 @@ static int show_format(WriterContext *w, InputFile *ifile) int ret = 0; writer_print_section_header(w, SECTION_ID_FORMAT); - print_str_validate("filename", fmt_ctx->filename); + print_str_validate("filename", fmt_ctx->url); print_int("nb_streams", fmt_ctx->nb_streams); print_int("nb_programs", fmt_ctx->nb_programs); print_str("format_name", fmt_ctx->iformat->name); diff --git a/tools/uncoded_frame.c b/tools/uncoded_frame.c index 3ca2ba4bbe..390322fe0f 100644 --- a/tools/uncoded_frame.c +++ b/tools/uncoded_frame.c @@ -143,7 +143,7 @@ int main(int argc, char **argv) goto fail; } if (!(st->mux->oformat->flags & AVFMT_NOFILE)) { - ret = avio_open2(&st->mux->pb, st->mux->filename, AVIO_FLAG_WRITE, + ret = avio_open2(&st->mux->pb, st->mux->url, AVIO_FLAG_WRITE, NULL, NULL); if (ret < 0) { av_log(st->mux, AV_LOG_ERROR, "Failed to init output: %s\n",