From a217cdce294b5162ae305a310b2e53e73c4d0481 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Tue, 17 May 2016 13:28:20 -0700 Subject: [PATCH] Misc cleanup in MediaInfo proto usage - Replaces SerializeToString with SerializeAsString. - Construct StringPiece instead of doing implicit conversion when doing Base64Encode. Change-Id: I9a9d4a138b0d949447396387adc599c7cde0b9f4 --- packager/media/event/muxer_listener_test_helper.cc | 6 ++---- packager/mpd/base/dash_iop_mpd_notifier.cc | 7 ++----- packager/mpd/base/mpd_utils.cc | 4 +++- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/packager/media/event/muxer_listener_test_helper.cc b/packager/media/event/muxer_listener_test_helper.cc index 5ee9788452..4a7489b420 100644 --- a/packager/media/event/muxer_listener_test_helper.cc +++ b/packager/media/event/muxer_listener_test_helper.cc @@ -119,10 +119,8 @@ bool MediaInfoEqual(const MediaInfo& expect, const MediaInfo& actual) { // I found out here // https://groups.google.com/forum/#!msg/protobuf/5sOExQkB2eQ/ZSBNZI0K54YJ // that the best way to check equality is to serialize and check equality. - std::string expect_serialized; - std::string actual_serialized; - EXPECT_TRUE(expect.SerializeToString(&expect_serialized)); - EXPECT_TRUE(actual.SerializeToString(&actual_serialized)); + std::string expect_serialized = expect.SerializeAsString(); + std::string actual_serialized = actual.SerializeAsString(); EXPECT_EQ(expect_serialized, actual_serialized); return expect_serialized == actual_serialized; } diff --git a/packager/mpd/base/dash_iop_mpd_notifier.cc b/packager/mpd/base/dash_iop_mpd_notifier.cc index ccd44c6189..7ed8f41d60 100644 --- a/packager/mpd/base/dash_iop_mpd_notifier.cc +++ b/packager/mpd/base/dash_iop_mpd_notifier.cc @@ -21,11 +21,8 @@ const int kStartingGroupId = 1; bool ProtectedContentEq( const MediaInfo::ProtectedContent& content_protection1, const MediaInfo::ProtectedContent& content_protection2) { - std::string s1; - std::string s2; - return content_protection1.SerializeToString(&s1) && - content_protection2.SerializeToString(&s2) && - s1 == s2; + return content_protection1.SerializeAsString() == + content_protection2.SerializeAsString(); } std::set GetUUIDs( diff --git a/packager/mpd/base/mpd_utils.cc b/packager/mpd/base/mpd_utils.cc index 9338d01e3c..a0b27626af 100644 --- a/packager/mpd/base/mpd_utils.cc +++ b/packager/mpd/base/mpd_utils.cc @@ -315,7 +315,9 @@ void AddContentProtectionElementsHelperTemplated( if (entry.has_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; cenc_pssh.name = kPsshElementName; cenc_pssh.content = base64_encoded_pssh;