1 /*
2    mkvextract -- extract tracks from Matroska files into other files
3 
4    Distributed under the GPL v2
5    see the file COPYING for details
6    or visit https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
7 
8    extracts tags from Matroska files into other files
9 
10    Written by Moritz Bunkus <moritz@bunkus.org>.
11 */
12 
13 #include "common/common_pch.h"
14 
15 #include <cassert>
16 #include <iostream>
17 
18 #include <ebml/EbmlHead.h>
19 #include <ebml/EbmlSubHead.h>
20 #include <ebml/EbmlStream.h>
21 #include <ebml/EbmlVoid.h>
22 #include <matroska/FileKax.h>
23 
24 #include <matroska/KaxTags.h>
25 
26 #include "common/ebml.h"
27 #include "common/kax_analyzer.h"
28 #include "common/mm_io.h"
29 #include "common/mm_io_x.h"
30 #include "common/xml/ebml_tags_converter.h"
31 #include "extract/mkvextract.h"
32 
33 using namespace libmatroska;
34 
35 bool
extract_tags(kax_analyzer_c & analyzer,options_c::mode_options_c & options)36 extract_tags(kax_analyzer_c &analyzer,
37              options_c::mode_options_c &options) {
38   auto tags = analyzer.read_all(EBML_INFO(KaxTags));
39 
40   if (!dynamic_cast<KaxTags *>(tags.get()))
41     return true;
42 
43   mtx::xml::ebml_tags_converter_c::write_xml(static_cast<KaxTags &>(*tags), *open_output_file(options.m_output_file_name));
44 
45   return true;
46 }
47