Permalink
Browse files

Merge pull request #1 from Memphiz/master

added metadata support...
  • Loading branch information...
2 parents aeb4987 + cbed0c1 commit 40da30532847d91ae2a643b123d637462a066dff @amejia1 committed May 10, 2012
Showing with 74 additions and 7 deletions.
  1. +1 −1 configure.in
  2. +1 −0 src/Makefile.am
  3. +10 −0 src/hairtunes.c
  4. +2 −0 src/hairtunes.h
  5. +58 −6 src/shairport.c
  6. +2 −0 src/shairport.h
View
@@ -8,7 +8,7 @@ AC_CONFIG_MACRO_DIR([m4])
# library version info
# NOTE: this is not the same as the library's release number
-LIBSHAIRPORT_INTERFACE=1
+LIBSHAIRPORT_INTERFACE=2
LIBSHAIRPORT_REVISION=0
LIBSHAIRPORT_AGE=0
LIBSHAIRPORT_LIBTOOL_VERSION=$LIBSHAIRPORT_INTERFACE:$LIBSHAIRPORT_REVISION:$LIBSHAIRPORT_MINOR
View
@@ -6,4 +6,5 @@ library_include_HEADERS = shairport.h
noinst_HEADERS = alac.h hairtunes.h socketlib.h shairport_private.h
libshairport_la_SOURCES=shairport.c hairtunes.c socketlib.c alac.c
+libshairport_la_CFLAGS=-Wl,--no-undefined
libshairport_la_LDFLAGS=-version-info @LIBSHAIRPORT_LIBTOOL_VERSION@
View
@@ -268,6 +268,16 @@ void __shairport_hairtunes_setvolume(float f)
fix_volume = 65536.0 * volume;
}
+void __shairport_hairtunes_set_metadata(const char *buffer, unsigned int size)
+{
+ g_ao.ao_set_metadata(buffer, size);
+}
+
+void __shairport_hairtunes_set_metadata_coverart(const char *buffer, unsigned int size)
+{
+ g_ao.ao_set_metadata_coverart(buffer, size);
+}
+
void __shairport_hairtunes_flush(void)
{
pthread_mutex_lock(&ab_mutex);
View
@@ -4,6 +4,8 @@
int __shairport_hairtunes_init(char *pAeskey, char *pAesiv, char *pFmtpstr, int pCtrlPort, int pTimingPort,
int pDataPort, char *pRtpHost, char*pPipeName, char *pLibaoDriver, char *pLibaoDeviceName, char *pLibaoDeviceId);
void __shairport_hairtunes_setvolume(float vol);
+void __shairport_hairtunes_set_metadata(const char *buffer, unsigned int size);
+void __shairport_hairtunes_set_metadata_coverart(const char *buffer, unsigned int size);
void __shairport_hairtunes_flush(void);
void __shairport_hairtunes_cleanup(void);
View
@@ -524,7 +524,7 @@ static void handleClient(int pSock, char *pPassword, char *pHWADDR)
while(1 == tMoreDataNeeded)
{
tError = readDataFromClient(pSock, &(tConn.recv));
- if(!tError && strlen(tConn.recv.data) > 0)
+ if(!tError && tConn.recv.current > 0)
{
__shairport_xprintf("Finished Reading some data from client\n");
// parse client request
@@ -643,7 +643,7 @@ static char *getFromBuffer(char *pBufferPtr, const char *pField, int pLenAfterFi
}
tSize = (int) (tShortest - tFound);
- __shairport_xprintf("Found %.*s length: %d\n", tSize, tFound, tSize);
+ __shairport_xprintf("Found %s length: %d\n",tFound, tSize);
if(pReturnSize != NULL)
{
*pReturnSize = tSize;
@@ -755,15 +755,15 @@ static int parseMessage(struct connection *pConn, unsigned char *pIpBin, unsigne
if(tContent != NULL)
{
unsigned int tContentSize = atoi(tContent);
- if(pConn->recv.marker == 0 || strlen(pConn->recv.data+pConn->recv.marker) != tContentSize)
+ if(pConn->recv.marker == 0 || pConn->recv.current-pConn->recv.marker != tContentSize)
{
if(isLogEnabledFor(HEADER_LOG_LEVEL))
{
__shairport_xprintf("Content-Length: %s value -> %d\n", tContent, tContentSize);
if(pConn->recv.marker != 0)
{
__shairport_xprintf("ContentPtr has %d, but needs %d\n",
- strlen(pConn->recv.data+pConn->recv.marker), tContentSize);
+ (pConn->recv.current-pConn->recv.marker), tContentSize);
}
}
// check if value in tContent > 2nd read from client.
@@ -1000,15 +1000,67 @@ static int parseMessage(struct connection *pConn, unsigned char *pIpBin, unsigne
{
propogateCSeq(pConn);
int tSize = 0;
+ char *buffer = NULL;
+ char *contentType = getFromHeader(pConn->recv.data, "Content-Type", &tSize);
+ char *tContent = getFromHeader(pConn->recv.data, "Content-Length", NULL);
+ int iContentSize = 0;
+ int isJpg = 0;
+
+ if(tContent != NULL)
+ {
+ iContentSize = atoi(tContent);
+ }
+
+ if( tSize > 1 &&
+ (strncmp(contentType, "application/x-dmap-tagged", tSize) == 0) ||
+ (strncmp(contentType, "image/jpeg", tSize) == 0) )
+ {
+ if( (pConn->recv.current - pConn->recv.marker) == iContentSize && pConn->recv.marker != 0)
+ {
+ if(strncmp(contentType, "image/jpeg", tSize) == 0)
+ {
+ isJpg = 1;
+ }
+ buffer = (char *)malloc(iContentSize * sizeof(char));
+ memcpy(buffer, pConn->recv.data + pConn->recv.marker, iContentSize);
+ }
+ else
+ {
+ iContentSize = 0;
+ }
+ }
+ else
+ {
+ iContentSize = 0;
+ }
char *tVol = getFromHeader(pConn->recv.data, "volume", &tSize);
- __shairport_xprintf("About to write [vol: %.*s] data to hairtunes\n", tSize, tVol);
+ if( tVol)
+ {
+ __shairport_xprintf("About to write [vol: %.*s] data to hairtunes\n", tSize, tVol);
+ }
// TBD VOLUME
#ifndef XBMC
write(pConn->hairtunes->in[1], "vol: ", 5);
write(pConn->hairtunes->in[1], tVol, tSize);
write(pConn->hairtunes->in[1], "\n", 1);
#else
- __shairport_hairtunes_setvolume(atof(tVol));
+ if(tVol)
+ {
+ __shairport_hairtunes_setvolume(atof(tVol));
+ }
+
+ if(iContentSize)
+ {
+ if(isJpg)
+ {
+ __shairport_hairtunes_set_metadata_coverart(buffer, iContentSize);
+ }
+ else
+ {
+ __shairport_hairtunes_set_metadata(buffer, iContentSize);
+ }
+ free(buffer);
+ }
#endif
__shairport_xprintf("Finished writing data write data to hairtunes\n");
}
View
@@ -73,6 +73,8 @@ struct AudioOutput
int (*ao_append_option)(ao_option **, const char *, const char *);
void (*ao_free_options)(ao_option *);
char* (*ao_get_option)(ao_option *, const char* );
+ void (*ao_set_metadata)(const char *buffer, unsigned int size);
+ void (*ao_set_metadata_coverart)(const char *buffer, unsigned int size);
};
int shairport_main(int argc, char **argv);

0 comments on commit 40da305

Please sign in to comment.