[xiph-commits] r18401 - in icecast/trunk/icecast: . src
giles at svn.xiph.org
giles at svn.xiph.org
Wed Jun 13 14:11:07 PDT 2012
Author: giles
Date: 2012-06-13 14:11:07 -0700 (Wed, 13 Jun 2012)
New Revision: 18401
Added:
icecast/trunk/icecast/src/format_opus.c
icecast/trunk/icecast/src/format_opus.h
Modified:
icecast/trunk/icecast/AUTHORS
icecast/trunk/icecast/src/Makefile.am
icecast/trunk/icecast/src/format_ogg.c
Log:
Add support for Opus audio in the Ogg container.
Patch by David Richards from the icecast-webm branch.
Modified: icecast/trunk/icecast/AUTHORS
===================================================================
--- icecast/trunk/icecast/AUTHORS 2012-06-13 21:09:23 UTC (rev 18400)
+++ icecast/trunk/icecast/AUTHORS 2012-06-13 21:11:07 UTC (rev 18401)
@@ -4,3 +4,4 @@
Karl Heyes <karl at xiph.org>
Philipp "ph3-der-loewe" Schafft <lion at lion.leolix.org>
Thomas B. "dm8tbr" Ruecker <thomas.rucker at tieto.com>
+David "oneman" Richards <kradradio at gmail.com>
Modified: icecast/trunk/icecast/src/Makefile.am
===================================================================
--- icecast/trunk/icecast/src/Makefile.am 2012-06-13 21:09:23 UTC (rev 18400)
+++ icecast/trunk/icecast/src/Makefile.am 2012-06-13 21:11:07 UTC (rev 18401)
@@ -12,12 +12,12 @@
auth.h auth_htpasswd.h auth_url.h \
format.h format_ogg.h format_mp3.h \
format_vorbis.h format_theora.h format_flac.h format_speex.h format_midi.h \
- format_kate.h format_skeleton.h
+ format_kate.h format_skeleton.h format_opus.h
icecast_SOURCES = cfgfile.c main.c logging.c sighandler.c connection.c global.c \
util.c slave.c source.c stats.c refbuf.c client.c \
xslt.c fserve.c event.c admin.c md5.c \
format.c format_ogg.c format_mp3.c format_midi.c format_flac.c \
- auth.c auth_htpasswd.c format_kate.c format_skeleton.c
+ auth.c auth_htpasswd.c format_kate.c format_skeleton.c format_opus.c
EXTRA_icecast_SOURCES = yp.c \
auth_url.c \
format_vorbis.c format_theora.c format_speex.c
Modified: icecast/trunk/icecast/src/format_ogg.c
===================================================================
--- icecast/trunk/icecast/src/format_ogg.c 2012-06-13 21:09:23 UTC (rev 18400)
+++ icecast/trunk/icecast/src/format_ogg.c 2012-06-13 21:11:07 UTC (rev 18401)
@@ -40,6 +40,7 @@
#ifdef HAVE_SPEEX
#include "format_speex.h"
#endif
+#include "format_opus.h"
#include "format_midi.h"
#include "format_flac.h"
#include "format_kate.h"
@@ -248,6 +249,9 @@
codec = initial_skeleton_page (plugin, page);
if (codec)
break;
+ codec = initial_opus_page (plugin, page);
+ if (codec)
+ break;
/* any others */
ERROR0 ("Seen BOS page with unknown type");
Added: icecast/trunk/icecast/src/format_opus.c
===================================================================
--- icecast/trunk/icecast/src/format_opus.c (rev 0)
+++ icecast/trunk/icecast/src/format_opus.c 2012-06-13 21:11:07 UTC (rev 18401)
@@ -0,0 +1,87 @@
+/* Icecast
+ *
+ * This program is distributed under the GNU General Public License,
+ * version 2. A copy of this license is included with this source.
+ * At your option, this specific source file can also be distributed
+ * under the GNU GPL version 3.
+ *
+ * Copyright 2012, David Richards, Mozilla Foundation,
+ * and others (see AUTHORS for details).
+ */
+
+
+/* Ogg codec handler for opus streams */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <ogg/ogg.h>
+
+typedef struct source_tag source_t;
+
+#include "format_opus.h"
+#include "refbuf.h"
+#include "client.h"
+
+#define CATMODULE "format-opus"
+#include "logging.h"
+
+static void opus_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec)
+{
+ ogg_stream_clear (&codec->os);
+ free (codec);
+}
+
+
+static refbuf_t *process_opus_page (ogg_state_t *ogg_info,
+ ogg_codec_t *codec, ogg_page *page)
+{
+ refbuf_t *refbuf;
+
+ if (codec->headers < 2)
+ {
+ ogg_packet packet;
+
+ ogg_stream_pagein (&codec->os, page);
+ while (ogg_stream_packetout (&codec->os, &packet) > 0)
+ {
+ /* first time around (normal case) yields comments */
+ codec->headers++;
+ }
+ /* add header page to associated list */
+ format_ogg_attach_header (ogg_info, page);
+ return NULL;
+ }
+ refbuf = make_refbuf_with_page (page);
+ return refbuf;
+}
+
+
+ogg_codec_t *initial_opus_page (format_plugin_t *plugin, ogg_page *page)
+{
+ ogg_state_t *ogg_info = plugin->_state;
+ ogg_codec_t *codec = calloc (1, sizeof (ogg_codec_t));
+ ogg_packet packet;
+
+ ogg_stream_init (&codec->os, ogg_page_serialno (page));
+ ogg_stream_pagein (&codec->os, page);
+
+ ogg_stream_packetout (&codec->os, &packet);
+
+ DEBUG0("checking for opus codec");
+ if (strncmp((char *)packet.packet, "OpusHead", 8) != 0)
+ {
+ ogg_stream_clear (&codec->os);
+ free (codec);
+ return NULL;
+ }
+ INFO0 ("seen initial opus header");
+ codec->process_page = process_opus_page;
+ codec->codec_free = opus_codec_free;
+ codec->headers = 1;
+ format_ogg_attach_header (ogg_info, page);
+ return codec;
+}
+
Added: icecast/trunk/icecast/src/format_opus.h
===================================================================
--- icecast/trunk/icecast/src/format_opus.h (rev 0)
+++ icecast/trunk/icecast/src/format_opus.h 2012-06-13 21:11:07 UTC (rev 18401)
@@ -0,0 +1,20 @@
+/* Icecast
+ *
+ * This program is distributed under the GNU General Public License,
+ * version 2. A copy of this license is included with this source.
+ * At your option, this specific source file can also be distributed
+ * under the GNU GPL version 3.
+ *
+ * Copyright 2012, David Richards, Mozilla Foundation,
+ * and others (see AUTHORS for details).
+ */
+
+
+#ifndef __FORMAT_OPUS_H
+#define __FORMAT_OPUS_H
+
+#include "format_ogg.h"
+
+ogg_codec_t *initial_opus_page (format_plugin_t *plugin, ogg_page *page);
+
+#endif /* __FORMAT_OPUS_H */
More information about the commits
mailing list