2008-04-18 22:11:37 -04:00
|
|
|
/* Icecast
|
|
|
|
*
|
|
|
|
* This program is distributed under the GNU General Public License, version 2.
|
|
|
|
* A copy of this license is included with this source.
|
|
|
|
*
|
2015-01-10 13:53:44 -05:00
|
|
|
* Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
|
2008-04-18 22:11:37 -04:00
|
|
|
* Michael Smith <msmith@xiph.org>,
|
|
|
|
* oddsock <oddsock@xiph.org>,
|
|
|
|
* Karl Heyes <karl@xiph.org>
|
|
|
|
* and others (see AUTHORS for details).
|
2018-11-26 02:42:05 -05:00
|
|
|
* Copyright 2014-2018, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
|
2008-04-18 22:11:37 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* Ogg codec handler for skeleton logical streams */
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <ogg/ogg.h>
|
|
|
|
|
|
|
|
#include "refbuf.h"
|
|
|
|
#include "format_ogg.h"
|
|
|
|
#include "format_skeleton.h"
|
|
|
|
#include "client.h"
|
|
|
|
#include "stats.h"
|
|
|
|
|
|
|
|
#define CATMODULE "format-skeleton"
|
|
|
|
#include "logging.h"
|
|
|
|
|
|
|
|
|
|
|
|
static void skeleton_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec)
|
|
|
|
{
|
2014-10-31 04:46:58 -04:00
|
|
|
ICECAST_LOG_DEBUG("freeing skeleton codec");
|
2008-04-18 22:11:37 -04:00
|
|
|
ogg_stream_clear (&codec->os);
|
|
|
|
free (codec);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* skeleton pages are not rebuilt, so here we just for headers and then
|
|
|
|
* pass them straight through to the the queue
|
|
|
|
*/
|
2014-12-09 11:08:27 -05:00
|
|
|
static refbuf_t *process_skeleton_page (ogg_state_t *ogg_info, ogg_codec_t *codec, ogg_page *page, format_plugin_t *plugin)
|
2008-04-18 22:11:37 -04:00
|
|
|
{
|
|
|
|
ogg_packet packet;
|
|
|
|
|
|
|
|
if (ogg_stream_pagein (&codec->os, page) < 0)
|
|
|
|
{
|
|
|
|
ogg_info->error = 1;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (ogg_stream_packetout (&codec->os, &packet) > 0)
|
|
|
|
{
|
|
|
|
codec->headers++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all skeleon packets are headers */
|
|
|
|
format_ogg_attach_header (ogg_info, page);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Check if specified BOS page is the start of a skeleton stream and
|
|
|
|
* if so, create a codec structure for handling it
|
|
|
|
*/
|
|
|
|
ogg_codec_t *initial_skeleton_page (format_plugin_t *plugin, ogg_page *page)
|
|
|
|
{
|
|
|
|
ogg_state_t *ogg_info = plugin->_state;
|
|
|
|
ogg_codec_t *codec = calloc (1, sizeof (ogg_codec_t));
|
|
|
|
ogg_packet packet;
|
|
|
|
|
|
|
|
ogg_stream_init (&codec->os, ogg_page_serialno (page));
|
|
|
|
ogg_stream_pagein (&codec->os, page);
|
|
|
|
|
|
|
|
ogg_stream_packetout (&codec->os, &packet);
|
|
|
|
|
2014-10-31 04:46:58 -04:00
|
|
|
ICECAST_LOG_DEBUG("checking for skeleton codec");
|
2008-04-18 22:11:37 -04:00
|
|
|
|
|
|
|
if ((packet.bytes<8) || memcmp(packet.packet, "fishead\0", 8))
|
|
|
|
{
|
|
|
|
ogg_stream_clear (&codec->os);
|
|
|
|
free (codec);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-31 04:46:58 -04:00
|
|
|
ICECAST_LOG_INFO("seen initial skeleton header");
|
2008-04-18 22:11:37 -04:00
|
|
|
codec->process_page = process_skeleton_page;
|
|
|
|
codec->codec_free = skeleton_codec_free;
|
|
|
|
codec->headers = 1;
|
|
|
|
codec->name = "Skeleton";
|
|
|
|
|
2014-11-30 15:32:30 -05:00
|
|
|
format_ogg_attach_header(ogg_info, page);
|
2008-04-18 22:11:37 -04:00
|
|
|
return codec;
|
|
|
|
}
|
|
|
|
|