2004-01-28 20:02:12 -05:00
|
|
|
/* Icecast
|
|
|
|
*
|
|
|
|
* This program is distributed under the GNU General Public License, version 2.
|
|
|
|
* A copy of this license is included with this source.
|
|
|
|
*
|
|
|
|
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
|
|
|
|
* Michael Smith <msmith@xiph.org>,
|
|
|
|
* oddsock <oddsock@xiph.org>,
|
|
|
|
* Karl Heyes <karl@xiph.org>
|
|
|
|
* and others (see AUTHORS for details).
|
|
|
|
*/
|
|
|
|
|
2003-07-06 11:27:50 -04:00
|
|
|
/* -*- c-basic-offset: 4; -*- */
|
2002-07-23 11:15:11 -04:00
|
|
|
/* format_mp3.c
|
|
|
|
**
|
2002-12-30 02:55:56 -05:00
|
|
|
** format plugin for mp3
|
2002-07-23 11:15:11 -04:00
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2003-07-20 21:58:54 -04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
2002-07-23 11:15:11 -04:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2003-07-22 20:27:10 -04:00
|
|
|
#ifdef HAVE_STRINGS_H
|
|
|
|
# include <strings.h>
|
|
|
|
#endif
|
2002-07-23 11:15:11 -04:00
|
|
|
|
|
|
|
#include "refbuf.h"
|
2002-12-30 02:55:56 -05:00
|
|
|
#include "source.h"
|
|
|
|
#include "client.h"
|
2002-07-23 11:15:11 -04:00
|
|
|
|
|
|
|
#include "stats.h"
|
|
|
|
#include "format.h"
|
2002-12-30 02:55:56 -05:00
|
|
|
#include "httpp/httpp.h"
|
|
|
|
|
|
|
|
#include "logging.h"
|
|
|
|
|
|
|
|
#include "format_mp3.h"
|
|
|
|
|
2003-07-07 18:02:39 -04:00
|
|
|
#ifdef WIN32
|
|
|
|
#define strcasecmp stricmp
|
|
|
|
#define strncasecmp strnicmp
|
2003-11-17 17:38:58 -05:00
|
|
|
#define snprintf _snprintf
|
2003-07-07 18:02:39 -04:00
|
|
|
#endif
|
|
|
|
|
2002-12-30 02:55:56 -05:00
|
|
|
#define CATMODULE "format-mp3"
|
|
|
|
|
2003-02-17 07:05:45 -05:00
|
|
|
/* Note that this seems to be 8192 in shoutcast - perhaps we want to be the
|
|
|
|
* same for compability with crappy clients?
|
|
|
|
*/
|
2002-12-30 02:55:56 -05:00
|
|
|
#define ICY_METADATA_INTERVAL 16000
|
2002-07-23 11:15:11 -04:00
|
|
|
|
2002-12-29 03:10:10 -05:00
|
|
|
static void format_mp3_free_plugin(format_plugin_t *self);
|
|
|
|
static int format_mp3_get_buffer(format_plugin_t *self, char *data,
|
|
|
|
unsigned long len, refbuf_t **buffer);
|
|
|
|
static refbuf_queue_t *format_mp3_get_predata(format_plugin_t *self);
|
2002-12-30 02:55:56 -05:00
|
|
|
static void *format_mp3_create_client_data(format_plugin_t *self,
|
|
|
|
source_t *source, client_t *client);
|
|
|
|
static int format_mp3_write_buf_to_client(format_plugin_t *self,
|
|
|
|
client_t *client, unsigned char *buf, int len);
|
|
|
|
static void format_mp3_send_headers(format_plugin_t *self,
|
|
|
|
source_t *source, client_t *client);
|
|
|
|
|
|
|
|
typedef struct {
|
2002-12-30 06:22:59 -05:00
|
|
|
int use_metadata;
|
2002-12-30 02:55:56 -05:00
|
|
|
int interval;
|
|
|
|
int offset;
|
2002-12-30 06:22:59 -05:00
|
|
|
int metadata_age;
|
|
|
|
int metadata_offset;
|
2002-12-30 02:55:56 -05:00
|
|
|
} mp3_client_data;
|
2002-12-31 15:15:03 -05:00
|
|
|
|
2003-02-17 07:05:45 -05:00
|
|
|
format_plugin_t *format_mp3_get_plugin(http_parser_t *parser)
|
2002-07-23 11:15:11 -04:00
|
|
|
{
|
2003-02-17 07:05:45 -05:00
|
|
|
char *metadata;
|
2003-03-14 21:10:19 -05:00
|
|
|
format_plugin_t *plugin;
|
2002-12-30 06:22:59 -05:00
|
|
|
mp3_state *state = calloc(1, sizeof(mp3_state));
|
2002-07-23 11:15:11 -04:00
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
plugin = (format_plugin_t *)malloc(sizeof(format_plugin_t));
|
2002-07-23 11:15:11 -04:00
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
plugin->type = FORMAT_TYPE_MP3;
|
|
|
|
plugin->has_predata = 0;
|
|
|
|
plugin->get_buffer = format_mp3_get_buffer;
|
|
|
|
plugin->get_predata = format_mp3_get_predata;
|
2002-12-30 02:55:56 -05:00
|
|
|
plugin->write_buf_to_client = format_mp3_write_buf_to_client;
|
2002-12-29 03:10:10 -05:00
|
|
|
plugin->create_client_data = format_mp3_create_client_data;
|
2002-12-30 02:55:56 -05:00
|
|
|
plugin->client_send_headers = format_mp3_send_headers;
|
2003-03-14 21:10:19 -05:00
|
|
|
plugin->free_plugin = format_mp3_free_plugin;
|
2002-08-10 04:01:56 -04:00
|
|
|
plugin->format_description = "MP3 audio";
|
2002-07-23 11:15:11 -04:00
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
plugin->_state = state;
|
2002-12-30 06:22:59 -05:00
|
|
|
|
2002-12-30 06:27:21 -05:00
|
|
|
state->metadata_age = 0;
|
|
|
|
state->metadata = strdup("");
|
2002-12-30 06:22:59 -05:00
|
|
|
thread_mutex_create(&(state->lock));
|
2002-07-23 11:15:11 -04:00
|
|
|
|
2003-02-17 07:05:45 -05:00
|
|
|
metadata = httpp_getvar(parser, "icy-metaint");
|
|
|
|
if(metadata)
|
|
|
|
state->inline_metadata_interval = atoi(metadata);
|
|
|
|
|
2003-03-14 21:10:19 -05:00
|
|
|
return plugin;
|
2002-07-23 11:15:11 -04:00
|
|
|
}
|
|
|
|
|
2002-12-30 06:22:59 -05:00
|
|
|
static int send_metadata(client_t *client, mp3_client_data *client_state,
|
|
|
|
mp3_state *source_state)
|
|
|
|
{
|
|
|
|
int len_byte;
|
|
|
|
int len;
|
2003-11-11 13:21:49 -05:00
|
|
|
int ret = -1;
|
2002-12-30 06:22:59 -05:00
|
|
|
unsigned char *buf;
|
|
|
|
int source_age;
|
2003-11-11 13:21:49 -05:00
|
|
|
char *fullmetadata = NULL;
|
|
|
|
int fullmetadata_size = 0;
|
|
|
|
const char meta_fmt[] = "StreamTitle='';";
|
2002-12-30 06:22:59 -05:00
|
|
|
|
2003-11-11 13:21:49 -05:00
|
|
|
do
|
|
|
|
{
|
|
|
|
thread_mutex_lock (&(source_state->lock));
|
|
|
|
if (source_state->metadata == NULL)
|
|
|
|
break; /* Shouldn't be possible */
|
|
|
|
|
2004-02-09 22:50:39 -05:00
|
|
|
fullmetadata_size = strlen (source_state->metadata) + sizeof (meta_fmt);
|
|
|
|
|
|
|
|
if (fullmetadata_size > 4080)
|
2003-11-11 13:21:49 -05:00
|
|
|
{
|
2004-02-09 22:50:39 -05:00
|
|
|
fullmetadata_size = 4080;
|
2003-11-11 13:21:49 -05:00
|
|
|
}
|
2004-02-09 22:50:39 -05:00
|
|
|
fullmetadata = malloc (fullmetadata_size);
|
|
|
|
if (fullmetadata == NULL)
|
|
|
|
break;
|
2002-12-31 14:48:28 -05:00
|
|
|
|
2004-02-09 22:50:39 -05:00
|
|
|
fullmetadata_size = snprintf (fullmetadata, fullmetadata_size,
|
|
|
|
"StreamTitle='%.*s';", fullmetadata_size-(sizeof (meta_fmt)-1), source_state->metadata);
|
2002-12-31 14:48:28 -05:00
|
|
|
|
2003-11-11 13:21:49 -05:00
|
|
|
source_age = source_state->metadata_age;
|
2002-12-31 14:48:28 -05:00
|
|
|
|
2003-11-11 13:21:49 -05:00
|
|
|
if (fullmetadata_size > 0 && source_age != client_state->metadata_age)
|
|
|
|
{
|
|
|
|
len_byte = (fullmetadata_size-1)/16 + 1; /* to give 1-255 */
|
|
|
|
client_state->metadata_offset = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
len_byte = 0;
|
|
|
|
len = 1 + len_byte*16;
|
|
|
|
buf = malloc (len);
|
|
|
|
if (buf == NULL)
|
|
|
|
break;
|
|
|
|
|
|
|
|
buf[0] = len_byte;
|
|
|
|
|
|
|
|
if (len > 1) {
|
|
|
|
strncpy (buf+1, fullmetadata, len-1);
|
|
|
|
buf[len-1] = '\0';
|
|
|
|
}
|
2002-12-30 06:27:21 -05:00
|
|
|
|
2003-11-11 13:21:49 -05:00
|
|
|
thread_mutex_unlock (&(source_state->lock));
|
2002-12-30 06:22:59 -05:00
|
|
|
|
2003-11-11 13:21:49 -05:00
|
|
|
/* only write what hasn't been written already */
|
|
|
|
ret = sock_write_bytes (client->con->sock, buf+client_state->metadata_offset, len-client_state->metadata_offset);
|
2002-12-30 06:22:59 -05:00
|
|
|
|
2003-11-11 13:21:49 -05:00
|
|
|
if (ret > 0 && ret < len) {
|
|
|
|
client_state->metadata_offset += ret;
|
|
|
|
}
|
|
|
|
else if (ret == len) {
|
|
|
|
client_state->metadata_age = source_age;
|
|
|
|
client_state->offset = 0;
|
|
|
|
client_state->metadata_offset = 0;
|
|
|
|
}
|
|
|
|
free (buf);
|
2004-02-09 22:50:39 -05:00
|
|
|
free (fullmetadata);
|
2003-11-11 13:21:49 -05:00
|
|
|
return ret;
|
2002-12-30 06:22:59 -05:00
|
|
|
|
2003-11-11 13:21:49 -05:00
|
|
|
} while (0);
|
2002-12-30 06:22:59 -05:00
|
|
|
|
|
|
|
thread_mutex_unlock(&(source_state->lock));
|
2004-02-09 22:50:39 -05:00
|
|
|
free (fullmetadata);
|
2003-11-11 13:21:49 -05:00
|
|
|
return -1;
|
2002-12-30 06:22:59 -05:00
|
|
|
}
|
|
|
|
|
2002-12-30 02:55:56 -05:00
|
|
|
static int format_mp3_write_buf_to_client(format_plugin_t *self,
|
|
|
|
client_t *client, unsigned char *buf, int len)
|
|
|
|
{
|
|
|
|
int ret;
|
2003-11-11 13:21:49 -05:00
|
|
|
mp3_client_data *mp3data = client->format_data;
|
2002-12-30 06:22:59 -05:00
|
|
|
|
2003-11-11 13:21:49 -05:00
|
|
|
if(((mp3_state *)self->_state)->metadata && mp3data->use_metadata)
|
2002-12-30 06:22:59 -05:00
|
|
|
{
|
|
|
|
mp3_client_data *state = client->format_data;
|
|
|
|
int max = state->interval - state->offset;
|
2002-12-30 02:55:56 -05:00
|
|
|
|
2002-12-30 06:22:59 -05:00
|
|
|
if(len == 0) /* Shouldn't happen */
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if(max > len)
|
|
|
|
max = len;
|
|
|
|
|
|
|
|
if(max > 0) {
|
|
|
|
ret = sock_write_bytes(client->con->sock, buf, max);
|
|
|
|
if(ret > 0)
|
|
|
|
state->offset += ret;
|
|
|
|
}
|
2002-12-31 14:48:28 -05:00
|
|
|
else {
|
2002-12-30 06:22:59 -05:00
|
|
|
ret = send_metadata(client, state, self->_state);
|
2003-01-01 02:31:46 -05:00
|
|
|
if(ret > 0)
|
|
|
|
client->con->sent_bytes += ret;
|
|
|
|
ret = 0;
|
|
|
|
}
|
2002-12-31 14:48:28 -05:00
|
|
|
|
2002-12-30 06:22:59 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
ret = sock_write_bytes(client->con->sock, buf, len);
|
|
|
|
}
|
2002-12-30 02:55:56 -05:00
|
|
|
|
|
|
|
if(ret < 0) {
|
2003-01-18 07:30:29 -05:00
|
|
|
if(sock_recoverable(sock_error())) {
|
2002-12-30 02:55:56 -05:00
|
|
|
DEBUG1("Client had recoverable error %ld", ret);
|
|
|
|
ret = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
client->con->sent_bytes += ret;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void format_mp3_free_plugin(format_plugin_t *self)
|
2002-07-23 11:15:11 -04:00
|
|
|
{
|
2003-03-14 21:10:19 -05:00
|
|
|
/* free the plugin instance */
|
2002-12-30 06:22:59 -05:00
|
|
|
mp3_state *state = self->_state;
|
|
|
|
thread_mutex_destroy(&(state->lock));
|
2002-12-30 06:27:21 -05:00
|
|
|
|
|
|
|
free(state->metadata);
|
2002-12-30 06:22:59 -05:00
|
|
|
free(state);
|
2003-03-14 21:10:19 -05:00
|
|
|
free(self);
|
2002-07-23 11:15:11 -04:00
|
|
|
}
|
|
|
|
|
2002-12-30 02:55:56 -05:00
|
|
|
static int format_mp3_get_buffer(format_plugin_t *self, char *data,
|
|
|
|
unsigned long len, refbuf_t **buffer)
|
2002-07-23 11:15:11 -04:00
|
|
|
{
|
2003-03-14 21:10:19 -05:00
|
|
|
refbuf_t *refbuf;
|
2003-02-17 07:05:45 -05:00
|
|
|
mp3_state *state = self->_state;
|
|
|
|
|
2003-02-24 08:37:15 -05:00
|
|
|
/* Set this to NULL in case it doesn't get set to a valid buffer later */
|
|
|
|
*buffer = NULL;
|
|
|
|
|
|
|
|
if(!data)
|
2002-07-23 11:15:11 -04:00
|
|
|
return 0;
|
2003-02-25 04:40:34 -05:00
|
|
|
|
2003-02-17 07:05:45 -05:00
|
|
|
if(state->inline_metadata_interval) {
|
2003-02-24 08:37:15 -05:00
|
|
|
/* Source is sending metadata, handle it... */
|
|
|
|
|
|
|
|
while(len > 0) {
|
|
|
|
int to_read = state->inline_metadata_interval - state->offset;
|
|
|
|
if(to_read > 0) {
|
|
|
|
refbuf_t *old_refbuf = *buffer;
|
|
|
|
|
|
|
|
if(to_read > len)
|
|
|
|
to_read = len;
|
|
|
|
|
|
|
|
if(old_refbuf) {
|
|
|
|
refbuf = refbuf_new(to_read + old_refbuf->len);
|
|
|
|
memcpy(refbuf->data, old_refbuf->data, old_refbuf->len);
|
|
|
|
memcpy(refbuf->data+old_refbuf->len, data, to_read);
|
|
|
|
|
|
|
|
refbuf_release(old_refbuf);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
refbuf = refbuf_new(to_read);
|
|
|
|
memcpy(refbuf->data, data, to_read);
|
|
|
|
}
|
|
|
|
|
|
|
|
*buffer = refbuf;
|
|
|
|
|
|
|
|
state->offset += to_read;
|
|
|
|
data += to_read;
|
|
|
|
len -= to_read;
|
|
|
|
}
|
|
|
|
else if(!state->metadata_length) {
|
|
|
|
/* Next up is the metadata byte... */
|
|
|
|
unsigned char byte = data[0];
|
|
|
|
data++;
|
|
|
|
len--;
|
|
|
|
|
|
|
|
/* According to the "spec"... this byte * 16 */
|
|
|
|
state->metadata_length = byte * 16;
|
2003-02-25 04:40:34 -05:00
|
|
|
|
2003-02-24 08:37:15 -05:00
|
|
|
if(state->metadata_length) {
|
|
|
|
state->metadata_buffer =
|
|
|
|
calloc(state->metadata_length + 1, 1);
|
|
|
|
|
|
|
|
/* Ensure we have a null-terminator even if the source
|
|
|
|
* stream is invalid.
|
|
|
|
*/
|
|
|
|
state->metadata_buffer[state->metadata_length] = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
state->offset = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
state->metadata_offset = 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Metadata to read! */
|
|
|
|
int readable = state->metadata_length - state->metadata_offset;
|
|
|
|
|
|
|
|
if(readable > len)
|
|
|
|
readable = len;
|
|
|
|
|
|
|
|
memcpy(state->metadata_buffer + state->metadata_offset,
|
|
|
|
data, readable);
|
|
|
|
|
2003-02-25 04:40:34 -05:00
|
|
|
state->metadata_offset += readable;
|
|
|
|
|
2003-02-24 08:37:15 -05:00
|
|
|
data += readable;
|
|
|
|
len -= readable;
|
|
|
|
|
|
|
|
if(state->metadata_offset == state->metadata_length)
|
|
|
|
{
|
|
|
|
if(state->metadata_length)
|
|
|
|
{
|
|
|
|
thread_mutex_lock(&(state->lock));
|
|
|
|
free(state->metadata);
|
2004-02-09 22:50:39 -05:00
|
|
|
/* Now, reformat state->metadata_buffer to strip off
|
|
|
|
StreamTitle=' and the closing '; (but only if there's
|
|
|
|
enough data for it to be correctly formatted) */
|
|
|
|
if(state->metadata_length >= 15) {
|
2004-02-09 23:29:54 -05:00
|
|
|
/* This is overly complex because the
|
|
|
|
metadata_length is the length of the actual raw
|
|
|
|
data, but the (null-terminated) string is going
|
|
|
|
to be shorter than this, and we can't trust that
|
|
|
|
the raw data doesn't have other embedded-nulls */
|
|
|
|
int stringlength;
|
|
|
|
|
2004-02-09 22:50:39 -05:00
|
|
|
state->metadata = malloc(state->metadata_length -
|
2004-02-09 23:37:30 -05:00
|
|
|
12);
|
2004-02-09 22:50:39 -05:00
|
|
|
memcpy(state->metadata,
|
|
|
|
state->metadata_buffer + 13,
|
2004-02-09 23:37:30 -05:00
|
|
|
state->metadata_length - 13);
|
|
|
|
/* Make sure we've got a null-terminator of some
|
|
|
|
sort */
|
|
|
|
state->metadata[state->metadata_length - 13] = 0;
|
|
|
|
|
|
|
|
/* Now figure out the _right_ one */
|
2004-02-09 23:29:54 -05:00
|
|
|
stringlength = strlen(state->metadata);
|
|
|
|
if(stringlength > 2)
|
|
|
|
state->metadata[stringlength - 2] = 0;
|
2004-02-09 22:50:39 -05:00
|
|
|
free(state->metadata_buffer);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
state->metadata = state->metadata_buffer;
|
|
|
|
|
|
|
|
stats_event(self->mount, "title", state->metadata);
|
2003-02-24 08:37:15 -05:00
|
|
|
state->metadata_buffer = NULL;
|
|
|
|
state->metadata_age++;
|
|
|
|
thread_mutex_unlock(&(state->lock));
|
|
|
|
}
|
2003-02-25 04:40:34 -05:00
|
|
|
|
|
|
|
state->offset = 0;
|
|
|
|
state->metadata_length = 0;
|
2003-02-24 08:37:15 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Either we got a buffer above (in which case it can be used), or
|
|
|
|
* we set *buffer to NULL in the prologue, so the return value is
|
|
|
|
* correct anyway...
|
|
|
|
*/
|
2003-02-17 07:05:45 -05:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
2003-02-24 08:37:15 -05:00
|
|
|
/* Simple case - no metadata, just dump data directly to a buffer */
|
2003-02-17 07:05:45 -05:00
|
|
|
refbuf = refbuf_new(len);
|
2002-07-23 11:15:11 -04:00
|
|
|
|
2003-02-17 07:05:45 -05:00
|
|
|
memcpy(refbuf->data, data, len);
|
2002-07-23 11:15:11 -04:00
|
|
|
|
2003-02-17 07:05:45 -05:00
|
|
|
*buffer = refbuf;
|
2003-03-14 21:10:19 -05:00
|
|
|
return 0;
|
2003-02-17 07:05:45 -05:00
|
|
|
}
|
2002-07-23 11:15:11 -04:00
|
|
|
}
|
|
|
|
|
2002-12-30 02:55:56 -05:00
|
|
|
static refbuf_queue_t *format_mp3_get_predata(format_plugin_t *self)
|
2002-07-23 11:15:11 -04:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-12-30 02:55:56 -05:00
|
|
|
static void *format_mp3_create_client_data(format_plugin_t *self,
|
|
|
|
source_t *source, client_t *client)
|
|
|
|
{
|
|
|
|
mp3_client_data *data = calloc(1,sizeof(mp3_client_data));
|
|
|
|
char *metadata;
|
|
|
|
|
|
|
|
data->interval = ICY_METADATA_INTERVAL;
|
|
|
|
data->offset = 0;
|
|
|
|
|
2002-12-31 14:48:28 -05:00
|
|
|
metadata = httpp_getvar(client->parser, "icy-metadata");
|
2002-12-30 02:55:56 -05:00
|
|
|
if(metadata)
|
2002-12-30 06:22:59 -05:00
|
|
|
data->use_metadata = atoi(metadata)>0?1:0;
|
2002-12-30 02:55:56 -05:00
|
|
|
|
|
|
|
return data;
|
2002-12-29 03:10:10 -05:00
|
|
|
}
|
2002-07-23 11:15:11 -04:00
|
|
|
|
2002-12-30 02:55:56 -05:00
|
|
|
static void format_mp3_send_headers(format_plugin_t *self,
|
|
|
|
source_t *source, client_t *client)
|
|
|
|
{
|
|
|
|
int bytes;
|
2003-11-11 13:21:49 -05:00
|
|
|
mp3_client_data *mp3data = client->format_data;
|
2002-12-30 02:55:56 -05:00
|
|
|
|
|
|
|
client->respcode = 200;
|
2002-12-30 10:19:46 -05:00
|
|
|
/* TODO: This may need to be ICY/1.0 for shoutcast-compatibility? */
|
2002-12-30 02:55:56 -05:00
|
|
|
bytes = sock_write(client->con->sock,
|
|
|
|
"HTTP/1.0 200 OK\r\n"
|
|
|
|
"Content-Type: %s\r\n",
|
|
|
|
format_get_mimetype(source->format->type));
|
|
|
|
|
2004-02-02 19:29:36 -05:00
|
|
|
if (bytes > 0)
|
|
|
|
client->con->sent_bytes += bytes;
|
2002-12-30 02:55:56 -05:00
|
|
|
|
2004-02-02 19:29:36 -05:00
|
|
|
if (mp3data->use_metadata)
|
|
|
|
{
|
2003-07-06 11:27:50 -04:00
|
|
|
int bytes = sock_write(client->con->sock, "icy-metaint:%d\r\n",
|
2002-12-30 02:55:56 -05:00
|
|
|
ICY_METADATA_INTERVAL);
|
|
|
|
if(bytes > 0)
|
|
|
|
client->con->sent_bytes += bytes;
|
|
|
|
}
|
2004-02-02 19:29:36 -05:00
|
|
|
format_send_general_headers(self, source, client);
|
2002-12-30 02:55:56 -05:00
|
|
|
}
|
|
|
|
|