From 322d22cc0ed8ba7b0c64d598c9d0502bdef83b21 Mon Sep 17 00:00:00 2001 From: "acolwell@chromium.org" Date: Mon, 26 Aug 2013 18:50:41 +0000 Subject: Change NeedKeyCB to use std::vector. Changes various NeedKeyCB instances to use std::vector instead of a scoped_ptr and a size parameter. TEST=All tests still pass. Review URL: https://chromiumcodereview.appspot.com/23072043 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@219575 0039d316-1c4b-4281-b951-d872f2087c98 --- media/mp4/mp4_stream_parser.cc | 6 +++--- media/mp4/mp4_stream_parser_unittest.cc | 7 +++---- 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'media/mp4') diff --git a/media/mp4/mp4_stream_parser.cc b/media/mp4/mp4_stream_parser.cc index fc4ee8a..51ed756 100644 --- a/media/mp4/mp4_stream_parser.cc +++ b/media/mp4/mp4_stream_parser.cc @@ -339,14 +339,14 @@ void MP4StreamParser::EmitNeedKeyIfNecessary( for (size_t i = 0; i < headers.size(); i++) total_size += headers[i].raw_box.size(); - scoped_ptr init_data(new uint8[total_size]); + std::vector init_data(total_size); size_t pos = 0; for (size_t i = 0; i < headers.size(); i++) { - memcpy(&init_data.get()[pos], &headers[i].raw_box[0], + memcpy(&init_data[pos], &headers[i].raw_box[0], headers[i].raw_box.size()); pos += headers[i].raw_box.size(); } - need_key_cb_.Run(kMp4InitDataType, init_data.Pass(), total_size); + need_key_cb_.Run(kMp4InitDataType, init_data); } bool MP4StreamParser::PrepareAVCBuffer( diff --git a/media/mp4/mp4_stream_parser_unittest.cc b/media/mp4/mp4_stream_parser_unittest.cc index fa880ac..816a210 100644 --- a/media/mp4/mp4_stream_parser_unittest.cc +++ b/media/mp4/mp4_stream_parser_unittest.cc @@ -94,11 +94,10 @@ class MP4StreamParserTest : public testing::Test { } void KeyNeededF(const std::string& type, - scoped_ptr init_data, int init_data_size) { - DVLOG(1) << "KeyNeededF: " << init_data_size; + const std::vector& init_data) { + DVLOG(1) << "KeyNeededF: " << init_data.size(); EXPECT_EQ(kMp4InitDataType, type); - EXPECT_TRUE(init_data.get()); - EXPECT_GT(init_data_size, 0); + EXPECT_FALSE(init_data.empty()); } scoped_ptr AddTextTrackF( -- cgit v1.1