libavformat: Rename the applehttp protocol to hls

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.

Signed-off-by: Martin Storsjö <martin@martin.st>
This commit is contained in:
Martin Storsjö 2012-02-14 12:00:49 +02:00
parent 65cd7bf32f
commit 8bdab32f4e
5 changed files with 43 additions and 8 deletions

View File

@ -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

View File

@ -329,11 +329,12 @@ OBJS-$(CONFIG_LIBRTMP) += librtmp.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

View File

@ -22,6 +22,7 @@
#include "rtp.h"
#include "rdt.h"
#include "url.h"
#include "version.h"
#define REGISTER_MUXER(X,x) { \
extern AVOutputFormat ff_##x##_muxer; \
@ -238,11 +239,14 @@ void av_register_all(void)
REGISTER_MUXDEMUX (YUV4MPEGPIPE, yuv4mpegpipe);
/* 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);

View File

@ -29,6 +29,7 @@
#include "avformat.h"
#include "internal.h"
#include "url.h"
#include "version.h"
#include <unistd.h>
/*
@ -195,11 +196,27 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
h->is_streamed = 1;
if (av_strstart(uri, "applehttp+", &nested_url)) {
if (av_strstart(uri, "hls+", &nested_url)) {
av_strlcpy(s->playlisturl, nested_url, sizeof(s->playlisturl));
} 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;
#if FF_API_APPLEHTTP_PROTO
} else 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, "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);
#endif
} else {
av_log(h, AV_LOG_ERROR, "Unsupported url %s\n", uri);
ret = AVERROR(EINVAL);
@ -303,6 +320,7 @@ retry:
goto start;
}
#if FF_API_APPLEHTTP_PROTO
URLProtocol ff_applehttp_protocol = {
.name = "applehttp",
.url_open = applehttp_open,
@ -311,3 +329,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),
};

View File

@ -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 */