OLD | NEW |
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 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 base::Bind(&KeyProvidingApp::OnResolveWithSession, | 226 base::Bind(&KeyProvidingApp::OnResolveWithSession, |
227 base::Unretained(this), | 227 base::Unretained(this), |
228 expected), | 228 expected), |
229 base::Bind( | 229 base::Bind( |
230 &KeyProvidingApp::OnReject, base::Unretained(this), expected))); | 230 &KeyProvidingApp::OnReject, base::Unretained(this), expected))); |
231 return promise.Pass(); | 231 return promise.Pass(); |
232 } | 232 } |
233 | 233 |
234 virtual void OnSessionMessage(const std::string& web_session_id, | 234 virtual void OnSessionMessage(const std::string& web_session_id, |
235 const std::vector<uint8>& message, | 235 const std::vector<uint8>& message, |
236 const GURL& destination_url) OVERRIDE { | 236 const GURL& destination_url) override { |
237 EXPECT_FALSE(web_session_id.empty()); | 237 EXPECT_FALSE(web_session_id.empty()); |
238 EXPECT_FALSE(message.empty()); | 238 EXPECT_FALSE(message.empty()); |
239 EXPECT_EQ(current_session_id_, web_session_id); | 239 EXPECT_EQ(current_session_id_, web_session_id); |
240 } | 240 } |
241 | 241 |
242 virtual void OnSessionClosed(const std::string& web_session_id) OVERRIDE { | 242 virtual void OnSessionClosed(const std::string& web_session_id) override { |
243 EXPECT_EQ(current_session_id_, web_session_id); | 243 EXPECT_EQ(current_session_id_, web_session_id); |
244 } | 244 } |
245 | 245 |
246 virtual void OnSessionKeysChange(const std::string& web_session_id, | 246 virtual void OnSessionKeysChange(const std::string& web_session_id, |
247 bool has_additional_usable_key) OVERRIDE { | 247 bool has_additional_usable_key) override { |
248 EXPECT_EQ(current_session_id_, web_session_id); | 248 EXPECT_EQ(current_session_id_, web_session_id); |
249 EXPECT_EQ(has_additional_usable_key, true); | 249 EXPECT_EQ(has_additional_usable_key, true); |
250 } | 250 } |
251 | 251 |
252 virtual void NeedKey(const std::string& type, | 252 virtual void NeedKey(const std::string& type, |
253 const std::vector<uint8>& init_data, | 253 const std::vector<uint8>& init_data, |
254 AesDecryptor* decryptor) OVERRIDE { | 254 AesDecryptor* decryptor) override { |
255 if (current_session_id_.empty()) { | 255 if (current_session_id_.empty()) { |
256 decryptor->CreateSession(type, | 256 decryptor->CreateSession(type, |
257 kInitData, | 257 kInitData, |
258 arraysize(kInitData), | 258 arraysize(kInitData), |
259 MediaKeys::TEMPORARY_SESSION, | 259 MediaKeys::TEMPORARY_SESSION, |
260 CreateSessionPromise(RESOLVED)); | 260 CreateSessionPromise(RESOLVED)); |
261 EXPECT_FALSE(current_session_id_.empty()); | 261 EXPECT_FALSE(current_session_id_.empty()); |
262 } | 262 } |
263 | 263 |
264 // Clear Key really needs the key ID in |init_data|. For WebM, they are the | 264 // Clear Key really needs the key ID in |init_data|. For WebM, they are the |
(...skipping 21 matching lines...) Expand all Loading... |
286 class RotatingKeyProvidingApp : public KeyProvidingApp { | 286 class RotatingKeyProvidingApp : public KeyProvidingApp { |
287 public: | 287 public: |
288 RotatingKeyProvidingApp() : num_distint_need_key_calls_(0) {} | 288 RotatingKeyProvidingApp() : num_distint_need_key_calls_(0) {} |
289 virtual ~RotatingKeyProvidingApp() { | 289 virtual ~RotatingKeyProvidingApp() { |
290 // Expect that NeedKey is fired multiple times with different |init_data|. | 290 // Expect that NeedKey is fired multiple times with different |init_data|. |
291 EXPECT_GT(num_distint_need_key_calls_, 1u); | 291 EXPECT_GT(num_distint_need_key_calls_, 1u); |
292 } | 292 } |
293 | 293 |
294 virtual void NeedKey(const std::string& type, | 294 virtual void NeedKey(const std::string& type, |
295 const std::vector<uint8>& init_data, | 295 const std::vector<uint8>& init_data, |
296 AesDecryptor* decryptor) OVERRIDE { | 296 AesDecryptor* decryptor) override { |
297 // Skip the request if the |init_data| has been seen. | 297 // Skip the request if the |init_data| has been seen. |
298 if (init_data == prev_init_data_) | 298 if (init_data == prev_init_data_) |
299 return; | 299 return; |
300 prev_init_data_ = init_data; | 300 prev_init_data_ = init_data; |
301 ++num_distint_need_key_calls_; | 301 ++num_distint_need_key_calls_; |
302 | 302 |
303 decryptor->CreateSession(type, | 303 decryptor->CreateSession(type, |
304 vector_as_array(&init_data), | 304 vector_as_array(&init_data), |
305 init_data.size(), | 305 init_data.size(), |
306 MediaKeys::TEMPORARY_SESSION, | 306 MediaKeys::TEMPORARY_SESSION, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 | 353 |
354 std::vector<uint8> prev_init_data_; | 354 std::vector<uint8> prev_init_data_; |
355 uint32 num_distint_need_key_calls_; | 355 uint32 num_distint_need_key_calls_; |
356 }; | 356 }; |
357 | 357 |
358 // Ignores needkey and does not perform a license request | 358 // Ignores needkey and does not perform a license request |
359 class NoResponseApp : public FakeEncryptedMedia::AppBase { | 359 class NoResponseApp : public FakeEncryptedMedia::AppBase { |
360 public: | 360 public: |
361 virtual void OnSessionMessage(const std::string& web_session_id, | 361 virtual void OnSessionMessage(const std::string& web_session_id, |
362 const std::vector<uint8>& message, | 362 const std::vector<uint8>& message, |
363 const GURL& default_url) OVERRIDE { | 363 const GURL& default_url) override { |
364 EXPECT_FALSE(web_session_id.empty()); | 364 EXPECT_FALSE(web_session_id.empty()); |
365 EXPECT_FALSE(message.empty()); | 365 EXPECT_FALSE(message.empty()); |
366 FAIL() << "Unexpected Message"; | 366 FAIL() << "Unexpected Message"; |
367 } | 367 } |
368 | 368 |
369 virtual void OnSessionClosed(const std::string& web_session_id) OVERRIDE { | 369 virtual void OnSessionClosed(const std::string& web_session_id) override { |
370 EXPECT_FALSE(web_session_id.empty()); | 370 EXPECT_FALSE(web_session_id.empty()); |
371 FAIL() << "Unexpected Closed"; | 371 FAIL() << "Unexpected Closed"; |
372 } | 372 } |
373 | 373 |
374 virtual void OnSessionKeysChange(const std::string& web_session_id, | 374 virtual void OnSessionKeysChange(const std::string& web_session_id, |
375 bool has_additional_usable_key) OVERRIDE { | 375 bool has_additional_usable_key) override { |
376 EXPECT_FALSE(web_session_id.empty()); | 376 EXPECT_FALSE(web_session_id.empty()); |
377 EXPECT_EQ(has_additional_usable_key, true); | 377 EXPECT_EQ(has_additional_usable_key, true); |
378 } | 378 } |
379 | 379 |
380 virtual void NeedKey(const std::string& type, | 380 virtual void NeedKey(const std::string& type, |
381 const std::vector<uint8>& init_data, | 381 const std::vector<uint8>& init_data, |
382 AesDecryptor* decryptor) OVERRIDE { | 382 AesDecryptor* decryptor) override { |
383 } | 383 } |
384 }; | 384 }; |
385 | 385 |
386 // Helper class that emulates calls made on the ChunkDemuxer by the | 386 // Helper class that emulates calls made on the ChunkDemuxer by the |
387 // Media Source API. | 387 // Media Source API. |
388 class MockMediaSource { | 388 class MockMediaSource { |
389 public: | 389 public: |
390 MockMediaSource(const std::string& filename, | 390 MockMediaSource(const std::string& filename, |
391 const std::string& mimetype, | 391 const std::string& mimetype, |
392 int initial_append_size) | 392 int initial_append_size) |
(...skipping 1214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1607 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { | 1607 TEST_F(PipelineIntegrationTest, BasicPlaybackPositiveStartTime) { |
1608 ASSERT_TRUE( | 1608 ASSERT_TRUE( |
1609 Start(GetTestDataFilePath("nonzero-start-time.webm"), PIPELINE_OK)); | 1609 Start(GetTestDataFilePath("nonzero-start-time.webm"), PIPELINE_OK)); |
1610 Play(); | 1610 Play(); |
1611 ASSERT_TRUE(WaitUntilOnEnded()); | 1611 ASSERT_TRUE(WaitUntilOnEnded()); |
1612 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), | 1612 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000), |
1613 demuxer_->GetStartTime()); | 1613 demuxer_->GetStartTime()); |
1614 } | 1614 } |
1615 | 1615 |
1616 } // namespace media | 1616 } // namespace media |
OLD | NEW |