1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-06-02 06:01:10 +00:00

Fix: Converted source->format->contenttype into a igloo string pool string

This commit is contained in:
Philipp Schafft 2023-03-17 15:18:41 +00:00
parent d0ebed5470
commit 2952a29c1e
5 changed files with 38 additions and 8 deletions

View File

@ -26,6 +26,10 @@
#include <stdlib.h>
#include <string.h>
#include <igloo/sp.h>
#include <igloo/error.h>
#include "global.h"
#include "refbuf.h"
#include "source.h"
#include "client.h"
@ -211,7 +215,9 @@ int format_ebml_get_plugin(source_t *source)
plugin->set_tag = NULL;
plugin->apply_settings = NULL;
plugin->contenttype = httpp_getvar(source->parser, "content-type");
if (igloo_sp_replace(httpp_getvar(source->parser, "content-type"), &(plugin->contenttype), igloo_instance) != igloo_ERROR_NONE) {
ICECAST_LOG_ERROR("Cannot set content type for EBML source %#H. BAD.", source->mount);
}
plugin->_state = ebml_source_state;
vorbis_comment_init(&plugin->vc);

View File

@ -30,6 +30,9 @@
# include <strings.h>
#endif
#include <igloo/sp.h>
#include <igloo/error.h>
#include "global.h"
#include "refbuf.h"
#include "event.h"
@ -78,6 +81,7 @@ int format_mp3_get_plugin(source_t *source)
format_plugin_t *plugin;
mp3_state *state = calloc(1, sizeof(mp3_state));
refbuf_t *meta;
const char *contenttype;
plugin = (format_plugin_t *) calloc(1, sizeof(format_plugin_t));
@ -90,10 +94,14 @@ int format_mp3_get_plugin(source_t *source)
plugin->set_tag = mp3_set_tag;
plugin->apply_settings = format_mp3_apply_settings;
plugin->contenttype = httpp_getvar(source->parser, "content-type");
if (plugin->contenttype == NULL) {
contenttype = httpp_getvar(source->parser, "content-type");
if (contenttype == NULL) {
/* We default to MP3 audio for old clients without content types */
plugin->contenttype = "audio/mpeg";
contenttype = "audio/mpeg";
}
if (igloo_sp_replace(contenttype, &(plugin->contenttype), igloo_instance) != igloo_ERROR_NONE) {
ICECAST_LOG_ERROR("Cannot set content type for legacy source %#H. BAD.", source->mount);
}
plugin->_state = state;

View File

@ -27,6 +27,10 @@
#include <ogg/ogg.h>
#include <igloo/sp.h>
#include <igloo/error.h>
#include "global.h"
#include "refbuf.h"
#include "source.h"
#include "client.h"
@ -178,7 +182,10 @@ int format_ogg_get_plugin(source_t *source)
plugin->set_tag = NULL;
if (strcmp (httpp_getvar (source->parser, "content-type"), "application/x-ogg") == 0)
httpp_setvar (source->parser, "content-type", "application/ogg");
plugin->contenttype = httpp_getvar (source->parser, "content-type");
if (igloo_sp_replace(httpp_getvar(source->parser, "content-type"), &(plugin->contenttype), igloo_instance) != igloo_ERROR_NONE) {
ICECAST_LOG_ERROR("Cannot set content type for Ogg source %#H. BAD.", source->mount);
}
ogg_sync_init (&state->oy);
vorbis_comment_init(&plugin->vc);

View File

@ -15,6 +15,10 @@
#include <stdlib.h>
#include <stdbool.h>
#include <igloo/sp.h>
#include <igloo/error.h>
#include "global.h"
#include "source.h"
#include "format.h"
#include "format_text.h"
@ -105,7 +109,9 @@ int format_text_get_plugin(source_t *source)
plugin->set_tag = NULL;
plugin->apply_settings = NULL;
plugin->contenttype = httpp_getvar(source->parser, "content-type");
if (igloo_sp_replace(httpp_getvar(source->parser, "content-type"), &(plugin->contenttype), igloo_instance) != igloo_ERROR_NONE) {
ICECAST_LOG_ERROR("Cannot set content type for text source %#H. BAD.", source->mount);
}
skip = httpp_getvar(source->parser, "x-icecast-text-skip-char");
if (skip) {

View File

@ -237,8 +237,11 @@ void source_clear_source (source_t *source)
source->parser = NULL;
source->con = NULL;
if (source->format)
source->format->contenttype = NULL;
if (source->format) {
if (igloo_sp_unref(&(source->format->contenttype), igloo_instance) != igloo_ERROR_NONE) {
ICECAST_LOG_ERROR("Cannot unref content type for source %#H", source->mount);
}
}
/* log bytes read in access log */
if (source->client && source->format)