|
27 | 27 | #include "matroskasegment.h" |
28 | 28 | #include "ebmlutils.h" |
29 | 29 | #include "ebmlelement.h" |
| 30 | +#include "ebmlstringelement.h" |
| 31 | +#include "ebmluintelement.h" |
30 | 32 | #include "ebmlmksegment.h" |
31 | 33 | #include "tlist.h" |
32 | 34 | #include "tdebug.h" |
@@ -96,7 +98,7 @@ Matroska::File::File(IOStream *stream, bool readProperties, |
96 | 98 |
|
97 | 99 | Matroska::File::~File() = default; |
98 | 100 |
|
99 | | -AudioProperties *Matroska::File::audioProperties() const |
| 101 | +Matroska::Properties *Matroska::File::audioProperties() const |
100 | 102 | { |
101 | 103 | return d->properties.get(); |
102 | 104 | } |
@@ -271,13 +273,19 @@ void Matroska::File::read(bool readProperties, Properties::ReadStyle readStyle) |
271 | 273 | offset_t fileLength = length(); |
272 | 274 |
|
273 | 275 | // Find the EBML Header |
274 | | - std::unique_ptr<EBML::Element> head(EBML::Element::factory(*this)); |
| 276 | + auto head = EBML::element_cast<EBML::Element::Id::EBMLHeader>( |
| 277 | + EBML::Element::factory(*this)); |
275 | 278 | if(!head || head->getId() != EBML::Element::Id::EBMLHeader) { |
276 | 279 | debug("Failed to find EBML head"); |
277 | 280 | setValid(false); |
278 | 281 | return; |
279 | 282 | } |
280 | | - head->skipData(*this); |
| 283 | + if(readProperties) { |
| 284 | + head->read(*this); |
| 285 | + } |
| 286 | + else { |
| 287 | + head->skipData(*this); |
| 288 | + } |
281 | 289 |
|
282 | 290 | // Find the Matroska segment in the file |
283 | 291 | std::unique_ptr<EBML::MkSegment> segment( |
@@ -307,6 +315,19 @@ void Matroska::File::read(bool readProperties, Properties::ReadStyle readStyle) |
307 | 315 |
|
308 | 316 | if(readProperties) { |
309 | 317 | d->properties = std::make_unique<Properties>(this); |
| 318 | + |
| 319 | + for(const auto &element : *head) { |
| 320 | + auto id = element->getId(); |
| 321 | + if (id == EBML::Element::Id::DocType) { |
| 322 | + d->properties->setDocType( |
| 323 | + EBML::element_cast<EBML::Element::Id::DocType>(element)->getValue()); |
| 324 | + } |
| 325 | + else if (id == EBML::Element::Id::DocTypeVersion) { |
| 326 | + d->properties->setDocTypeVersion(static_cast<int>( |
| 327 | + EBML::element_cast<EBML::Element::Id::DocTypeVersion>(element)->getValue())); |
| 328 | + } |
| 329 | + } |
| 330 | + |
310 | 331 | segment->parseInfo(d->properties.get()); |
311 | 332 | segment->parseTracks(d->properties.get()); |
312 | 333 | if(d->tag) { |
|
0 commit comments