1
0
mirror of https://github.com/mpv-player/mpv synced 2024-12-28 01:52:19 +00:00

demux_mkv: read tags.

This commit is contained in:
Anton Khirnov 2010-03-28 14:21:42 +02:00 committed by Uoti Urpala
parent bc072fb7dc
commit de42015a97
4 changed files with 85 additions and 4 deletions

View File

@ -159,7 +159,16 @@ elements_matroska = (
'Tag*, 7373, sub', (
'Targets, 63c0, sub', (
'TargetTypeValue, 68ca, uint',
'TargetTrackUID, 63c5, uint',
'TargetEditionUID, 63c9, uint',
'TargetChapterUID, 63c4, uint',
'TargetAttachmentUID, 63c6, uint',
),
'SimpleTag*, 67c8, sub', (
'TagName, 45a3, str',
'TagLanguage, 447a, str',
'TagString, 4487, str'
),
),
),
),

View File

@ -888,7 +888,23 @@ static int demux_mkv_read_chapters(struct demuxer *demuxer)
static int demux_mkv_read_tags(demuxer_t *demuxer)
{
ebml_read_skip(demuxer->stream, NULL);
stream_t *s = demuxer->stream;
struct ebml_parse_ctx parse_ctx = {};
struct ebml_tags tags = {};
if (ebml_read_element(s, &parse_ctx, &tags, &ebml_tags_desc) < 0)
return 1;
for (int i = 0; i < tags.n_tag; i++) {
struct ebml_tag tag = tags.tag[i];
if (tag.targets.target_track_uid || tag.targets.target_edition_uid ||
tag.targets.target_chapter_uid || tag.targets.target_attachment_uid)
continue;
for (int j; j < tag.n_simple_tag; j++)
demux_info_add_bstr(demuxer, tag.simple_tag[j].tag_name, tag.simple_tag[j].tag_string);
}
return 0;
}

View File

@ -1,17 +1,44 @@
// Generated by TOOLS/matroska.py, do not edit manually
E("TagString", tag_string, EBML_TYPE_STR)
E("TagLanguage", tag_language, EBML_TYPE_STR)
E("TagName", tag_name, EBML_TYPE_STR)
#define N simple_tag
E_S("SimpleTag", 3)
F(MATROSKA_ID_TAGNAME, tag_name, 0)
F(MATROSKA_ID_TAGLANGUAGE, tag_language, 0)
F(MATROSKA_ID_TAGSTRING, tag_string, 0)
}};
#undef N
E("TargetAttachmentUID", target_attachment_uid, EBML_TYPE_UINT)
E("TargetChapterUID", target_chapter_uid, EBML_TYPE_UINT)
E("TargetEditionUID", target_edition_uid, EBML_TYPE_UINT)
E("TargetTrackUID", target_track_uid, EBML_TYPE_UINT)
E("TargetTypeValue", target_type_value, EBML_TYPE_UINT)
#define N targets
E_S("Targets", 1)
E_S("Targets", 5)
F(MATROSKA_ID_TARGETTYPEVALUE, target_type_value, 0)
F(MATROSKA_ID_TARGETTRACKUID, target_track_uid, 0)
F(MATROSKA_ID_TARGETEDITIONUID, target_edition_uid, 0)
F(MATROSKA_ID_TARGETCHAPTERUID, target_chapter_uid, 0)
F(MATROSKA_ID_TARGETATTACHMENTUID, target_attachment_uid, 0)
}};
#undef N
#define N tag
E_S("Tag", 1)
E_S("Tag", 2)
F(MATROSKA_ID_TARGETS, targets, 0)
F(MATROSKA_ID_SIMPLETAG, simple_tag, 1)
}};
#undef N

View File

@ -102,18 +102,46 @@
#define MATROSKA_ID_TAG 0x7373
#define MATROSKA_ID_TARGETS 0x63c0
#define MATROSKA_ID_TARGETTYPEVALUE 0x68ca
#define MATROSKA_ID_TARGETTRACKUID 0x63c5
#define MATROSKA_ID_TARGETEDITIONUID 0x63c9
#define MATROSKA_ID_TARGETCHAPTERUID 0x63c4
#define MATROSKA_ID_TARGETATTACHMENTUID 0x63c6
#define MATROSKA_ID_SIMPLETAG 0x67c8
#define MATROSKA_ID_TAGNAME 0x45a3
#define MATROSKA_ID_TAGLANGUAGE 0x447a
#define MATROSKA_ID_TAGSTRING 0x4487
struct ebml_simple_tag {
struct bstr tag_name;
struct bstr tag_language;
struct bstr tag_string;
int n_tag_name;
int n_tag_language;
int n_tag_string;
};
struct ebml_targets {
uint64_t target_type_value;
uint64_t target_track_uid;
uint64_t target_edition_uid;
uint64_t target_chapter_uid;
uint64_t target_attachment_uid;
int n_target_type_value;
int n_target_track_uid;
int n_target_edition_uid;
int n_target_chapter_uid;
int n_target_attachment_uid;
};
struct ebml_tag {
struct ebml_targets targets;
struct ebml_targets targets;
struct ebml_simple_tag *simple_tag;
int n_targets;
int n_simple_tag;
};
struct ebml_tags {
@ -429,5 +457,6 @@ extern const struct ebml_elem_desc ebml_chapter_display_desc;
extern const struct ebml_elem_desc ebml_tags_desc;
extern const struct ebml_elem_desc ebml_tag_desc;
extern const struct ebml_elem_desc ebml_targets_desc;
extern const struct ebml_elem_desc ebml_simple_tag_desc;
#define MAX_EBML_SUBELEMENTS 19