summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_mpgaudio.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/demux_mpgaudio.c')
-rw-r--r--src/demuxers/demux_mpgaudio.c117
1 files changed, 35 insertions, 82 deletions
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c
index 6205f9a08..8bcb7b760 100644
--- a/src/demuxers/demux_mpgaudio.c
+++ b/src/demuxers/demux_mpgaudio.c
@@ -38,10 +38,10 @@
/*
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "compat.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"
@@ -59,7 +59,7 @@
#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 FOURCC_TAG( 0x00, 0x00, 0x01, 0xBA )
+#define MPEG_MARKER ME_FOURCC( 0x00, 0x00, 0x01, 0xBA )
/* Xing header stuff */
@@ -478,7 +478,7 @@ static vbri_header_t *XINE_MALLOC parse_vbri_header(mpg_audio_frame_t *frame,
lprintf("entry_frames: %d\n", vbri->entry_frames);
if ((ptr + (vbri->toc_entries + 1) * vbri->entry_size) >= (buf + bufsize)) return 0;
- vbri->toc = calloc (vbri->toc_entries + 1, sizeof (int));
+ vbri->toc = xine_xcalloc ((vbri->toc_entries + 1), sizeof(int));
if (!vbri->toc) {
free (vbri);
return NULL;
@@ -758,8 +758,8 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int s
/* the stream is broken, don't keep info about previous frames */
this->free_bitrate_size = 0;
- if ( id3v2_istag(header) ) {
- if (!id3v2_parse_tag(this->input, this->stream, header)) {
+ if ( id3v2_istag(_X_ME_32(header)) ) {
+ if (!id3v2_parse_tag(this->input, this->stream, _X_ME_32(header))) {
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
LOG_MODULE ": ID3V2 tag parsing error\n");
bytes = 1; /* resync */
@@ -861,19 +861,16 @@ static int detect_mpgaudio_file(input_plugin_t *input,
if (preview_len < 4)
return 0;
- lprintf("got preview %02x %02x %02x %02x\n",
- buf[0], buf[1], buf[2], buf[3]);
+ head = _X_ME_32(buf);
- head = _X_BE_32(buf);
+ lprintf("got preview %08x\n", head);
- if ((head == ID3V22_TAG) ||
- (head == ID3V23_TAG) ||
- (head == ID3V24_TAG)) {
+ if (id3v2_istag(head)) {
/* check if a mp3 frame follows the tag
* id3v2 are not specific to mp3 files,
* flac files can contain id3v2 tags
*/
- uint32_t tag_size = _X_BE_32_synchsafe(&buf[6]);
+ int tag_size = _X_BE_32_synchsafe(&buf[6]);
lprintf("try to skip id3v2 tag (%d bytes)\n", tag_size);
if ((10 + tag_size) >= preview_len) {
lprintf("cannot skip id3v2 tag\n");
@@ -988,7 +985,7 @@ static void demux_mpgaudio_send_headers (demux_plugin_t *this_gen) {
*/
{
char scratch_buf[256];
- char *mpeg_ver[3] = {"1", "2", "2.5"};
+ static const char mpeg_ver[3][4] = {"1", "2", "2.5"};
snprintf(scratch_buf, 256, "MPEG %s Layer %1d%s",
mpeg_ver[this->cur_frame.version_idx], this->cur_frame.layer,
@@ -1131,11 +1128,6 @@ static int demux_mpgaudio_seek (demux_plugin_t *this_gen,
return this->status;
}
-static void demux_mpgaudio_dispose (demux_plugin_t *this) {
-
- free (this);
-}
-
static int demux_mpgaudio_get_stream_length (demux_plugin_t *this_gen) {
demux_mpgaudio_t *this = (demux_mpgaudio_t *) this_gen;
@@ -1171,18 +1163,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
}
break;
- case METHOD_BY_EXTENSION: {
- const char *const mrl = input->get_mrl(input);
- const char *const extensions = class_gen->get_extensions (class_gen);
-
- lprintf ("stage by extension %s\n", mrl);
-
- if (!_x_demux_check_extension (mrl, extensions))
- return NULL;
-
- }
- break;
-
+ case METHOD_BY_MRL:
case METHOD_EXPLICIT:
break;
@@ -1195,7 +1176,7 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
this->demux_plugin.send_headers = demux_mpgaudio_send_headers;
this->demux_plugin.send_chunk = demux_mpgaudio_send_chunk;
this->demux_plugin.seek = demux_mpgaudio_seek;
- this->demux_plugin.dispose = demux_mpgaudio_dispose;
+ this->demux_plugin.dispose = default_demux_plugin_dispose;
this->demux_plugin.get_status = demux_mpgaudio_get_status;
this->demux_plugin.get_stream_length = demux_mpgaudio_get_stream_length;
this->demux_plugin.get_capabilities = demux_mpgaudio_get_capabilities;
@@ -1218,49 +1199,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t *str
/*
* demux mpegaudio class
*/
-
-static const char *get_description (demux_class_t *this_gen) {
- return "MPEG audio demux plugin";
-}
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "MPEGAUDIO";
-}
-
-static const char *get_extensions (demux_class_t *this_gen) {
- demux_mpgaudio_class_t *this = (demux_mpgaudio_class_t *) this_gen;
-
- if( _x_decoder_available(this->xine, BUF_AUDIO_MPEG) )
- return "mp3 mp2 mpa mpega";
- else
- return "";
-}
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- demux_mpgaudio_class_t *this = (demux_mpgaudio_class_t *) this_gen;
-
- if( _x_decoder_available(this->xine, BUF_AUDIO_MPEG) )
- return "audio/mpeg2: mp2: MPEG audio;"
- "audio/x-mpeg2: mp2: MPEG audio;"
- "audio/mpeg3: mp3: MPEG audio;"
- "audio/x-mpeg3: mp3: MPEG audio;"
- "audio/mpeg: mpa,abs,mpega: MPEG audio;"
- "audio/x-mpeg: mpa,abs,mpega: MPEG audio;"
- "audio/x-mpegurl: mp3: MPEG audio;"
- "audio/mpegurl: mp3: MPEG audio;"
- "audio/mp3: mp3: MPEG audio;"
- "audio/x-mp3: mp3: MPEG audio;";
- else
- return "";
-}
-
-static void class_dispose (demux_class_t *this_gen) {
-
- demux_mpgaudio_class_t *this = (demux_mpgaudio_class_t *) this_gen;
-
- free (this);
-}
-
void *demux_mpgaudio_init_class (xine_t *xine, void *data) {
demux_mpgaudio_class_t *this;
@@ -1269,11 +1207,26 @@ void *demux_mpgaudio_init_class (xine_t *xine, void *data) {
this->xine = xine;
this->demux_class.open_plugin = open_plugin;
- this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.description = N_("MPEG audio demux plugin");
+ this->demux_class.identifier = "MPEGAUDIO";
+ if( _x_decoder_available(this->xine, BUF_AUDIO_MPEG) ) {
+ this->demux_class.mimetypes =
+ "audio/mpeg2: mp2: MPEG audio;"
+ "audio/x-mpeg2: mp2: MPEG audio;"
+ "audio/mpeg3: mp3: MPEG audio;"
+ "audio/x-mpeg3: mp3: MPEG audio;"
+ "audio/mpeg: mpa,abs,mpega: MPEG audio;"
+ "audio/x-mpeg: mpa,abs,mpega: MPEG audio;"
+ "audio/x-mpegurl: mp3: MPEG audio;"
+ "audio/mpegurl: mp3: MPEG audio;"
+ "audio/mp3: mp3: MPEG audio;"
+ "audio/x-mp3: mp3: MPEG audio;";
+ this->demux_class.extensions = "mp3 mp2 mpa mpega";
+ } else {
+ this->demux_class.mimetypes = NULL;
+ this->demux_class.extensions = NULL;
+ }
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}