diff --git a/src/http.c b/src/http.c index 98c289c8..f7500120 100644 --- a/src/http.c +++ b/src/http.c @@ -667,9 +667,9 @@ metadata_packet_get(struct http_icy_metadata *metadata, AVFormatContext *fmtctx) else metadata->title = strdup(metadata->title); } - else if ((strncmp(icy_token, "StreamUrl", strlen("StreamUrl")) == 0) && !metadata->artwork_url && strlen(ptr) > 0) + else if ((strncmp(icy_token, "StreamUrl", strlen("StreamUrl")) == 0) && !metadata->url && strlen(ptr) > 0) { - metadata->artwork_url = strdup(ptr); + metadata->url = strdup(ptr); } if (end) @@ -741,10 +741,7 @@ http_icy_metadata_get(AVFormatContext *fmtctx, int packet_only) int got_packet; int got_header; - metadata = malloc(sizeof(struct http_icy_metadata)); - if (!metadata) - return NULL; - memset(metadata, 0, sizeof(struct http_icy_metadata)); + CHECK_NULL(L_HTTP, metadata = calloc(1, sizeof(struct http_icy_metadata))); got_packet = (metadata_packet_get(metadata, fmtctx) == 0); got_header = (!packet_only) && (metadata_header_get(metadata, fmtctx) == 0); @@ -761,7 +758,7 @@ http_icy_metadata_get(AVFormatContext *fmtctx, int packet_only) metadata->genre, metadata->title, metadata->artist, - metadata->artwork_url, + metadata->url, metadata->hash ); */ @@ -816,10 +813,7 @@ http_icy_metadata_get(AVFormatContext *fmtctx, int packet_only) return NULL; } - metadata = malloc(sizeof(struct http_icy_metadata)); - if (!metadata) - return NULL; - memset(metadata, 0, sizeof(struct http_icy_metadata)); + CHECK_NULL(L_HTTP, metadata = calloc(1, sizeof(struct http_icy_metadata))); got_header = 0; if ( (value = keyval_get(ctx.input_headers, "icy-name")) ) @@ -853,7 +847,7 @@ http_icy_metadata_get(AVFormatContext *fmtctx, int packet_only) metadata->genre, metadata->title, metadata->artist, - metadata->artwork_url, + metadata->url, metadata->hash );*/ @@ -864,24 +858,14 @@ http_icy_metadata_get(AVFormatContext *fmtctx, int packet_only) void http_icy_metadata_free(struct http_icy_metadata *metadata, int content_only) { - if (metadata->name) - free(metadata->name); + if (!metadata) + return; - if (metadata->description) - free(metadata->description); - - if (metadata->genre) - free(metadata->genre); - - if (metadata->title) - free(metadata->title); - - if (metadata->artist) - free(metadata->artist); - - if (metadata->artwork_url) - free(metadata->artwork_url); - - if (!content_only) - free(metadata); + free(metadata->name); + free(metadata->description); + free(metadata->genre); + free(metadata->title); + free(metadata->artist); + free(metadata->url); + free(metadata); } diff --git a/src/http.h b/src/http.h index faa7ed9a..6cf52a08 100644 --- a/src/http.h +++ b/src/http.h @@ -49,7 +49,7 @@ struct http_icy_metadata /* Track specific, comes from icy_metadata_packet */ char *title; char *artist; - char *artwork_url; + char *url; uint32_t hash; }; diff --git a/src/inputs/file_http.c b/src/inputs/file_http.c index 5206fee3..6d0f9b51 100644 --- a/src/inputs/file_http.c +++ b/src/inputs/file_http.c @@ -147,7 +147,7 @@ metadata_get_http(struct input_metadata *metadata, struct input_source *source) swap_pointers(&metadata->artist, &m->artist); // Note we map title to album, because clients should show stream name as titel swap_pointers(&metadata->album, &m->title); - swap_pointers(&metadata->artwork_url, &m->artwork_url); + swap_pointers(&metadata->artwork_url, &m->url); http_icy_metadata_free(m, 0); return 0;