From 7e533ec5cab0797000ce14faef6b1f46a9a63092 Mon Sep 17 00:00:00 2001 From: Kongqun Yang Date: Thu, 19 May 2016 16:43:13 -0700 Subject: [PATCH] More cleanup in proto usage Change-Id: If35f95dbff47bc9e8c1c42cb56d75719367abfc0 --- packager/hls/base/simple_hls_notifier.cc | 4 +++- packager/hls/base/simple_hls_notifier.h | 4 ++++ packager/hls/base/simple_hls_notifier_unittest.cc | 12 ++++++------ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packager/hls/base/simple_hls_notifier.cc b/packager/hls/base/simple_hls_notifier.cc index 6406933184..860323629c 100644 --- a/packager/hls/base/simple_hls_notifier.cc +++ b/packager/hls/base/simple_hls_notifier.cc @@ -136,7 +136,9 @@ bool SimpleHlsNotifier::NotifyEncryptionUpdate( } std::string content_id_base64; - base::Base64Encode(pssh_data.content_id(), &content_id_base64); + base::Base64Encode(base::StringPiece(pssh_data.content_id().data(), + pssh_data.content_id().size()), + &content_id_base64); std::string json_format = base::StringPrintf( "{" "\"provider\":\"%s\"," diff --git a/packager/hls/base/simple_hls_notifier.h b/packager/hls/base/simple_hls_notifier.h index bd0217c59c..2336afaf22 100644 --- a/packager/hls/base/simple_hls_notifier.h +++ b/packager/hls/base/simple_hls_notifier.h @@ -7,6 +7,10 @@ #ifndef PACKAGER_HLS_BASE_SIMPLE_HLS_NOTIFIER_H_ #define PACKAGER_HLS_BASE_SIMPLE_HLS_NOTIFIER_H_ +#include +#include +#include + #include "packager/base/atomic_sequence_num.h" #include "packager/base/macros.h" #include "packager/base/memory/scoped_ptr.h" diff --git a/packager/hls/base/simple_hls_notifier_unittest.cc b/packager/hls/base/simple_hls_notifier_unittest.cc index 7ebc21f714..25dbc8885b 100644 --- a/packager/hls/base/simple_hls_notifier_unittest.cc +++ b/packager/hls/base/simple_hls_notifier_unittest.cc @@ -185,8 +185,8 @@ TEST_F(SimpleHlsNotifierTest, NotifyEncryptionUpdate) { }; widevine_pssh_data.add_key_id()->assign(kAnyKeyId, kAnyKeyId + arraysize(kAnyKeyId)); - std::string widevine_pssh_data_str; - ASSERT_TRUE(widevine_pssh_data.SerializeToString(&widevine_pssh_data_str)); + std::string widevine_pssh_data_str = widevine_pssh_data.SerializeAsString(); + EXPECT_TRUE(!widevine_pssh_data_str.empty()); std::vector pssh_data(widevine_pssh_data_str.begin(), widevine_pssh_data_str.end()); @@ -255,8 +255,8 @@ TEST_F(SimpleHlsNotifierTest, MultipleKeyIdsInPssh) { kFirstKeyId + arraysize(kFirstKeyId)); widevine_pssh_data.add_key_id()->assign( kSecondKeyId, kSecondKeyId + arraysize(kSecondKeyId)); - std::string widevine_pssh_data_str; - ASSERT_TRUE(widevine_pssh_data.SerializeToString(&widevine_pssh_data_str)); + std::string widevine_pssh_data_str = widevine_pssh_data.SerializeAsString(); + EXPECT_TRUE(!widevine_pssh_data_str.empty()); std::vector pssh_data(widevine_pssh_data_str.begin(), widevine_pssh_data_str.end()); @@ -320,8 +320,8 @@ TEST_F(SimpleHlsNotifierTest, NotifyEncryptionUpdateEmptyIv) { }; widevine_pssh_data.add_key_id()->assign(kAnyKeyId, kAnyKeyId + arraysize(kAnyKeyId)); - std::string widevine_pssh_data_str; - ASSERT_TRUE(widevine_pssh_data.SerializeToString(&widevine_pssh_data_str)); + std::string widevine_pssh_data_str = widevine_pssh_data.SerializeAsString(); + EXPECT_TRUE(!widevine_pssh_data_str.empty()); std::vector pssh_data(widevine_pssh_data_str.begin(), widevine_pssh_data_str.end());