Source release v3.0.1 + third_party

This commit is contained in:
Joey Parrish
2015-09-11 16:15:34 -07:00
parent 0546ee6732
commit b5d6be97cb
32 changed files with 1344 additions and 129 deletions

View File

@@ -7,8 +7,15 @@
namespace wvcdm {
bool BufferReader::Read1(uint8_t* v) {
if (v == NULL) {
LOGE("BufferReader::Read1 : Failure during parse: Null output parameter "
"when expecting non-null");
return false;
}
if (!HasBytes(1)) {
LOGW("BufferReader::Read1 : Failure while parsing: Not enough bytes (1)");
LOGV("BufferReader::Read1 : Failure while parsing: "
"Not enough bytes (1)");
return false;
}
@@ -19,9 +26,15 @@ bool BufferReader::Read1(uint8_t* v) {
// Internal implementation of multi-byte reads
template <typename T>
bool BufferReader::Read(T* v) {
if (v == NULL) {
LOGE("BufferReader::Read<T> : Failure during parse: Null output parameter "
"when expecting non-null (%s)", __PRETTY_FUNCTION__);
return false;
}
if (!HasBytes(sizeof(T))) {
LOGW("BufferReader::Read<T> : Failure during parse: Not enough bytes (%u)",
sizeof(T));
LOGV("BufferReader::Read<T> : Failure during parse: "
"Not enough bytes (%u)", sizeof(T));
return false;
}
@@ -41,10 +54,16 @@ bool BufferReader::Read4s(int32_t* v) { return Read(v); }
bool BufferReader::Read8(uint64_t* v) { return Read(v); }
bool BufferReader::Read8s(int64_t* v) { return Read(v); }
bool BufferReader::ReadString(std::string* str, int count) {
bool BufferReader::ReadString(std::string* str, size_t count) {
if (str == NULL) {
LOGE("BufferReader::ReadString : Failure during parse: Null output "
"parameter when expecting non-null");
return false;
}
if (!HasBytes(count)) {
LOGW("BufferReader::ReadString : Parse Failure: Not enough bytes (%d)",
count);
LOGV("BufferReader::ReadString : Parse Failure: "
"Not enough bytes (%d)", count);
return false;
}
@@ -53,9 +72,16 @@ bool BufferReader::ReadString(std::string* str, int count) {
return true;
}
bool BufferReader::ReadVec(std::vector<uint8_t>* vec, int count) {
bool BufferReader::ReadVec(std::vector<uint8_t>* vec, size_t count) {
if (vec == NULL) {
LOGE("BufferReader::ReadVec : Failure during parse: Null output parameter "
"when expecting non-null");
return false;
}
if (!HasBytes(count)) {
LOGW("BufferReader::ReadVec : Parse Failure: Not enough bytes (%d)", count);
LOGV("BufferReader::ReadVec : Parse Failure: "
"Not enough bytes (%d)", count);
return false;
}
@@ -65,10 +91,10 @@ bool BufferReader::ReadVec(std::vector<uint8_t>* vec, int count) {
return true;
}
bool BufferReader::SkipBytes(int bytes) {
bool BufferReader::SkipBytes(size_t bytes) {
if (!HasBytes(bytes)) {
LOGW("BufferReader::SkipBytes : Parse Failure: Not enough bytes (%d)",
bytes);
LOGV("BufferReader::SkipBytes : Parse Failure: "
"Not enough bytes (%d)", bytes);
return false;
}
@@ -77,6 +103,12 @@ bool BufferReader::SkipBytes(int bytes) {
}
bool BufferReader::Read4Into8(uint64_t* v) {
if (v == NULL) {
LOGE("BufferReader::Read4Into8 : Failure during parse: Null output "
"parameter when expecting non-null");
return false;
}
uint32_t tmp;
if (!Read4(&tmp)) {
return false;
@@ -86,6 +118,12 @@ bool BufferReader::Read4Into8(uint64_t* v) {
}
bool BufferReader::Read4sInto8s(int64_t* v) {
if (v == NULL) {
LOGE("BufferReader::Read4sInto8s : Failure during parse: Null output "
"parameter when expecting non-null");
return false;
}
// Beware of the need for sign extension.
int32_t tmp;
if (!Read4s(&tmp)) {
@@ -94,5 +132,4 @@ bool BufferReader::Read4sInto8s(int64_t* v) {
*v = tmp;
return true;
}
} // namespace wvcdm