[Icecast-dev] Streaming AAC with libshout?
Paul Kelly
paul at stjohnspoint.co.uk
Mon Jun 24 08:08:47 PDT 2013
Romain Beauxis wrote:
>
> As for libshout, I do not think that it is currently posible to send
> AAC data using it. First, libshout doesn't have support to buffer and
> control timing of data sent. And even is you use the un-timed API
> (shout_send_raw), the library cannot set the proper mime type, due to
> a limited list of possible values.
The attached patch fixes that, for the published version of libshout
2.3.1. It adds new formats SHOUT_FORMAT_AAC and SHOUT_FORMAT_AACPLUS
with mime types of audio/aac and audio/aacp respectively.
Works fine for real-time streaming using shout_send_raw().
Note that you will need to run automake after applying the patch, before
re-running ./configure.
Best regards
Paul
-------------- next part --------------
--- libshout-2.3.1/include/shout/shout.h.in 2012-02-01 22:02:18.000000000 +0100
+++ libshout-2.3.1-patched/include/shout/shout.h.in 2013-06-24 17:01:43.825462821 +0200
@@ -42,6 +42,8 @@
#define SHOUT_FORMAT_OGG (0)
#define SHOUT_FORMAT_MP3 (1)
#define SHOUT_FORMAT_WEBM (2)
+#define SHOUT_FORMAT_AAC (3)
+#define SHOUT_FORMAT_AACPLUS (4)
/* backward-compatibility alias */
#define SHOUT_FORMAT_VORBIS SHOUT_FORMAT_OGG
--- libshout-2.3.1/src/aac.c 1970-01-01 01:00:00.000000000 +0100
+++ libshout-2.3.1-patched/src/aac.c 2013-06-24 17:01:26.617463179 +0200
@@ -0,0 +1,44 @@
+/* -*- c-basic-offset: 8; -*- */
+/* aac.c: libshout AAC and AAC+ format handler
+ * $Id$
+ *
+ * Copyright (C) 2002-2013 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
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <shout/shout.h>
+#include "shout_private.h"
+
+/* -- static prototypes -- */
+static int send_aac(shout_t *self, const unsigned char *data, size_t len);
+
+int shout_open_aac(shout_t *self)
+{
+
+ self->send = send_aac;
+ self->close = NULL;
+
+ return SHOUTERR_SUCCESS;
+}
+
+static int send_aac(shout_t* self, const unsigned char* buff, size_t len)
+{
+ /* Parsing AAC not supported; must be streamed using shout_send_raw() */
+ return self->error = SHOUTERR_UNSUPPORTED;
+}
--- libshout-2.3.1/src/Makefile.am 2012-05-24 20:19:57.000000000 +0200
+++ libshout-2.3.1-patched/src/Makefile.am 2013-06-24 17:01:31.402214479 +0200
@@ -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 webm.c opus.c $(MAYBE_THEORA) $(MAYBE_SPEEX)
+libshout_la_SOURCES = shout.c util.c ogg.c vorbis.c mp3.c webm.c opus.c aac.c $(MAYBE_THEORA) $(MAYBE_SPEEX)
AM_CFLAGS = @XIPH_CFLAGS@
libshout_la_LIBADD = net/libicenet.la timing/libicetiming.la avl/libiceavl.la\
--- libshout-2.3.1/src/shout.c 2012-05-24 22:25:35.000000000 +0200
+++ libshout-2.3.1-patched/src/shout.c 2013-06-24 17:01:23.140215059 +0200
@@ -728,7 +728,9 @@
if (format != SHOUT_FORMAT_OGG
&& format != SHOUT_FORMAT_MP3
- && format != SHOUT_FORMAT_WEBM)
+ && format != SHOUT_FORMAT_WEBM
+ && format != SHOUT_FORMAT_AAC
+ && format != SHOUT_FORMAT_AACPLUS)
return self->error = SHOUTERR_UNSUPPORTED;
self->format = format;
@@ -1003,6 +1005,9 @@
} else if (self->format == SHOUT_FORMAT_WEBM) {
if ((rc = self->error = shout_open_webm(self)) != SHOUTERR_SUCCESS)
goto failure;
+ } else if (self->format == SHOUT_FORMAT_AAC || self->format == SHOUT_FORMAT_AACPLUS) {
+ if ((rc = self->error = shout_open_aac(self)) != SHOUTERR_SUCCESS)
+ goto failure;
} else {
rc = SHOUTERR_INSANE;
goto failure;
@@ -1136,6 +1141,10 @@
break;
if (self->format == SHOUT_FORMAT_WEBM && queue_printf(self, "Content-Type: video/webm\r\n"))
break;
+ if (self->format == SHOUT_FORMAT_AAC && queue_printf(self, "Content-Type: audio/aac\r\n"))
+ break;
+ if (self->format == SHOUT_FORMAT_AACPLUS && queue_printf(self, "Content-Type: audio/aacp\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))
--- libshout-2.3.1/src/shout_private.h 2012-02-02 01:16:37.000000000 +0100
+++ libshout-2.3.1-patched/src/shout_private.h 2013-06-24 17:01:19.733462098 +0200
@@ -109,5 +109,6 @@
int shout_open_ogg(shout_t *self);
int shout_open_mp3(shout_t *self);
+int shout_open_aac(shout_t *self);
#endif /* __LIBSHOUT_SHOUT_PRIVATE_H__ */
More information about the Icecast-dev
mailing list