xine-lib: xine-lib-1.2.12/src/demuxers/demux_mpgaudio.c File Reference

xine-lib 1.2.12

Data Structures | Macros | Functions
demux_mpgaudio.c File Reference
`#include <stdio.h>`
`#include <fcntl.h>`
`#include <unistd.h>`
`#include <string.h>`
`#include <stdlib.h>`
`#include <xine/xine_internal.h>`
`#include <xine/xineutils.h>`
`#include <xine/demux.h>`
`#include <xine/compat.h>`
`#include "bswap.h"`
`#include "group_audio.h"`
`#include "id3.h"`

## Data Structures
struct | mpg_audio_frame_t
struct | xing_header_t
struct | vbri_header_t
struct | demux_mpgaudio_t

## Macros
#define | LOG_MODULE "demux_mpgaudio"
#define | LOG_VERBOSE
#define | NUM_PREVIEW_BUFFERS 2
#define | NUM_VALID_FRAMES 3
#define | FOURCC_TAG BE_FOURCC
#define | RIFF_CHECK_BYTES 1024
#define | RIFF_TAG FOURCC_TAG('R', 'I', 'F', 'F')
#define | AVI_TAG FOURCC_TAG('A', 'V', 'I', ' ')
#define | CDXA_TAG FOURCC_TAG('C', 'D', 'X', 'A')
#define | MPEG_MARKER ME_FOURCC( 0x00, 0x00, 0x01, 0xBA )
#define | XING_TAG FOURCC_TAG('X', 'i', 'n', 'g')
#define | INFO_TAG FOURCC_TAG('I', 'n', 'f', 'o')
#define | LAME_TAG FOURCC_TAG('L', 'A', 'M', 'E')
#define | XING_FRAMES_FLAG 0x0001
#define | XING_BYTES_FLAG 0x0002
#define | XING_TOC_FLAG 0x0004
#define | XING_VBR_SCALE_FLAG 0x0008
#define | XING_TOC_LENGTH 100
#define | LAME_HEADER_LENGTH 0xC0
#define | VBRI_TAG FOURCC_TAG('V', 'B', 'R', 'I')

## Functions
static int | parse_frame_header (mpg_audio_frame_t *const frame, const uint8_t *const buf)
static xing_header_t * | parse_xing_header (mpg_audio_frame_t *frame, uint8_t *buf, int bufsize)
static void | _free_vbri_header (vbri_header_t **pp)
static vbri_header_t * | parse_vbri_header (mpg_audio_frame_t *frame, uint8_t *buf, int bufsize)
static int | parse_frame_payload (demux_mpgaudio_t *this, uint8_t *frame_header, int decoder_flags)
static int | sniff_buffer_looks_like_mp3 (uint8_t *buf, int buflen, int *version, int *layer)
static int | read_frame_header (demux_mpgaudio_t *this, uint8_t *header_buf, int bytes)
static int | demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int send_header)
static int | demux_mpgaudio_send_chunk (demux_plugin_t *this_gen)
static int | demux_mpgaudio_get_status (demux_plugin_t *this_gen)
static int | detect_mpgaudio_file (input_plugin_t *input, int *version, int *layer)
static void | demux_mpgaudio_send_headers (demux_plugin_t *this_gen)
static off_t | xing_get_seek_point (xing_header_t *xing, int time, int stream_length)
static off_t | vbri_get_seek_point (vbri_header_t *vbri, int time, int stream_length)
static int | demux_mpgaudio_seek (demux_plugin_t *this_gen, off_t start_pos, int start_time, int playing)
static int | demux_mpgaudio_get_stream_length (demux_plugin_t *this_gen)
static uint32_t | demux_mpgaudio_get_capabilities (demux_plugin_t *this_gen)
static int | demux_mpgaudio_get_optional_data (demux_plugin_t *this_gen, void *data, int data_type)
static void | demux_mpgaudio_dispose (demux_plugin_t *this_gen)
static demux_plugin_t * | open_plugin (demux_class_t *class_gen, xine_stream_t *stream, input_plugin_t *input)
void * | demux_mpgaudio_init_class (xine_t *xine, const void *data)

## Macro Definition Documentation

## ◆ AVI_TAG

#define AVI_TAG FOURCC_TAG('A', 'V', 'I', ' ')

## ◆ CDXA_TAG

#define CDXA_TAG FOURCC_TAG('C', 'D', 'X', 'A')

## ◆ FOURCC_TAG

#define FOURCC_TAG BE_FOURCC

## ◆ INFO_TAG

#define INFO_TAG FOURCC_TAG('I', 'n', 'f', 'o')

## ◆ LAME_HEADER_LENGTH

#define LAME_HEADER_LENGTH 0xC0

## ◆ LAME_TAG

#define LAME_TAG FOURCC_TAG('L', 'A', 'M', 'E')

## ◆ LOG_MODULE

#define LOG_MODULE "demux_mpgaudio"

## ◆ LOG_VERBOSE

#define LOG_VERBOSE

## ◆ MPEG_MARKER

#define MPEG_MARKER ME_FOURCC( 0x00, 0x00, 0x01, 0xBA )

## ◆ NUM_PREVIEW_BUFFERS

#define NUM_PREVIEW_BUFFERS 2

## ◆ NUM_VALID_FRAMES

#define NUM_VALID_FRAMES 3

## ◆ RIFF_CHECK_BYTES

#define RIFF_CHECK_BYTES 1024

## ◆ RIFF_TAG

#define RIFF_TAG FOURCC_TAG('R', 'I', 'F', 'F')

## ◆ VBRI_TAG

#define VBRI_TAG FOURCC_TAG('V', 'B', 'R', 'I')

## ◆ XING_BYTES_FLAG

#define XING_BYTES_FLAG 0x0002

## ◆ XING_FRAMES_FLAG

#define XING_FRAMES_FLAG 0x0001

## ◆ XING_TAG

#define XING_TAG FOURCC_TAG('X', 'i', 'n', 'g')

## ◆ XING_TOC_FLAG

#define XING_TOC_FLAG 0x0004

## ◆ XING_TOC_LENGTH

#define XING_TOC_LENGTH 100

## ◆ XING_VBR_SCALE_FLAG

#define XING_VBR_SCALE_FLAG 0x0008

## Function Documentation

## ◆ _free_vbri_header()

static void _free_vbri_header | ( | vbri_header_t ** | pp | ) |
| static

References _x_freep(), and vbri_header_t::toc.

Referenced by demux_mpgaudio_dispose(), and parse_frame_payload().

## ◆ demux_mpgaudio_dispose()

static void demux_mpgaudio_dispose | ( | demux_plugin_t * | this_gen | ) |
| static

References _free_vbri_header(), and _x_freep().

Referenced by open_plugin().

## ◆ demux_mpgaudio_get_capabilities()

static uint32_t demux_mpgaudio_get_capabilities | ( | demux_plugin_t * | this_gen | ) |
| static

References DEMUX_CAP_NOCAP.

Referenced by open_plugin().

## ◆ demux_mpgaudio_get_optional_data()

static int demux_mpgaudio_get_optional_data | ( | demux_plugin_t * | this_gen,
|  | void * | data,
|  | int | data_type
| ) |  |
| static

References DEMUX_OPTIONAL_UNSUPPORTED.

Referenced by open_plugin().

## ◆ demux_mpgaudio_get_status()

static int demux_mpgaudio_get_status | ( | demux_plugin_t * | this_gen | ) |
| static

Referenced by open_plugin().

## ◆ demux_mpgaudio_get_stream_length()

static int demux_mpgaudio_get_stream_length | ( | demux_plugin_t * | this_gen | ) |
| static

Referenced by open_plugin().

## ◆ demux_mpgaudio_init_class()

void * demux_mpgaudio_init_class | ( | xine_t * | xine,
|  | const void * | data
| ) |  |

References N_, NULL, open_plugin(), and demux_class_s::open_plugin.

## ◆ demux_mpgaudio_next()

static int demux_mpgaudio_next | ( | demux_mpgaudio_t * | this,
|  | int | decoder_flags,
|  | int | send_header
| ) |  |
| static

References _X_ME_32, BUF_AUDIO_MPEG, BUF_FLAG_FRAME_END, BUF_FLAG_HEADER, BUF_FLAG_STDHEADER, buf_element_s::decoder_flags, buf_element_s::decoder_info, id3v2_istag(), id3v2_parse_tag(), input(), LOG_MODULE, lprintf, next_frame(), NUM_VALID_FRAMES, parse_frame_header(), parse_frame_payload(), read_frame_header(), send_header(), buf_element_s::size, buf_element_s::type, XINE_VERBOSITY_LOG, and xprintf.

Referenced by demux_mpgaudio_send_chunk(), and demux_mpgaudio_send_headers().

## ◆ demux_mpgaudio_seek()

static int demux_mpgaudio_seek | ( | demux_plugin_t * | this_gen,
|  | off_t | start_pos,
|  | int | start_time,
|  | int | playing
| ) |  |
| static

References _x_demux_control_newpts(), _x_demux_flush_engine(), BUF_FLAG_SEEK, DEMUX_OK, input(), INPUT_CAP_SEEKABLE, lprintf, vbri_get_seek_point(), xing_get_seek_point(), and XING_TOC_FLAG.

Referenced by open_plugin().

## ◆ demux_mpgaudio_send_chunk()

static int demux_mpgaudio_send_chunk | ( | demux_plugin_t * | this_gen | ) |
| static

References BUF_AUDIO_MPEG, BUF_FLAG_FRAME_END, buf_element_s::content, buf_element_s::decoder_flags, DEMUX_FINISHED, demux_mpgaudio_next(), buf_element_s::size, and buf_element_s::type.

Referenced by open_plugin().

## ◆ demux_mpgaudio_send_headers()

static void demux_mpgaudio_send_headers | ( | demux_plugin_t * | this_gen | ) |
| static

References _x_demux_control_start(), _x_meta_info_set_utf8(), _x_stream_info_set(), BUF_FLAG_PREVIEW, DEMUX_FINISHED, demux_mpgaudio_next(), DEMUX_OK, id3v1_parse_tag(), input(), INPUT_IS_SEEKABLE, lprintf, NUM_PREVIEW_BUFFERS, xing_header_t::stream_frames, vbri_header_t::stream_frames, xing_header_t::stream_size, vbri_header_t::stream_size, XINE_META_INFO_AUDIOCODEC, XINE_STREAM_INFO_AUDIO_BITRATE, XINE_STREAM_INFO_BITRATE, XINE_STREAM_INFO_HAS_AUDIO, and XINE_STREAM_INFO_HAS_VIDEO.

Referenced by open_plugin().

## ◆ detect_mpgaudio_file()

static int detect_mpgaudio_file | ( | input_plugin_t * | input,
|  | int * | version,
|  | int * | layer
| ) |  |
| static

References _X_BE_32_synchsafe(), _x_demux_read_header(), _X_ME_32, id3v2_istag(), input(), INPUT_IS_SEEKABLE, lprintf, MAX_PREVIEW_SIZE, MPEG_MARKER, and sniff_buffer_looks_like_mp3().

Referenced by open_plugin().

## ◆ open_plugin()

static demux_plugin_t * open_plugin | ( | demux_class_t * | class_gen,
|  | xine_stream_t * | stream,
|  | input_plugin_t * | input
| ) |  |
| static

References xine_stream_s::audio_fifo, xine_stream_s::content_detection_method, DEMUX_FINISHED, demux_mpgaudio_dispose(), demux_mpgaudio_get_capabilities(), demux_mpgaudio_get_optional_data(), demux_mpgaudio_get_status(), demux_mpgaudio_get_stream_length(), demux_mpgaudio_seek(), demux_mpgaudio_send_chunk(), demux_mpgaudio_send_headers(), detect_mpgaudio_file(), input(), lprintf, METHOD_BY_CONTENT, METHOD_BY_MRL, METHOD_EXPLICIT, NULL, and NUM_VALID_FRAMES.

Referenced by demux_mpgaudio_init_class().

## ◆ parse_frame_header()

static int parse_frame_header | ( | mpg_audio_frame_t *const | frame,
|  | const uint8_t *const | buf
| ) |  |
| static

References _X_BE_32, mpg_audio_frame_t::bitrate, mpg_audio_frame_t::channel_mode, mpg_audio_frame_t::duration, mpg_audio_frame_t::freq, mpg_audio_frame_t::is_free_bitrate, mpg_audio_frame_t::layer, lprintf, mpg_audio_frame_t::lsf_bit, mpg_audio_frame_t::padding, mpg_audio_frame_t::size, and mpg_audio_frame_t::version_idx.

Referenced by demux_mpgaudio_next(), parse_frame_payload(), and sniff_buffer_looks_like_mp3().

## ◆ parse_frame_payload()

static int parse_frame_payload | ( | demux_mpgaudio_t * | this,
|  | uint8_t * | frame_header,
|  | int | decoder_flags
| ) |  |
| static

References _free_vbri_header(), _X_BE_32, BUF_AUDIO_MPEG, BUF_FLAG_AUDIO_PADDING, BUF_FLAG_FRAME_END, buf_element_s::content, buf_element_s::decoder_flags, buf_element_s::decoder_info, buf_element_s::extra_info, buf_element_s::free_buffer, input(), extra_info_s::input_normpos, extra_info_s::input_time, LOG_MODULE, lprintf, buf_element_s::max_size, next_frame(), NUM_VALID_FRAMES, parse_frame_header(), parse_vbri_header(), parse_xing_header(), buf_element_s::pts, buf_element_s::size, buf_element_s::type, XINE_VERBOSITY_LOG, and xprintf.

Referenced by demux_mpgaudio_next().

## ◆ parse_vbri_header()

static vbri_header_t * parse_vbri_header | ( | mpg_audio_frame_t * | frame,
|  | uint8_t * | buf,
|  | int | bufsize
| ) |  |
| static

References _X_BE_16, _X_BE_32, vbri_header_t::delai, vbri_header_t::entry_frames, vbri_header_t::entry_size, lprintf, NULL, vbri_header_t::quality, vbri_header_t::stream_frames, vbri_header_t::stream_size, vbri_header_t::toc, vbri_header_t::toc_entries, vbri_header_t::toc_scale_factor, VBRI_TAG, vbri_header_t::version, and xine_xcalloc().

Referenced by parse_frame_payload().

## ◆ parse_xing_header()

static xing_header_t * parse_xing_header | ( | mpg_audio_frame_t * | frame,
|  | uint8_t * | buf,
|  | int | bufsize
| ) |  |
| static

References _X_BE_32, mpg_audio_frame_t::channel_mode, xing_header_t::end_delay, xing_header_t::flags, LAME_HEADER_LENGTH, LAME_TAG, lprintf, mpg_audio_frame_t::lsf_bit, NULL, xing_header_t::start_delay, xing_header_t::stream_frames, xing_header_t::stream_size, xing_header_t::toc, xing_header_t::vbr_scale, XING_BYTES_FLAG, XING_FRAMES_FLAG, XING_TAG, XING_TOC_FLAG, XING_TOC_LENGTH, and XING_VBR_SCALE_FLAG.

Referenced by parse_frame_payload().

## ◆ read_frame_header()

static int read_frame_header | ( | demux_mpgaudio_t * | this,
|  | uint8_t * | header_buf,
|  | int | bytes
| ) |  |
| static

References input().

Referenced by demux_mpgaudio_next().

## ◆ sniff_buffer_looks_like_mp3()

static int sniff_buffer_looks_like_mp3 | ( | uint8_t * | buf,
|  | int | buflen,
|  | int * | version,
|  | int * | layer
| ) |  |
| static

References mpg_audio_frame_t::layer, lprintf, NULL, parse_frame_header(), mpg_audio_frame_t::size, and mpg_audio_frame_t::version_idx.

Referenced by detect_mpgaudio_file().

## ◆ vbri_get_seek_point()

static off_t vbri_get_seek_point | ( | vbri_header_t * | vbri,
|  | int | time,
|  | int | stream_length
| ) |  |
| static

References lprintf, vbri_header_t::toc, and vbri_header_t::toc_entries.

Referenced by demux_mpgaudio_seek().

## ◆ xing_get_seek_point()

static off_t xing_get_seek_point | ( | xing_header_t * | xing,
|  | int | time,
|  | int | stream_length
| ) |  |
| static

References xing_header_t::stream_size, and xing_header_t::toc.

Referenced by demux_mpgaudio_seek().