From: Juho Vähä-Herttua Date: Sun, 13 May 2012 13:09:09 +0000 (+0300) Subject: Pass metadata and coverart to the RTP thread X-Git-Tag: upstream/0.9.0~4^2~77 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=3baaba9d370042e04c70653d46e18bc289d83269;p=deb_shairplay.git Pass metadata and coverart to the RTP thread --- diff --git a/src/lib/raop.c b/src/lib/raop.c index d85756b..a0289b7 100644 --- a/src/lib/raop.c +++ b/src/lib/raop.c @@ -299,9 +299,11 @@ conn_request(void *ptr, http_request_t *request, http_response_t **response) } free(datastr); } else if (!strcmp(content_type, "image/jpeg")) { - logger_log(&conn->raop->logger, LOGGER_INFO, "UNHANDLED: Got image data of %d bytes", datalen); + logger_log(&conn->raop->logger, LOGGER_INFO, "Got image data of %d bytes", datalen); + raop_rtp_set_coverart(conn->raop_rtp, data, datalen); } else if (!strcmp(content_type, "application/x-dmap-tagged")) { - logger_log(&conn->raop->logger, LOGGER_INFO, "UNHANDLED: Got metadata of %d bytes", datalen); + logger_log(&conn->raop->logger, LOGGER_INFO, "Got metadata of %d bytes", datalen); + raop_rtp_set_metadata(conn->raop_rtp, data, datalen); } } else if (!strcmp(method, "FLUSH")) { const char *rtpinfo; diff --git a/src/lib/raop_rtp.c b/src/lib/raop_rtp.c index 3c7c177..1896e16 100644 --- a/src/lib/raop_rtp.c +++ b/src/lib/raop_rtp.c @@ -39,13 +39,21 @@ struct raop_rtp_s { struct sockaddr_storage remote_saddr; socklen_t remote_saddr_len; + /* MUTEX LOCKED VARIABLES START */ /* These variables only edited mutex locked */ int running; int joined; + float volume; + unsigned char *metadata; + int metadata_len; + unsigned char *coverart; + int coverart_len; + int flush; thread_handle_t thread; mutex_handle_t run_mutex; + /* MUTEX LOCKED VARIABLES END */ /* Remote control and timing ports */ unsigned short control_rport; @@ -153,6 +161,8 @@ raop_rtp_destroy(raop_rtp_t *raop_rtp) MUTEX_DESTROY(raop_rtp->run_mutex); raop_buffer_destroy(raop_rtp->buffer); + free(raop_rtp->metadata); + free(raop_rtp->coverart); free(raop_rtp); } } @@ -560,6 +570,48 @@ raop_rtp_set_volume(raop_rtp_t *raop_rtp, float volume) MUTEX_UNLOCK(raop_rtp->run_mutex); } +void +raop_rtp_set_metadata(raop_rtp_t *raop_rtp, const char *data, int datalen) +{ + unsigned char *metadata; + + assert(raop_rtp); + + if (datalen <= 0) { + return; + } + metadata = malloc(datalen); + assert(metadata); + memcpy(metadata, data, datalen); + + /* Set metadata in thread instead */ + MUTEX_LOCK(raop_rtp->run_mutex); + raop_rtp->metadata = metadata; + raop_rtp->metadata_len = datalen; + MUTEX_UNLOCK(raop_rtp->run_mutex); +} + +void +raop_rtp_set_coverart(raop_rtp_t *raop_rtp, const char *data, int datalen) +{ + unsigned char *coverart; + + assert(raop_rtp); + + if (datalen <= 0) { + return; + } + coverart = malloc(datalen); + assert(coverart); + memcpy(coverart, data, datalen); + + /* Set coverart in thread instead */ + MUTEX_LOCK(raop_rtp->run_mutex); + raop_rtp->coverart = coverart; + raop_rtp->coverart_len = datalen; + MUTEX_UNLOCK(raop_rtp->run_mutex); +} + void raop_rtp_flush(raop_rtp_t *raop_rtp, int next_seq) { diff --git a/src/lib/raop_rtp.h b/src/lib/raop_rtp.h index 1e947d6..19734fc 100644 --- a/src/lib/raop_rtp.h +++ b/src/lib/raop_rtp.h @@ -30,6 +30,8 @@ raop_rtp_t *raop_rtp_init(logger_t *logger, raop_callbacks_t *callbacks, const c void raop_rtp_start(raop_rtp_t *raop_rtp, int use_udp, unsigned short control_rport, unsigned short timing_rport, unsigned short *control_lport, unsigned short *timing_lport, unsigned short *data_lport); void raop_rtp_set_volume(raop_rtp_t *raop_rtp, float volume); +void raop_rtp_set_metadata(raop_rtp_t *raop_rtp, const char *data, int datalen); +void raop_rtp_set_coverart(raop_rtp_t *raop_rtp, const char *data, int datalen); void raop_rtp_flush(raop_rtp_t *raop_rtp, int next_seq); void raop_rtp_stop(raop_rtp_t *raop_rtp); void raop_rtp_destroy(raop_rtp_t *raop_rtp);