Commit e5ca11ca authored by brendan's avatar brendan

Send ice-audio-info header in HTTP protocol, instead of ice-bitrate.

This header is encoded like the query part of a GET request, eg
ice-audio-info: bitrate=128&samplerate=44100&channels=2

Oddsock, knock yourself out. :)

svn path=/trunk/libshout/; revision=4361
parent ccdb215d
......@@ -240,7 +240,7 @@ int shout_set_metadata(shout_t *self, shout_metadata_t *metadata)
if (!self || !metadata)
return SHOUTERR_INSANE;
if (!(encvalue = util_dict_urlencode(metadata, '&')))
if (!(encvalue = util_dict_urlencode(metadata)))
return SHOUTERR_MALLOC;
if (!self->connected)
......@@ -683,9 +683,7 @@ unsigned int shout_get_protocol(shout_t *self)
static int send_http_request(shout_t *self, char *username, char *password)
{
char *auth;
const char *bitrate;
bitrate = shout_get_audio_info(self, SHOUT_AI_BITRATE);
const char *ai;
if (!sock_write(self->socket, "SOURCE %s HTTP/1.0\r\n", self->mount))
return SHOUTERR_SOCKET;
......@@ -708,8 +706,19 @@ static int send_http_request(shout_t *self, char *username, char *password)
if (!sock_write(self->socket, "ice-genre: %s\r\n", self->genre))
return SHOUTERR_SOCKET;
}
#if 0
ai = shout_get_audio_info(self, SHOUT_AI_BITRATE);
if (bitrate && !sock_write(self->socket, "ice-bitrate: %s\r\n", bitrate))
return SHOUTERR_SOCKET;
#else
if (ai = util_dict_urlencode(self->audio_info)) {
if (!sock_write(self->socket, "ice-audio-info: %s\r\n", ai)) {
free(ai);
return SHOUTERR_SOCKET;
}
}
#endif
if (!sock_write(self->socket, "ice-public: %d\r\n", self->public))
return SHOUTERR_SOCKET;
if (self->description) {
......
......@@ -197,10 +197,9 @@ int util_dict_set(util_dict *dict, const char *key, const char *val)
}
/* given a dictionary, URL-encode each key and val and stringify them in order as
key=val;key=val... if val is set, or just key;key if val is NULL.
sep is the separator character (';' in the example above)
key=val&key=val... if val is set, or just key&key if val is NULL.
TODO: Memory management needs overhaul. */
char *util_dict_urlencode(util_dict *dict, char sep)
char *util_dict_urlencode(util_dict *dict)
{
char *res, *tmp;
char *enc;
......@@ -230,7 +229,7 @@ char *util_dict_urlencode(util_dict *dict, char sep)
return NULL;
} else
res = tmp;
sprintf(res + strlen(res), "%c%s", sep, enc);
sprintf(res + strlen(res), "&%s", enc);
free(enc);
}
......
......@@ -18,7 +18,7 @@ void util_dict_free(util_dict *dict);
/* dict, key must not be NULL. */
int util_dict_set(util_dict *dict, const char *key, const char *val);
const char *util_dict_get(util_dict *dict, const char *key);
char *util_dict_urlencode(util_dict *dict, char sep);
char *util_dict_urlencode(util_dict *dict);
char *util_base64_encode(char *data);
char *util_url_encode(const char *data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment