This source file includes following definitions.
- duration_
- OnListStart
- OnListEnd
- OnUInt
- OnFloat
- OnBinary
- OnString
#include "media/formats/webm/webm_info_parser.h"
#include "base/logging.h"
#include "media/formats/webm/webm_constants.h"
namespace media {
static const int kWebMDefaultTimecodeScale = 1000000;
WebMInfoParser::WebMInfoParser()
: timecode_scale_(-1),
duration_(-1) {
}
WebMInfoParser::~WebMInfoParser() {}
int WebMInfoParser::Parse(const uint8* buf, int size) {
timecode_scale_ = -1;
duration_ = -1;
WebMListParser parser(kWebMIdInfo, this);
int result = parser.Parse(buf, size);
if (result <= 0)
return result;
return parser.IsParsingComplete() ? result : 0;
}
WebMParserClient* WebMInfoParser::OnListStart(int id) { return this; }
bool WebMInfoParser::OnListEnd(int id) {
if (id == kWebMIdInfo && timecode_scale_ == -1) {
timecode_scale_ = kWebMDefaultTimecodeScale;
}
return true;
}
bool WebMInfoParser::OnUInt(int id, int64 val) {
if (id != kWebMIdTimecodeScale)
return true;
if (timecode_scale_ != -1) {
DVLOG(1) << "Multiple values for id " << std::hex << id << " specified";
return false;
}
timecode_scale_ = val;
return true;
}
bool WebMInfoParser::OnFloat(int id, double val) {
if (id != kWebMIdDuration) {
DVLOG(1) << "Unexpected float for id" << std::hex << id;
return false;
}
if (duration_ != -1) {
DVLOG(1) << "Multiple values for duration.";
return false;
}
duration_ = val;
return true;
}
bool WebMInfoParser::OnBinary(int id, const uint8* data, int size) {
return true;
}
bool WebMInfoParser::OnString(int id, const std::string& str) {
return true;
}
}