diff options
Diffstat (limited to 'src/demuxers/demux_mpgaudio.c')
-rw-r--r-- | src/demuxers/demux_mpgaudio.c | 107 |
1 files changed, 30 insertions, 77 deletions
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c index 73e43c199..1648be926 100644 --- a/src/demuxers/demux_mpgaudio.c +++ b/src/demuxers/demux_mpgaudio.c @@ -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 */ @@ -410,7 +410,7 @@ static vbri_header_t* 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 = xine_xmalloc (sizeof(int) * (vbri->toc_entries + 1)); + vbri->toc = xine_xcalloc ((vbri->toc_entries + 1), sizeof(int)); if (!vbri->toc) { free (vbri); return NULL; @@ -608,8 +608,8 @@ static int demux_mpgaudio_next (demux_mpgaudio_t *this, int decoder_flags, int s return parse_frame_payload(this, header_buf, decoder_flags); - } else if ( id3v2_istag(header_buf) ) { - if (!id3v2_parse_tag(this->input, this->stream, header_buf)) { + } else if ( id3v2_istag(_X_ME_32(header_buf)) ) { + if (!id3v2_parse_tag(this->input, this->stream, _X_ME_32(header_buf))) { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, LOG_MODULE ": ID3V2 tag parsing error\n"); bytes = 1; /* resync */ @@ -682,19 +682,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"); @@ -950,11 +947,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; @@ -988,18 +980,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; @@ -1012,7 +993,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; @@ -1030,49 +1011,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; @@ -1081,11 +1019,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; } |