diff options
author | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-05-19 22:09:34 +0200 |
---|---|---|
committer | Stefano Sabatini <stefano.sabatini-lala@poste.it> | 2011-05-22 20:01:31 +0200 |
commit | 5ecdfd008bce961c3241eaa1f8dc06e82a6b12db (patch) | |
tree | 65def2a600cdbb8f1dfa3b40cec010e33738bee7 /libavformat/utils.c | |
parent | 83db71977700d3337c84d5945ac8b7e7ee881ac2 (diff) | |
download | ffmpeg-5ecdfd008bce961c3241eaa1f8dc06e82a6b12db.tar.gz |
lavf: deprecate avformat_alloc_output_context() in favor of avformat_alloc_output_context2()
The new function accepts a slightly more intuitive order of paramters,
and returns an error code, thus allowing applications to report a
meaningful error message.
Diffstat (limited to 'libavformat/utils.c')
-rw-r--r-- | libavformat/utils.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/libavformat/utils.c b/libavformat/utils.c index c5e570028e..71c325a542 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2751,8 +2751,13 @@ int av_set_parameters(AVFormatContext *s, AVFormatParameters *ap) return 0; } -AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputFormat *oformat, const char *filename){ +int avformat_alloc_output_context2(AVFormatContext **avctx, AVOutputFormat *oformat, + const char *format, const char *filename) +{ AVFormatContext *s= avformat_alloc_context(); + int ret = 0; + + *avctx = NULL; if(!s) goto nomem; @@ -2761,11 +2766,13 @@ AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputForma oformat = av_guess_format(format, NULL, NULL); if (!oformat) { av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format); + ret = AVERROR(EINVAL); goto error; } } else { oformat = av_guess_format(NULL, filename, NULL); if (!oformat) { + ret = AVERROR(EINVAL); av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n", filename); goto error; @@ -2787,14 +2794,26 @@ AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputForma if(filename) av_strlcpy(s->filename, filename, sizeof(s->filename)); - return s; + *avctx = s; + return 0; nomem: av_log(s, AV_LOG_ERROR, "Out of memory\n"); + ret = AVERROR(ENOMEM); error: avformat_free_context(s); - return NULL; + return ret; } +#if FF_API_ALLOC_OUTPUT_CONTEXT +AVFormatContext *avformat_alloc_output_context(const char *format, + AVOutputFormat *oformat, const char *filename) +{ + AVFormatContext *avctx; + int ret = avformat_alloc_output_context2(&avctx, oformat, format, filename); + return ret < 0 ? NULL : avctx; +} +#endif + static int validate_codec_tag(AVFormatContext *s, AVStream *st) { const AVCodecTag *avctag; |