diff options
Diffstat (limited to 'lib/libshout-idjc/src/proto_xaudiocast.c')
-rw-r--r-- | lib/libshout-idjc/src/proto_xaudiocast.c | 96 |
1 files changed, 51 insertions, 45 deletions
diff --git a/lib/libshout-idjc/src/proto_xaudiocast.c b/lib/libshout-idjc/src/proto_xaudiocast.c index aef8297b49..3440790a6b 100644 --- a/lib/libshout-idjc/src/proto_xaudiocast.c +++ b/lib/libshout-idjc/src/proto_xaudiocast.c @@ -22,68 +22,74 @@ */ #ifdef HAVE_CONFIG_H - #include <config.h> +# include <config.h> #endif #include <stdlib.h> #include <string.h> -#include <shout/shout.h> +#include <shoutidjc/shout.h> #include "shout_private.h" int shout_create_xaudiocast_request(shout_t *self) { - const char *bitrate; - const char *val; - int ret; + const char *bitrate; + const char *val; + char *mount = NULL; + int ret; - bitrate = shout_get_audio_info(self, SHOUT_AI_BITRATE); - if (!bitrate) - bitrate = "0"; + bitrate = shout_get_audio_info(self, SHOUT_AI_BITRATE); + if (!bitrate) + bitrate = "0"; - ret = SHOUTERR_MALLOC; - do { - if (shout_queue_printf(self, "SOURCE %s %s\n", self->password, self->mount)) - break; - if (shout_queue_printf(self, "x-audiocast-name: %s\n", shout_get_meta(self, "name"))) - break; - val = shout_get_meta(self, "url"); - if (shout_queue_printf(self, "x-audiocast-url: %s\n", val ? val : "http://www.icecast.org/")) - break; - val = shout_get_meta(self, "genre"); - if (shout_queue_printf(self, "x-audiocast-genre: %s\n", val ? val : "icecast")) - break; - if (shout_queue_printf(self, "x-audiocast-bitrate: %s\n", bitrate)) - break; - if (shout_queue_printf(self, "x-audiocast-public: %i\n", self->public)) - break; - val = shout_get_meta(self, "description"); - if (shout_queue_printf(self, "x-audiocast-description: %s\n", val ? val : "Broadcasting with the icecast streaming media server!")) - break; - if (self->dumpfile && shout_queue_printf(self, "x-audiocast-dumpfile: %s\n", self->dumpfile)) - break; - if (shout_queue_str(self, "\n")) - break; + ret = SHOUTERR_MALLOC; + do { + if (!(mount = _shout_util_url_encode_resource(self->mount))) + break; + if (shout_queue_printf(self, "SOURCE %s %s\n", self->password, mount)) + break; + if (shout_queue_printf(self, "x-audiocast-name: %s\n", shout_get_meta(self, "name"))) + break; + val = shout_get_meta(self, "url"); + if (shout_queue_printf(self, "x-audiocast-url: %s\n", val ? val : "http://www.icecast.org/")) + break; + val = shout_get_meta(self, "genre"); + if (shout_queue_printf(self, "x-audiocast-genre: %s\n", val ? val : "icecast")) + break; + if (shout_queue_printf(self, "x-audiocast-bitrate: %s\n", bitrate)) + break; + if (shout_queue_printf(self, "x-audiocast-public: %i\n", self->public)) + break; + val = shout_get_meta(self, "description"); + if (shout_queue_printf(self, "x-audiocast-description: %s\n", val ? val : "Broadcasting with the icecast streaming media server!")) + break; + if (self->dumpfile && shout_queue_printf(self, "x-audiocast-dumpfile: %s\n", self->dumpfile)) + break; + if (shout_queue_str(self, "\n")) + break; - ret = SHOUTERR_SUCCESS; - } while (0); - - return ret; + ret = SHOUTERR_SUCCESS; + } while (0); + + if (mount) + free(mount); + + return ret; } int shout_parse_xaudiocast_response(shout_t *self) { - char *response; + char *response; - if (shout_queue_collect(self->rqueue.head, &response) <= 0) - return SHOUTERR_MALLOC; - shout_queue_free(&self->rqueue); + if (shout_queue_collect(self->rqueue.head, &response) <= 0) + return SHOUTERR_MALLOC; + shout_queue_free(&self->rqueue); - if (!strstr(response, "OK")) { - free(response); - return SHOUTERR_NOLOGIN; - } - free(response); + if (!strstr(response, "OK")) { + free(response); + return SHOUTERR_NOLOGIN; + } + free(response); - return SHOUTERR_SUCCESS; + return SHOUTERR_SUCCESS; } |