summaryrefslogtreecommitdiff
path: root/src/demuxers/demux_matroska.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/demuxers/demux_matroska.c')
-rw-r--r--src/demuxers/demux_matroska.c146
1 files changed, 49 insertions, 97 deletions
diff --git a/src/demuxers/demux_matroska.c b/src/demuxers/demux_matroska.c
index 3d1935587..f9f0b23d5 100644
--- a/src/demuxers/demux_matroska.c
+++ b/src/demuxers/demux_matroska.c
@@ -43,10 +43,10 @@
#define LOG
*/
-#include "xine_internal.h"
-#include "xineutils.h"
-#include "demux.h"
-#include "buffer.h"
+#include <xine/xine_internal.h>
+#include <xine/xineutils.h>
+#include <xine/demux.h>
+#include <xine/buffer.h>
#include "bswap.h"
#include "ebml.h"
@@ -1135,7 +1135,7 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
case MATROSKA_ID_TR_CODECPRIVATE:
{
- char *codec_private;
+ uint8_t *codec_private;
if (elem.len >= 0x80000000)
return 0;
codec_private = malloc (elem.len);
@@ -1251,10 +1251,10 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
}
xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
- "demux_matroska: Track %d, %s %s\n",
- track->track_num,
- (track->codec_id ? track->codec_id : ""),
- (track->language ? track->language : ""));
+ "demux_matroska: Track %d, %s %s\n",
+ track->track_num,
+ (track->codec_id ? track->codec_id : ""),
+ (track->language ? track->language : ""));
if (track->codec_id) {
void (*init_codec)(demux_matroska_t *, matroska_track_t *) = NULL;
@@ -1267,13 +1267,15 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
_x_bmiheader_le2me(bih);
track->buf_type = _x_fourcc_to_buf_video(bih->biCompression);
+ if (!track->buf_type)
+ _x_report_video_fourcc (this->stream->xine, LOG_MODULE, bih->biCompression);
init_codec = init_codec_video;
}
} else if (!strcmp(track->codec_id, MATROSKA_CODEC_ID_V_UNCOMPRESSED)) {
} else if ((!strcmp(track->codec_id, MATROSKA_CODEC_ID_V_MPEG4_SP)) ||
- (!strcmp(track->codec_id, MATROSKA_CODEC_ID_V_MPEG4_ASP)) ||
- (!strcmp(track->codec_id, MATROSKA_CODEC_ID_V_MPEG4_AP))) {
+ (!strcmp(track->codec_id, MATROSKA_CODEC_ID_V_MPEG4_ASP)) ||
+ (!strcmp(track->codec_id, MATROSKA_CODEC_ID_V_MPEG4_AP))) {
xine_bmiheader *bih;
lprintf("MATROSKA_CODEC_ID_V_MPEG4_*\n");
@@ -1374,8 +1376,8 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
track->buf_type = BUF_VIDEO_THEORA_RAW;
init_codec = init_codec_xiph;
} else if ((!strcmp(track->codec_id, MATROSKA_CODEC_ID_A_MPEG1_L1)) ||
- (!strcmp(track->codec_id, MATROSKA_CODEC_ID_A_MPEG1_L2)) ||
- (!strcmp(track->codec_id, MATROSKA_CODEC_ID_A_MPEG1_L3))) {
+ (!strcmp(track->codec_id, MATROSKA_CODEC_ID_A_MPEG1_L2)) ||
+ (!strcmp(track->codec_id, MATROSKA_CODEC_ID_A_MPEG1_L3))) {
lprintf("MATROSKA_CODEC_ID_A_MPEG1\n");
track->buf_type = BUF_AUDIO_MPEG;
init_codec = init_codec_audio;
@@ -1413,10 +1415,12 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
_x_waveformatex_le2me(wfh);
track->buf_type = _x_formattag_to_buf_audio(wfh->wFormatTag);
+ if (!track->buf_type)
+ _x_report_audio_format_tag (this->stream->xine, LOG_MODULE, wfh->wFormatTag);
init_codec = init_codec_audio;
}
} else if (!strncmp(track->codec_id, MATROSKA_CODEC_ID_A_AAC,
- sizeof(MATROSKA_CODEC_ID_A_AAC) - 1)) {
+ sizeof(MATROSKA_CODEC_ID_A_AAC) - 1)) {
lprintf("MATROSKA_CODEC_ID_A_AAC\n");
track->buf_type = BUF_AUDIO_AAC;
init_codec = init_codec_aac;
@@ -1500,10 +1504,10 @@ static int parse_track_entry(demux_matroska_t *this, matroska_track_t *track) {
}
if (init_codec) {
- if (! track->fifo) {
- xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
- "demux_matroska: Error: fifo not set up for track of type type %" PRIu32 "\n", track->track_type);
- return 0;
+ if (! track->fifo) {
+ xprintf(this->stream->xine, XINE_VERBOSITY_LOG,
+ "demux_matroska: Error: fifo not set up for track of type type %" PRIu32 "\n", track->track_type);
+ return 0;
}
init_codec(this, track);
}
@@ -1653,10 +1657,10 @@ static int parse_cue_point(demux_matroska_t *this) {
this->num_indexes++;
}
if ((index->num_entries % 1024) == 0) {
- index->pos = (off_t *)realloc(index->pos, sizeof(off_t) *
- (index->num_entries + 1024));
- index->timecode = (off_t *)realloc(index->timecode, sizeof(uint64_t) *
- (index->num_entries + 1024));
+ index->pos = realloc(index->pos, sizeof(off_t) *
+ (index->num_entries + 1024));
+ index->timecode = realloc(index->timecode, sizeof(uint64_t) *
+ (index->num_entries + 1024));
}
index->pos[index->num_entries] = pos;
index->timecode[index->num_entries] = timecode;
@@ -1742,10 +1746,7 @@ static int parse_tags(demux_matroska_t *this) {
static void alloc_block_data (demux_matroska_t *this, size_t len) {
/* memory management */
if (this->block_data_size < len) {
- if (this->block_data)
- this->block_data = realloc(this->block_data, len);
- else
- this->block_data = malloc(len);
+ this->block_data = realloc(this->block_data, len);
this->block_data_size = len;
}
}
@@ -2844,37 +2845,26 @@ static void demux_matroska_dispose (demux_plugin_t *this_gen) {
/* free tracks */
for (i = 0; i < this->num_tracks; i++) {
- matroska_track_t *track;
-
- track = this->tracks[i];
- if (track->language)
- free (track->language);
- if (track->codec_id)
- free (track->codec_id);
- if (track->codec_private)
- free (track->codec_private);
- if (track->video_track)
- free (track->video_track);
- if (track->audio_track)
- free (track->audio_track);
- if (track->sub_track)
- free (track->sub_track);
+ matroska_track_t *const track = this->tracks[i];
+
+ free (track->language);
+ free (track->codec_id);
+ free (track->codec_private);
+ free (track->video_track);
+ free (track->audio_track);
+ free (track->sub_track);
free (track);
}
/* Free the cues. */
for (i = 0; i < this->num_indexes; i++) {
- if (this->indexes[i].pos)
- free(this->indexes[i].pos);
- if (this->indexes[i].timecode)
- free(this->indexes[i].timecode);
+ free(this->indexes[i].pos);
+ free(this->indexes[i].timecode);
}
- if (this->indexes)
- free(this->indexes);
+ free(this->indexes);
/* Free the top_level elem list */
- if (this->top_level_list)
- free(this->top_level_list);
+ free(this->top_level_list);
free(this->title);
@@ -2982,18 +2972,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;
@@ -3052,36 +3031,6 @@ error:
/*
* demux matroska class
*/
-
-static const char *get_description (demux_class_t *this_gen) {
- return "matroska & webm demux plugin";
-}
-
-
-static const char *get_identifier (demux_class_t *this_gen) {
- return "matroska";
-}
-
-
-static const char *get_extensions (demux_class_t *this_gen) {
- return "mkv wbm webm";
-}
-
-
-static const char *get_mimetypes (demux_class_t *this_gen) {
- return "video/mkv: mkv: matroska;"
- "video/x-matroska: mkv: matroska;"
- "video/webm: wbm,webm: WebM;";
-}
-
-
-static void class_dispose (demux_class_t *this_gen) {
-
- demux_matroska_class_t *this = (demux_matroska_class_t *) this_gen;
-
- free (this);
-}
-
static void *init_class (xine_t *xine, void *data) {
demux_matroska_class_t *this;
@@ -3090,11 +3039,14 @@ static void *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_("matroska & webm demux plugin");
+ this->demux_class.identifier = "matroska";
+ this->demux_class.mimetypes = "video/mkv: mkv: matroska;"
+ "video/x-matroska: mkv: matroska;"
+ "video/webm: wbm,webm: WebM;";
+
+ this->demux_class.extensions = "mkv wbm webm";
+ this->demux_class.dispose = default_demux_class_dispose;
return this;
}
@@ -3108,6 +3060,6 @@ static const demuxer_info_t demux_info_matroska = {
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 26, "matroska", XINE_VERSION_CODE, &demux_info_matroska, init_class },
+ { PLUGIN_DEMUX, 27, "matroska", XINE_VERSION_CODE, &demux_info_matroska, init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};