ISOProtectionSchemeInfoBox.cpp [plain text]
#include "config.h"
#include "ISOProtectionSchemeInfoBox.h"
#include "ISOSchemeInformationBox.h"
#include "ISOSchemeTypeBox.h"
#include <JavaScriptCore/DataView.h>
using JSC::DataView;
namespace WebCore {
bool ISOProtectionSchemeInfoBox::parse(DataView& view, unsigned& offset)
{
unsigned localOffset = offset;
if (!ISOBox::parse(view, localOffset))
return false;
if (!m_originalFormatBox.read(view, localOffset))
return false;
if (localOffset - offset == m_size) {
offset = localOffset;
return true;
}
auto optionalBoxType = ISOBox::peekBox(view, localOffset);
if (!optionalBoxType)
return false;
if (optionalBoxType.value().first == ISOSchemeTypeBox::boxTypeName()) {
m_schemeTypeBox = makeUnique<ISOSchemeTypeBox>();
if (!m_schemeTypeBox->read(view, localOffset))
return false;
if (localOffset - offset == m_size) {
offset = localOffset;
return true;
}
optionalBoxType = ISOBox::peekBox(view, localOffset);
if (!optionalBoxType)
return false;
}
if (optionalBoxType.value().first == ISOSchemeInformationBox::boxTypeName()) {
m_schemeInformationBox = makeUnique<ISOSchemeInformationBox>();
if (!m_schemeInformationBox->read(view, localOffset))
return false;
if (localOffset - offset != m_size)
return false;
}
offset = localOffset;
return true;
}
}