Prepare logging errors when parsing AVC config

This commit is contained in:
Martchus 2018-08-23 23:19:44 +02:00
parent 534cb2a6f7
commit 3332314eb6
4 changed files with 8 additions and 5 deletions

View File

@ -1,5 +1,6 @@
#include "./avcconfiguration.h"
#include "../diagnostics.h"
#include "../exceptions.h"
#include "../mediaformat.h"
@ -20,10 +21,11 @@ namespace TagParser {
/*!
* \brief Parses the AVC configuration using the specified \a reader.
* \throws Throws TruncatedDataException() when the config size exceeds the specified \a maxSize.
* \remarks Logging/reporting parsing errors is not implemented yet.
* \todo Implement logging/reporting parsing errors.
*/
void AvcConfiguration::parse(BinaryReader &reader, uint64 maxSize)
void AvcConfiguration::parse(BinaryReader &reader, uint64 maxSize, Diagnostics &diag)
{
VAR_UNUSED(diag)
if (maxSize < 7) {
throw TruncatedDataException();
}

View File

@ -8,6 +8,7 @@
namespace TagParser {
class MediaFormat;
class Diagnostics;
struct TAG_PARSER_EXPORT AvcConfiguration {
AvcConfiguration();
@ -18,7 +19,7 @@ struct TAG_PARSER_EXPORT AvcConfiguration {
std::vector<SpsInfo> spsInfos;
std::vector<PpsInfo> ppsInfos;
void parse(IoUtilities::BinaryReader &reader, uint64 maxSize);
void parse(IoUtilities::BinaryReader &reader, uint64 maxSize, Diagnostics &diag);
};
/*!

View File

@ -505,7 +505,7 @@ void MatroskaTrack::internalParseHeader(Diagnostics &diag)
auto avcConfig = make_unique<TagParser::AvcConfiguration>();
try {
m_istream->seekg(static_cast<streamoff>(codecPrivateElement->dataOffset()));
avcConfig->parse(m_reader, codecPrivateElement->dataSize());
avcConfig->parse(m_reader, codecPrivateElement->dataSize(), diag);
Mp4Track::addInfo(*avcConfig, *this);
} catch (const TruncatedDataException &) {
diag.emplace_back(DiagLevel::Critical, "AVC configuration is truncated.", context);

View File

@ -1721,7 +1721,7 @@ void Mp4Track::internalParseHeader(Diagnostics &diag)
m_istream->seekg(avcConfigAtom->dataOffset());
m_avcConfig = make_unique<TagParser::AvcConfiguration>();
try {
m_avcConfig->parse(reader, avcConfigAtom->dataSize());
m_avcConfig->parse(reader, avcConfigAtom->dataSize(), diag);
addInfo(*m_avcConfig, *this);
} catch (const TruncatedDataException &) {
diag.emplace_back(DiagLevel::Critical, "AVC configuration is truncated.", context);