Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:rmax
icecast
icecast-mjpeg.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File icecast-mjpeg.patch of Package icecast
--- src/Makefile.am +++ src/Makefile.am @@ -10,13 +10,13 @@ global.h util.h slave.h source.h stats.h refbuf.h client.h \ compat.h fserve.h xslt.h yp.h event.h md5.h \ auth.h auth_htpasswd.h auth_url.h \ - format.h format_ogg.h format_mp3.h \ + format.h format_ogg.h format_mp3.h format_mjpeg.h \ format_vorbis.h format_theora.h format_flac.h format_speex.h format_midi.h \ format_kate.h format_skeleton.h icecast_SOURCES = cfgfile.c main.c logging.c sighandler.c connection.c global.c \ util.c slave.c source.c stats.c refbuf.c client.c \ xslt.c fserve.c event.c admin.c md5.c \ - format.c format_ogg.c format_mp3.c format_midi.c format_flac.c \ + format.c format_ogg.c format_mp3.c format_midi.c format_flac.c format_mjpeg.c \ auth.c auth_htpasswd.c format_kate.c format_skeleton.c EXTRA_icecast_SOURCES = yp.c \ auth_url.c \ --- src/format.c +++ src/format.c @@ -40,6 +40,7 @@ #include "format_ogg.h" #include "format_mp3.h" +#include "format_mjpeg.h" #include "logging.h" #include "stats.h" @@ -64,6 +65,9 @@ return FORMAT_TYPE_OGG; else if(strcmp(contenttype, "video/ogg") == 0) return FORMAT_TYPE_OGG; +#define MIXED "multipart/x-mixed-replace" + else if(strncmp(contenttype, MIXED, strlen(MIXED)) == 0) + return FORMAT_TYPE_MJPEG; else /* We default to the Generic format handler, which can handle many more formats than just mp3 */ @@ -81,6 +84,9 @@ case FORMAT_TYPE_GENERIC: ret = format_mp3_get_plugin (source); break; + case FORMAT_TYPE_MJPEG: + ret = format_mjpeg_get_plugin (source); + break; default: break; } --- src/format.h +++ src/format.h @@ -29,6 +29,7 @@ { FORMAT_ERROR, /* No format, source not processable */ FORMAT_TYPE_OGG, + FORMAT_TYPE_MJPEG, FORMAT_TYPE_GENERIC } format_type_t; --- src/format_mjpeg.c +++ src/format_mjpeg.c @@ -0,0 +1,108 @@ +/* -*- c-basic-offset: 4; -*- */ +/* 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). + */ + +/* format_mp3.c +** +** format plugin for mp3 +** +*/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#ifdef HAVE_STRINGS_H +# include <strings.h> +#endif + +#include "refbuf.h" +#include "source.h" +#include "client.h" + +#include "stats.h" +#include "format.h" +#include "httpp/httpp.h" + +#include "logging.h" + +#include "format_mp3.h" + +#ifdef WIN32 +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define snprintf _snprintf +#endif + +#define CATMODULE "format-mjpeg" + +static void format_mjpeg_free_plugin(format_plugin_t *self); +static refbuf_t *mjpeg_get (source_t *source); +static void write_mjpeg_to_file (struct source_tag *source, refbuf_t *refbuf); + +int format_mjpeg_get_plugin (source_t *source) +{ + format_plugin_t *plugin; + + plugin = (format_plugin_t *)calloc(1, sizeof(format_plugin_t)); + + plugin->type = FORMAT_TYPE_MJPEG; + plugin->get_buffer = mjpeg_get; + plugin->write_buf_to_client = format_generic_write_to_client; + plugin->write_buf_to_file = write_mjpeg_to_file; + // plugin->create_client_data = format_mjpeg_create_client_data; + plugin->free_plugin = format_mjpeg_free_plugin; + // plugin->set_tag = mjpeg_set_tag; + // plugin->apply_settings = format_mjpeg_apply_settings; + + plugin->contenttype = httpp_getvar (source->parser, "content-type"); + // plugin->_state = state; + + source->format = plugin; + return 0; +} + + +static void format_mjpeg_free_plugin(format_plugin_t *self) +{ + free(self); +} + +/* read an mp3 stream which does not have shoutcast style metadata */ +static refbuf_t *mjpeg_get (source_t *source) +{ +#define REFBUF_SIZE 1400 + refbuf_t *refbuf = refbuf_new (REFBUF_SIZE); + refbuf->len = client_read_bytes (source->client, refbuf->data, REFBUF_SIZE); + if (refbuf->len <= 0) { + refbuf_release(refbuf); + return NULL; + } + refbuf->sync_point = 1; + return refbuf; +} + +static void write_mjpeg_to_file (struct source_tag *source, refbuf_t *refbuf) +{ + if (refbuf->len == 0) + return; + if (fwrite (refbuf->data, 1, refbuf->len, source->dumpfile) < (size_t)refbuf->len) + { + WARN0 ("Write to dump file failed, disabling"); + fclose (source->dumpfile); + source->dumpfile = NULL; + } +} + --- src/format_mjpeg.h +++ src/format_mjpeg.h @@ -0,0 +1,23 @@ +/* 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). + */ + +/* format_mp3.h +** +** mp3 format plugin +** +*/ +#ifndef __FORMAT_MJPEG_H__ +#define __FORMAT_MJPEG_H__ + +int format_mjpeg_get_plugin(struct source_tag *src); + +#endif /* __FORMAT_MJPEG_H__ */
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor