[xiph-cvs] cvs commit: libshout/src shout.c util.c util.h
Brendan
brendan at xiph.org
Sat Feb 22 14:32:48 PST 2003
brendan 03/02/22 17:32:48
Modified: src shout.c util.c util.h
Log:
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. :)
Revision Changes Path
1.26 +13 -4 libshout/src/shout.c
Index: shout.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/shout.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- shout.c 22 Feb 2003 22:17:52 -0000 1.25
+++ shout.c 22 Feb 2003 22:32:47 -0000 1.26
@@ -240,7 +240,7 @@
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 @@
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 @@
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) {
<p><p>1.7 +3 -4 libshout/src/util.c
Index: util.c
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/util.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- util.c 22 Feb 2003 22:17:52 -0000 1.6
+++ util.c 22 Feb 2003 22:32:47 -0000 1.7
@@ -197,10 +197,9 @@
}
/* 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 @@
return NULL;
} else
res = tmp;
- sprintf(res + strlen(res), "%c%s", sep, enc);
+ sprintf(res + strlen(res), "&%s", enc);
free(enc);
}
<p><p>1.6 +1 -1 libshout/src/util.h
Index: util.h
===================================================================
RCS file: /usr/local/cvsroot/libshout/src/util.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- util.h 22 Feb 2003 22:17:52 -0000 1.5
+++ util.h 22 Feb 2003 22:32:47 -0000 1.6
@@ -18,7 +18,7 @@
/* 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);
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list