Misc cleanup in MediaInfo proto usage
- Replaces SerializeToString with SerializeAsString. - Construct StringPiece instead of doing implicit conversion when doing Base64Encode. Change-Id: I9a9d4a138b0d949447396387adc599c7cde0b9f4
This commit is contained in:
parent
c923cb283a
commit
a217cdce29
|
@ -119,10 +119,8 @@ bool MediaInfoEqual(const MediaInfo& expect, const MediaInfo& actual) {
|
||||||
// I found out here
|
// I found out here
|
||||||
// https://groups.google.com/forum/#!msg/protobuf/5sOExQkB2eQ/ZSBNZI0K54YJ
|
// https://groups.google.com/forum/#!msg/protobuf/5sOExQkB2eQ/ZSBNZI0K54YJ
|
||||||
// that the best way to check equality is to serialize and check equality.
|
// that the best way to check equality is to serialize and check equality.
|
||||||
std::string expect_serialized;
|
std::string expect_serialized = expect.SerializeAsString();
|
||||||
std::string actual_serialized;
|
std::string actual_serialized = actual.SerializeAsString();
|
||||||
EXPECT_TRUE(expect.SerializeToString(&expect_serialized));
|
|
||||||
EXPECT_TRUE(actual.SerializeToString(&actual_serialized));
|
|
||||||
EXPECT_EQ(expect_serialized, actual_serialized);
|
EXPECT_EQ(expect_serialized, actual_serialized);
|
||||||
return expect_serialized == actual_serialized;
|
return expect_serialized == actual_serialized;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,11 +21,8 @@ const int kStartingGroupId = 1;
|
||||||
bool ProtectedContentEq(
|
bool ProtectedContentEq(
|
||||||
const MediaInfo::ProtectedContent& content_protection1,
|
const MediaInfo::ProtectedContent& content_protection1,
|
||||||
const MediaInfo::ProtectedContent& content_protection2) {
|
const MediaInfo::ProtectedContent& content_protection2) {
|
||||||
std::string s1;
|
return content_protection1.SerializeAsString() ==
|
||||||
std::string s2;
|
content_protection2.SerializeAsString();
|
||||||
return content_protection1.SerializeToString(&s1) &&
|
|
||||||
content_protection2.SerializeToString(&s2) &&
|
|
||||||
s1 == s2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<std::string> GetUUIDs(
|
std::set<std::string> GetUUIDs(
|
||||||
|
|
|
@ -315,7 +315,9 @@ void AddContentProtectionElementsHelperTemplated(
|
||||||
|
|
||||||
if (entry.has_pssh()) {
|
if (entry.has_pssh()) {
|
||||||
std::string base64_encoded_pssh;
|
std::string base64_encoded_pssh;
|
||||||
base::Base64Encode(entry.pssh(), &base64_encoded_pssh);
|
base::Base64Encode(
|
||||||
|
base::StringPiece(entry.pssh().data(), entry.pssh().size()),
|
||||||
|
&base64_encoded_pssh);
|
||||||
Element cenc_pssh;
|
Element cenc_pssh;
|
||||||
cenc_pssh.name = kPsshElementName;
|
cenc_pssh.name = kPsshElementName;
|
||||||
cenc_pssh.content = base64_encoded_pssh;
|
cenc_pssh.content = base64_encoded_pssh;
|
||||||
|
|
Loading…
Reference in New Issue