Remove void elements from masters recursively when overwriting elements

This commit is contained in:
Moritz Bunkus 2011-07-07 12:18:15 +02:00
parent 1b2e02ecae
commit ffba1a4b4b
3 changed files with 22 additions and 0 deletions

View File

@ -27,6 +27,7 @@
#include <ebml/EbmlString.h>
#include <ebml/EbmlUInteger.h>
#include <ebml/EbmlUnicodeString.h>
#include <ebml/EbmlVoid.h>
#include <matroska/KaxChapters.h>
#include <matroska/KaxTags.h>
@ -593,3 +594,22 @@ fix_mandatory_elements(EbmlElement *master) {
else if (NULL != dynamic_cast<KaxChapters *>(master))
fix_mandatory_chapter_elements(master);
}
void
remove_voids_from_master(EbmlElement *element) {
EbmlMaster *master = dynamic_cast<EbmlMaster *>(element);
if (NULL == master)
return;
size_t idx = 0;
while (master->ListSize() > idx) {
element = (*master)[idx];
if (NULL != dynamic_cast<EbmlVoid *>(element))
master->Remove(idx);
else {
remove_voids_from_master(element);
++idx;
}
}
}

View File

@ -183,6 +183,7 @@ GetFirstOrNextChild(EbmlMaster *master,
EbmlElement *MTX_DLL_API empty_ebml_master(EbmlElement *e);
EbmlElement *MTX_DLL_API create_ebml_element(const EbmlCallbacks &callbacks, const EbmlId &id);
EbmlMaster *MTX_DLL_API sort_ebml_master(EbmlMaster *e);
void MTX_DLL_API remove_voids_from_master(EbmlElement *element);
const EbmlCallbacks *MTX_DLL_API find_ebml_callbacks(const EbmlCallbacks &base, const EbmlId &id);
const EbmlCallbacks *MTX_DLL_API find_ebml_callbacks(const EbmlCallbacks &base, const char *debug_name);

View File

@ -326,6 +326,7 @@ kax_analyzer_c::update_element(EbmlElement *e,
reopen_file();
fix_mandatory_elements(e);
remove_voids_from_master(e);
placement_strategy_e strategy = get_placement_strategy_for(e);