On Mon, 28 Jul 2014, [email protected] wrote:
From: Marvin Scholz <[email protected]>
Check if strdup failed
---
Icecast is basically a convenience wrapper around the HTTP protocol.
---
Changelog | 1 +
configure | 1 +
doc/general.texi | 1 +
doc/protocols.texi | 40 +++++++++
libavformat/Makefile | 1 +
libavformat/allformats.c | 1 +
libavformat/icecast.c | 227 +++++++++++++++++++++++++++++++++++++++++++++++
libavformat/version.h | 2 +-
8 files changed, 273 insertions(+), 1 deletion(-)
create mode 100644 libavformat/icecast.c
This looks good enough to me now - will push in a little while
+static int icecast_write(URLContext *h, const uint8_t *buf, int size)
+{
+ IcecastContext *s = h->priv_data;
+ if (!s->send_started) {
+ s->send_started = 1;
+ if (!s->content_type && size >= 8) {
+ static const uint8_t oggs[4] = { 0x4F, 0x67, 0x67, 0x53 };
+ 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, "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, "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, "Set it with -content_type
video/webm\n");
+ } else {
+ av_log(h, AV_LOG_WARNING, "It seems you are streaming an
unsupported format.\n");
+ av_log(h, AV_LOG_WARNING, "It might work, but is not officially
supported in Icecast!\n");
+ }
+ }
+ }
+ return ffurl_write(s->hd, buf, size);
+}
What happened to the idea of making _open a no-op and connecting only at
this point?
Also, keep in mind that the _write function in principle could be fed with
only 1 byte at a time. In this case, when it's just a warning, it's not a
big issue and there's no need to complicate the logic - but if we'd use
this to actually set the content type automatically and not just warn if
it isn't set right, we'd need to buffer the written data until we've got
enough to identify a full header.
// Martin
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel