[FFmpeg-devel] [PATCH v2 1/2] avformat/hlsenc, utils: Moved is_http_proto from hlsenc to utils for re-use
Aman Gupta
ffmpeg at tmm1.net
Wed Dec 27 00:22:48 EET 2017
On Sat, Dec 16, 2017 at 11:03 AM Karthick J <kjeyapal at akamai.com> wrote:
> From: Karthick Jeyapal <kjeyapal at akamai.com>
>
> ---
> libavformat/hlsenc.c | 12 +++---------
> libavformat/internal.h | 8 ++++++++
> libavformat/utils.c | 5 +++++
> 3 files changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index e3442c3..03d54c7 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -240,15 +240,10 @@ static int mkdir_p(const char *path) {
> return ret;
> }
>
> -static int is_http_proto(char *filename) {
> - const char *proto = avio_find_protocol_name(filename);
> - return proto ? (!av_strcasecmp(proto, "http") ||
> !av_strcasecmp(proto, "https")) : 0;
> -}
> -
> static int hlsenc_io_open(AVFormatContext *s, AVIOContext **pb, char
> *filename,
> AVDictionary **options) {
> HLSContext *hls = s->priv_data;
> - int http_base_proto = filename ? is_http_proto(filename) : 0;
> + int http_base_proto = filename ? ff_is_http_proto(filename) : 0;
> int err = AVERROR_MUXER_NOT_FOUND;
> if (!*pb || !http_base_proto || !hls->http_persistent) {
> err = s->io_open(s, pb, filename, AVIO_FLAG_WRITE, options);
> @@ -264,8 +259,7 @@ static int hlsenc_io_open(AVFormatContext *s,
> AVIOContext **pb, char *filename,
>
> static void hlsenc_io_close(AVFormatContext *s, AVIOContext **pb, char
> *filename) {
> HLSContext *hls = s->priv_data;
> - int http_base_proto = filename ? is_http_proto(filename) : 0;
> -
> + int http_base_proto = filename ? ff_is_http_proto(filename) : 0;
> if (!http_base_proto || !hls->http_persistent || hls->key_info_file
> || hls->encrypt) {
> ff_format_io_close(s, pb);
> } else {
> @@ -275,7 +269,7 @@ static void hlsenc_io_close(AVFormatContext *s,
> AVIOContext **pb, char *filename
>
> static void set_http_options(AVFormatContext *s, AVDictionary **options,
> HLSContext *c)
> {
> - int http_base_proto = is_http_proto(s->filename);
> + int http_base_proto = ff_is_http_proto(s->filename);
>
> if (c->method) {
> av_dict_set(options, "method", c->method, 0);
> diff --git a/libavformat/internal.h b/libavformat/internal.h
> index 36a5721..8f168c9 100644
> --- a/libavformat/internal.h
> +++ b/libavformat/internal.h
> @@ -619,6 +619,14 @@ int ff_format_output_open(AVFormatContext *s, const
> char *url, AVDictionary **op
> void ff_format_io_close(AVFormatContext *s, AVIOContext **pb);
>
> /**
> + * Utility function to check if the file uses http or https protocol
> + *
> + * @param s AVFormatContext
> + * @param filename URL or file name to open for writing
> + */
> +int ff_is_http_proto(char *filename);
+1 from me. This would be useful for some of the changes I'm making to the
hls demuxer as well.
Any objections?
Aman
> +
> +/**
> * Parse creation_time in AVFormatContext metadata if exists and warn if
> the
> * parsing fails.
> *
> diff --git a/libavformat/utils.c b/libavformat/utils.c
> index 84e4920..f18a7c8 100644
> --- a/libavformat/utils.c
> +++ b/libavformat/utils.c
> @@ -5459,6 +5459,11 @@ void ff_format_io_close(AVFormatContext *s,
> AVIOContext **pb)
> *pb = NULL;
> }
>
> +int ff_is_http_proto(char *filename) {
> + const char *proto = avio_find_protocol_name(filename);
> + return proto ? (!av_strcasecmp(proto, "http") ||
> !av_strcasecmp(proto, "https")) : 0;
> +}
> +
> int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t
> *timestamp, int return_seconds)
> {
> AVDictionaryEntry *entry;
> --
> 1.9.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list