[xiph-commits] r18167 - in icecast/trunk/libshout: include/shout src

giles at svn.xiph.org giles at svn.xiph.org
Wed Feb 1 15:26:32 PST 2012


Author: giles
Date: 2012-02-01 15:26:31 -0800 (Wed, 01 Feb 2012)
New Revision: 18167

Added:
   icecast/trunk/libshout/src/webm.c
Modified:
   icecast/trunk/libshout/include/shout/shout.h.in
   icecast/trunk/libshout/src/Makefile.am
   icecast/trunk/libshout/src/shout.c
Log:
Add support for webm streaming.

This doesn't do data inspection to throttle the upload stream,
but is still useful as-is for feeding webm video to icecast
through gstreamer's shout2send module.


Modified: icecast/trunk/libshout/include/shout/shout.h.in
===================================================================
--- icecast/trunk/libshout/include/shout/shout.h.in	2012-02-01 01:43:09 UTC (rev 18166)
+++ icecast/trunk/libshout/include/shout/shout.h.in	2012-02-01 23:26:31 UTC (rev 18167)
@@ -41,6 +41,7 @@
 
 #define SHOUT_FORMAT_OGG	(0)
 #define SHOUT_FORMAT_MP3	(1)
+#define SHOUT_FORMAT_WEBM	(2)
 /* backward-compatibility alias */
 #define SHOUT_FORMAT_VORBIS	SHOUT_FORMAT_OGG
 

Modified: icecast/trunk/libshout/src/Makefile.am
===================================================================
--- icecast/trunk/libshout/src/Makefile.am	2012-02-01 01:43:09 UTC (rev 18166)
+++ icecast/trunk/libshout/src/Makefile.am	2012-02-01 23:26:31 UTC (rev 18167)
@@ -22,7 +22,7 @@
 
 EXTRA_DIST = theora.c speex.c
 noinst_HEADERS = shout_ogg.h shout_private.h util.h
-libshout_la_SOURCES = shout.c util.c ogg.c vorbis.c mp3.c $(MAYBE_THEORA) $(MAYBE_SPEEX)
+libshout_la_SOURCES = shout.c util.c ogg.c vorbis.c mp3.c webm.c $(MAYBE_THEORA) $(MAYBE_SPEEX)
 AM_CFLAGS = @XIPH_CFLAGS@
 
 libshout_la_LIBADD = net/libicenet.la timing/libicetiming.la avl/libiceavl.la\

Modified: icecast/trunk/libshout/src/shout.c
===================================================================
--- icecast/trunk/libshout/src/shout.c	2012-02-01 01:43:09 UTC (rev 18166)
+++ icecast/trunk/libshout/src/shout.c	2012-02-01 23:26:31 UTC (rev 18167)
@@ -727,7 +727,9 @@
 	if (self->state != SHOUT_STATE_UNCONNECTED)
 		return self->error = SHOUTERR_CONNECTED;
 
-	if (format != SHOUT_FORMAT_OGG && format != SHOUT_FORMAT_MP3)
+	if (format != SHOUT_FORMAT_OGG
+         && format != SHOUT_FORMAT_MP3
+	 && format != SHOUT_FORMAT_WEBM)
 		return self->error = SHOUTERR_UNSUPPORTED;
 
 	self->format = format;
@@ -999,6 +1001,9 @@
 		} else if (self->format == SHOUT_FORMAT_MP3) {
 			if ((rc = self->error = shout_open_mp3(self)) != SHOUTERR_SUCCESS)
                                 goto failure;
+		} else if (self->format == SHOUT_FORMAT_WEBM) {
+			if ((rc = self->error = shout_open_webm(self)) != SHOUTERR_SUCCESS)
+				goto failure;
 		} else {
                         rc = SHOUTERR_INSANE;
                         goto failure;
@@ -1130,6 +1135,8 @@
 			break;
 		if (self->format == SHOUT_FORMAT_MP3 && queue_printf(self, "Content-Type: audio/mpeg\r\n"))
 			break;
+		if (self->format == SHOUT_FORMAT_WEBM && queue_printf(self, "Content-Type: video/webm\r\n"))
+			break;
 		if (queue_printf(self, "ice-name: %s\r\n", self->name ? self->name : "no name"))
 			break;
 		if (queue_printf(self, "ice-public: %d\r\n", self->public))

Added: icecast/trunk/libshout/src/webm.c
===================================================================
--- icecast/trunk/libshout/src/webm.c	                        (rev 0)
+++ icecast/trunk/libshout/src/webm.c	2012-02-01 23:26:31 UTC (rev 18167)
@@ -0,0 +1,68 @@
+/* -*- c-basic-offset: 8; -*- */
+/* webm.c: WebM data handler
+ * $Id: ogg.c 10686 2006-01-03 18:47:54Z brendan $
+ *
+ *  Copyright (C) 2002-2012 the Icecast team <team at icecast.org>
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public
+ *  License along with this library; if not, write to the Free
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+ #include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#ifdef HAVE_INTTYPES_H
+#include <inttypes.h>
+#endif
+
+#include <shout/shout.h>
+#include "shout_private.h"
+
+/* -- local datatypes -- */
+typedef struct {
+  /* no local state */
+} webm_data_t;
+
+/* -- static prototypes -- */
+static int send_webm(shout_t *self, const unsigned char *data, size_t len);
+static void close_webm(shout_t *self);
+
+int shout_open_webm(shout_t *self)
+{
+	self->format_data = NULL;
+	self->send = send_webm;
+	self->close = close_webm;
+
+	return SHOUTERR_SUCCESS;
+}
+
+static int send_webm(shout_t *self, const unsigned char *data, size_t len)
+{
+	/* HACK: just send the raw data, no throttle */
+
+	int ret = shout_send_raw(self, data, len);
+	if (ret != len)
+		return self->error = SHOUTERR_SOCKET;
+
+	return self->error = SHOUTERR_SUCCESS;
+}
+
+static void close_webm(shout_t *self)
+{
+	/* no private state */
+}



More information about the commits mailing list