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
3 // found in the LICENSE file.
6 #include "base/command_line.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "base/stl_util.h"
9 #include "base/strings/string_util.h"
10 #include "build/build_config.h"
11 #include "media/base/cdm_callback_promise.h"
12 #include "media/base/cdm_context.h"
13 #include "media/base/cdm_key_information.h"
14 #include "media/base/decoder_buffer.h"
15 #include "media/base/media.h"
16 #include "media/base/media_keys.h"
17 #include "media/base/media_switches.h"
18 #include "media/base/test_data_util.h"
19 #include "media/cdm/aes_decryptor.h"
20 #include "media/cdm/json_web_key.h"
21 #include "media/filters/chunk_demuxer.h"
22 #include "media/renderers/renderer_impl.h"
23 #include "media/test/pipeline_integration_test_base.h"
24 #include "testing/gmock/include/gmock/gmock.h"
27 #if defined(MOJO_RENDERER)
28 #include "media/mojo/services/mojo_renderer_impl.h"
29 #include "mojo/application/public/cpp/application_impl.h"
30 #include "mojo/application/public/cpp/application_test_base.h"
31 #include "mojo/application/public/cpp/connect.h"
33 // TODO(dalecurtis): The mojo renderer is in another process, so we have no way
34 // currently to get hashes for video and audio samples. This also means that
35 // real audio plays out for each test.
36 #define EXPECT_HASH_EQ(a, b)
37 #define EXPECT_VIDEO_FORMAT_EQ(a, b)
39 // TODO(xhwang): EME support is not complete for the mojo renderer, so all
40 // encrypted tests are currently disabled.
41 #define DISABLE_EME_TESTS 1
43 // TODO(xhwang,dalecurtis): Text tracks are not currently supported by the mojo
45 #define DISABLE_TEXT_TRACK_TESTS 1
47 #define EXPECT_HASH_EQ(a, b) EXPECT_EQ(a, b)
48 #define EXPECT_VIDEO_FORMAT_EQ(a, b) EXPECT_EQ(a, b)
52 using testing::AnyNumber
;
53 using testing::AtLeast
;
54 using testing::AtMost
;
55 using testing::SaveArg
;
59 const char kSourceId
[] = "SourceId";
61 const char kWebM
[] = "video/webm; codecs=\"vp8,vorbis\"";
62 const char kWebMVP9
[] = "video/webm; codecs=\"vp9\"";
63 const char kAudioOnlyWebM
[] = "video/webm; codecs=\"vorbis\"";
64 const char kOpusAudioOnlyWebM
[] = "video/webm; codecs=\"opus\"";
65 const char kVideoOnlyWebM
[] = "video/webm; codecs=\"vp8\"";
66 #if defined(USE_PROPRIETARY_CODECS)
67 const char kADTS
[] = "audio/aac";
68 const char kMP4
[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\"";
69 const char kMP4VideoAVC3
[] = "video/mp4; codecs=\"avc3.64001f\"";
70 #if !defined(DISABLE_EME_TESTS)
71 const char kMP4Video
[] = "video/mp4; codecs=\"avc1.4D4041\"";
72 const char kMP4Audio
[] = "audio/mp4; codecs=\"mp4a.40.2\"";
73 #endif // !defined(DISABLE_EME_TESTS)
74 const char kMP3
[] = "audio/mpeg";
75 #endif // defined(USE_PROPRIETARY_CODECS)
77 // Key used to encrypt test files.
78 const uint8 kSecretKey
[] = {
79 0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
80 0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c
83 // The key ID for all encrypted files.
84 const uint8 kKeyId
[] = {
85 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
86 0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35
89 const int kAppendWholeFile
= -1;
91 // Constants for the Media Source config change tests.
92 const int kAppendTimeSec
= 1;
93 const int kAppendTimeMs
= kAppendTimeSec
* 1000;
94 const int k320WebMFileDurationMs
= 2736;
95 #if !defined(DISABLE_EME_TESTS)
96 const int k320EncWebMFileDurationMs
= 2737;
97 #endif // !defined(DISABLE_EME_TESTS)
98 const int k640WebMFileDurationMs
= 2749;
99 const int kOpusEndTrimmingWebMFileDurationMs
= 2741;
100 const int kVP9WebMFileDurationMs
= 2736;
101 const int kVP8AWebMFileDurationMs
= 2734;
103 #if defined(USE_PROPRIETARY_CODECS)
104 #if !defined(DISABLE_EME_TESTS)
105 const int k640IsoFileDurationMs
= 2737;
106 const int k640IsoCencFileDurationMs
= 2736;
107 #endif // !defined(DISABLE_EME_TESTS)
108 const int k1280IsoFileDurationMs
= 2736;
109 const int k1280IsoAVC3FileDurationMs
= 2736;
110 #endif // defined(USE_PROPRIETARY_CODECS)
112 // Return a timeline offset for bear-320x240-live.webm.
113 static base::Time
kLiveTimelineOffset() {
114 // The file contians the following UTC timeline offset:
115 // 2012-11-10 12:34:56.789123456
116 // Since base::Time only has a resolution of microseconds,
117 // construct a base::Time for 2012-11-10 12:34:56.789123.
118 base::Time::Exploded exploded_time
;
119 exploded_time
.year
= 2012;
120 exploded_time
.month
= 11;
121 exploded_time
.day_of_month
= 10;
122 exploded_time
.hour
= 12;
123 exploded_time
.minute
= 34;
124 exploded_time
.second
= 56;
125 exploded_time
.millisecond
= 789;
126 base::Time timeline_offset
= base::Time::FromUTCExploded(exploded_time
);
128 timeline_offset
+= base::TimeDelta::FromMicroseconds(123);
130 return timeline_offset
;
133 // FFmpeg only supports time a resolution of seconds so this
134 // helper function truncates a base::Time to seconds resolution.
135 static base::Time
TruncateToFFmpegTimeResolution(base::Time t
) {
136 base::Time::Exploded exploded_time
;
137 t
.UTCExplode(&exploded_time
);
138 exploded_time
.millisecond
= 0;
140 return base::Time::FromUTCExploded(exploded_time
);
143 // Note: Tests using this class only exercise the DecryptingDemuxerStream path.
144 // They do not exercise the Decrypting{Audio|Video}Decoder path.
145 class FakeEncryptedMedia
{
147 // Defines the behavior of the "app" that responds to EME events.
150 virtual ~AppBase() {}
152 virtual void OnSessionMessage(const std::string
& session_id
,
153 MediaKeys::MessageType message_type
,
154 const std::vector
<uint8
>& message
,
155 const GURL
& legacy_destination_url
) = 0;
157 virtual void OnSessionClosed(const std::string
& session_id
) = 0;
159 virtual void OnSessionKeysChange(const std::string
& session_id
,
160 bool has_additional_usable_key
,
161 CdmKeysInfo keys_info
) = 0;
163 // Errors are not expected unless overridden.
164 virtual void OnLegacySessionError(const std::string
& session_id
,
165 const std::string
& error_name
,
167 const std::string
& error_message
) {
168 FAIL() << "Unexpected Key Error";
171 virtual void OnEncryptedMediaInitData(EmeInitDataType init_data_type
,
172 const std::vector
<uint8
>& init_data
,
173 AesDecryptor
* decryptor
) = 0;
176 FakeEncryptedMedia(AppBase
* app
)
177 : decryptor_(GURL::EmptyGURL(),
178 base::Bind(&FakeEncryptedMedia::OnSessionMessage
,
179 base::Unretained(this)),
180 base::Bind(&FakeEncryptedMedia::OnSessionClosed
,
181 base::Unretained(this)),
182 base::Bind(&FakeEncryptedMedia::OnSessionKeysChange
,
183 base::Unretained(this))),
184 cdm_context_(&decryptor_
),
187 CdmContext
* GetCdmContext() { return &cdm_context_
; }
189 // Callbacks for firing session events. Delegate to |app_|.
190 void OnSessionMessage(const std::string
& session_id
,
191 MediaKeys::MessageType message_type
,
192 const std::vector
<uint8
>& message
,
193 const GURL
& legacy_destination_url
) {
194 app_
->OnSessionMessage(session_id
, message_type
, message
,
195 legacy_destination_url
);
198 void OnSessionClosed(const std::string
& session_id
) {
199 app_
->OnSessionClosed(session_id
);
202 void OnSessionKeysChange(const std::string
& session_id
,
203 bool has_additional_usable_key
,
204 CdmKeysInfo keys_info
) {
205 app_
->OnSessionKeysChange(session_id
, has_additional_usable_key
,
209 void OnLegacySessionError(const std::string
& session_id
,
210 const std::string
& error_name
,
212 const std::string
& error_message
) {
213 app_
->OnLegacySessionError(session_id
, error_name
, system_code
,
217 void OnEncryptedMediaInitData(EmeInitDataType init_data_type
,
218 const std::vector
<uint8
>& init_data
) {
219 app_
->OnEncryptedMediaInitData(init_data_type
, init_data
, &decryptor_
);
223 class TestCdmContext
: public CdmContext
{
225 TestCdmContext(Decryptor
* decryptor
) : decryptor_(decryptor
) {}
227 Decryptor
* GetDecryptor() final
{ return decryptor_
; }
228 int GetCdmId() const final
{ return kInvalidCdmId
; }
231 Decryptor
* decryptor_
;
234 AesDecryptor decryptor_
;
235 TestCdmContext cdm_context_
;
236 scoped_ptr
<AppBase
> app_
;
239 enum PromiseResult
{ RESOLVED
, REJECTED
};
241 // Provides |kSecretKey| in response to needkey.
242 class KeyProvidingApp
: public FakeEncryptedMedia::AppBase
{
246 void OnResolveWithSession(PromiseResult expected
,
247 const std::string
& session_id
) {
248 EXPECT_EQ(expected
, RESOLVED
);
249 EXPECT_GT(session_id
.length(), 0ul);
250 current_session_id_
= session_id
;
253 void OnResolve(PromiseResult expected
) {
254 EXPECT_EQ(expected
, RESOLVED
);
257 void OnReject(PromiseResult expected
,
258 media::MediaKeys::Exception exception_code
,
260 const std::string
& error_message
) {
261 EXPECT_EQ(expected
, REJECTED
) << error_message
;
264 scoped_ptr
<SimpleCdmPromise
> CreatePromise(PromiseResult expected
) {
265 scoped_ptr
<media::SimpleCdmPromise
> promise(new media::CdmCallbackPromise
<>(
267 &KeyProvidingApp::OnResolve
, base::Unretained(this), expected
),
269 &KeyProvidingApp::OnReject
, base::Unretained(this), expected
)));
270 return promise
.Pass();
273 scoped_ptr
<NewSessionCdmPromise
> CreateSessionPromise(
274 PromiseResult expected
) {
275 scoped_ptr
<media::NewSessionCdmPromise
> promise(
276 new media::CdmCallbackPromise
<std::string
>(
277 base::Bind(&KeyProvidingApp::OnResolveWithSession
,
278 base::Unretained(this),
281 &KeyProvidingApp::OnReject
, base::Unretained(this), expected
)));
282 return promise
.Pass();
285 void OnSessionMessage(const std::string
& session_id
,
286 MediaKeys::MessageType message_type
,
287 const std::vector
<uint8
>& message
,
288 const GURL
& legacy_destination_url
) override
{
289 EXPECT_FALSE(session_id
.empty());
290 EXPECT_FALSE(message
.empty());
291 EXPECT_EQ(current_session_id_
, session_id
);
294 void OnSessionClosed(const std::string
& session_id
) override
{
295 EXPECT_EQ(current_session_id_
, session_id
);
298 void OnSessionKeysChange(const std::string
& session_id
,
299 bool has_additional_usable_key
,
300 CdmKeysInfo keys_info
) override
{
301 EXPECT_EQ(current_session_id_
, session_id
);
302 EXPECT_EQ(has_additional_usable_key
, true);
305 void OnEncryptedMediaInitData(EmeInitDataType init_data_type
,
306 const std::vector
<uint8
>& init_data
,
307 AesDecryptor
* decryptor
) override
{
308 // Since only 1 session is created, skip the request if the |init_data|
309 // has been seen before (no need to add the same key again).
310 if (init_data
== prev_init_data_
)
312 prev_init_data_
= init_data
;
314 if (current_session_id_
.empty()) {
315 if (init_data_type
== EmeInitDataType::CENC
) {
316 // Since the 'cenc' files are not created with proper 'pssh' boxes,
317 // simply pretend that this is a webm file and pass the expected
318 // key ID as the init_data.
319 // http://crbug.com/460308
320 decryptor
->CreateSessionAndGenerateRequest(
321 MediaKeys::TEMPORARY_SESSION
, EmeInitDataType::WEBM
,
322 std::vector
<uint8
>(kKeyId
, kKeyId
+ arraysize(kKeyId
)),
323 CreateSessionPromise(RESOLVED
));
325 decryptor
->CreateSessionAndGenerateRequest(
326 MediaKeys::TEMPORARY_SESSION
, init_data_type
, init_data
,
327 CreateSessionPromise(RESOLVED
));
329 EXPECT_FALSE(current_session_id_
.empty());
332 // Clear Key really needs the key ID from |init_data|. For WebM, they are
333 // the same, but this is not the case for ISO CENC (key ID embedded in a
334 // 'pssh' box). Therefore, provide the correct key ID.
335 const uint8
* key_id
= vector_as_array(&init_data
);
336 size_t key_id_length
= init_data
.size();
337 if (init_data_type
== EmeInitDataType::CENC
) {
339 key_id_length
= arraysize(kKeyId
);
342 // Convert key into a JSON structure and then add it.
343 std::string jwk
= GenerateJWKSet(
344 kSecretKey
, arraysize(kSecretKey
), key_id
, key_id_length
);
345 decryptor
->UpdateSession(current_session_id_
,
346 std::vector
<uint8
>(jwk
.begin(), jwk
.end()),
347 CreatePromise(RESOLVED
));
350 std::string current_session_id_
;
351 std::vector
<uint8
> prev_init_data_
;
354 class RotatingKeyProvidingApp
: public KeyProvidingApp
{
356 RotatingKeyProvidingApp() : num_distint_need_key_calls_(0) {}
357 ~RotatingKeyProvidingApp() override
{
358 // Expect that OnEncryptedMediaInitData is fired multiple times with
359 // different |init_data|.
360 EXPECT_GT(num_distint_need_key_calls_
, 1u);
363 void OnEncryptedMediaInitData(EmeInitDataType init_data_type
,
364 const std::vector
<uint8
>& init_data
,
365 AesDecryptor
* decryptor
) override
{
366 // Skip the request if the |init_data| has been seen.
367 if (init_data
== prev_init_data_
)
369 prev_init_data_
= init_data
;
370 ++num_distint_need_key_calls_
;
372 std::vector
<uint8
> key_id
;
373 std::vector
<uint8
> key
;
374 EXPECT_TRUE(GetKeyAndKeyId(init_data
, &key
, &key_id
));
376 if (init_data_type
== EmeInitDataType::CENC
) {
377 // Since the 'cenc' files are not created with proper 'pssh' boxes,
378 // simply pretend that this is a webm file and pass the expected
379 // key ID as the init_data.
380 // http://crbug.com/460308
381 decryptor
->CreateSessionAndGenerateRequest(
382 MediaKeys::TEMPORARY_SESSION
, EmeInitDataType::WEBM
, key_id
,
383 CreateSessionPromise(RESOLVED
));
385 decryptor
->CreateSessionAndGenerateRequest(
386 MediaKeys::TEMPORARY_SESSION
, init_data_type
, init_data
,
387 CreateSessionPromise(RESOLVED
));
390 // Convert key into a JSON structure and then add it.
391 std::string jwk
= GenerateJWKSet(vector_as_array(&key
),
393 vector_as_array(&key_id
),
395 decryptor
->UpdateSession(current_session_id_
,
396 std::vector
<uint8
>(jwk
.begin(), jwk
.end()),
397 CreatePromise(RESOLVED
));
401 bool GetKeyAndKeyId(std::vector
<uint8
> init_data
,
402 std::vector
<uint8
>* key
,
403 std::vector
<uint8
>* key_id
) {
404 // For WebM, init_data is key_id; for ISO CENC, init_data should contain
405 // the key_id. We assume key_id is in the end of init_data here (that is
406 // only a reasonable assumption for WebM and clear key ISO CENC).
407 DCHECK_GE(init_data
.size(), arraysize(kKeyId
));
408 std::vector
<uint8
> key_id_from_init_data(
409 init_data
.end() - arraysize(kKeyId
), init_data
.end());
411 key
->assign(kSecretKey
, kSecretKey
+ arraysize(kSecretKey
));
412 key_id
->assign(kKeyId
, kKeyId
+ arraysize(kKeyId
));
414 // The Key and KeyId for this testing key provider are created by left
415 // rotating kSecretKey and kKeyId. Note that this implementation is only
416 // intended for testing purpose. The actual key rotation algorithm can be
417 // much more complicated.
418 // Find out the rotating position from |key_id_from_init_data| and apply on
420 for (size_t pos
= 0; pos
< arraysize(kKeyId
); ++pos
) {
421 std::rotate(key_id
->begin(), key_id
->begin() + pos
, key_id
->end());
422 if (*key_id
== key_id_from_init_data
) {
423 std::rotate(key
->begin(), key
->begin() + pos
, key
->end());
430 std::vector
<uint8
> prev_init_data_
;
431 uint32 num_distint_need_key_calls_
;
434 // Ignores needkey and does not perform a license request
435 class NoResponseApp
: public FakeEncryptedMedia::AppBase
{
437 void OnSessionMessage(const std::string
& session_id
,
438 MediaKeys::MessageType message_type
,
439 const std::vector
<uint8
>& message
,
440 const GURL
& legacy_destination_url
) override
{
441 EXPECT_FALSE(session_id
.empty());
442 EXPECT_FALSE(message
.empty());
443 FAIL() << "Unexpected Message";
446 void OnSessionClosed(const std::string
& session_id
) override
{
447 EXPECT_FALSE(session_id
.empty());
448 FAIL() << "Unexpected Closed";
451 void OnSessionKeysChange(const std::string
& session_id
,
452 bool has_additional_usable_key
,
453 CdmKeysInfo keys_info
) override
{
454 EXPECT_FALSE(session_id
.empty());
455 EXPECT_EQ(has_additional_usable_key
, true);
458 void OnEncryptedMediaInitData(EmeInitDataType init_data_type
,
459 const std::vector
<uint8
>& init_data
,
460 AesDecryptor
* decryptor
) override
{}
463 // Helper class that emulates calls made on the ChunkDemuxer by the
465 class MockMediaSource
{
467 MockMediaSource(const std::string
& filename
,
468 const std::string
& mimetype
,
469 int initial_append_size
)
470 : current_position_(0),
471 initial_append_size_(initial_append_size
),
473 chunk_demuxer_(new ChunkDemuxer(
474 base::Bind(&MockMediaSource::DemuxerOpened
, base::Unretained(this)),
475 base::Bind(&MockMediaSource::OnEncryptedMediaInitData
,
476 base::Unretained(this)),
478 scoped_refptr
<MediaLog
>(new MediaLog()),
480 owned_chunk_demuxer_(chunk_demuxer_
) {
481 file_data_
= ReadTestDataFile(filename
);
483 if (initial_append_size_
== kAppendWholeFile
)
484 initial_append_size_
= file_data_
->data_size();
486 DCHECK_GT(initial_append_size_
, 0);
487 DCHECK_LE(initial_append_size_
, file_data_
->data_size());
490 virtual ~MockMediaSource() {}
492 scoped_ptr
<Demuxer
> GetDemuxer() { return owned_chunk_demuxer_
.Pass(); }
494 void set_encrypted_media_init_data_cb(
495 const Demuxer::EncryptedMediaInitDataCB
& encrypted_media_init_data_cb
) {
496 encrypted_media_init_data_cb_
= encrypted_media_init_data_cb
;
499 void Seek(base::TimeDelta seek_time
, int new_position
, int seek_append_size
) {
500 chunk_demuxer_
->StartWaitingForSeek(seek_time
);
502 chunk_demuxer_
->Abort(
504 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_
);
506 DCHECK_GE(new_position
, 0);
507 DCHECK_LT(new_position
, file_data_
->data_size());
508 current_position_
= new_position
;
510 AppendData(seek_append_size
);
513 void AppendData(int size
) {
514 DCHECK(chunk_demuxer_
);
515 DCHECK_LT(current_position_
, file_data_
->data_size());
516 DCHECK_LE(current_position_
+ size
, file_data_
->data_size());
518 chunk_demuxer_
->AppendData(
519 kSourceId
, file_data_
->data() + current_position_
, size
,
520 base::TimeDelta(), kInfiniteDuration(), &last_timestamp_offset_
,
521 base::Bind(&MockMediaSource::InitSegmentReceived
,
522 base::Unretained(this)));
523 current_position_
+= size
;
526 void AppendAtTime(base::TimeDelta timestamp_offset
,
529 CHECK(!chunk_demuxer_
->IsParsingMediaSegment(kSourceId
));
530 chunk_demuxer_
->AppendData(kSourceId
, pData
, size
,
531 base::TimeDelta(), kInfiniteDuration(),
533 base::Bind(&MockMediaSource::InitSegmentReceived
,
534 base::Unretained(this)));
535 last_timestamp_offset_
= timestamp_offset
;
538 void AppendAtTimeWithWindow(base::TimeDelta timestamp_offset
,
539 base::TimeDelta append_window_start
,
540 base::TimeDelta append_window_end
,
543 CHECK(!chunk_demuxer_
->IsParsingMediaSegment(kSourceId
));
544 chunk_demuxer_
->AppendData(kSourceId
,
550 base::Bind(&MockMediaSource::InitSegmentReceived
,
551 base::Unretained(this)));
552 last_timestamp_offset_
= timestamp_offset
;
556 chunk_demuxer_
->MarkEndOfStream(PIPELINE_OK
);
562 chunk_demuxer_
->Shutdown();
563 chunk_demuxer_
= NULL
;
566 void DemuxerOpened() {
567 base::MessageLoop::current()->PostTask(
568 FROM_HERE
, base::Bind(&MockMediaSource::DemuxerOpenedTask
,
569 base::Unretained(this)));
572 void DemuxerOpenedTask() {
573 // This code assumes that |mimetype_| is one of the following forms.
575 // 2. video/webm;codec="vorbis,vp8".
576 size_t semicolon
= mimetype_
.find(";");
577 std::string type
= mimetype_
;
578 std::vector
<std::string
> codecs
;
579 if (semicolon
!= std::string::npos
) {
580 type
= mimetype_
.substr(0, semicolon
);
581 size_t codecs_param_start
= mimetype_
.find("codecs=\"", semicolon
);
583 CHECK_NE(codecs_param_start
, std::string::npos
);
585 codecs_param_start
+= 8; // Skip over the codecs=".
587 size_t codecs_param_end
= mimetype_
.find("\"", codecs_param_start
);
589 CHECK_NE(codecs_param_end
, std::string::npos
);
591 std::string codecs_param
=
592 mimetype_
.substr(codecs_param_start
,
593 codecs_param_end
- codecs_param_start
);
594 Tokenize(codecs_param
, ",", &codecs
);
597 CHECK_EQ(chunk_demuxer_
->AddId(kSourceId
, type
, codecs
), ChunkDemuxer::kOk
);
599 AppendData(initial_append_size_
);
602 void OnEncryptedMediaInitData(EmeInitDataType init_data_type
,
603 const std::vector
<uint8
>& init_data
) {
604 DCHECK(!init_data
.empty());
605 CHECK(!encrypted_media_init_data_cb_
.is_null());
606 encrypted_media_init_data_cb_
.Run(init_data_type
, init_data
);
609 base::TimeDelta
last_timestamp_offset() const {
610 return last_timestamp_offset_
;
613 MOCK_METHOD0(InitSegmentReceived
, void(void));
616 scoped_refptr
<DecoderBuffer
> file_data_
;
617 int current_position_
;
618 int initial_append_size_
;
619 std::string mimetype_
;
620 ChunkDemuxer
* chunk_demuxer_
;
621 scoped_ptr
<Demuxer
> owned_chunk_demuxer_
;
622 Demuxer::EncryptedMediaInitDataCB encrypted_media_init_data_cb_
;
623 base::TimeDelta last_timestamp_offset_
;
626 #if defined(MOJO_RENDERER)
627 class PipelineIntegrationTestHost
: public mojo::test::ApplicationTestBase
,
628 public PipelineIntegrationTestBase
{
630 bool ShouldCreateDefaultRunLoop() override
{ return false; }
632 void SetUp() override
{
633 ApplicationTestBase::SetUp();
634 if (!IsMediaLibraryInitialized())
635 InitializeMediaLibraryForTesting();
639 scoped_ptr
<Renderer
> CreateRenderer() override
{
640 mojo::URLRequestPtr
request(mojo::URLRequest::New());
641 request
->url
= mojo::String::From("mojo:media");
642 mojo::ServiceProvider
* service_provider
=
644 ->ConnectToApplication(request
.Pass())
645 ->GetServiceProvider();
647 mojo::MediaRendererPtr mojo_media_renderer
;
648 mojo::ConnectToService(service_provider
, &mojo_media_renderer
);
649 return make_scoped_ptr(new MojoRendererImpl(message_loop_
.task_runner(),
650 mojo_media_renderer
.Pass()));
654 class PipelineIntegrationTestHost
: public testing::Test
,
655 public PipelineIntegrationTestBase
{};
658 class PipelineIntegrationTest
: public PipelineIntegrationTestHost
{
660 void StartPipelineWithMediaSource(MockMediaSource
* source
) {
661 EXPECT_CALL(*source
, InitSegmentReceived()).Times(AtLeast(1));
662 EXPECT_CALL(*this, OnMetadata(_
))
664 .WillRepeatedly(SaveArg
<0>(&metadata_
));
665 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH
))
668 // Encrypted content not used, so this is never called.
669 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
671 demuxer_
= source
->GetDemuxer().Pass();
673 demuxer_
.get(), CreateRenderer(),
674 base::Bind(&PipelineIntegrationTest::OnEnded
, base::Unretained(this)),
675 base::Bind(&PipelineIntegrationTest::OnError
, base::Unretained(this)),
676 base::Bind(&PipelineIntegrationTest::OnStatusCallback
,
677 base::Unretained(this)),
678 base::Bind(&PipelineIntegrationTest::OnMetadata
,
679 base::Unretained(this)),
680 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged
,
681 base::Unretained(this)),
682 base::Closure(), base::Bind(&PipelineIntegrationTest::OnAddTextTrack
,
683 base::Unretained(this)),
684 base::Bind(&PipelineIntegrationTest::OnWaitingForDecryptionKey
,
685 base::Unretained(this)));
687 EXPECT_EQ(PIPELINE_OK
, pipeline_status_
);
690 void StartHashedPipelineWithMediaSource(MockMediaSource
* source
) {
691 hashing_enabled_
= true;
692 StartPipelineWithMediaSource(source
);
695 void StartPipelineWithEncryptedMedia(
696 MockMediaSource
* source
,
697 FakeEncryptedMedia
* encrypted_media
) {
698 EXPECT_CALL(*source
, InitSegmentReceived()).Times(AtLeast(1));
699 EXPECT_CALL(*this, OnMetadata(_
))
701 .WillRepeatedly(SaveArg
<0>(&metadata_
));
702 EXPECT_CALL(*this, OnBufferingStateChanged(BUFFERING_HAVE_ENOUGH
))
704 EXPECT_CALL(*this, DecryptorAttached(true));
706 // Encrypted content used but keys provided in advance, so this is
708 EXPECT_CALL(*this, OnWaitingForDecryptionKey()).Times(0);
710 demuxer_
= source
->GetDemuxer().Pass();
712 pipeline_
->SetCdm(encrypted_media
->GetCdmContext(),
713 base::Bind(&PipelineIntegrationTest::DecryptorAttached
,
714 base::Unretained(this)));
717 demuxer_
.get(), CreateRenderer(),
718 base::Bind(&PipelineIntegrationTest::OnEnded
, base::Unretained(this)),
719 base::Bind(&PipelineIntegrationTest::OnError
, base::Unretained(this)),
720 base::Bind(&PipelineIntegrationTest::OnStatusCallback
,
721 base::Unretained(this)),
722 base::Bind(&PipelineIntegrationTest::OnMetadata
,
723 base::Unretained(this)),
724 base::Bind(&PipelineIntegrationTest::OnBufferingStateChanged
,
725 base::Unretained(this)),
726 base::Closure(), base::Bind(&PipelineIntegrationTest::OnAddTextTrack
,
727 base::Unretained(this)),
728 base::Bind(&PipelineIntegrationTest::OnWaitingForDecryptionKey
,
729 base::Unretained(this)));
731 source
->set_encrypted_media_init_data_cb(
732 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData
,
733 base::Unretained(encrypted_media
)));
736 EXPECT_EQ(PIPELINE_OK
, pipeline_status_
);
739 // Verifies that seeking works properly for ChunkDemuxer when the
740 // seek happens while there is a pending read on the ChunkDemuxer
741 // and no data is available.
742 bool TestSeekDuringRead(const std::string
& filename
,
743 const std::string
& mimetype
,
744 int initial_append_size
,
745 base::TimeDelta start_seek_time
,
746 base::TimeDelta seek_time
,
747 int seek_file_position
,
748 int seek_append_size
) {
749 MockMediaSource
source(filename
, mimetype
, initial_append_size
);
750 StartPipelineWithMediaSource(&source
);
752 if (pipeline_status_
!= PIPELINE_OK
)
756 if (!WaitUntilCurrentTimeIsAfter(start_seek_time
))
759 source
.Seek(seek_time
, seek_file_position
, seek_append_size
);
760 if (!Seek(seek_time
))
763 source
.EndOfStream();
771 TEST_F(PipelineIntegrationTest
, BasicPlayback
) {
772 ASSERT_EQ(PIPELINE_OK
, Start("bear-320x240.webm"));
776 ASSERT_TRUE(WaitUntilOnEnded());
779 TEST_F(PipelineIntegrationTest
, BasicPlaybackOpusOgg
) {
780 ASSERT_EQ(PIPELINE_OK
, Start("bear-opus.ogg"));
784 ASSERT_TRUE(WaitUntilOnEnded());
787 TEST_F(PipelineIntegrationTest
, BasicPlaybackHashed
) {
788 ASSERT_EQ(PIPELINE_OK
, Start("bear-320x240.webm", kHashed
));
792 ASSERT_TRUE(WaitUntilOnEnded());
794 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash());
795 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash());
796 EXPECT_TRUE(demuxer_
->GetTimelineOffset().is_null());
799 TEST_F(PipelineIntegrationTest
, BasicPlaybackLive
) {
800 ASSERT_EQ(PIPELINE_OK
, Start("bear-320x240-live.webm", kHashed
));
804 ASSERT_TRUE(WaitUntilOnEnded());
806 EXPECT_HASH_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash());
807 EXPECT_HASH_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash());
809 // TODO: Fix FFmpeg code to return higher resolution time values so
810 // we don't have to truncate our expectations here.
811 EXPECT_EQ(TruncateToFFmpegTimeResolution(kLiveTimelineOffset()),
812 demuxer_
->GetTimelineOffset());
815 TEST_F(PipelineIntegrationTest
, F32PlaybackHashed
) {
816 ASSERT_EQ(PIPELINE_OK
, Start("sfx_f32le.wav", kHashed
));
818 ASSERT_TRUE(WaitUntilOnEnded());
819 EXPECT_HASH_EQ(std::string(kNullVideoHash
), GetVideoHash());
820 EXPECT_HASH_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash());
823 #if !defined(DISABLE_EME_TESTS)
824 TEST_F(PipelineIntegrationTest
, BasicPlaybackEncrypted
) {
825 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
826 set_encrypted_media_init_data_cb(
827 base::Bind(&FakeEncryptedMedia::OnEncryptedMediaInitData
,
828 base::Unretained(&encrypted_media
)));
830 ASSERT_EQ(PIPELINE_OK
, Start("bear-320x240-av_enc-av.webm",
831 encrypted_media
.GetCdmContext()));
835 ASSERT_TRUE(WaitUntilOnEnded());
838 #endif // !defined(DISABLE_EME_TESTS)
840 TEST_F(PipelineIntegrationTest
, BasicPlayback_MediaSource
) {
841 MockMediaSource
source("bear-320x240.webm", kWebM
, 219229);
842 StartPipelineWithMediaSource(&source
);
843 source
.EndOfStream();
845 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
846 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
847 EXPECT_EQ(k320WebMFileDurationMs
,
848 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
852 ASSERT_TRUE(WaitUntilOnEnded());
854 EXPECT_TRUE(demuxer_
->GetTimelineOffset().is_null());
859 TEST_F(PipelineIntegrationTest
, BasicPlayback_MediaSource_Live
) {
860 MockMediaSource
source("bear-320x240-live.webm", kWebM
, 219221);
861 StartPipelineWithMediaSource(&source
);
862 source
.EndOfStream();
864 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
865 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
866 EXPECT_EQ(k320WebMFileDurationMs
,
867 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
871 ASSERT_TRUE(WaitUntilOnEnded());
873 EXPECT_EQ(kLiveTimelineOffset(),
874 demuxer_
->GetTimelineOffset());
879 TEST_F(PipelineIntegrationTest
, BasicPlayback_MediaSource_VP9_WebM
) {
880 MockMediaSource
source("bear-vp9.webm", kWebMVP9
, 67504);
881 StartPipelineWithMediaSource(&source
);
882 source
.EndOfStream();
884 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
885 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
886 EXPECT_EQ(kVP9WebMFileDurationMs
,
887 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
891 ASSERT_TRUE(WaitUntilOnEnded());
896 TEST_F(PipelineIntegrationTest
, BasicPlayback_MediaSource_VP8A_WebM
) {
897 MockMediaSource
source("bear-vp8a.webm", kVideoOnlyWebM
, kAppendWholeFile
);
898 StartPipelineWithMediaSource(&source
);
899 source
.EndOfStream();
901 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
902 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
903 EXPECT_EQ(kVP8AWebMFileDurationMs
,
904 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
908 ASSERT_TRUE(WaitUntilOnEnded());
913 TEST_F(PipelineIntegrationTest
, BasicPlayback_MediaSource_Opus_WebM
) {
914 MockMediaSource
source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM
,
916 StartPipelineWithMediaSource(&source
);
917 source
.EndOfStream();
919 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
920 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
921 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs
,
922 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
925 ASSERT_TRUE(WaitUntilOnEnded());
930 // Flaky. http://crbug.com/304776
931 TEST_F(PipelineIntegrationTest
, DISABLED_MediaSource_Opus_Seeking_WebM
) {
932 MockMediaSource
source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM
,
934 StartHashedPipelineWithMediaSource(&source
);
936 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
937 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
938 EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs
,
939 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
941 base::TimeDelta start_seek_time
= base::TimeDelta::FromMilliseconds(1000);
942 base::TimeDelta seek_time
= base::TimeDelta::FromMilliseconds(2000);
945 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time
));
946 source
.Seek(seek_time
, 0x1D5, 34017);
947 source
.EndOfStream();
948 ASSERT_TRUE(Seek(seek_time
));
950 ASSERT_TRUE(WaitUntilOnEnded());
952 EXPECT_HASH_EQ("0.76,0.20,-0.82,-0.58,-1.29,-0.29,", GetAudioHash());
958 TEST_F(PipelineIntegrationTest
, MediaSource_ConfigChange_WebM
) {
959 MockMediaSource
source("bear-320x240-16x9-aspect.webm", kWebM
,
961 StartPipelineWithMediaSource(&source
);
963 scoped_refptr
<DecoderBuffer
> second_file
=
964 ReadTestDataFile("bear-640x360.webm");
966 source
.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec
),
967 second_file
->data(), second_file
->data_size());
969 source
.EndOfStream();
971 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
972 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
973 EXPECT_EQ(kAppendTimeMs
+ k640WebMFileDurationMs
,
974 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
978 EXPECT_TRUE(WaitUntilOnEnded());
983 #if !defined(DISABLE_EME_TESTS)
984 TEST_F(PipelineIntegrationTest
, MediaSource_ConfigChange_Encrypted_WebM
) {
985 MockMediaSource
source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM
,
987 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
988 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
990 scoped_refptr
<DecoderBuffer
> second_file
=
991 ReadTestDataFile("bear-640x360-av_enc-av.webm");
993 source
.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec
),
994 second_file
->data(), second_file
->data_size());
996 source
.EndOfStream();
998 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
999 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1000 EXPECT_EQ(kAppendTimeMs
+ k640WebMFileDurationMs
,
1001 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1005 EXPECT_TRUE(WaitUntilOnEnded());
1010 // Config changes from encrypted to clear are not currently supported.
1011 TEST_F(PipelineIntegrationTest
,
1012 MediaSource_ConfigChange_ClearThenEncrypted_WebM
) {
1013 MockMediaSource
source("bear-320x240-16x9-aspect.webm", kWebM
,
1015 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
1016 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1018 scoped_refptr
<DecoderBuffer
> second_file
=
1019 ReadTestDataFile("bear-640x360-av_enc-av.webm");
1021 source
.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec
),
1022 second_file
->data(), second_file
->data_size());
1024 source
.EndOfStream();
1026 message_loop_
.Run();
1027 EXPECT_EQ(PIPELINE_ERROR_DECODE
, pipeline_status_
);
1029 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1030 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1031 // The second video was not added, so its time has not been added.
1032 EXPECT_EQ(k320WebMFileDurationMs
,
1033 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1037 EXPECT_EQ(PIPELINE_ERROR_DECODE
, WaitUntilEndedOrError());
1041 // Config changes from clear to encrypted are not currently supported.
1042 TEST_F(PipelineIntegrationTest
,
1043 MediaSource_ConfigChange_EncryptedThenClear_WebM
) {
1044 MockMediaSource
source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM
,
1046 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
1047 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1049 scoped_refptr
<DecoderBuffer
> second_file
=
1050 ReadTestDataFile("bear-640x360.webm");
1052 source
.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec
),
1053 second_file
->data(), second_file
->data_size());
1055 source
.EndOfStream();
1057 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1058 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1059 // The second video was not added, so its time has not been added.
1060 EXPECT_EQ(k320EncWebMFileDurationMs
,
1061 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1065 EXPECT_EQ(PIPELINE_ERROR_DECODE
, WaitUntilEndedOrError());
1068 #endif // !defined(DISABLE_EME_TESTS)
1070 #if defined(USE_PROPRIETARY_CODECS)
1071 TEST_F(PipelineIntegrationTest
, MediaSource_ADTS
) {
1072 MockMediaSource
source("sfx.adts", kADTS
, kAppendWholeFile
);
1073 StartPipelineWithMediaSource(&source
);
1074 source
.EndOfStream();
1076 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1077 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1078 EXPECT_EQ(325, pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1082 EXPECT_TRUE(WaitUntilOnEnded());
1085 TEST_F(PipelineIntegrationTest
, MediaSource_ADTS_TimestampOffset
) {
1086 MockMediaSource
source("sfx.adts", kADTS
, kAppendWholeFile
);
1087 StartHashedPipelineWithMediaSource(&source
);
1088 EXPECT_EQ(325, source
.last_timestamp_offset().InMilliseconds());
1090 // Trim off multiple frames off the beginning of the segment which will cause
1091 // the first decoded frame to be incorrect if preroll isn't implemented.
1092 const base::TimeDelta adts_preroll_duration
=
1093 base::TimeDelta::FromSecondsD(2.5 * 1024 / 44100);
1094 const base::TimeDelta append_time
=
1095 source
.last_timestamp_offset() - adts_preroll_duration
;
1097 scoped_refptr
<DecoderBuffer
> second_file
= ReadTestDataFile("sfx.adts");
1098 source
.AppendAtTimeWithWindow(append_time
,
1099 append_time
+ adts_preroll_duration
,
1100 kInfiniteDuration(),
1101 second_file
->data(),
1102 second_file
->data_size());
1103 source
.EndOfStream();
1105 EXPECT_EQ(592, source
.last_timestamp_offset().InMilliseconds());
1106 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1107 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1108 EXPECT_EQ(592, pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1112 EXPECT_TRUE(WaitUntilOnEnded());
1114 // Verify preroll is stripped.
1115 EXPECT_HASH_EQ("-0.06,0.97,-0.90,-0.70,-0.53,-0.34,", GetAudioHash());
1118 TEST_F(PipelineIntegrationTest
, BasicPlaybackHashed_MP3
) {
1119 ASSERT_EQ(PIPELINE_OK
, Start("sfx.mp3", kHashed
));
1123 ASSERT_TRUE(WaitUntilOnEnded());
1125 // Verify codec delay and preroll are stripped.
1126 EXPECT_HASH_EQ("1.30,2.72,4.56,5.08,3.74,2.03,", GetAudioHash());
1129 TEST_F(PipelineIntegrationTest
, MediaSource_MP3
) {
1130 MockMediaSource
source("sfx.mp3", kMP3
, kAppendWholeFile
);
1131 StartHashedPipelineWithMediaSource(&source
);
1132 source
.EndOfStream();
1134 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1135 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1136 EXPECT_EQ(313, pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1140 EXPECT_TRUE(WaitUntilOnEnded());
1142 // Verify that codec delay was stripped.
1143 EXPECT_HASH_EQ("1.01,2.71,4.18,4.32,3.04,1.12,", GetAudioHash());
1146 TEST_F(PipelineIntegrationTest
, MediaSource_MP3_TimestampOffset
) {
1147 MockMediaSource
source("sfx.mp3", kMP3
, kAppendWholeFile
);
1148 StartPipelineWithMediaSource(&source
);
1149 EXPECT_EQ(313, source
.last_timestamp_offset().InMilliseconds());
1151 // There are 576 silent frames at the start of this mp3. The second append
1152 // should trim them off.
1153 const base::TimeDelta mp3_preroll_duration
=
1154 base::TimeDelta::FromSecondsD(576.0 / 44100);
1155 const base::TimeDelta append_time
=
1156 source
.last_timestamp_offset() - mp3_preroll_duration
;
1158 scoped_refptr
<DecoderBuffer
> second_file
= ReadTestDataFile("sfx.mp3");
1159 source
.AppendAtTimeWithWindow(append_time
,
1160 append_time
+ mp3_preroll_duration
,
1161 kInfiniteDuration(),
1162 second_file
->data(),
1163 second_file
->data_size());
1164 source
.EndOfStream();
1166 EXPECT_EQ(613, source
.last_timestamp_offset().InMilliseconds());
1167 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1168 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1169 EXPECT_EQ(613, pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1173 EXPECT_TRUE(WaitUntilOnEnded());
1176 TEST_F(PipelineIntegrationTest
, MediaSource_MP3_Icecast
) {
1177 MockMediaSource
source("icy_sfx.mp3", kMP3
, kAppendWholeFile
);
1178 StartPipelineWithMediaSource(&source
);
1179 source
.EndOfStream();
1183 EXPECT_TRUE(WaitUntilOnEnded());
1186 TEST_F(PipelineIntegrationTest
, MediaSource_ConfigChange_MP4
) {
1187 MockMediaSource
source("bear-640x360-av_frag.mp4", kMP4
, kAppendWholeFile
);
1188 StartPipelineWithMediaSource(&source
);
1190 scoped_refptr
<DecoderBuffer
> second_file
=
1191 ReadTestDataFile("bear-1280x720-av_frag.mp4");
1193 source
.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec
),
1194 second_file
->data(), second_file
->data_size());
1196 source
.EndOfStream();
1198 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1199 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1200 EXPECT_EQ(kAppendTimeMs
+ k1280IsoFileDurationMs
,
1201 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1205 EXPECT_TRUE(WaitUntilOnEnded());
1210 #if !defined(DISABLE_EME_TESTS)
1211 TEST_F(PipelineIntegrationTest
,
1212 MediaSource_ConfigChange_Encrypted_MP4_CENC_VideoOnly
) {
1213 MockMediaSource
source("bear-640x360-v_frag-cenc.mp4", kMP4Video
,
1215 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
1216 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1218 scoped_refptr
<DecoderBuffer
> second_file
=
1219 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4");
1221 source
.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec
),
1222 second_file
->data(), second_file
->data_size());
1224 source
.EndOfStream();
1226 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1227 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1228 EXPECT_EQ(kAppendTimeMs
+ k1280IsoFileDurationMs
,
1229 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1233 EXPECT_TRUE(WaitUntilOnEnded());
1238 TEST_F(PipelineIntegrationTest
,
1239 MediaSource_ConfigChange_Encrypted_MP4_CENC_KeyRotation_VideoOnly
) {
1240 MockMediaSource
source("bear-640x360-v_frag-cenc-key_rotation.mp4", kMP4Video
,
1242 FakeEncryptedMedia
encrypted_media(new RotatingKeyProvidingApp());
1243 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1245 scoped_refptr
<DecoderBuffer
> second_file
=
1246 ReadTestDataFile("bear-1280x720-v_frag-cenc-key_rotation.mp4");
1248 source
.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec
),
1249 second_file
->data(), second_file
->data_size());
1251 source
.EndOfStream();
1253 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1254 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1255 EXPECT_EQ(kAppendTimeMs
+ k1280IsoFileDurationMs
,
1256 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1260 EXPECT_TRUE(WaitUntilOnEnded());
1265 // Config changes from clear to encrypted are not currently supported.
1266 // TODO(ddorwin): Figure out why this CHECKs in AppendAtTime().
1267 TEST_F(PipelineIntegrationTest
,
1268 DISABLED_MediaSource_ConfigChange_ClearThenEncrypted_MP4_CENC
) {
1269 MockMediaSource
source("bear-640x360-av_frag.mp4", kMP4Video
,
1271 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
1272 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1274 scoped_refptr
<DecoderBuffer
> second_file
=
1275 ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4");
1277 source
.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec
),
1278 second_file
->data(), second_file
->data_size());
1280 source
.EndOfStream();
1282 message_loop_
.Run();
1283 EXPECT_EQ(PIPELINE_ERROR_DECODE
, pipeline_status_
);
1285 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1286 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1287 // The second video was not added, so its time has not been added.
1288 EXPECT_EQ(k640IsoFileDurationMs
,
1289 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1293 EXPECT_EQ(PIPELINE_ERROR_DECODE
, WaitUntilEndedOrError());
1297 // Config changes from encrypted to clear are not currently supported.
1298 TEST_F(PipelineIntegrationTest
,
1299 MediaSource_ConfigChange_EncryptedThenClear_MP4_CENC
) {
1300 MockMediaSource
source("bear-640x360-v_frag-cenc.mp4", kMP4Video
,
1302 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
1303 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1305 scoped_refptr
<DecoderBuffer
> second_file
=
1306 ReadTestDataFile("bear-1280x720-av_frag.mp4");
1308 source
.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec
),
1309 second_file
->data(), second_file
->data_size());
1311 source
.EndOfStream();
1313 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1314 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1315 // The second video was not added, so its time has not been added.
1316 EXPECT_EQ(k640IsoCencFileDurationMs
,
1317 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1321 EXPECT_EQ(PIPELINE_ERROR_DECODE
, WaitUntilEndedOrError());
1324 #endif // !defined(DISABLE_EME_TESTS)
1326 // Verify files which change configuration midstream fail gracefully.
1327 TEST_F(PipelineIntegrationTest
, MidStreamConfigChangesFail
) {
1328 ASSERT_EQ(PIPELINE_OK
, Start("midstream_config_change.mp3"));
1330 ASSERT_EQ(WaitUntilEndedOrError(), PIPELINE_ERROR_DECODE
);
1335 TEST_F(PipelineIntegrationTest
, BasicPlayback_16x9AspectRatio
) {
1336 ASSERT_EQ(PIPELINE_OK
, Start("bear-320x240-16x9-aspect.webm"));
1338 ASSERT_TRUE(WaitUntilOnEnded());
1341 #if !defined(DISABLE_EME_TESTS)
1342 TEST_F(PipelineIntegrationTest
, EncryptedPlayback_WebM
) {
1343 MockMediaSource
source("bear-320x240-av_enc-av.webm", kWebM
, 219816);
1344 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
1345 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1347 source
.EndOfStream();
1348 ASSERT_EQ(PIPELINE_OK
, pipeline_status_
);
1352 ASSERT_TRUE(WaitUntilOnEnded());
1357 TEST_F(PipelineIntegrationTest
, EncryptedPlayback_ClearStart_WebM
) {
1358 MockMediaSource
source("bear-320x240-av_enc-av_clear-1s.webm", kWebM
,
1360 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
1361 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1363 source
.EndOfStream();
1364 ASSERT_EQ(PIPELINE_OK
, pipeline_status_
);
1368 ASSERT_TRUE(WaitUntilOnEnded());
1373 TEST_F(PipelineIntegrationTest
, EncryptedPlayback_NoEncryptedFrames_WebM
) {
1374 MockMediaSource
source("bear-320x240-av_enc-av_clear-all.webm", kWebM
,
1376 FakeEncryptedMedia
encrypted_media(new NoResponseApp());
1377 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1379 source
.EndOfStream();
1380 ASSERT_EQ(PIPELINE_OK
, pipeline_status_
);
1384 ASSERT_TRUE(WaitUntilOnEnded());
1388 #endif // !defined(DISABLE_EME_TESTS)
1390 #if defined(USE_PROPRIETARY_CODECS)
1391 #if !defined(DISABLE_EME_TESTS)
1392 TEST_F(PipelineIntegrationTest
, EncryptedPlayback_MP4_CENC_VideoOnly
) {
1393 MockMediaSource
source("bear-1280x720-v_frag-cenc.mp4", kMP4Video
,
1395 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
1396 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1398 source
.EndOfStream();
1399 ASSERT_EQ(PIPELINE_OK
, pipeline_status_
);
1403 ASSERT_TRUE(WaitUntilOnEnded());
1408 TEST_F(PipelineIntegrationTest
, EncryptedPlayback_MP4_CENC_AudioOnly
) {
1409 MockMediaSource
source("bear-1280x720-a_frag-cenc.mp4", kMP4Audio
,
1411 FakeEncryptedMedia
encrypted_media(new KeyProvidingApp());
1412 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1414 source
.EndOfStream();
1415 ASSERT_EQ(PIPELINE_OK
, pipeline_status_
);
1419 ASSERT_TRUE(WaitUntilOnEnded());
1424 TEST_F(PipelineIntegrationTest
,
1425 EncryptedPlayback_NoEncryptedFrames_MP4_CENC_VideoOnly
) {
1426 MockMediaSource
source("bear-1280x720-v_frag-cenc_clear-all.mp4", kMP4Video
,
1428 FakeEncryptedMedia
encrypted_media(new NoResponseApp());
1429 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1431 source
.EndOfStream();
1432 ASSERT_EQ(PIPELINE_OK
, pipeline_status_
);
1436 ASSERT_TRUE(WaitUntilOnEnded());
1441 TEST_F(PipelineIntegrationTest
,
1442 EncryptedPlayback_NoEncryptedFrames_MP4_CENC_AudioOnly
) {
1443 MockMediaSource
source("bear-1280x720-a_frag-cenc_clear-all.mp4", kMP4Audio
,
1445 FakeEncryptedMedia
encrypted_media(new NoResponseApp());
1446 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1448 source
.EndOfStream();
1449 ASSERT_EQ(PIPELINE_OK
, pipeline_status_
);
1453 ASSERT_TRUE(WaitUntilOnEnded());
1458 TEST_F(PipelineIntegrationTest
, EncryptedPlayback_MP4_CENC_KeyRotation_Video
) {
1459 MockMediaSource
source("bear-1280x720-v_frag-cenc-key_rotation.mp4",
1460 kMP4Video
, kAppendWholeFile
);
1461 FakeEncryptedMedia
encrypted_media(new RotatingKeyProvidingApp());
1462 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1464 source
.EndOfStream();
1465 ASSERT_EQ(PIPELINE_OK
, pipeline_status_
);
1469 ASSERT_TRUE(WaitUntilOnEnded());
1474 TEST_F(PipelineIntegrationTest
, EncryptedPlayback_MP4_CENC_KeyRotation_Audio
) {
1475 MockMediaSource
source("bear-1280x720-a_frag-cenc-key_rotation.mp4",
1476 kMP4Audio
, kAppendWholeFile
);
1477 FakeEncryptedMedia
encrypted_media(new RotatingKeyProvidingApp());
1478 StartPipelineWithEncryptedMedia(&source
, &encrypted_media
);
1480 source
.EndOfStream();
1481 ASSERT_EQ(PIPELINE_OK
, pipeline_status_
);
1485 ASSERT_TRUE(WaitUntilOnEnded());
1489 #endif // !defined(DISABLE_EME_TESTS)
1491 TEST_F(PipelineIntegrationTest
, BasicPlayback_MediaSource_VideoOnly_MP4_AVC3
) {
1492 MockMediaSource
source("bear-1280x720-v_frag-avc3.mp4", kMP4VideoAVC3
,
1494 StartPipelineWithMediaSource(&source
);
1495 source
.EndOfStream();
1497 EXPECT_EQ(1u, pipeline_
->GetBufferedTimeRanges().size());
1498 EXPECT_EQ(0, pipeline_
->GetBufferedTimeRanges().start(0).InMilliseconds());
1499 EXPECT_EQ(k1280IsoAVC3FileDurationMs
,
1500 pipeline_
->GetBufferedTimeRanges().end(0).InMilliseconds());
1504 ASSERT_TRUE(WaitUntilOnEnded());
1508 #endif // defined(USE_PROPRIETARY_CODECS)
1510 TEST_F(PipelineIntegrationTest
, SeekWhilePaused
) {
1511 ASSERT_EQ(PIPELINE_OK
, Start("bear-320x240.webm"));
1513 base::TimeDelta
duration(pipeline_
->GetMediaDuration());
1514 base::TimeDelta
start_seek_time(duration
/ 4);
1515 base::TimeDelta
seek_time(duration
* 3 / 4);
1518 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time
));
1520 ASSERT_TRUE(Seek(seek_time
));
1521 EXPECT_EQ(seek_time
, pipeline_
->GetMediaTime());
1523 ASSERT_TRUE(WaitUntilOnEnded());
1525 // Make sure seeking after reaching the end works as expected.
1527 ASSERT_TRUE(Seek(seek_time
));
1528 EXPECT_EQ(seek_time
, pipeline_
->GetMediaTime());
1530 ASSERT_TRUE(WaitUntilOnEnded());
1533 TEST_F(PipelineIntegrationTest
, SeekWhilePlaying
) {
1534 ASSERT_EQ(PIPELINE_OK
, Start("bear-320x240.webm"));
1536 base::TimeDelta
duration(pipeline_
->GetMediaDuration());
1537 base::TimeDelta
start_seek_time(duration
/ 4);
1538 base::TimeDelta
seek_time(duration
* 3 / 4);
1541 ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time
));
1542 ASSERT_TRUE(Seek(seek_time
));
1543 EXPECT_GE(pipeline_
->GetMediaTime(), seek_time
);
1544 ASSERT_TRUE(WaitUntilOnEnded());
1546 // Make sure seeking after reaching the end works as expected.
1547 ASSERT_TRUE(Seek(seek_time
));
1548 EXPECT_GE(pipeline_
->GetMediaTime(), seek_time
);
1549 ASSERT_TRUE(WaitUntilOnEnded());
1552 #if defined(USE_PROPRIETARY_CODECS)
1553 TEST_F(PipelineIntegrationTest
, Rotated_Metadata_0
) {
1554 ASSERT_EQ(PIPELINE_OK
, Start("bear_rotate_0.mp4"));
1555 ASSERT_EQ(VIDEO_ROTATION_0
, metadata_
.video_rotation
);
1558 TEST_F(PipelineIntegrationTest
, Rotated_Metadata_90
) {
1559 ASSERT_EQ(PIPELINE_OK
, Start("bear_rotate_90.mp4"));
1560 ASSERT_EQ(VIDEO_ROTATION_90
, metadata_
.video_rotation
);
1563 TEST_F(PipelineIntegrationTest
, Rotated_Metadata_180
) {
1564 ASSERT_EQ(PIPELINE_OK
, Start("bear_rotate_180.mp4"));
1565 ASSERT_EQ(VIDEO_ROTATION_180
, metadata_
.video_rotation
);
1568 TEST_F(PipelineIntegrationTest
, Rotated_Metadata_270
) {
1569 ASSERT_EQ(PIPELINE_OK
, Start("bear_rotate_270.mp4"));
1570 ASSERT_EQ(VIDEO_ROTATION_270
, metadata_
.video_rotation
);
1574 // Verify audio decoder & renderer can handle aborted demuxer reads.
1575 TEST_F(PipelineIntegrationTest
, ChunkDemuxerAbortRead_AudioOnly
) {
1576 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-audio-only.webm", kAudioOnlyWebM
,
1578 base::TimeDelta::FromMilliseconds(464),
1579 base::TimeDelta::FromMilliseconds(617),
1583 // Verify video decoder & renderer can handle aborted demuxer reads.
1584 TEST_F(PipelineIntegrationTest
, ChunkDemuxerAbortRead_VideoOnly
) {
1585 ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM
,
1587 base::TimeDelta::FromMilliseconds(167),
1588 base::TimeDelta::FromMilliseconds(1668),
1592 // Verify that Opus audio in WebM containers can be played back.
1593 TEST_F(PipelineIntegrationTest
, BasicPlayback_AudioOnly_Opus_WebM
) {
1594 ASSERT_EQ(PIPELINE_OK
, Start("bear-opus-end-trimming.webm"));
1596 ASSERT_TRUE(WaitUntilOnEnded());
1599 // Verify that VP9 video in WebM containers can be played back.
1600 TEST_F(PipelineIntegrationTest
, BasicPlayback_VideoOnly_VP9_WebM
) {
1601 ASSERT_EQ(PIPELINE_OK
, Start("bear-vp9.webm"));
1603 ASSERT_TRUE(WaitUntilOnEnded());
1606 // Verify that VP9 video and Opus audio in the same WebM container can be played
1608 TEST_F(PipelineIntegrationTest
, BasicPlayback_VP9_Opus_WebM
) {
1609 ASSERT_EQ(PIPELINE_OK
, Start("bear-vp9-opus.webm"));
1611 ASSERT_TRUE(WaitUntilOnEnded());
1614 // Verify that VP8 video with alpha channel can be played back.
1615 TEST_F(PipelineIntegrationTest
, BasicPlayback_VP8A_WebM
) {
1616 ASSERT_EQ(PIPELINE_OK
, Start("bear-vp8a.webm"));
1618 ASSERT_TRUE(WaitUntilOnEnded());
1619 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_
, VideoFrame::YV12A
);
1622 // Verify that VP8A video with odd width/height can be played back.
1623 TEST_F(PipelineIntegrationTest
, BasicPlayback_VP8A_Odd_WebM
) {
1624 ASSERT_EQ(PIPELINE_OK
, Start("bear-vp8a-odd-dimensions.webm"));
1626 ASSERT_TRUE(WaitUntilOnEnded());
1627 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_
, VideoFrame::YV12A
);
1630 // Verify that VP9 video with odd width/height can be played back.
1631 TEST_F(PipelineIntegrationTest
, BasicPlayback_VP9_Odd_WebM
) {
1632 ASSERT_EQ(PIPELINE_OK
, Start("bear-vp9-odd-dimensions.webm"));
1634 ASSERT_TRUE(WaitUntilOnEnded());
1637 #if !defined(DISABLE_TEXT_TRACK_TESTS)
1638 // Verify that VP8 video with inband text track can be played back.
1639 TEST_F(PipelineIntegrationTest
, BasicPlayback_VP8_WebVTT_WebM
) {
1640 EXPECT_CALL(*this, OnAddTextTrack(_
, _
));
1641 ASSERT_EQ(PIPELINE_OK
, Start("bear-vp8-webvtt.webm"));
1643 ASSERT_TRUE(WaitUntilOnEnded());
1645 #endif // !defined(DISABLE_TEXT_TRACK_TESTS)
1647 // Verify that VP9 video with 4:4:4 subsampling can be played back.
1648 TEST_F(PipelineIntegrationTest
, P444_VP9_WebM
) {
1649 ASSERT_EQ(PIPELINE_OK
, Start("bear-320x240-P444.webm"));
1651 ASSERT_TRUE(WaitUntilOnEnded());
1652 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_
, VideoFrame::YV24
);
1655 // Verify that frames of VP9 video in the BT.709 color space have the YV12HD
1657 TEST_F(PipelineIntegrationTest
, BT709_VP9_WebM
) {
1658 ASSERT_EQ(PIPELINE_OK
, Start("bear-vp9-bt709.webm"));
1660 ASSERT_TRUE(WaitUntilOnEnded());
1661 EXPECT_VIDEO_FORMAT_EQ(last_video_frame_format_
, VideoFrame::YV12
);
1662 EXPECT_EQ(last_video_frame_color_space_
, VideoFrame::COLOR_SPACE_HD_REC709
);
1665 // Verify that videos with an odd frame size playback successfully.
1666 TEST_F(PipelineIntegrationTest
, BasicPlayback_OddVideoSize
) {
1667 ASSERT_EQ(PIPELINE_OK
, Start("butterfly-853x480.webm"));
1669 ASSERT_TRUE(WaitUntilOnEnded());
1672 // Verify that OPUS audio in a webm which reports a 44.1kHz sample rate plays
1673 // correctly at 48kHz
1674 TEST_F(PipelineIntegrationTest
, BasicPlayback_Opus441kHz
) {
1675 ASSERT_EQ(PIPELINE_OK
, Start("sfx-opus-441.webm"));
1677 ASSERT_TRUE(WaitUntilOnEnded());
1679 demuxer_
->GetStream(DemuxerStream::AUDIO
)
1680 ->audio_decoder_config()
1681 .samples_per_second());
1684 // Same as above but using MediaSource.
1685 TEST_F(PipelineIntegrationTest
, BasicPlayback_MediaSource_Opus441kHz
) {
1686 MockMediaSource
source(
1687 "sfx-opus-441.webm", kOpusAudioOnlyWebM
, kAppendWholeFile
);
1688 StartPipelineWithMediaSource(&source
);
1689 source
.EndOfStream();
1691 ASSERT_TRUE(WaitUntilOnEnded());
1695 demuxer_
->GetStream(DemuxerStream::AUDIO
)
1696 ->audio_decoder_config()
1697 .samples_per_second());
1700 // Ensures audio-only playback with missing or negative timestamps works. Tests
1701 // the common live-streaming case for chained ogg. See http://crbug.com/396864.
1702 TEST_F(PipelineIntegrationTest
, BasicPlaybackChainedOgg
) {
1703 ASSERT_EQ(PIPELINE_OK
, Start("double-sfx.ogg"));
1705 ASSERT_TRUE(WaitUntilOnEnded());
1706 ASSERT_EQ(base::TimeDelta(), demuxer_
->GetStartTime());
1709 // Ensures audio-video playback with missing or negative timestamps fails softly
1710 // instead of crashing. See http://crbug.com/396864.
1711 TEST_F(PipelineIntegrationTest
, BasicPlaybackChainedOggVideo
) {
1712 ASSERT_EQ(PIPELINE_OK
, Start("double-bear.ogv"));
1714 EXPECT_EQ(PIPELINE_ERROR_DECODE
, WaitUntilEndedOrError());
1715 ASSERT_EQ(base::TimeDelta(), demuxer_
->GetStartTime());
1718 // Tests that we signal ended even when audio runs longer than video track.
1719 TEST_F(PipelineIntegrationTest
, BasicPlaybackAudioLongerThanVideo
) {
1720 ASSERT_EQ(PIPELINE_OK
, Start("bear_audio_longer_than_video.ogv"));
1721 // Audio track is 2000ms. Video track is 1001ms. Duration should be higher
1723 EXPECT_EQ(2000, pipeline_
->GetMediaDuration().InMilliseconds());
1725 ASSERT_TRUE(WaitUntilOnEnded());
1728 // Tests that we signal ended even when audio runs shorter than video track.
1729 TEST_F(PipelineIntegrationTest
, BasicPlaybackAudioShorterThanVideo
) {
1730 ASSERT_EQ(PIPELINE_OK
, Start("bear_audio_shorter_than_video.ogv"));
1731 // Audio track is 500ms. Video track is 1001ms. Duration should be higher of
1733 EXPECT_EQ(1001, pipeline_
->GetMediaDuration().InMilliseconds());
1735 ASSERT_TRUE(WaitUntilOnEnded());
1738 TEST_F(PipelineIntegrationTest
, BasicPlaybackPositiveStartTime
) {
1739 ASSERT_EQ(PIPELINE_OK
, Start("nonzero-start-time.webm"));
1741 ASSERT_TRUE(WaitUntilOnEnded());
1742 ASSERT_EQ(base::TimeDelta::FromMicroseconds(396000),
1743 demuxer_
->GetStartTime());
1746 } // namespace media