Author: titmuss
Date: Wed May 21 04:38:36 2008
New Revision: 2501
URL: http://svn.slimdevices.com?rev=2501&root=Jive&view=rev
Log:
Bug: N/A
Description:
Send shoutcast metadata to SqueezeCenter. This uses the existing META command,
it is planned to implement a new version of the META command that
allows timing information to be sent with the metadata.
Modified:
7.2/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua
7.2/trunk/squeezeplay/src/squeezeplay/share/jive/net/SlimProto.lua
7.2/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode.c
7.2/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_priv.h
7.2/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua?rev=2501&root=Jive&r1=2500&r2=2501&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua
(original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/audio/Playback.lua Wed May
21 04:38:36 2008
@@ -183,6 +183,19 @@
self.sentDecoderFullEvent = true
end
+ end
+
+
+ -- stream metadata
+ local metadata = Decode:streamMetadata()
+ if metadata then
+ debug.dump(metadata)
+
+ -- XXXX extend META with more data
+ self.slimproto:send({
+ opcode = "META",
+ metadata = metadata.metadata,
+ })
end
end
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/net/SlimProto.lua
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/share/jive/net/SlimProto.lua?rev=2501&root=Jive&r1=2500&r2=2501&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/net/SlimProto.lua
(original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/share/jive/net/SlimProto.lua Wed May
21 04:38:36 2008
@@ -194,8 +194,11 @@
end,
META = function(self, data)
- -- XXXX
- log:warn("TODO")
+ assert(data.metadata)
+
+ return {
+ data.metadata
+ }
end,
BODY = function(self, data)
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode.c?rev=2501&root=Jive&r1=2500&r2=2501&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode.c (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode.c Wed May 21
04:38:36 2008
@@ -19,6 +19,7 @@
#define DECODE_MQUEUE_SIZE 512
+#define DECODE_METADATA_SIZE 128
/* decoder thread */
static SDL_Thread *decode_thread;
@@ -44,6 +45,10 @@
/* decoder mqueue */
struct mqueue decode_mqueue;
static Uint32 decode_mqueue_buffer[DECODE_MQUEUE_SIZE / sizeof(Uint32)];
+
+
+/* meta data mqueue */
+struct decode_metadata *decode_metadata;
/* audio instance */
@@ -241,6 +246,61 @@
return 0;
}
+/*
+ * stream metadata interface
+ */
+void decode_queue_metadata(struct decode_metadata *metadata) {
+ fifo_lock(&decode_fifo);
+
+ if (decode_metadata) {
+ DEBUG_TRACE("Dropped metadata");
+ free(decode_metadata);
+ }
+
+ metadata->timestamp = SDL_GetTicks();
+ metadata->fullness = fifo_bytes_used(&decode_fifo);
+
+ decode_metadata = metadata;
+
+ fifo_unlock(&decode_fifo);
+}
+
+
+static int decode_stream_metadata(lua_State *L) {
+ /*
+ * 1: self
+ */
+
+ fifo_lock(&decode_fifo);
+
+ if (!decode_metadata) {
+ fifo_unlock(&decode_fifo);
+ return 0;
+ }
+
+ lua_newtable(L);
+
+ lua_pushinteger(L, decode_metadata->type);
+ lua_setfield(L, 2, "type");
+
+ lua_pushinteger(L, decode_metadata->timestamp);
+ lua_setfield(L, 2, "timestamp");
+
+ lua_pushinteger(L, decode_metadata->fullness);
+ lua_setfield(L, 2, "fullness");
+
+ lua_pushlstring(L, (char *) &decode_metadata->data,
decode_metadata->len);
+ lua_setfield(L, 2, "metadata");
+
+ free(decode_metadata);
+ decode_metadata = NULL;
+
+ fifo_unlock(&decode_fifo);
+
+ return 1;
+}
+
+
/*
* lua decoder interface
@@ -451,6 +511,7 @@
{ "flush", decode_flush },
{ "start", decode_start },
{ "status", decode_status },
+ { "streamMetadata", decode_stream_metadata },
{ NULL, NULL }
};
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_priv.h
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_priv.h?rev=2501&root=Jive&r1=2500&r2=2501&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_priv.h
(original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/audio/decode/decode_priv.h Wed
May 21 04:38:36 2008
@@ -53,6 +53,24 @@
extern int decode_output_samplerate();
+/* Stream metadata */
+
+struct decode_metadata {
+ enum {
+ SHOUTCAST = 0,
+ WMA_GUID = 1,
+ } type;
+
+ u32_t timestamp;
+ size_t fullness;
+
+ size_t len;
+ u8_t data;
+};
+
+extern void decode_queue_metadata(struct decode_metadata *metadata);
+
+
/* Audio output api */
struct decode_audio {
void (*init)(void);
Modified: 7.2/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c
URL:
http://svn.slimdevices.com/7.2/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c?rev=2501&root=Jive&r1=2500&r2=2501&view=diff
==============================================================================
--- 7.2/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c (original)
+++ 7.2/trunk/squeezeplay/src/squeezeplay/src/audio/streambuf.c Wed May 21
04:38:36 2008
@@ -10,6 +10,7 @@
#include "audio/fifo.h"
#include "audio/decode/decode.h"
+#include "audio/decode/decode_priv.h"
#if defined(WIN32)
@@ -292,22 +293,28 @@
}
else {
/* we're reading the metadata */
- u32_t icy_len = -icy_meta_remaining;
- u8_t *icy_buf;
+ struct decode_metadata *icy_buf;
+ size_t icy_len = -icy_meta_remaining;
if (avail < icy_len) {
/* wait for more data */
break;
}
- icy_buf = malloc(icy_len);
- r = streambuf_fast_read(icy_buf, icy_len, icy_len,
NULL);
+ icy_buf = malloc(sizeof(struct decode_metadata) +
icy_len - 1);
+
+ icy_buf->type = SHOUTCAST;
+ icy_buf->len = icy_len;
+
+ r = streambuf_fast_read(&icy_buf->data, icy_len,
icy_len, NULL);
assert(r == icy_len);
// XXXX queue metadata
- assert( strstr( (char *)icy_buf, "StreamTitle" ) !=
NULL );
- DEBUG_TRACE("got icy metadata: %s", icy_buf);
- free(icy_buf);
+ assert( strstr( (char *)&icy_buf->data, "StreamTitle" )
!= NULL );
+ DEBUG_TRACE("got icy metadata: %s", (char *)
&icy_buf->data);
+
+ decode_queue_metadata(icy_buf);
+ /* decode will free icy_buf */
icy_meta_remaining = icy_meta_interval;
}
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins