Commit 491c52d3 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'eb9244f2'

* commit 'eb9244f2':
  Add Icecast protocol

Conflicts:
	Changelog
	configure
	doc/protocols.texi
	libavformat/icecast.c
	libavformat/version.h

See: e3dc2c86Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents e3dc2c86 eb9244f2
...@@ -2484,7 +2484,7 @@ gopher_protocol_select="network" ...@@ -2484,7 +2484,7 @@ gopher_protocol_select="network"
http_protocol_select="tcp_protocol" http_protocol_select="tcp_protocol"
httpproxy_protocol_select="tcp_protocol" httpproxy_protocol_select="tcp_protocol"
https_protocol_select="tls_protocol" https_protocol_select="tls_protocol"
icecast_protocol_select="http" icecast_protocol_select="http_protocol"
librtmp_protocol_deps="librtmp" librtmp_protocol_deps="librtmp"
librtmpe_protocol_deps="librtmp" librtmpe_protocol_deps="librtmp"
librtmps_protocol_deps="librtmp" librtmps_protocol_deps="librtmp"
......
...@@ -295,39 +295,41 @@ ffplay -cookies "nlqptid=nltid=tsn; path=/; domain=somedomain.com;" http://somed ...@@ -295,39 +295,41 @@ ffplay -cookies "nlqptid=nltid=tsn; path=/; domain=somedomain.com;" http://somed
@section Icecast @section Icecast
Icecast protocol Icecast protocol (stream to Icecast servers)
This protocol accepts the following options:
@table @option @table @option
@item ice_genre @item ice_genre
Set the genre of the stream. Set the stream genre.
@item ice_name @item ice_name
Set the name of the stream. Set the stream name.
@item ice_description @item ice_description
Set the description of the stream. Set the stream description.
@item ice_url @item ice_url
Set the stream website url. Set the stream website URL.
@item ice_public @item ice_public
Set if the stream should be public. Set if the stream should be public.
Default is 0 (not public). The default is 0 (not public).
@item ice_password @item user_agent
Password for the mountpoint. Override the User-Agent header. If not specified a string of the form
"Lavf/<version>" will be used.
@item legacy_icecast @item password
If set to 1, enable support for legacy Icecast (Version < 2.4), using the SOURCE method Set the Icecast mountpoint password.
instead of the PUT method.
@item content_type @item content_type
Set a specific content type for the stream. Set the stream content type. This must be set if it is different from
This MUST be set if streaming else than audio/mpeg audio/mpeg.
@item user_agent @item legacy_icecast
Override the User-Agent header. If not specified the protocol will use a This enables support for Icecast versions < 2.4.0, that do not support the
string describing the libavformat build. ("Lavf/<version>") HTTP PUT method but the SOURCE method.
@end table @end table
......
...@@ -72,6 +72,14 @@ static void cat_header(AVBPrint *bp, const char key[], const char value[]) ...@@ -72,6 +72,14 @@ static void cat_header(AVBPrint *bp, const char key[], const char value[])
av_bprintf(bp, "%s: %s\r\n", key, value); av_bprintf(bp, "%s: %s\r\n", key, value);
} }
static int icecast_close(URLContext *h)
{
IcecastContext *s = h->priv_data;
if (s->hd)
ffurl_close(s->hd);
return 0;
}
static int icecast_open(URLContext *h, const char *uri, int flags) static int icecast_open(URLContext *h, const char *uri, int flags)
{ {
IcecastContext *s = h->priv_data; IcecastContext *s = h->priv_data;
...@@ -81,10 +89,13 @@ static int icecast_open(URLContext *h, const char *uri, int flags) ...@@ -81,10 +89,13 @@ static int icecast_open(URLContext *h, const char *uri, int flags)
// URI part variables // URI part variables
char h_url[1024], host[1024], auth[1024], path[1024]; char h_url[1024], host[1024], auth[1024], path[1024];
char *user = NULL, *headers = NULL; char *headers = NULL, *user = NULL;
int port, ret; int port, ret;
AVBPrint bp; AVBPrint bp;
if (flags & AVIO_FLAG_READ)
return AVERROR(ENOSYS);
av_bprint_init(&bp, 0, 1); av_bprint_init(&bp, 0, 1);
// Build header strings // Build header strings
...@@ -122,9 +133,15 @@ static int icecast_open(URLContext *h, const char *uri, int flags) ...@@ -122,9 +133,15 @@ static int icecast_open(URLContext *h, const char *uri, int flags)
av_free(s->pass); av_free(s->pass);
av_log(h, AV_LOG_WARNING, "Overwriting -password <pass> with URI password!\n"); av_log(h, AV_LOG_WARNING, "Overwriting -password <pass> with URI password!\n");
} }
s->pass = av_strdup(sep); if (!(s->pass = av_strdup(sep))) {
ret = AVERROR(ENOMEM);
goto cleanup;
}
}
if (!(user = av_strdup(auth))) {
ret = AVERROR(ENOMEM);
goto cleanup;
} }
user = av_strdup(auth);
} }
// Build new authstring // Build new authstring
...@@ -163,13 +180,13 @@ static int icecast_write(URLContext *h, const uint8_t *buf, int size) ...@@ -163,13 +180,13 @@ static int icecast_write(URLContext *h, const uint8_t *buf, int size)
static const uint8_t webm[4] = { 0x1A, 0x45, 0xDF, 0xA3 }; static const uint8_t webm[4] = { 0x1A, 0x45, 0xDF, 0xA3 };
static const uint8_t opus[8] = { 0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64 }; static const uint8_t opus[8] = { 0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64 };
if (memcmp(buf, oggs, sizeof(oggs)) == 0) { if (memcmp(buf, oggs, sizeof(oggs)) == 0) {
av_log(h, AV_LOG_WARNING, "Streaming ogg but appropriate content type NOT set!\n"); av_log(h, AV_LOG_WARNING, "Streaming Ogg but appropriate content type NOT set!\n");
av_log(h, AV_LOG_WARNING, "Set it with -content_type application/ogg\n"); av_log(h, AV_LOG_WARNING, "Set it with -content_type application/ogg\n");
} else if (memcmp(buf, opus, sizeof(opus)) == 0) { } else if (memcmp(buf, opus, sizeof(opus)) == 0) {
av_log(h, AV_LOG_WARNING, "Streaming opus but appropriate content type NOT set!\n"); av_log(h, AV_LOG_WARNING, "Streaming Opus but appropriate content type NOT set!\n");
av_log(h, AV_LOG_WARNING, "Set it with -content_type audio/ogg\n"); av_log(h, AV_LOG_WARNING, "Set it with -content_type audio/ogg\n");
} else if (memcmp(buf, webm, sizeof(webm)) == 0) { } else if (memcmp(buf, webm, sizeof(webm)) == 0) {
av_log(h, AV_LOG_WARNING, "Streaming webm but appropriate content type NOT set!\n"); av_log(h, AV_LOG_WARNING, "Streaming WebM but appropriate content type NOT set!\n");
av_log(h, AV_LOG_WARNING, "Set it with -content_type video/webm\n"); av_log(h, AV_LOG_WARNING, "Set it with -content_type video/webm\n");
} else { } else {
av_log(h, AV_LOG_WARNING, "It seems you are streaming an unsupported format.\n"); av_log(h, AV_LOG_WARNING, "It seems you are streaming an unsupported format.\n");
...@@ -180,14 +197,6 @@ static int icecast_write(URLContext *h, const uint8_t *buf, int size) ...@@ -180,14 +197,6 @@ static int icecast_write(URLContext *h, const uint8_t *buf, int size)
return ffurl_write(s->hd, buf, size); return ffurl_write(s->hd, buf, size);
} }
static int icecast_close(URLContext *h)
{
IcecastContext *s = h->priv_data;
if (s->hd)
ffurl_close(s->hd);
return 0;
}
static const AVClass icecast_context_class = { static const AVClass icecast_context_class = {
.class_name = "icecast", .class_name = "icecast",
.item_name = av_default_item_name, .item_name = av_default_item_name,
......
...@@ -30,8 +30,9 @@ ...@@ -30,8 +30,9 @@
#include "libavutil/version.h" #include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 55 #define LIBAVFORMAT_VERSION_MAJOR 55
#define LIBAVFORMAT_VERSION_MINOR 51 #define LIBAVFORMAT_VERSION_MINOR 51
#define LIBAVFORMAT_VERSION_MICRO 100 #define LIBAVFORMAT_VERSION_MICRO 101
#define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \ #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
LIBAVFORMAT_VERSION_MINOR, \ LIBAVFORMAT_VERSION_MINOR, \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment