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"
http_protocol_select="tcp_protocol"
httpproxy_protocol_select="tcp_protocol"
https_protocol_select="tls_protocol"
icecast_protocol_select="http"
icecast_protocol_select="http_protocol"
librtmp_protocol_deps="librtmp"
librtmpe_protocol_deps="librtmp"
librtmps_protocol_deps="librtmp"
......
......@@ -295,39 +295,41 @@ ffplay -cookies "nlqptid=nltid=tsn; path=/; domain=somedomain.com;" http://somed
@section Icecast
Icecast protocol
Icecast protocol (stream to Icecast servers)
This protocol accepts the following options:
@table @option
@item ice_genre
Set the genre of the stream.
Set the stream genre.
@item ice_name
Set the name of the stream.
Set the stream name.
@item ice_description
Set the description of the stream.
Set the stream description.
@item ice_url
Set the stream website url.
Set the stream website URL.
@item ice_public
Set if the stream should be public.
Default is 0 (not public).
The default is 0 (not public).
@item ice_password
Password for the mountpoint.
@item user_agent
Override the User-Agent header. If not specified a string of the form
"Lavf/<version>" will be used.
@item legacy_icecast
If set to 1, enable support for legacy Icecast (Version < 2.4), using the SOURCE method
instead of the PUT method.
@item password
Set the Icecast mountpoint password.
@item content_type
Set a specific content type for the stream.
This MUST be set if streaming else than audio/mpeg
Set the stream content type. This must be set if it is different from
audio/mpeg.
@item user_agent
Override the User-Agent header. If not specified the protocol will use a
string describing the libavformat build. ("Lavf/<version>")
@item legacy_icecast
This enables support for Icecast versions < 2.4.0, that do not support the
HTTP PUT method but the SOURCE method.
@end table
......
......@@ -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);
}
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)
{
IcecastContext *s = h->priv_data;
......@@ -81,10 +89,13 @@ static int icecast_open(URLContext *h, const char *uri, int flags)
// URI part variables
char h_url[1024], host[1024], auth[1024], path[1024];
char *user = NULL, *headers = NULL;
char *headers = NULL, *user = NULL;
int port, ret;
AVBPrint bp;
if (flags & AVIO_FLAG_READ)
return AVERROR(ENOSYS);
av_bprint_init(&bp, 0, 1);
// Build header strings
......@@ -122,9 +133,15 @@ static int icecast_open(URLContext *h, const char *uri, int flags)
av_free(s->pass);
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
......@@ -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 opus[8] = { 0x4F, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64 };
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");
} 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");
} 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");
} else {
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)
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 = {
.class_name = "icecast",
.item_name = av_default_item_name,
......
......@@ -30,8 +30,9 @@
#include "libavutil/version.h"
#define LIBAVFORMAT_VERSION_MAJOR 55
#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, \
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