Skip to content

Commit

Permalink
Allow to specify/override stream genre, url, description, title, user…
Browse files Browse the repository at this point in the history
…-agent for relay
  • Loading branch information
root committed Jun 7, 2012
1 parent 5023262 commit 76dc45d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
11 changes: 11 additions & 0 deletions src/cfgfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ relay_server *config_clear_relay (relay_server *relay)
if (master->mount) xmlFree (master->mount);
free (master);
}
if (relay->stream_name) xmlFree (relay->stream_name);
if (relay->stream_description) xmlFree (relay->stream_description);
if (relay->stream_url) xmlFree (relay->stream_url);
if (relay->stream_genre) xmlFree (relay->stream_genre);
if (relay->user_agent) xmlFree (relay->user_agent);
if (relay->localmount) xmlFree (relay->localmount);
if (relay->username) xmlFree (relay->username);
if (relay->password) xmlFree (relay->password);
Expand Down Expand Up @@ -1050,6 +1055,12 @@ static int _parse_relay (xmlNodePtr node, void *arg)
{ "username", config_get_str, &relay->username },
{ "password", config_get_str, &relay->password },
{ "enable", config_get_bool, &relay->running },
{ "stream-name", config_get_str, &relay->stream_name },
{ "stream-description", config_get_str, &relay->stream_description },
{ "stream-url", config_get_str, &relay->stream_url },
{ "genre", config_get_str, &relay->stream_genre },
{ "user-agent", config_get_str, &relay->user_agent },

{ NULL, NULL, NULL },
};

Expand Down
5 changes: 5 additions & 0 deletions src/cfgfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,11 @@ typedef struct _relay_server
int on_demand;
int running;
int cleanup;
char *stream_name;
char *stream_description;
char *stream_url;
char *stream_genre;
char *user_agent;
} relay_server;


Expand Down
24 changes: 21 additions & 3 deletions src/slave.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ relay_server *relay_copy (relay_server *r)
copy->username = (char *)xmlStrdup (XMLSTR(r->username));
if (r->password)
copy->password = (char *)xmlStrdup (XMLSTR(r->password));
if (r->user_agent)
copy->user_agent = (char *)xmlStrdup (XMLSTR(r->user_agent));
if (r->stream_name)
copy->stream_name = (char *)xmlStrdup (XMLSTR(r->stream_name));
if (r->stream_description)
copy->stream_description = (char *)xmlStrdup (XMLSTR(r->stream_description));
if (r->stream_url)
copy->stream_url = (char *)xmlStrdup (XMLSTR(r->stream_url));
if (r->stream_genre)
copy->stream_genre = (char *)xmlStrdup (XMLSTR(r->stream_genre));
copy->mp3metadata = r->mp3metadata;
copy->on_demand = r->on_demand;
copy->interval = r->interval;
Expand Down Expand Up @@ -276,10 +286,10 @@ int redirect_client (const char *mountpoint, client_t *client)


static http_parser_t *get_relay_response (connection_t *con, const char *mount,
const char *server, int ask_for_metadata, const char *auth_header)
const char *server, int ask_for_metadata, const char *auth_header, relay_server *relay)
{
ice_config_t *config = config_get_config ();
char *server_id = strdup (config->server_id);
char *server_id = strdup (relay->user_agent ? relay->user_agent : config->server_id);
http_parser_t *parser = NULL;
char response [4096];

Expand Down Expand Up @@ -375,7 +385,7 @@ static int open_relay_connection (client_t *client, relay_server *relay, relay_s
break;
}

parser = get_relay_response (con, mount, server, ask_for_metadata, auth_header);
parser = get_relay_response (con, mount, server, ask_for_metadata, auth_header, relay);

if (parser == NULL)
{
Expand Down Expand Up @@ -421,6 +431,14 @@ static int open_relay_connection (client_t *client, relay_server *relay, relay_s
client->parser = NULL;
break;
}
if (relay->stream_description) // override even if exists
httpp_setvar (parser, "icy-description", relay->stream_description);
if (relay->stream_name)
httpp_setvar (parser, "icy-name", relay->stream_name);
if (relay->stream_url)
httpp_setvar (parser, "icy-url", relay->stream_url);
if (relay->stream_genre)
httpp_setvar (parser, "icy-genre", relay->stream_genre);
sock_set_blocking (streamsock, 0);
thread_mutex_lock (&relay->source->lock);
client->parser = parser; // old parser will be free in the format clear
Expand Down

0 comments on commit 76dc45d

Please sign in to comment.