summaryrefslogtreecommitdiff
path: root/libavformat/icecast.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-08-04 14:13:45 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-08-04 14:14:13 +0200
commit491c52d3b077dc1f298322a719059398a5f76af8 (patch)
treefd1c32bfdcc217e39a7a31aa5b07ffee3491cff7 /libavformat/icecast.c
parente3dc2c86fc4178b100484c54f12c88705cdf6724 (diff)
parenteb9244f20210fd420fb9b3c98126f9cae525d1cc (diff)
Merge commit 'eb9244f20210fd420fb9b3c98126f9cae525d1cc'
* commit 'eb9244f20210fd420fb9b3c98126f9cae525d1cc': Add Icecast protocol Conflicts: Changelog configure doc/protocols.texi libavformat/icecast.c libavformat/version.h See: e3dc2c86fc4178b100484c54f12c88705cdf6724 Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/icecast.c')
-rw-r--r--libavformat/icecast.c37
1 files changed, 23 insertions, 14 deletions
diff --git a/libavformat/icecast.c b/libavformat/icecast.c
index 67d807e2ce..56a2976f06 100644
--- a/libavformat/icecast.c
+++ b/libavformat/icecast.c
@@ -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,