diff --git a/libavformat/hdsenc.c b/libavformat/hdsenc.c index 01efa1f8da..d3292a8342 100644 --- a/libavformat/hdsenc.c +++ b/libavformat/hdsenc.c @@ -29,6 +29,7 @@ #include "mux.h" #include "os_support.h" +#include "libavutil/attributes_internal.h" #include "libavutil/avstring.h" #include "libavutil/base64.h" #include "libavutil/intreadwrite.h" @@ -311,7 +312,6 @@ static void close_file(AVFormatContext *s, OutputStream *os) static int hds_write_header(AVFormatContext *s) { HDSContext *c = s->priv_data; - const AVOutputFormat *oformat; int ret = 0, i; if (mkdir(s->url, 0777) == -1 && errno != EEXIST) { @@ -319,10 +319,6 @@ static int hds_write_header(AVFormatContext *s) return AVERROR(errno); } - oformat = av_guess_format("flv", NULL, NULL); - if (!oformat) { - return AVERROR_MUXER_NOT_FOUND; - } c->streams = av_calloc(s->nb_streams, sizeof(*c->streams)); if (!c->streams) { @@ -363,7 +359,8 @@ static int hds_write_header(AVFormatContext *s) return AVERROR(ENOMEM); } os->ctx = ctx; - ctx->oformat = oformat; + EXTERN const FFOutputFormat ff_flv_muxer; + ctx->oformat = &ff_flv_muxer.p; ctx->interrupt_callback = s->interrupt_callback; ctx->flags = s->flags; diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index dcf5da9bb8..957b9a5ddd 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -28,6 +28,7 @@ #include #endif +#include "libavutil/attributes_internal.h" #include "libavutil/avassert.h" #include "libavutil/mathematics.h" #include "libavutil/avstring.h" @@ -2972,12 +2973,12 @@ static int hls_init(AVFormatContext *s) if (vs->has_video > 1) av_log(s, AV_LOG_WARNING, "More than a single video stream present, expect issues decoding it.\n"); if (hls->segment_type == SEGMENT_TYPE_FMP4) { - vs->oformat = av_guess_format("mp4", NULL, NULL); + EXTERN const FFOutputFormat ff_mp4_muxer; + vs->oformat = &ff_mp4_muxer.p; } else { - vs->oformat = av_guess_format("mpegts", NULL, NULL); + EXTERN const FFOutputFormat ff_mpegts_muxer; + vs->oformat = &ff_mpegts_muxer.p; } - if (!vs->oformat) - return AVERROR_MUXER_NOT_FOUND; if (hls->segment_filename) { ret = format_name(hls->segment_filename, &vs->basename, i, vs->varname); @@ -3054,9 +3055,8 @@ static int hls_init(AVFormatContext *s) return ret; if (vs->has_subtitle) { - vs->vtt_oformat = av_guess_format("webvtt", NULL, NULL); - if (!vs->vtt_oformat) - return AVERROR_MUXER_NOT_FOUND; + EXTERN const FFOutputFormat ff_webvtt_muxer; + vs->vtt_oformat = &ff_webvtt_muxer.p; p = strrchr(vs->m3u8_name, '.'); if (p) diff --git a/libavformat/rtpenc_mpegts.c b/libavformat/rtpenc_mpegts.c index f9ff7e99cd..897db10f76 100644 --- a/libavformat/rtpenc_mpegts.c +++ b/libavformat/rtpenc_mpegts.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/attributes_internal.h" #include "libavutil/mathematics.h" #include "libavutil/mem.h" #include "libavutil/opt.h" @@ -58,22 +59,19 @@ static int rtp_mpegts_write_header(AVFormatContext *s) { MuxChain *chain = s->priv_data; AVFormatContext *mpegts_ctx = NULL, *rtp_ctx = NULL; - const AVOutputFormat *mpegts_format = av_guess_format("mpegts", NULL, NULL); - const AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL); int i, ret = AVERROR(ENOMEM); AVStream *st; AVDictionary *mpegts_muxer_options = NULL; AVDictionary *rtp_muxer_options = NULL; - if (!mpegts_format || !rtp_format) - return AVERROR(ENOSYS); mpegts_ctx = avformat_alloc_context(); if (!mpegts_ctx) return AVERROR(ENOMEM); chain->pkt = av_packet_alloc(); if (!chain->pkt) goto fail; - mpegts_ctx->oformat = mpegts_format; + EXTERN const FFOutputFormat ff_mpegts_muxer; + mpegts_ctx->oformat = &ff_mpegts_muxer.p; mpegts_ctx->max_delay = s->max_delay; av_dict_copy(&mpegts_ctx->metadata, s->metadata, 0); for (i = 0; i < s->nb_streams; i++) { @@ -106,7 +104,8 @@ static int rtp_mpegts_write_header(AVFormatContext *s) ret = AVERROR(ENOMEM); goto fail; } - rtp_ctx->oformat = rtp_format; + EXTERN const FFOutputFormat ff_rtp_muxer; + rtp_ctx->oformat = &ff_rtp_muxer.p; st = avformat_new_stream(rtp_ctx, NULL); if (!st) { ret = AVERROR(ENOMEM); diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index adf3008003..3a4c1e0413 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -31,6 +31,7 @@ #include "avc.h" #include "url.h" +#include "libavutil/attributes_internal.h" #include "libavutil/mem.h" #include "libavutil/opt.h" #include "libavutil/avstring.h" @@ -283,17 +284,12 @@ static int ism_write_header(AVFormatContext *s) { SmoothStreamingContext *c = s->priv_data; int ret = 0, i; - const AVOutputFormat *oformat; if (mkdir(s->url, 0777) == -1 && errno != EEXIST) { av_log(s, AV_LOG_ERROR, "mkdir failed\n"); return AVERROR(errno); } - oformat = av_guess_format("ismv", NULL, NULL); - if (!oformat) { - return AVERROR_MUXER_NOT_FOUND; - } c->streams = av_calloc(s->nb_streams, sizeof(*c->streams)); if (!c->streams) { @@ -325,7 +321,8 @@ static int ism_write_header(AVFormatContext *s) } if ((ret = ff_copy_whiteblacklists(ctx, s)) < 0) return ret; - ctx->oformat = oformat; + EXTERN const FFOutputFormat ff_ismv_muxer; + ctx->oformat = &ff_ismv_muxer.p; ctx->interrupt_callback = s->interrupt_callback; if (!(st = avformat_new_stream(ctx, NULL))) { diff --git a/libavformat/webm_chunk.c b/libavformat/webm_chunk.c index 57329f1788..19506faebe 100644 --- a/libavformat/webm_chunk.c +++ b/libavformat/webm_chunk.c @@ -30,6 +30,7 @@ #include "internal.h" #include "mux.h" +#include "libavutil/attributes_internal.h" #include "libavutil/bprint.h" #include "libavutil/log.h" #include "libavutil/mem.h" @@ -51,7 +52,6 @@ typedef struct WebMChunkContext { static int webm_chunk_init(AVFormatContext *s) { WebMChunkContext *wc = s->priv_data; - const AVOutputFormat *oformat; AVFormatContext *oc; AVStream *st, *ost = s->streams[0]; AVDictionary *dict = NULL; @@ -68,11 +68,9 @@ static int webm_chunk_init(AVFormatContext *s) wc->prev_pts = AV_NOPTS_VALUE; - oformat = av_guess_format("webm", s->url, "video/webm"); - if (!oformat) - return AVERROR_MUXER_NOT_FOUND; + EXTERN const FFOutputFormat ff_webm_muxer; - ret = avformat_alloc_output_context2(&wc->avf, oformat, NULL, NULL); + ret = avformat_alloc_output_context2(&wc->avf, &ff_webm_muxer.p, NULL, NULL); if (ret < 0) return ret; oc = wc->avf; diff --git a/libavformat/whip.c b/libavformat/whip.c index 08bd19d9c7..8306296b20 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -21,6 +21,8 @@ #include "libavcodec/h264.h" #include "libavcodec/startcode.h" + +#include "libavutil/attributes_internal.h" #include "libavutil/avassert.h" #include "libavutil/base64.h" #include "libavutil/bprint.h" @@ -1540,12 +1542,6 @@ static int create_rtp_muxer(AVFormatContext *s) WHIPContext *whip = s->priv_data; whip->udp->flags |= AVIO_FLAG_NONBLOCK; - const AVOutputFormat *rtp_format = av_guess_format("rtp", NULL, NULL); - if (!rtp_format) { - av_log(whip, AV_LOG_ERROR, "Failed to guess rtp muxer\n"); - ret = AVERROR(ENOSYS); - goto end; - } /* The UDP buffer size, may greater than MTU. */ buffer_size = MAX_UDP_BUFFER_SIZE; @@ -1559,7 +1555,8 @@ static int create_rtp_muxer(AVFormatContext *s) goto end; } - rtp_ctx->oformat = rtp_format; + EXTERN const FFOutputFormat ff_rtp_muxer; + rtp_ctx->oformat = &ff_rtp_muxer.p; if (!avformat_new_stream(rtp_ctx, NULL)) { ret = AVERROR(ENOMEM); goto end;