]> git.sesse.net Git - ffmpeg/commitdiff
avformat/hlsenc, utils: Moved is_http_proto from hlsenc to utils for re-use
authorKarthick Jeyapal <kjeyapal@akamai.com>
Fri, 29 Dec 2017 10:11:09 +0000 (18:11 +0800)
committerSteven Liu <lq@chinaffmpeg.org>
Fri, 29 Dec 2017 10:11:09 +0000 (18:11 +0800)
Reviewed-by: Aman Gupta <aman@tmm1.net>
Reviewed-by: Steven Liu <lq@onvideo.cn>
libavformat/hlsenc.c
libavformat/internal.h
libavformat/utils.c

index 5cff3b4bf643276f8d312636167ebe793c982cc8..e6f3241765176be77ba6c18893ee78b1a290b5b2 100644 (file)
@@ -241,15 +241,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);
@@ -265,8 +260,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);
 #if CONFIG_HTTP_PROTOCOL
@@ -281,7 +275,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);
index 30715b3f500eb4987adb0b9cdfcb1037c5f2f885..0cd0556dc799ed50edee70234c189f71277018fd 100644 (file)
@@ -621,6 +621,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);
+
 /**
  * Parse creation_time in AVFormatContext metadata if exists and warn if the
  * parsing fails.
index 9b46bd673731082458f72756cd651658440200bc..2185a6f05b0891cf1ce171e66d996f748481d299 100644 (file)
@@ -5472,6 +5472,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;