diff options
author | Steven Blackburn <beeka@sourceforge.net> | 2011-09-28 23:18:38 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-09-30 08:53:09 +0200 |
commit | 21851c06733080b4c131d553d5d1f8784c12410f (patch) | |
tree | 64304c3288048c5401454fbf71f94c23a165a2a8 /src | |
parent | 7e219c362cf8bca80f60a79b77d95a228ff8ffcb (diff) |
Add support for streaming to a DLNA client
The Naim Uniti does not appear to support icecast-style streaming of FLAC
music but does support the codec from a DLNA server. This change looks for
"transferMode.dlna.org: Streaming" in the HTTP request header and responds
with something the Uniti (and hopefully other DLNA clients) accepts.
The only difference in the DLNA streaming mode is the reponse header and
that icecast metadata is disabled. If a client request indicates both modes
are supported, the DLNA mode is preferred (as the Uniti says it supports
both but then rejects a FLAC ICY stream).
Note: This change may be specific to Naim equipment (the only device it was
tested on). E.g. the hardcoding of Content-Length which works but is not a
logically correct value. The change should be backwards-compatible, so
only those clients requesting a DLNA stream will see any difference.
Diffstat (limited to 'src')
-rw-r--r-- | src/output/httpd_client.c | 40 |
1 files changed, 35 insertions, 5 deletions
diff --git a/src/output/httpd_client.c b/src/output/httpd_client.c index 7a50f6fe6..8efedc2b3 100644 --- a/src/output/httpd_client.c +++ b/src/output/httpd_client.c @@ -93,6 +93,11 @@ struct httpd_client { */ size_t current_position; + /** + * If DLNA streaming was an option. + */ + bool dlna_streaming_requested; + /* ICY */ /** @@ -234,6 +239,15 @@ httpd_client_handle_line(struct httpd_client *client, const char *line) return true; } + if (g_ascii_strncasecmp(line, "transferMode.dlna.org: Streaming", 32) == 0) { + /* Send as dlna */ + client->dlna_streaming_requested = true; + /* metadata is not supported by dlna streaming, so disable it */ + client->metadata_supported = false; + client->metadata_requested = false; + return true; + } + /* expect more request headers */ return true; } @@ -285,16 +299,21 @@ httpd_client_send_response(struct httpd_client *client) assert(client != NULL); assert(client->state == RESPONSE); - if (!client->metadata_requested) { + if (client->dlna_streaming_requested) { g_snprintf(buffer, sizeof(buffer), - "HTTP/1.1 200 OK\r\n" + "HTTP/1.1 206 OK\r\n" "Content-Type: %s\r\n" + "Content-Length: 10000\r\n" + "Content-RangeX: 0-1000000/1000000\r\n" + "transferMode.dlna.org: Streaming\r\n" + "Accept-Ranges: bytes\r\n" "Connection: close\r\n" - "Pragma: no-cache\r\n" - "Cache-Control: no-cache, no-store\r\n" + "realTimeInfo.dlna.org: DLNA.ORG_TLAG=*\r\n" + "contentFeatures.dlna.org: DLNA.ORG_OP=01;DLNA.ORG_CI=0\r\n" "\r\n", client->httpd->content_type); - } else { + + } else if (client->metadata_requested) { gchar *metadata_header; metadata_header = icy_server_metadata_header( @@ -307,6 +326,16 @@ httpd_client_send_response(struct httpd_client *client) g_strlcpy(buffer, metadata_header, sizeof(buffer)); g_free(metadata_header); + + } else { /* revert to a normal HTTP request */ + g_snprintf(buffer, sizeof(buffer), + "HTTP/1.1 200 OK\r\n" + "Content-Type: %s\r\n" + "Connection: close\r\n" + "Pragma: no-cache\r\n" + "Cache-Control: no-cache, no-store\r\n" + "\r\n", + client->httpd->content_type); } status = g_io_channel_write_chars(client->channel, @@ -476,6 +505,7 @@ httpd_client_new(struct httpd_output *httpd, int fd, bool metadata_supported) client->input = fifo_buffer_new(4096); client->state = REQUEST; + client->dlna_streaming_requested = false; client->metadata_supported = metadata_supported; client->metadata_requested = false; client->metadata_sent = true; |