1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-09-29 04:25:55 -04:00

Update: Parse FLAC block types and report via ICECAST_LOG_DEBUG()

This commit is contained in:
Philipp Schafft 2022-03-15 22:33:28 +00:00
parent 65f7f559e4
commit 756e3b7d22

View File

@ -19,6 +19,7 @@
#endif
#include <stdlib.h>
#include <stdint.h>
#include <ogg/ogg.h>
#include <string.h>
@ -30,6 +31,64 @@
#define CATMODULE "format-flac"
#include "logging.h"
typedef enum {
FLAC_BLOCK_TYPE__ERROR = -1,
FLAC_BLOCK_TYPE_STREAMINFO = 0,
FLAC_BLOCK_TYPE_PADDING = 1,
FLAC_BLOCK_TYPE_APPLICATION = 2,
FLAC_BLOCK_TYPE_SEEKTABLE = 3,
FLAC_BLOCK_TYPE_VORBIS_COMMENT = 4,
FLAC_BLOCK_TYPE_CUESHEET = 5,
FLAC_BLOCK_TYPE_PICTURE = 6
} flac_block_type_t;
static flac_block_type_t flac_blocktype(const ogg_packet * packet)
{
uint8_t type;
if (packet->bytes <= 4)
return FLAC_BLOCK_TYPE__ERROR;
type = packet->packet[0] & 0x7F;
if (type <= FLAC_BLOCK_TYPE_PICTURE) {
return type;
} else {
return FLAC_BLOCK_TYPE__ERROR;
}
}
static const char * flac_block_type_to_name(flac_block_type_t type)
{
switch (type) {
case FLAC_BLOCK_TYPE__ERROR:
return "<error>";
break;
case FLAC_BLOCK_TYPE_STREAMINFO:
return "STREAMINFO";
break;
case FLAC_BLOCK_TYPE_PADDING:
return "PADDING";
break;
case FLAC_BLOCK_TYPE_APPLICATION:
return "APPLICATION";
break;
case FLAC_BLOCK_TYPE_SEEKTABLE:
return "SEEKTABLE";
break;
case FLAC_BLOCK_TYPE_VORBIS_COMMENT:
return "VORBIS_COMMENT";
break;
case FLAC_BLOCK_TYPE_CUESHEET:
return "CUESHEET";
break;
case FLAC_BLOCK_TYPE_PICTURE:
return "PICTURE";
break;
}
return "<unknown>";
}
static void flac_codec_free (ogg_state_t *ogg_info, ogg_codec_t *codec)
{
@ -55,13 +114,18 @@ static refbuf_t *process_flac_page (ogg_state_t *ogg_info, ogg_codec_t *codec, o
while (ogg_stream_packetout(&codec->os, &packet)) {
if (packet.bytes >= 1) {
int type = packet.packet[0];
uint8_t type = packet.packet[0];
flac_block_type_t blocktype;
if (type == 0xFF) {
codec->headers = 0;
break;
}
blocktype = flac_blocktype(&packet);
ICECAST_LOG_DEBUG("Found header of type %s%s", flac_block_type_to_name(blocktype), (type & 0x80) ? "|0x80" : "");
if (type >= 1 && type <= 0x7E)
continue;
if (type >= 0x81 && type <= 0xFE)