diff options
-rwxr-xr-x | TOOLS/matroska.py | 9 | ||||
-rw-r--r-- | libmpdemux/demux_mkv.c | 18 | ||||
-rw-r--r-- | libmpdemux/ebml_defs.c | 31 | ||||
-rw-r--r-- | libmpdemux/ebml_types.h | 33 |
4 files changed, 86 insertions, 5 deletions
diff --git a/TOOLS/matroska.py b/TOOLS/matroska.py index 77268c8183..410678d8c0 100755 --- a/TOOLS/matroska.py +++ b/TOOLS/matroska.py @@ -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' + ), ), ), ), diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 9a5c5eceb2..b0ba439658 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -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; } diff --git a/libmpdemux/ebml_defs.c b/libmpdemux/ebml_defs.c index f0296a3d62..918c5055c5 100644 --- a/libmpdemux/ebml_defs.c +++ b/libmpdemux/ebml_defs.c @@ -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 diff --git a/libmpdemux/ebml_types.h b/libmpdemux/ebml_types.h index 45b274731b..9dde5814ba 100644 --- a/libmpdemux/ebml_types.h +++ b/libmpdemux/ebml_types.h @@ -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 |