Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: media/filters/pipeline_integration_test.cc

Issue 263003003: Add mp4 key rotation tests in pipeline integration test (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | media/test/data/README » ('j') | media/test/data/README » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/pipeline_integration_test_base.h" 5 #include "media/filters/pipeline_integration_test_base.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 std::string jwk = GenerateJWKSet( 241 std::string jwk = GenerateJWKSet(
242 kSecretKey, arraysize(kSecretKey), key_id, key_id_length); 242 kSecretKey, arraysize(kSecretKey), key_id, key_id_length);
243 decryptor->UpdateSession(current_session_id_, 243 decryptor->UpdateSession(current_session_id_,
244 reinterpret_cast<const uint8*>(jwk.data()), 244 reinterpret_cast<const uint8*>(jwk.data()),
245 jwk.size()); 245 jwk.size());
246 } 246 }
247 247
248 uint32 current_session_id_; 248 uint32 current_session_id_;
249 }; 249 };
250 250
251 class RotatingKeyProvidingApp : public KeyProvidingApp {
252 public:
253 virtual void NeedKey(const std::string& type,
254 const std::vector<uint8>& init_data,
255 AesDecryptor* decryptor) OVERRIDE {
256 EXPECT_TRUE(decryptor->CreateSession(current_session_id_ + 1,
xhwang 2014/05/09 04:52:24 It'll be nice to make sure NeedKey is fired multip
kqyang 2014/05/09 21:07:25 Done.
257 type,
258 vector_as_array(&init_data),
259 init_data.size()));
260
261 std::vector<uint8> key_id;
262 std::vector<uint8> key;
263 EXPECT_TRUE(GetKeyAndKeyId(init_data, &key, &key_id));
264
265 // Convert key into a JSON structure and then add it.
266 std::string jwk = GenerateJWKSet(vector_as_array(&key),
267 key.size(),
268 vector_as_array(&key_id),
269 key_id.size());
270 decryptor->UpdateSession(current_session_id_,
271 reinterpret_cast<const uint8*>(jwk.data()),
272 jwk.size());
273 }
274
275 private:
276 bool GetKeyAndKeyId(std::vector<uint8> init_data,
277 std::vector<uint8>* key,
278 std::vector<uint8>* key_id) {
279 // For WebM, init_data is key_id; for ISO CENC, init_data should contain
280 // the key_id. We assume key_id is in the end of init_data here (that is
281 // only a reasonable assumption for WebM and clear key ISO CENC).
282 DCHECK_GE(init_data.size(), arraysize(kKeyId));
283 std::vector<uint8> key_id_from_init_data(
284 init_data.end() - arraysize(kKeyId), init_data.end());
285
286 // The Key and KeyId for this testing key provider are created by rotating
287 // kSecretKey and kKeyId.
288 key->assign(kSecretKey, kSecretKey + arraysize(kSecretKey));
289 key_id->assign(kKeyId, kKeyId + arraysize(kKeyId));
290
291 // Find out the rotating position from |key_id_from_init_data| and apply on
292 // |key|.
293 for (size_t pos = 0; pos < arraysize(kKeyId); ++pos) {
294 std::rotate(key_id->begin(), key_id->begin() + pos, key_id->end());
xhwang 2014/05/09 04:52:24 This "rotate" and "key rotation" are two different
kqyang 2014/05/09 21:07:25 Done.
295 if (*key_id == key_id_from_init_data) {
296 std::rotate(key->begin(), key->begin() + pos, key->end());
297 return true;
298 }
299 }
300 return false;
301 }
302 };
303
251 // Ignores needkey and does not perform a license request 304 // Ignores needkey and does not perform a license request
252 class NoResponseApp : public FakeEncryptedMedia::AppBase { 305 class NoResponseApp : public FakeEncryptedMedia::AppBase {
253 public: 306 public:
254 virtual void OnSessionCreated(uint32 session_id, 307 virtual void OnSessionCreated(uint32 session_id,
255 const std::string& web_session_id) OVERRIDE { 308 const std::string& web_session_id) OVERRIDE {
256 EXPECT_GT(session_id, 0u); 309 EXPECT_GT(session_id, 0u);
257 EXPECT_FALSE(web_session_id.empty()); 310 EXPECT_FALSE(web_session_id.empty());
258 } 311 }
259 312
260 virtual void OnSessionMessage(uint32 session_id, 313 virtual void OnSessionMessage(uint32 session_id,
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs, 1003 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs,
951 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1004 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
952 1005
953 Play(); 1006 Play();
954 1007
955 EXPECT_TRUE(WaitUntilOnEnded()); 1008 EXPECT_TRUE(WaitUntilOnEnded());
956 source.Abort(); 1009 source.Abort();
957 Stop(); 1010 Stop();
958 } 1011 }
959 1012
1013 TEST_P(PipelineIntegrationTest,
1014 MediaSource_ConfigChange_Encrypted_MP4_CENC_KeyRotation_VideoOnly) {
1015 MockMediaSource source("bear-640x360-v_frag-cenc-key_rotation.mp4",
1016 kMP4Video, kAppendWholeFile, GetParam());
1017 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp());
1018 StartPipelineWithEncryptedMedia(&source, &encrypted_media);
1019
1020 scoped_refptr<DecoderBuffer> second_file =
1021 ReadTestDataFile("bear-1280x720-v_frag-cenc-key_rotation.mp4");
1022
1023 source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec),
1024 second_file->data(), second_file->data_size());
1025
1026 source.EndOfStream();
1027
1028 EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
1029 EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
1030 EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs,
1031 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1032
1033 Play();
1034
1035 EXPECT_TRUE(WaitUntilOnEnded());
1036 source.Abort();
1037 Stop();
1038 }
1039
960 // Config changes from clear to encrypted are not currently supported. 1040 // Config changes from clear to encrypted are not currently supported.
961 // TODO(ddorwin): Figure out why this CHECKs in AppendAtTime(). 1041 // TODO(ddorwin): Figure out why this CHECKs in AppendAtTime().
962 TEST_P(PipelineIntegrationTest, 1042 TEST_P(PipelineIntegrationTest,
963 DISABLED_MediaSource_ConfigChange_ClearThenEncrypted_MP4_CENC) { 1043 DISABLED_MediaSource_ConfigChange_ClearThenEncrypted_MP4_CENC) {
964 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4Video, 1044 MockMediaSource source("bear-640x360-av_frag.mp4", kMP4Video,
965 kAppendWholeFile, GetParam()); 1045 kAppendWholeFile, GetParam());
966 FakeEncryptedMedia encrypted_media(new KeyProvidingApp()); 1046 FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
967 StartPipelineWithEncryptedMedia(&source, &encrypted_media); 1047 StartPipelineWithEncryptedMedia(&source, &encrypted_media);
968 1048
969 scoped_refptr<DecoderBuffer> second_file = 1049 scoped_refptr<DecoderBuffer> second_file =
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 EXPECT_EQ(k1280IsoAVC3FileDurationMs, 1240 EXPECT_EQ(k1280IsoAVC3FileDurationMs,
1161 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds()); 1241 pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
1162 1242
1163 Play(); 1243 Play();
1164 1244
1165 ASSERT_TRUE(WaitUntilOnEnded()); 1245 ASSERT_TRUE(WaitUntilOnEnded());
1166 source.Abort(); 1246 source.Abort();
1167 Stop(); 1247 Stop();
1168 } 1248 }
1169 1249
1250 TEST_P(PipelineIntegrationTest, EncryptedPlayback_MP4_CENC_KeyRotation_Video) {
1251 MockMediaSource source("bear-1280x720-v_frag-cenc-key_rotation.mp4",
1252 kMP4Video, kAppendWholeFile, GetParam());
1253 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp());
1254 StartPipelineWithEncryptedMedia(&source, &encrypted_media);
1255
1256 source.EndOfStream();
1257 ASSERT_EQ(PIPELINE_OK, pipeline_status_);
1258
1259 Play();
1260
1261 ASSERT_TRUE(WaitUntilOnEnded());
1262 source.Abort();
1263 Stop();
1264 }
1265
1266 TEST_P(PipelineIntegrationTest, EncryptedPlayback_MP4_CENC_KeyRotation_Audio) {
1267 MockMediaSource source("bear-1280x720-a_frag-cenc-key_rotation.mp4",
1268 kMP4Audio, kAppendWholeFile, GetParam());
1269 FakeEncryptedMedia encrypted_media(new RotatingKeyProvidingApp());
1270 StartPipelineWithEncryptedMedia(&source, &encrypted_media);
1271
1272 source.EndOfStream();
1273 ASSERT_EQ(PIPELINE_OK, pipeline_status_);
1274
1275 Play();
1276
1277 ASSERT_TRUE(WaitUntilOnEnded());
1278 source.Abort();
1279 Stop();
1280 }
1170 #endif 1281 #endif
1171 1282
1172 // TODO(acolwell): Fix flakiness http://crbug.com/117921 1283 // TODO(acolwell): Fix flakiness http://crbug.com/117921
1173 TEST_F(PipelineIntegrationTest, DISABLED_SeekWhilePaused) { 1284 TEST_F(PipelineIntegrationTest, DISABLED_SeekWhilePaused) {
1174 ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240.webm"), PIPELINE_OK)); 1285 ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240.webm"), PIPELINE_OK));
1175 1286
1176 base::TimeDelta duration(pipeline_->GetMediaDuration()); 1287 base::TimeDelta duration(pipeline_->GetMediaDuration());
1177 base::TimeDelta start_seek_time(duration / 4); 1288 base::TimeDelta start_seek_time(duration / 4);
1178 base::TimeDelta seek_time(duration * 3 / 4); 1289 base::TimeDelta seek_time(duration * 3 / 4);
1179 1290
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1282 Play(); 1393 Play();
1283 ASSERT_TRUE(WaitUntilOnEnded()); 1394 ASSERT_TRUE(WaitUntilOnEnded());
1284 } 1395 }
1285 1396
1286 // TODO(wolenetz): Enable MSE testing of new frame processor based on this flag, 1397 // TODO(wolenetz): Enable MSE testing of new frame processor based on this flag,
1287 // once the new processor has landed. See http://crbug.com/249422. 1398 // once the new processor has landed. See http://crbug.com/249422.
1288 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, PipelineIntegrationTest, 1399 INSTANTIATE_TEST_CASE_P(LegacyFrameProcessor, PipelineIntegrationTest,
1289 Values(true)); 1400 Values(true));
1290 1401
1291 } // namespace media 1402 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/test/data/README » ('j') | media/test/data/README » ('J')

Powered by Google App Engine
This is Rietveld 408576698