[3/6] libavformat: Rename the applehttp protocol to hls

Message ID 1329214941-97881-3-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö Feb. 14, 2012, 10:22 a.m.
Keep the old protocol name around for backwards compatibility
until the next bump.

Deprecate the method of implicitly assuming the nested protocol.
For applehttp://server/path, it might have felt logical, but
supporting hls://server/path isn't quite as intuitive. Therefore
only support hls+http://server/path from now on.

Using this protocol at all is discouraged, since the hls demuxer
is more complete and fits into the architecture better. There
have been cases where the protocol implementation worked better
than the demuxer, but this should no longer be the case.
---
 doc/protocols.texi                           |   11 +++++------
 libavformat/Makefile                         |    3 ++-
 libavformat/allformats.c                     |    3 +++
 libavformat/{applehttpproto.c => hlsproto.c} |   23 +++++++++++++++++++++++
 libavformat/version.h                        |    3 +++
 5 files changed, 36 insertions(+), 7 deletions(-)
 rename libavformat/{applehttpproto.c => hlsproto.c} (90%)

Comments

Diego Biurrun Feb. 14, 2012, 10:50 a.m. | #1
On Tue, Feb 14, 2012 at 12:22:18PM +0200, Martin Storsjö wrote:
> Keep the old protocol name around for backwards compatibility
> until the next bump.

Aren't we still in the break API season?

Diego
Martin Storsjö Feb. 14, 2012, 10:56 a.m. | #2
On Tue, 14 Feb 2012, Diego Biurrun wrote:

> On Tue, Feb 14, 2012 at 12:22:18PM +0200, Martin Storsjö wrote:
>> Keep the old protocol name around for backwards compatibility
>> until the next bump.
>
> Aren't we still in the break API season?

Yes, but I prefer to only break stuff which has been advertised with a 
replacement for some time.

// Martin
Diego Biurrun Feb. 14, 2012, 11:07 a.m. | #3
On Tue, Feb 14, 2012 at 12:22:18PM +0200, Martin Storsjö wrote:
> 
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -241,11 +241,14 @@ void av_register_all(void)
>  
>      /* protocols */
> +#if FF_API_APPLEHTTP_PROTO
>      REGISTER_PROTOCOL (APPLEHTTP, applehttp);
> +#endif
>      REGISTER_PROTOCOL (CONCAT, concat);
>      REGISTER_PROTOCOL (CRYPTO, crypto);
>      REGISTER_PROTOCOL (FILE, file);
>      REGISTER_PROTOCOL (GOPHER, gopher);
> +    REGISTER_PROTOCOL (HLS, hls);
>      REGISTER_PROTOCOL (HTTP, http);

This file is missing a version.h #include.

It also misses a config.h #include, btw.

> --- a/libavformat/applehttpproto.c
> +++ b/libavformat/hlsproto.c
> @@ -197,9 +197,21 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
>  
>      if (av_strstart(uri, "applehttp+", &nested_url)) {
>          av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));
> +        av_log(h, AV_LOG_WARNING, "The applehttp protocol is deprecated, "
> +                                  "use hls+%s as url instead.\n", nested_url);
> +    } else if (av_strstart(uri, "hls+", &nested_url)) {
> +        av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));
>      } else if (av_strstart(uri, "applehttp://", &nested_url)) {
>          av_strlcpy(s->playlisturl, "http://", sizeof(s->playlisturl));
>          av_strlcat(s->playlisturl, nested_url, sizeof(s->playlisturl));
> +        av_log(h, AV_LOG_WARNING, "The applehttp protocol is deprecated, "
> +                                  "use hls+http://%s as url instead.\n",
> +                                  nested_url);
> +    } else if (av_strstart(uri, "hls://", &nested_url)) {
> +        av_log(h, AV_LOG_ERROR, "No nested protocol specified. Specify e.g. "
> +                                "hls+http://%s\n", nested_url);

I would suggest breaking the lines before the text, it should be possible
to keep it on one line then.

> @@ -303,6 +315,7 @@ retry:
>  
> +#if FF_API_APPLEHTTP_PROTO
>  URLProtocol ff_applehttp_protocol = {
>      .name           = "applehttp",
>      .url_open       = applehttp_open,

You miss a version.h #include.

Diego
Martin Storsjö Feb. 14, 2012, 11:49 a.m. | #4
On Tue, 14 Feb 2012, Diego Biurrun wrote:

> On Tue, Feb 14, 2012 at 12:22:18PM +0200, Martin Storsjö wrote:
>>
>> --- a/libavformat/allformats.c
>> +++ b/libavformat/allformats.c
>> @@ -241,11 +241,14 @@ void av_register_all(void)
>>
>>      /* protocols */
>> +#if FF_API_APPLEHTTP_PROTO
>>      REGISTER_PROTOCOL (APPLEHTTP, applehttp);
>> +#endif
>>      REGISTER_PROTOCOL (CONCAT, concat);
>>      REGISTER_PROTOCOL (CRYPTO, crypto);
>>      REGISTER_PROTOCOL (FILE, file);
>>      REGISTER_PROTOCOL (GOPHER, gopher);
>> +    REGISTER_PROTOCOL (HLS, hls);
>>      REGISTER_PROTOCOL (HTTP, http);
>
> This file is missing a version.h #include.

Added. (For the audience, it is already implicitly included by avformat.h, 
where it obviously is needed for disabling APIs when they're removed.)

> It also misses a config.h #include, btw.

That's a separate cleanup (the rest of this file already is very much 
dependent on config.h) so I'm not doing it in this commit.

>> --- a/libavformat/applehttpproto.c
>> +++ b/libavformat/hlsproto.c
>> @@ -197,9 +197,21 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
>>
>>      if (av_strstart(uri, "applehttp+", &nested_url)) {
>>          av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));
>> +        av_log(h, AV_LOG_WARNING, "The applehttp protocol is deprecated, "
>> +                                  "use hls+%s as url instead.\n", nested_url);
>> +    } else if (av_strstart(uri, "hls+", &nested_url)) {
>> +        av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));
>>      } else if (av_strstart(uri, "applehttp://", &nested_url)) {
>>          av_strlcpy(s->playlisturl, "http://", sizeof(s->playlisturl));
>>          av_strlcat(s->playlisturl, nested_url, sizeof(s->playlisturl));
>> +        av_log(h, AV_LOG_WARNING, "The applehttp protocol is deprecated, "
>> +                                  "use hls+http://%s as url instead.\n",
>> +                                  nested_url);
>> +    } else if (av_strstart(uri, "hls://", &nested_url)) {
>> +        av_log(h, AV_LOG_ERROR, "No nested protocol specified. Specify e.g. "
>> +                                "hls+http://%s\n", nested_url);
>
> I would suggest breaking the lines before the text, it should be possible
> to keep it on one line then.

They don't really fit then either, but perhaps it's nicer that way anyway.

>> @@ -303,6 +315,7 @@ retry:
>>
>> +#if FF_API_APPLEHTTP_PROTO
>>  URLProtocol ff_applehttp_protocol = {
>>      .name           = "applehttp",
>>      .url_open       = applehttp_open,
>
> You miss a version.h #include.

Added.

// Martin

Patch

diff --git a/doc/protocols.texi b/doc/protocols.texi
index f5bb532..e00c1e1 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -19,20 +19,19 @@  supported protocols.
 
 A description of the currently available protocols follows.
 
-@section applehttp
+@section hls
 
 Read Apple HTTP Live Streaming compliant segmented stream as
 a uniform one. The M3U8 playlists describing the segments can be
 remote HTTP resources or local files, accessed using the standard
 file protocol.
-HTTP is default, specific protocol can be declared by specifying
-"+@var{proto}" after the applehttp URI scheme name, where @var{proto}
+The nested protocol is declared by specifying
+"+@var{proto}" after the hls URI scheme name, where @var{proto}
 is either "file" or "http".
 
 @example
-applehttp://host/path/to/remote/resource.m3u8
-applehttp+http://host/path/to/remote/resource.m3u8
-applehttp+file://path/to/local/resource.m3u8
+hls+http://host/path/to/remote/resource.m3u8
+hls+file://path/to/local/resource.m3u8
 @end example
 
 @section concat
diff --git a/libavformat/Makefile b/libavformat/Makefile
index db8bf79..b55e9dc 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -327,11 +327,12 @@  OBJS-$(CONFIG_LIBNUT_MUXER)              += libnut.o
 # protocols I/O
 OBJS+= avio.o aviobuf.o
 
-OBJS-$(CONFIG_APPLEHTTP_PROTOCOL)        += applehttpproto.o
+OBJS-$(CONFIG_APPLEHTTP_PROTOCOL)        += hlsproto.o
 OBJS-$(CONFIG_CONCAT_PROTOCOL)           += concat.o
 OBJS-$(CONFIG_CRYPTO_PROTOCOL)           += crypto.o
 OBJS-$(CONFIG_FILE_PROTOCOL)             += file.o
 OBJS-$(CONFIG_GOPHER_PROTOCOL)           += gopher.o
+OBJS-$(CONFIG_HLS_PROTOCOL)              += hlsproto.o
 OBJS-$(CONFIG_HTTP_PROTOCOL)             += http.o httpauth.o
 OBJS-$(CONFIG_HTTPPROXY_PROTOCOL)        += http.o httpauth.o
 OBJS-$(CONFIG_HTTPS_PROTOCOL)            += http.o httpauth.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index 3a39aca..bfffa3a 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -241,11 +241,14 @@  void av_register_all(void)
     REGISTER_MUXDEMUX (LIBNUT, libnut);
 
     /* protocols */
+#if FF_API_APPLEHTTP_PROTO
     REGISTER_PROTOCOL (APPLEHTTP, applehttp);
+#endif
     REGISTER_PROTOCOL (CONCAT, concat);
     REGISTER_PROTOCOL (CRYPTO, crypto);
     REGISTER_PROTOCOL (FILE, file);
     REGISTER_PROTOCOL (GOPHER, gopher);
+    REGISTER_PROTOCOL (HLS, hls);
     REGISTER_PROTOCOL (HTTP, http);
     REGISTER_PROTOCOL (HTTPPROXY, httpproxy);
     REGISTER_PROTOCOL (HTTPS, https);
diff --git a/libavformat/applehttpproto.c b/libavformat/hlsproto.c
similarity index 90%
rename from libavformat/applehttpproto.c
rename to libavformat/hlsproto.c
index 46758ba..d5b8e70 100644
--- a/libavformat/applehttpproto.c
+++ b/libavformat/hlsproto.c
@@ -197,9 +197,21 @@  static int applehttp_open(URLContext *h, const char *uri, int flags)
 
     if (av_strstart(uri, "applehttp+", &nested_url)) {
         av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));
+        av_log(h, AV_LOG_WARNING, "The applehttp protocol is deprecated, "
+                                  "use hls+%s as url instead.\n", nested_url);
+    } else if (av_strstart(uri, "hls+", &nested_url)) {
+        av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));
     } else if (av_strstart(uri, "applehttp://", &nested_url)) {
         av_strlcpy(s->playlisturl, "http://", sizeof(s->playlisturl));
         av_strlcat(s->playlisturl, nested_url, sizeof(s->playlisturl));
+        av_log(h, AV_LOG_WARNING, "The applehttp protocol is deprecated, "
+                                  "use hls+http://%s as url instead.\n",
+                                  nested_url);
+    } else if (av_strstart(uri, "hls://", &nested_url)) {
+        av_log(h, AV_LOG_ERROR, "No nested protocol specified. Specify e.g. "
+                                "hls+http://%s\n", nested_url);
+        ret = AVERROR(EINVAL);
+        goto fail;
     } else {
         av_log(h, AV_LOG_ERROR, "Unsupported url %s\n", uri);
         ret = AVERROR(EINVAL);
@@ -303,6 +315,7 @@  retry:
     goto start;
 }
 
+#if FF_API_APPLEHTTP_PROTO
 URLProtocol ff_applehttp_protocol = {
     .name           = "applehttp",
     .url_open       = applehttp_open,
@@ -311,3 +324,13 @@  URLProtocol ff_applehttp_protocol = {
     .flags          = URL_PROTOCOL_FLAG_NESTED_SCHEME,
     .priv_data_size = sizeof(AppleHTTPContext),
 };
+#endif
+
+URLProtocol ff_hls_protocol = {
+    .name           = "hls",
+    .url_open       = applehttp_open,
+    .url_read       = applehttp_read,
+    .url_close      = applehttp_close,
+    .flags          = URL_PROTOCOL_FLAG_NESTED_SCHEME,
+    .priv_data_size = sizeof(AppleHTTPContext),
+};
diff --git a/libavformat/version.h b/libavformat/version.h
index 6f3b387..443d752 100644
--- a/libavformat/version.h
+++ b/libavformat/version.h
@@ -50,5 +50,8 @@ 
 #ifndef FF_API_CLOSE_INPUT_FILE
 #define FF_API_CLOSE_INPUT_FILE        (LIBAVFORMAT_VERSION_MAJOR < 55)
 #endif
+#ifndef FF_API_APPLEHTTP_PROTO
+#define FF_API_APPLEHTTP_PROTO         (LIBAVFORMAT_VERSION_MAJOR < 55)
+#endif
 
 #endif /* AVFORMAT_VERSION_H */