Add an option to allow write |mvex| before |trak|
Under command line flag --mvex_before_trak. This is needed to workaround Android MediaExtractor bug which requires |mvex| to appear before |trak|. Closes #711. Change-Id: Id41d71af5c0016f59023dda6408bbf502e12ac55
This commit is contained in:
parent
4028bf727b
commit
055c67888b
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "packager/media/formats/mp4/box_definitions.h"
|
#include "packager/media/formats/mp4/box_definitions.h"
|
||||||
|
|
||||||
|
#include <gflags/gflags.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
|
||||||
#include "packager/base/logging.h"
|
#include "packager/base/logging.h"
|
||||||
|
@ -12,6 +13,11 @@
|
||||||
#include "packager/media/base/rcheck.h"
|
#include "packager/media/base/rcheck.h"
|
||||||
#include "packager/media/formats/mp4/box_buffer.h"
|
#include "packager/media/formats/mp4/box_buffer.h"
|
||||||
|
|
||||||
|
DEFINE_bool(mvex_before_trak,
|
||||||
|
false,
|
||||||
|
"Android MediaExtractor requires mvex to be written before trak. "
|
||||||
|
"Set the flag to true to comply with the requirement.");
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
const uint32_t kFourCCSize = 4;
|
const uint32_t kFourCCSize = 4;
|
||||||
|
|
||||||
|
@ -2328,9 +2334,17 @@ bool Movie::ReadWriteInternal(BoxBuffer* buffer) {
|
||||||
// We do not care the content of metadata box in the source content, so just
|
// We do not care the content of metadata box in the source content, so just
|
||||||
// skip reading the box.
|
// skip reading the box.
|
||||||
RCHECK(buffer->TryReadWriteChild(&metadata));
|
RCHECK(buffer->TryReadWriteChild(&metadata));
|
||||||
|
if (FLAGS_mvex_before_trak) {
|
||||||
|
// |extends| has to be written before |tracks| to workaround Android
|
||||||
|
// MediaExtractor bug which requires |mvex| to be placed before |trak|.
|
||||||
|
// See https://github.com/google/shaka-packager/issues/711 for details.
|
||||||
|
RCHECK(buffer->TryReadWriteChild(&extends));
|
||||||
|
}
|
||||||
for (uint32_t i = 0; i < tracks.size(); ++i)
|
for (uint32_t i = 0; i < tracks.size(); ++i)
|
||||||
RCHECK(buffer->ReadWriteChild(&tracks[i]));
|
RCHECK(buffer->ReadWriteChild(&tracks[i]));
|
||||||
|
if (!FLAGS_mvex_before_trak) {
|
||||||
RCHECK(buffer->TryReadWriteChild(&extends));
|
RCHECK(buffer->TryReadWriteChild(&extends));
|
||||||
|
}
|
||||||
for (uint32_t i = 0; i < pssh.size(); ++i)
|
for (uint32_t i = 0; i < pssh.size(); ++i)
|
||||||
RCHECK(buffer->ReadWriteChild(&pssh[i]));
|
RCHECK(buffer->ReadWriteChild(&pssh[i]));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue