[xiph-commits] r9225 - in icecast/trunk/icecast: . src

karl at motherfish-iii.xiph.org karl at motherfish-iii.xiph.org
Sat May 7 04:01:43 PDT 2005


Author: karl
Date: 2005-05-07 04:01:35 -0700 (Sat, 07 May 2005)
New Revision: 9225

Added:
   icecast/trunk/icecast/src/format_flac.c
   icecast/trunk/icecast/src/format_flac.h
   icecast/trunk/icecast/src/format_midi.c
   icecast/trunk/icecast/src/format_midi.h
   icecast/trunk/icecast/src/format_speex.c
   icecast/trunk/icecast/src/format_speex.h
Modified:
   icecast/trunk/icecast/Makefile.am
   icecast/trunk/icecast/configure.in
   icecast/trunk/icecast/src/Makefile.am
   icecast/trunk/icecast/src/format_ogg.c
Log:
Add more Ogg codec handlers, there has not been that much testing on these
mainly due to client support, but they are only for detection and plug
straight into the ogg handler.
The win32 project files will need updating to take the new files into account


Modified: icecast/trunk/icecast/Makefile.am
===================================================================
--- icecast/trunk/icecast/Makefile.am	2005-05-07 08:07:05 UTC (rev 9224)
+++ icecast/trunk/icecast/Makefile.am	2005-05-07 11:01:35 UTC (rev 9225)
@@ -6,7 +6,7 @@
 SUBDIRS = src conf debian doc web admin win32
 
 EXTRA_DIST = HACKING m4/acx_pthread.m4 m4/ogg.m4 \
-    m4/theora.m4 m4/vorbis.m4 \
+    m4/theora.m4 m4/vorbis.m4 m4/speex.m4 \
     m4/xiph_compiler.m4 m4/xiph_curl.m4 m4/xiph_net.m4 \
     m4/xiph_types.m4 m4/xiph_xml2.m4 icecast.spec
 

Modified: icecast/trunk/icecast/configure.in
===================================================================
--- icecast/trunk/icecast/configure.in	2005-05-07 08:07:05 UTC (rev 9224)
+++ icecast/trunk/icecast/configure.in	2005-05-07 11:01:35 UTC (rev 9225)
@@ -1,4 +1,4 @@
-AC_INIT([Icecast], [2.2.0], [icecast at xiph.org])
+AC_INIT([Icecast], [2.2.0-trunk], [icecast at xiph.org])
 
 AC_PREREQ(2.54)
 AC_CONFIG_SRCDIR(src/main.c)
@@ -91,6 +91,16 @@
     [ AC_MSG_WARN([Theora disabled!])
     ])
 
+XIPH_PATH_SPEEX(
+    [ XIPH_VAR_APPEND([XIPH_CPPFLAGS],[$SPEEX_CFLAGS])
+    XIPH_VAR_PREPEND([XIPH_LIBS],[$SPEEX_LIBS])
+    XIPH_VAR_APPEND([XIPH_LDFLAGS],[$SPEEX_LDFLAGS])
+    ICECAST_OPTIONAL="$ICECAST_OPTIONAL format_speex.o"
+    ],
+    [ AC_MSG_WARN([Speex support disabled!])
+    ])
+
+
 ACX_PTHREAD(, AC_MSG_ERROR([POSIX threads missing]))
 XIPH_VAR_APPEND([XIPH_CFLAGS],[$PTHREAD_CFLAGS])
 XIPH_VAR_APPEND([XIPH_CPPFLAGS],[$PTHREAD_CPPFLAGS])

Modified: icecast/trunk/icecast/src/Makefile.am
===================================================================
--- icecast/trunk/icecast/src/Makefile.am	2005-05-07 08:07:05 UTC (rev 9224)
+++ icecast/trunk/icecast/src/Makefile.am	2005-05-07 11:01:35 UTC (rev 9225)
@@ -10,12 +10,13 @@
     global.h util.h slave.h source.h stats.h refbuf.h client.h format.h \
     compat.h format_mp3.h fserve.h xslt.h yp.h event.h md5.h \
     auth.h format_ogg.h \
-    format_vorbis.h format_theora.h
+    format_vorbis.h format_theora.h format_flac.h format_speex.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 format.c format_ogg.c \
-    format_mp3.c xslt.c fserve.c event.c admin.c auth.c md5.c
+    util.c slave.c source.c stats.c refbuf.c client.c \
+    xslt.c fserve.c event.c admin.c auth.c md5.c \
+    format.c format_ogg.c format_mp3.c format_midi.c format_flac.c
 EXTRA_icecast_SOURCES = yp.c \
-    format_vorbis.c format_theora.c
+    format_vorbis.c format_theora.c format_speex.c
     
 icecast_DEPENDENCIES = @ICECAST_OPTIONAL@ net/libicenet.la thread/libicethread.la \
     httpp/libicehttpp.la log/libicelog.la avl/libiceavl.la timing/libicetiming.la

Added: icecast/trunk/icecast/src/format_flac.c
===================================================================
--- icecast/trunk/icecast/src/format_flac.c	2005-05-07 08:07:05 UTC (rev 9224)
+++ icecast/trunk/icecast/src/format_flac.c	2005-05-07 11:01:35 UTC (rev 9225)
@@ -0,0 +1,126 @@
+/* Icecast
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright 2000-2004, Jack Moffitt <jack at xiph.org, 
+ *                      Michael Smith <msmith at xiph.org>,
+ *                      oddsock <oddsock at xiph.org>,
+ *                      Karl Heyes <karl at xiph.org>
+ *                      and others (see AUTHORS for details).
+ */
+
+
+/* Ogg codec handler for FLAC logical streams */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <ogg/ogg.h>
+#include <string.h>
+
+typedef struct source_tag source_t;
+
+#include "refbuf.h"
+#include "format_ogg.h"
+#include "client.h"
+#include "stats.h"
+
+#define CATMODULE "format-flac"
+#include "logging.h"
+
+
+static void flac_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec)
+{
+    DEBUG0 ("freeing FLAC codec");
+    stats_event (ogg_info->mount, "FLAC_version", NULL);
+    ogg_stream_clear (&codec->os);
+    free (codec);
+}
+
+
+/* Here, we just verify the page is ok and then add it to the queue */
+static refbuf_t *process_flac_page (ogg_state_t *ogg_info, ogg_codec_t *codec, ogg_page *page)
+{
+    refbuf_t * refbuf;
+
+    if (ogg_stream_pagein (&codec->os, page) < 0)
+    {
+        ogg_info->error = 1;
+        return NULL;
+    }
+    if (codec->headers)
+    {
+        ogg_packet packet;
+        while (ogg_stream_packetout (&codec->os, &packet))
+        {
+            int type = packet.packet[0];
+            if (type == 0xFF)
+            {
+                codec->headers = 0;
+                break;
+            }
+            if (type >= 1 && type <= 0x7E)
+                continue;
+            if (type >= 0x81 && type <= 0xFE)
+                continue;
+            ogg_info->error = 1;
+            return NULL;
+        }
+        if (codec->headers)
+        {
+            format_ogg_attach_header (ogg_info, page);
+            return NULL;
+        }
+    }
+    refbuf = make_refbuf_with_page (page);
+    return refbuf;
+}
+
+
+/* Check for flac header in logical stream */
+
+ogg_codec_t *initial_flac_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 FLAC codec");
+    do
+    {
+        unsigned char *parse = packet.packet;
+
+        if (page->header_len + page->body_len != 79)
+            break;
+        if (*parse != 0x7F)
+            break;
+        parse++;
+        if (memcmp (parse, "FLAC", 4) != 0)
+            break;
+
+        INFO0 ("seen initial FLAC header");
+
+        parse += 4;
+        stats_event_args (ogg_info->mount, "FLAC_version", "%d.%d",  parse[0], parse[1]);
+        codec->process_page = process_flac_page;
+        codec->codec_free = flac_codec_free;
+        codec->headers = 1;
+        codec->name = "FLAC";
+
+        format_ogg_attach_header (ogg_info, page);
+        return codec;
+    } while (0);
+
+    ogg_stream_clear (&codec->os);
+    free (codec);
+    return NULL;
+}
+

Added: icecast/trunk/icecast/src/format_flac.h
===================================================================
--- icecast/trunk/icecast/src/format_flac.h	2005-05-07 08:07:05 UTC (rev 9224)
+++ icecast/trunk/icecast/src/format_flac.h	2005-05-07 11:01:35 UTC (rev 9225)
@@ -0,0 +1,21 @@
+/* Icecast
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright 2000-2004, Jack Moffitt <jack at xiph.org, 
+ *                      Michael Smith <msmith at xiph.org>,
+ *                      oddsock <oddsock at xiph.org>,
+ *                      Karl Heyes <karl at xiph.org>
+ *                      and others (see AUTHORS for details).
+ */
+
+
+#ifndef __FORMAT_FLAC_H
+#define __FORMAT_FLAC_H
+
+#include "format_ogg.h"
+
+ogg_codec_t *initial_flac_page (format_plugin_t *plugin, ogg_page *page);
+
+#endif /* __FORMAT_FLAC_H */

Added: icecast/trunk/icecast/src/format_midi.c
===================================================================
--- icecast/trunk/icecast/src/format_midi.c	2005-05-07 08:07:05 UTC (rev 9224)
+++ icecast/trunk/icecast/src/format_midi.c	2005-05-07 11:01:35 UTC (rev 9225)
@@ -0,0 +1,95 @@
+/* Icecast
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright 2000-2004, Jack Moffitt <jack at xiph.org, 
+ *                      Michael Smith <msmith at xiph.org>,
+ *                      oddsock <oddsock at xiph.org>,
+ *                      Karl Heyes <karl at xiph.org>
+ *                      and others (see AUTHORS for details).
+ */
+
+
+/* Ogg codec handler for MIDI logical streams */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <ogg/ogg.h>
+#include <string.h>
+
+typedef struct source_tag source_t;
+
+#include "refbuf.h"
+#include "format_ogg.h"
+#include "client.h"
+#include "stats.h"
+
+#define CATMODULE "format-midi"
+#include "logging.h"
+
+
+static void midi_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec)
+{
+    DEBUG0 ("freeing MIDI codec");
+    ogg_stream_clear (&codec->os);
+    free (codec);
+}
+
+
+/* Here, we just verify the page is ok and then add it to the queue */
+static refbuf_t *process_midi_page (ogg_state_t *ogg_info, ogg_codec_t *codec, ogg_page *page)
+{
+    refbuf_t * refbuf;
+
+    if (ogg_stream_pagein (&codec->os, page) < 0)
+    {
+        ogg_info->error = 1;
+        return NULL;
+    }
+    refbuf = make_refbuf_with_page (page);
+    return refbuf;
+}
+
+
+/* Check for midi header in logical stream */
+
+ogg_codec_t *initial_midi_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 MIDI codec");
+    do
+    {
+        if (packet.bytes < 9)
+            break;
+        if (memcmp (packet.packet, "OggMIDI\000", 8) != 0)
+            break;
+        if (packet.bytes != 12)
+            break;
+
+        INFO0 ("seen initial MIDI header");
+        codec->process_page = process_midi_page;
+        codec->codec_free = midi_codec_free;
+        codec->headers = 1;
+        codec->name = "MIDI";
+
+        format_ogg_attach_header (ogg_info, page);
+        return codec;
+    } while (0);
+
+    ogg_stream_clear (&codec->os);
+    free (codec);
+    return NULL;
+}
+

Added: icecast/trunk/icecast/src/format_midi.h
===================================================================
--- icecast/trunk/icecast/src/format_midi.h	2005-05-07 08:07:05 UTC (rev 9224)
+++ icecast/trunk/icecast/src/format_midi.h	2005-05-07 11:01:35 UTC (rev 9225)
@@ -0,0 +1,21 @@
+/* Icecast
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright 2000-2004, Jack Moffitt <jack at xiph.org, 
+ *                      Michael Smith <msmith at xiph.org>,
+ *                      oddsock <oddsock at xiph.org>,
+ *                      Karl Heyes <karl at xiph.org>
+ *                      and others (see AUTHORS for details).
+ */
+
+
+#ifndef __FORMAT_MIDI_H
+#define __FORMAT_MIDI_H
+
+#include "format_ogg.h"
+
+ogg_codec_t *initial_midi_page (format_plugin_t *plugin, ogg_page *page);
+
+#endif /* __FORMAT_MIDI_H */

Modified: icecast/trunk/icecast/src/format_ogg.c
===================================================================
--- icecast/trunk/icecast/src/format_ogg.c	2005-05-07 08:07:05 UTC (rev 9224)
+++ icecast/trunk/icecast/src/format_ogg.c	2005-05-07 11:01:35 UTC (rev 9225)
@@ -37,6 +37,11 @@
 #ifdef HAVE_THEORA
 #include "format_theora.h"
 #endif
+#ifdef HAVE_SPEEX
+#include "format_speex.h"
+#endif
+#include "format_midi.h"
+#include "format_flac.h"
 
 #ifdef _WIN32
 #define snprintf _snprintf
@@ -217,6 +222,18 @@
         if (codec)
             break;
 #endif
+        codec = initial_midi_page (plugin, page);
+        if (codec)
+            break;
+        codec = initial_flac_page (plugin, page);
+        if (codec)
+            break;
+#ifdef HAVE_SPEEX
+        codec = initial_speex_page (plugin, page);
+        if (codec)
+            break;
+#endif
+
         /* any others */
         ERROR0 ("Seen BOS page with unknown type");
         return -1;

Added: icecast/trunk/icecast/src/format_speex.c
===================================================================
--- icecast/trunk/icecast/src/format_speex.c	2005-05-07 08:07:05 UTC (rev 9224)
+++ icecast/trunk/icecast/src/format_speex.c	2005-05-07 11:01:35 UTC (rev 9225)
@@ -0,0 +1,92 @@
+/* Icecast
+ *  
+ *  This program is distributed under the GNU General Public License, version 2.
+ *  A copy of this license is included with this source.
+ *
+ * Copyright 2000-2004, Jack Moffitt <jack at xiph.org>, 
+ *                      Michael Smith <msmith at xiph.org>,
+ *                      oddsock <oddsock at xiph.org>,
+ *                      Karl Heyes <karl at xiph.org>
+ *                      and others (see AUTHORS for details).
+ */
+
+
+/* Ogg codec handler for speex streams */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdlib.h>
+#include <ogg/ogg.h>
+#include <speex/speex_header.h>
+
+typedef struct source_tag source_t;
+
+#include "format_speex.h"
+#include "refbuf.h"
+#include "client.h"
+
+#define CATMODULE "format-speex"
+#include "logging.h"
+
+static void speex_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec)
+{
+    ogg_stream_clear (&codec->os);
+    free (codec);
+}
+
+
+static refbuf_t *process_speex_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_speex_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;
+    SpeexHeader *header;
+
+    ogg_stream_init (&codec->os, ogg_page_serialno (page));
+    ogg_stream_pagein (&codec->os, page);
+
+    ogg_stream_packetout (&codec->os, &packet);
+
+    DEBUG0("checking for speex codec");
+    header = speex_packet_to_header (packet.packet, packet.bytes);
+    if (header == NULL)
+    {
+        ogg_stream_clear (&codec->os);
+        free (header);
+        free (codec);
+        return NULL;
+    }
+    INFO0 ("seen initial speex header");
+    codec->process_page = process_speex_page;
+    codec->codec_free = speex_codec_free;
+    codec->headers = 1;
+    format_ogg_attach_header (ogg_info, page);
+    free (header);
+    return codec;
+}

Added: icecast/trunk/icecast/src/format_speex.h
===================================================================
--- icecast/trunk/icecast/src/format_speex.h	2005-05-07 08:07:05 UTC (rev 9224)
+++ icecast/trunk/icecast/src/format_speex.h	2005-05-07 11:01:35 UTC (rev 9225)
@@ -0,0 +1,21 @@
+/* Icecast
+ *
+ * This program is distributed under the GNU General Public License, version 2.
+ * A copy of this license is included with this source.
+ *
+ * Copyright 2000-2004, Jack Moffitt <jack at xiph.org, 
+ *                      Michael Smith <msmith at xiph.org>,
+ *                      oddsock <oddsock at xiph.org>,
+ *                      Karl Heyes <karl at xiph.org>
+ *                      and others (see AUTHORS for details).
+ */
+
+
+#ifndef __FORMAT_SPEEX_H
+#define __FORMAT_SPEEX_H
+
+#include "format_ogg.h"
+
+ogg_codec_t *initial_speex_page (format_plugin_t *plugin, ogg_page *page);
+
+#endif /* __FORMAT_SPEEX_H */



More information about the commits mailing list