demux, matroska: remove demuxer type field

The Matroska timeline code was the only thing which still used the
demuxer.type field. This field explicitly identifies a demuxer
implementation. The purpose of the Matroska timeline code was to reject
files that are not Matroska. But it already forces the Matroska format,
meaning loading will explicitly only use the Matroska demuxer. If the
demuxer can't open the file, no other demuxer will be tried, and thus
checking the field is redundant.

The change in demux_mkv_timeline.c removes the if condition, and
unindents the if body.
This commit is contained in:
wm4 2015-02-17 23:55:45 +01:00
parent 082371a160
commit fa9b587426
4 changed files with 30 additions and 40 deletions

View File

@ -900,7 +900,6 @@ static struct demuxer *open_given_type(struct mpv_global *global,
struct demuxer *demuxer = talloc_ptrtype(NULL, demuxer);
*demuxer = (struct demuxer) {
.desc = desc,
.type = desc->type,
.stream = stream,
.seekable = stream->seekable,
.filepos = -1,

View File

@ -36,11 +36,6 @@
#define MAX_PACKS 16000
#define MAX_PACK_BYTES (400 * 1024 * 1024)
enum demuxer_type {
DEMUXER_TYPE_GENERIC = 0,
DEMUXER_TYPE_MATROSKA,
};
// DEMUXER control commands/answers
#define DEMUXER_CTRL_NOTIMPL -1
#define DEMUXER_CTRL_DONTKNOW 0
@ -111,8 +106,6 @@ typedef struct demuxer_desc {
const char *name; // Demuxer name, used with -demuxer switch
const char *desc; // Displayed to user
enum demuxer_type type; // optional
// Return 0 on success, otherwise -1
int (*open)(struct demuxer *demuxer, enum demux_check check);
// The following functions are all optional
@ -185,7 +178,6 @@ typedef struct demuxer {
const char *filetype; // format name when not identified by demuxer (libavformat)
int64_t filepos; // input stream current pos.
char *filename; // same as stream->url
enum demuxer_type type;
bool seekable;
bool partially_seekable; // implies seekable=true
double start_time;

View File

@ -2884,7 +2884,6 @@ static void mkv_free(struct demuxer *demuxer)
const demuxer_desc_t demuxer_desc_matroska = {
.name = "mkv",
.desc = "Matroska",
.type = DEMUXER_TYPE_MATROSKA,
.open = demux_mkv_open,
.fill_buffer = demux_mkv_fill_buffer,
.close = mkv_free,

View File

@ -212,45 +212,45 @@ static bool check_file_seg(struct tl_ctx *ctx, struct demuxer ***sources,
free_stream(s);
return was_valid;
}
if (d->type == DEMUXER_TYPE_MATROSKA) {
struct matroska_data *m = &d->matroska_data;
for (int i = 1; i < *num_sources; i++) {
struct matroska_segment_uid *uid = *uids + i;
if ((*sources)[i])
continue;
/* Accept the source if the segment uid matches and the edition
* either matches or isn't specified. */
if (!memcmp(uid->segment, m->uid.segment, 16) &&
(!uid->edition || uid->edition == m->uid.edition))
{
MP_INFO(ctx, "Match for source %d: %s\n", i, d->filename);
struct matroska_data *m = &d->matroska_data;
for (int j = 0; j < m->num_ordered_chapters; j++) {
struct matroska_chapter *c = m->ordered_chapters + j;
for (int i = 1; i < *num_sources; i++) {
struct matroska_segment_uid *uid = *uids + i;
if ((*sources)[i])
continue;
/* Accept the source if the segment uid matches and the edition
* either matches or isn't specified. */
if (!memcmp(uid->segment, m->uid.segment, 16) &&
(!uid->edition || uid->edition == m->uid.edition))
{
MP_INFO(ctx, "Match for source %d: %s\n", i, d->filename);
if (!c->has_segment_uid)
continue;
for (int j = 0; j < m->num_ordered_chapters; j++) {
struct matroska_chapter *c = m->ordered_chapters + j;
if (has_source_request(*uids, *num_sources, &c->uid))
continue;
/* Set the requested segment. */
MP_TARRAY_GROW(NULL, *uids, *num_sources);
(*uids)[*num_sources] = c->uid;
/* Add a new source slot. */
MP_TARRAY_APPEND(NULL, *sources, *num_sources, NULL);
}
if (enable_cache(ctx->global, &s, &d, &params) < 0)
if (!c->has_segment_uid)
continue;
(*sources)[i] = d;
return true;
if (has_source_request(*uids, *num_sources, &c->uid))
continue;
/* Set the requested segment. */
MP_TARRAY_GROW(NULL, *uids, *num_sources);
(*uids)[*num_sources] = c->uid;
/* Add a new source slot. */
MP_TARRAY_APPEND(NULL, *sources, *num_sources, NULL);
}
if (enable_cache(ctx->global, &s, &d, &params) < 0)
continue;
(*sources)[i] = d;
return true;
}
}
free_demuxer(d);
free_stream(s);
return was_valid;