Home | History | Annotate | Download | only in filters
      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.
      4 
      5 #include "media/filters/pipeline_integration_test_base.h"
      6 
      7 #include "base/bind.h"
      8 #include "base/command_line.h"
      9 #include "base/memory/scoped_ptr.h"
     10 #include "base/strings/string_util.h"
     11 #include "build/build_config.h"
     12 #include "media/base/decoder_buffer.h"
     13 #include "media/base/media_keys.h"
     14 #include "media/base/media_switches.h"
     15 #include "media/base/test_data_util.h"
     16 #include "media/cdm/aes_decryptor.h"
     17 #include "media/cdm/json_web_key.h"
     18 #include "media/filters/chunk_demuxer.h"
     19 
     20 using testing::AnyNumber;
     21 using testing::AtMost;
     22 
     23 namespace media {
     24 
     25 const char kSourceId[] = "SourceId";
     26 const uint8 kInitData[] = { 0x69, 0x6e, 0x69, 0x74 };
     27 
     28 const char kWebM[] = "video/webm; codecs=\"vp8,vorbis\"";
     29 const char kWebMVP9[] = "video/webm; codecs=\"vp9\"";
     30 const char kAudioOnlyWebM[] = "video/webm; codecs=\"vorbis\"";
     31 const char kOpusAudioOnlyWebM[] = "video/webm; codecs=\"opus\"";
     32 const char kVideoOnlyWebM[] = "video/webm; codecs=\"vp8\"";
     33 const char kMP4VideoType[] = "video/mp4";
     34 const char kMP4AudioType[] = "audio/mp4";
     35 #if defined(USE_PROPRIETARY_CODECS)
     36 const char kMP4[] = "video/mp4; codecs=\"avc1.4D4041,mp4a.40.2\"";
     37 const char kMP4Video[] = "video/mp4; codecs=\"avc1.4D4041\"";
     38 const char kMP4VideoAVC3[] = "video/mp4; codecs=\"avc3.64001f\"";
     39 const char kMP4Audio[] = "audio/mp4; codecs=\"mp4a.40.2\"";
     40 const char kMP3[] = "audio/mpeg";
     41 #endif  // defined(USE_PROPRIETARY_CODECS)
     42 
     43 // Key used to encrypt test files.
     44 const uint8 kSecretKey[] = {
     45   0xeb, 0xdd, 0x62, 0xf1, 0x68, 0x14, 0xd2, 0x7b,
     46   0x68, 0xef, 0x12, 0x2a, 0xfc, 0xe4, 0xae, 0x3c
     47 };
     48 
     49 // The key ID for all encrypted files.
     50 const uint8 kKeyId[] = {
     51   0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
     52   0x38, 0x39, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35
     53 };
     54 
     55 const int kAppendWholeFile = -1;
     56 
     57 // Constants for the Media Source config change tests.
     58 const int kAppendTimeSec = 1;
     59 const int kAppendTimeMs = kAppendTimeSec * 1000;
     60 const int k320WebMFileDurationMs = 2737;
     61 const int k640WebMFileDurationMs = 2763;
     62 const int kOpusEndTrimmingWebMFileDurationMs = 2771;
     63 const int kVP9WebMFileDurationMs = 2735;
     64 const int kVP8AWebMFileDurationMs = 2700;
     65 
     66 #if defined(USE_PROPRIETARY_CODECS)
     67 const int k640IsoFileDurationMs = 2737;
     68 const int k640IsoCencFileDurationMs = 2736;
     69 const int k1280IsoFileDurationMs = 2736;
     70 const int k1280IsoAVC3FileDurationMs = 2735;
     71 #endif  // defined(USE_PROPRIETARY_CODECS)
     72 
     73 // Note: Tests using this class only exercise the DecryptingDemuxerStream path.
     74 // They do not exercise the Decrypting{Audio|Video}Decoder path.
     75 class FakeEncryptedMedia {
     76  public:
     77   // Defines the behavior of the "app" that responds to EME events.
     78   class AppBase {
     79    public:
     80     virtual ~AppBase() {}
     81 
     82     virtual void OnSessionCreated(uint32 session_id,
     83                                   const std::string& web_session_id) = 0;
     84 
     85     virtual void OnSessionMessage(uint32 session_id,
     86                                   const std::vector<uint8>& message,
     87                                   const std::string& destination_url) = 0;
     88 
     89     virtual void OnSessionReady(uint32 session_id) = 0;
     90 
     91     virtual void OnSessionClosed(uint32 session_id) = 0;
     92 
     93     // Errors are not expected unless overridden.
     94     virtual void OnSessionError(uint32 session_id,
     95                                 MediaKeys::KeyError error_code,
     96                                 int system_code) {
     97       FAIL() << "Unexpected Key Error";
     98     }
     99 
    100     virtual void NeedKey(const std::string& type,
    101                          const std::vector<uint8>& init_data,
    102                          AesDecryptor* decryptor) = 0;
    103   };
    104 
    105   FakeEncryptedMedia(AppBase* app)
    106       : decryptor_(base::Bind(&FakeEncryptedMedia::OnSessionCreated,
    107                               base::Unretained(this)),
    108                    base::Bind(&FakeEncryptedMedia::OnSessionMessage,
    109                               base::Unretained(this)),
    110                    base::Bind(&FakeEncryptedMedia::OnSessionReady,
    111                               base::Unretained(this)),
    112                    base::Bind(&FakeEncryptedMedia::OnSessionClosed,
    113                               base::Unretained(this)),
    114                    base::Bind(&FakeEncryptedMedia::OnSessionError,
    115                               base::Unretained(this))),
    116         app_(app) {}
    117 
    118   AesDecryptor* decryptor() {
    119     return &decryptor_;
    120   }
    121 
    122   // Callbacks for firing session events. Delegate to |app_|.
    123   void OnSessionCreated(uint32 session_id, const std::string& web_session_id) {
    124     app_->OnSessionCreated(session_id, web_session_id);
    125   }
    126 
    127   void OnSessionMessage(uint32 session_id,
    128                         const std::vector<uint8>& message,
    129                         const std::string& destination_url) {
    130     app_->OnSessionMessage(session_id, message, destination_url);
    131   }
    132 
    133   void OnSessionReady(uint32 session_id) {
    134     app_->OnSessionReady(session_id);
    135   }
    136 
    137   void OnSessionClosed(uint32 session_id) {
    138     app_->OnSessionClosed(session_id);
    139   }
    140 
    141   void OnSessionError(uint32 session_id,
    142                       MediaKeys::KeyError error_code,
    143                       int system_code) {
    144     app_->OnSessionError(session_id, error_code, system_code);
    145   }
    146 
    147   void NeedKey(const std::string& type,
    148                const std::vector<uint8>& init_data) {
    149     app_->NeedKey(type, init_data, &decryptor_);
    150   }
    151 
    152  private:
    153   AesDecryptor decryptor_;
    154   scoped_ptr<AppBase> app_;
    155 };
    156 
    157 // Provides |kSecretKey| in response to needkey.
    158 class KeyProvidingApp : public FakeEncryptedMedia::AppBase {
    159  public:
    160   KeyProvidingApp() : current_session_id_(0) {}
    161 
    162   virtual void OnSessionCreated(uint32 session_id,
    163                                 const std::string& web_session_id) OVERRIDE {
    164     EXPECT_GT(session_id, 0u);
    165     EXPECT_FALSE(web_session_id.empty());
    166   }
    167 
    168   virtual void OnSessionMessage(uint32 session_id,
    169                                 const std::vector<uint8>& message,
    170                                 const std::string& default_url) OVERRIDE {
    171     EXPECT_GT(session_id, 0u);
    172     EXPECT_FALSE(message.empty());
    173 
    174     current_session_id_ = session_id;
    175   }
    176 
    177   virtual void OnSessionReady(uint32 session_id) OVERRIDE {
    178     EXPECT_GT(session_id, 0u);
    179   }
    180 
    181   virtual void OnSessionClosed(uint32 session_id) OVERRIDE {
    182     EXPECT_GT(session_id, 0u);
    183   }
    184 
    185   virtual void NeedKey(const std::string& type,
    186                        const std::vector<uint8>& init_data,
    187                        AesDecryptor* decryptor) OVERRIDE {
    188     if (current_session_id_ == 0u) {
    189       EXPECT_TRUE(
    190           decryptor->CreateSession(12, type, kInitData, arraysize(kInitData)));
    191     }
    192 
    193     EXPECT_EQ(current_session_id_, 12u);
    194 
    195     // Clear Key really needs the key ID in |init_data|. For WebM, they are the
    196     // same, but this is not the case for ISO CENC. Therefore, provide the
    197     // correct key ID.
    198     const uint8* key_id = init_data.empty() ? NULL : &init_data[0];
    199     size_t key_id_length = init_data.size();
    200     if (type == kMP4AudioType || type == kMP4VideoType) {
    201       key_id = kKeyId;
    202       key_id_length = arraysize(kKeyId);
    203     }
    204 
    205     // Convert key into a JSON structure and then add it.
    206     std::string jwk = GenerateJWKSet(
    207         kSecretKey, arraysize(kSecretKey), key_id, key_id_length);
    208     decryptor->UpdateSession(current_session_id_,
    209                              reinterpret_cast<const uint8*>(jwk.data()),
    210                              jwk.size());
    211   }
    212 
    213   uint32 current_session_id_;
    214 };
    215 
    216 // Ignores needkey and does not perform a license request
    217 class NoResponseApp : public FakeEncryptedMedia::AppBase {
    218  public:
    219   virtual void OnSessionCreated(uint32 session_id,
    220                                 const std::string& web_session_id) OVERRIDE {
    221     EXPECT_GT(session_id, 0u);
    222     EXPECT_FALSE(web_session_id.empty());
    223   }
    224 
    225   virtual void OnSessionMessage(uint32 session_id,
    226                                 const std::vector<uint8>& message,
    227                                 const std::string& default_url) OVERRIDE {
    228     EXPECT_GT(session_id, 0u);
    229     EXPECT_FALSE(message.empty());
    230     FAIL() << "Unexpected KeyMessage";
    231   }
    232 
    233   virtual void OnSessionReady(uint32 session_id) OVERRIDE {
    234     EXPECT_GT(session_id, 0u);
    235     FAIL() << "Unexpected Ready";
    236   }
    237 
    238   virtual void OnSessionClosed(uint32 session_id) OVERRIDE {
    239     EXPECT_GT(session_id, 0u);
    240     FAIL() << "Unexpected Closed";
    241   }
    242 
    243   virtual void NeedKey(const std::string& type,
    244                        const std::vector<uint8>& init_data,
    245                        AesDecryptor* decryptor) OVERRIDE {
    246   }
    247 };
    248 
    249 // Helper class that emulates calls made on the ChunkDemuxer by the
    250 // Media Source API.
    251 class MockMediaSource {
    252  public:
    253   MockMediaSource(const std::string& filename, const std::string& mimetype,
    254                   int initial_append_size)
    255       : file_path_(GetTestDataFilePath(filename)),
    256         current_position_(0),
    257         initial_append_size_(initial_append_size),
    258         mimetype_(mimetype),
    259         chunk_demuxer_(new ChunkDemuxer(
    260             base::Bind(&MockMediaSource::DemuxerOpened,
    261                        base::Unretained(this)),
    262             base::Bind(&MockMediaSource::DemuxerNeedKey,
    263                        base::Unretained(this)),
    264             LogCB())),
    265         owned_chunk_demuxer_(chunk_demuxer_) {
    266 
    267     file_data_ = ReadTestDataFile(filename);
    268 
    269     if (initial_append_size_ == kAppendWholeFile)
    270       initial_append_size_ = file_data_->data_size();
    271 
    272     DCHECK_GT(initial_append_size_, 0);
    273     DCHECK_LE(initial_append_size_, file_data_->data_size());
    274   }
    275 
    276   virtual ~MockMediaSource() {}
    277 
    278   scoped_ptr<Demuxer> GetDemuxer() { return owned_chunk_demuxer_.Pass(); }
    279 
    280   void set_need_key_cb(const Demuxer::NeedKeyCB& need_key_cb) {
    281     need_key_cb_ = need_key_cb;
    282   }
    283 
    284   void Seek(base::TimeDelta seek_time, int new_position, int seek_append_size) {
    285     chunk_demuxer_->StartWaitingForSeek(seek_time);
    286 
    287     chunk_demuxer_->Abort(kSourceId);
    288 
    289     DCHECK_GE(new_position, 0);
    290     DCHECK_LT(new_position, file_data_->data_size());
    291     current_position_ = new_position;
    292 
    293     AppendData(seek_append_size);
    294   }
    295 
    296   void AppendData(int size) {
    297     DCHECK(chunk_demuxer_);
    298     DCHECK_LT(current_position_, file_data_->data_size());
    299     DCHECK_LE(current_position_ + size, file_data_->data_size());
    300     chunk_demuxer_->AppendData(
    301         kSourceId, file_data_->data() + current_position_, size);
    302     current_position_ += size;
    303   }
    304 
    305   void AppendAtTime(const base::TimeDelta& timestampOffset,
    306                     const uint8* pData, int size) {
    307     CHECK(chunk_demuxer_->SetTimestampOffset(kSourceId, timestampOffset));
    308     chunk_demuxer_->AppendData(kSourceId, pData, size);
    309     CHECK(chunk_demuxer_->SetTimestampOffset(kSourceId, base::TimeDelta()));
    310   }
    311 
    312   void EndOfStream() {
    313     chunk_demuxer_->MarkEndOfStream(PIPELINE_OK);
    314   }
    315 
    316   void Abort() {
    317     if (!chunk_demuxer_)
    318       return;
    319     chunk_demuxer_->Shutdown();
    320     chunk_demuxer_ = NULL;
    321   }
    322 
    323   void DemuxerOpened() {
    324     base::MessageLoop::current()->PostTask(
    325         FROM_HERE, base::Bind(&MockMediaSource::DemuxerOpenedTask,
    326                               base::Unretained(this)));
    327   }
    328 
    329   void DemuxerOpenedTask() {
    330     // This code assumes that |mimetype_| is one of the following forms.
    331     // 1. audio/mpeg
    332     // 2. video/webm;codec="vorbis,vp8".
    333     size_t semicolon = mimetype_.find(";");
    334     std::string type = mimetype_;
    335     std::vector<std::string> codecs;
    336     if (semicolon != std::string::npos) {
    337       type = mimetype_.substr(0, semicolon);
    338       size_t codecs_param_start = mimetype_.find("codecs=\"", semicolon);
    339 
    340       CHECK_NE(codecs_param_start, std::string::npos);
    341 
    342       codecs_param_start += 8; // Skip over the codecs=".
    343 
    344       size_t codecs_param_end = mimetype_.find("\"", codecs_param_start);
    345 
    346       CHECK_NE(codecs_param_end, std::string::npos);
    347 
    348       std::string codecs_param =
    349           mimetype_.substr(codecs_param_start,
    350                            codecs_param_end - codecs_param_start);
    351       Tokenize(codecs_param, ",", &codecs);
    352     }
    353 
    354     CHECK_EQ(chunk_demuxer_->AddId(kSourceId, type, codecs), ChunkDemuxer::kOk);
    355     AppendData(initial_append_size_);
    356   }
    357 
    358   void DemuxerNeedKey(const std::string& type,
    359                       const std::vector<uint8>& init_data) {
    360     DCHECK(!init_data.empty());
    361     CHECK(!need_key_cb_.is_null());
    362     need_key_cb_.Run(type, init_data);
    363   }
    364 
    365  private:
    366   base::FilePath file_path_;
    367   scoped_refptr<DecoderBuffer> file_data_;
    368   int current_position_;
    369   int initial_append_size_;
    370   std::string mimetype_;
    371   ChunkDemuxer* chunk_demuxer_;
    372   scoped_ptr<Demuxer> owned_chunk_demuxer_;
    373   Demuxer::NeedKeyCB need_key_cb_;
    374 };
    375 
    376 class PipelineIntegrationTest
    377     : public testing::Test,
    378       public PipelineIntegrationTestBase {
    379  public:
    380   void StartPipelineWithMediaSource(MockMediaSource* source) {
    381     EXPECT_CALL(*this, OnBufferingState(Pipeline::kHaveMetadata))
    382         .Times(AtMost(1));
    383     EXPECT_CALL(*this, OnBufferingState(Pipeline::kPrerollCompleted))
    384         .Times(AtMost(1));
    385     pipeline_->Start(
    386         CreateFilterCollection(source->GetDemuxer(), NULL),
    387         base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
    388         base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)),
    389         QuitOnStatusCB(PIPELINE_OK),
    390         base::Bind(&PipelineIntegrationTest::OnBufferingState,
    391                    base::Unretained(this)),
    392         base::Closure());
    393 
    394     message_loop_.Run();
    395   }
    396 
    397   void StartHashedPipelineWithMediaSource(MockMediaSource* source) {
    398     hashing_enabled_ = true;
    399     StartPipelineWithMediaSource(source);
    400   }
    401 
    402   void StartPipelineWithEncryptedMedia(
    403       MockMediaSource* source,
    404       FakeEncryptedMedia* encrypted_media) {
    405     EXPECT_CALL(*this, OnBufferingState(Pipeline::kHaveMetadata))
    406         .Times(AtMost(1));
    407     EXPECT_CALL(*this, OnBufferingState(Pipeline::kPrerollCompleted))
    408         .Times(AtMost(1));
    409     pipeline_->Start(
    410         CreateFilterCollection(source->GetDemuxer(),
    411                                encrypted_media->decryptor()),
    412         base::Bind(&PipelineIntegrationTest::OnEnded, base::Unretained(this)),
    413         base::Bind(&PipelineIntegrationTest::OnError, base::Unretained(this)),
    414         QuitOnStatusCB(PIPELINE_OK),
    415         base::Bind(&PipelineIntegrationTest::OnBufferingState,
    416                    base::Unretained(this)),
    417         base::Closure());
    418 
    419     source->set_need_key_cb(base::Bind(&FakeEncryptedMedia::NeedKey,
    420                                        base::Unretained(encrypted_media)));
    421 
    422     message_loop_.Run();
    423   }
    424 
    425   // Verifies that seeking works properly for ChunkDemuxer when the
    426   // seek happens while there is a pending read on the ChunkDemuxer
    427   // and no data is available.
    428   bool TestSeekDuringRead(const std::string& filename,
    429                           const std::string& mimetype,
    430                           int initial_append_size,
    431                           base::TimeDelta start_seek_time,
    432                           base::TimeDelta seek_time,
    433                           int seek_file_position,
    434                           int seek_append_size) {
    435     MockMediaSource source(filename, mimetype, initial_append_size);
    436     StartPipelineWithMediaSource(&source);
    437 
    438     if (pipeline_status_ != PIPELINE_OK)
    439       return false;
    440 
    441     Play();
    442     if (!WaitUntilCurrentTimeIsAfter(start_seek_time))
    443       return false;
    444 
    445     source.Seek(seek_time, seek_file_position, seek_append_size);
    446     if (!Seek(seek_time))
    447       return false;
    448 
    449     source.EndOfStream();
    450 
    451     source.Abort();
    452     Stop();
    453     return true;
    454   }
    455 };
    456 
    457 TEST_F(PipelineIntegrationTest, BasicPlayback) {
    458   ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240.webm"), PIPELINE_OK));
    459 
    460   Play();
    461 
    462   ASSERT_TRUE(WaitUntilOnEnded());
    463 }
    464 
    465 TEST_F(PipelineIntegrationTest, BasicPlaybackHashed) {
    466   ASSERT_TRUE(Start(
    467       GetTestDataFilePath("bear-320x240.webm"), PIPELINE_OK, kHashed));
    468 
    469   Play();
    470 
    471   ASSERT_TRUE(WaitUntilOnEnded());
    472 
    473   EXPECT_EQ("f0be120a90a811506777c99a2cdf7cc1", GetVideoHash());
    474   EXPECT_EQ("-3.59,-2.06,-0.43,2.15,0.77,-0.95,", GetAudioHash());
    475 }
    476 
    477 TEST_F(PipelineIntegrationTest, F32PlaybackHashed) {
    478   ASSERT_TRUE(
    479       Start(GetTestDataFilePath("sfx_f32le.wav"), PIPELINE_OK, kHashed));
    480   Play();
    481   ASSERT_TRUE(WaitUntilOnEnded());
    482   EXPECT_EQ(std::string(kNullVideoHash), GetVideoHash());
    483   EXPECT_EQ("3.03,2.86,2.99,3.31,3.57,4.06,", GetAudioHash());
    484 }
    485 
    486 TEST_F(PipelineIntegrationTest, BasicPlaybackEncrypted) {
    487   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    488   set_need_key_cb(base::Bind(&FakeEncryptedMedia::NeedKey,
    489                              base::Unretained(&encrypted_media)));
    490 
    491   ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240-av_enc-av.webm"),
    492                     encrypted_media.decryptor()));
    493 
    494   Play();
    495 
    496   ASSERT_TRUE(WaitUntilOnEnded());
    497   Stop();
    498 }
    499 
    500 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource) {
    501   MockMediaSource source("bear-320x240.webm", kWebM, 219229);
    502   StartPipelineWithMediaSource(&source);
    503   source.EndOfStream();
    504 
    505   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    506   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    507   EXPECT_EQ(k320WebMFileDurationMs,
    508             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    509 
    510   Play();
    511 
    512   ASSERT_TRUE(WaitUntilOnEnded());
    513   source.Abort();
    514   Stop();
    515 }
    516 
    517 // TODO(fgalligan): Enable after new vp9 files are landed.
    518 // http://crbug.com/259116
    519 TEST_F(PipelineIntegrationTest,
    520        DISABLED_BasicPlayback_MediaSource_VideoOnly_VP9_WebM) {
    521   MockMediaSource source("bear-vp9.webm", kWebMVP9, 32393);
    522   StartPipelineWithMediaSource(&source);
    523   source.EndOfStream();
    524 
    525   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    526   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    527   EXPECT_EQ(kVP9WebMFileDurationMs,
    528             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    529 
    530   Play();
    531 
    532   ASSERT_TRUE(WaitUntilOnEnded());
    533   source.Abort();
    534   Stop();
    535 }
    536 
    537 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VP8A_WebM) {
    538   EXPECT_CALL(*this, OnSetOpaque(false)).Times(AnyNumber());
    539   MockMediaSource source("bear-vp8a.webm", kVideoOnlyWebM, kAppendWholeFile);
    540   StartPipelineWithMediaSource(&source);
    541   source.EndOfStream();
    542 
    543   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    544   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    545   EXPECT_EQ(kVP8AWebMFileDurationMs,
    546             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    547 
    548   Play();
    549 
    550   ASSERT_TRUE(WaitUntilOnEnded());
    551   source.Abort();
    552   Stop();
    553 }
    554 
    555 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_Opus_WebM) {
    556   EXPECT_CALL(*this, OnSetOpaque(false)).Times(AnyNumber());
    557   MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM,
    558                          kAppendWholeFile);
    559   StartPipelineWithMediaSource(&source);
    560   source.EndOfStream();
    561 
    562   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    563   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    564   EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs,
    565             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    566   Play();
    567 
    568   ASSERT_TRUE(WaitUntilOnEnded());
    569   source.Abort();
    570   Stop();
    571 }
    572 
    573 // Flaky. http://crbug.com/304776
    574 TEST_F(PipelineIntegrationTest, DISABLED_MediaSource_Opus_Seeking_WebM) {
    575   EXPECT_CALL(*this, OnSetOpaque(false)).Times(AnyNumber());
    576   MockMediaSource source("bear-opus-end-trimming.webm", kOpusAudioOnlyWebM,
    577                          kAppendWholeFile);
    578   StartHashedPipelineWithMediaSource(&source);
    579 
    580 
    581   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    582   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    583   EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs,
    584             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    585 
    586   base::TimeDelta start_seek_time = base::TimeDelta::FromMilliseconds(1000);
    587   base::TimeDelta seek_time = base::TimeDelta::FromMilliseconds(2000);
    588 
    589   Play();
    590   ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time));
    591   source.Seek(seek_time, 0x1D5, 34017);
    592   source.EndOfStream();
    593   ASSERT_TRUE(Seek(seek_time));
    594 
    595   ASSERT_TRUE(WaitUntilOnEnded());
    596 
    597   EXPECT_EQ("0.76,0.20,-0.82,-0.58,-1.29,-0.29,", GetAudioHash());
    598 
    599   source.Abort();
    600   Stop();
    601 }
    602 
    603 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_WebM) {
    604   MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM,
    605                          kAppendWholeFile);
    606   StartPipelineWithMediaSource(&source);
    607 
    608   scoped_refptr<DecoderBuffer> second_file =
    609       ReadTestDataFile("bear-640x360.webm");
    610 
    611   source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec),
    612                       second_file->data(), second_file->data_size());
    613 
    614   source.EndOfStream();
    615 
    616   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    617   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    618   EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs,
    619             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    620 
    621   Play();
    622 
    623   EXPECT_TRUE(WaitUntilOnEnded());
    624   source.Abort();
    625   Stop();
    626 }
    627 
    628 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_Encrypted_WebM) {
    629   MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM,
    630                          kAppendWholeFile);
    631   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    632   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    633 
    634   scoped_refptr<DecoderBuffer> second_file =
    635       ReadTestDataFile("bear-640x360-av_enc-av.webm");
    636 
    637   source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec),
    638                       second_file->data(), second_file->data_size());
    639 
    640   source.EndOfStream();
    641 
    642   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    643   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    644   EXPECT_EQ(kAppendTimeMs + k640WebMFileDurationMs,
    645             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    646 
    647   Play();
    648 
    649   EXPECT_TRUE(WaitUntilOnEnded());
    650   source.Abort();
    651   Stop();
    652 }
    653 
    654 // Config changes from encrypted to clear are not currently supported.
    655 TEST_F(PipelineIntegrationTest,
    656        MediaSource_ConfigChange_ClearThenEncrypted_WebM) {
    657   MockMediaSource source("bear-320x240-16x9-aspect.webm", kWebM,
    658                          kAppendWholeFile);
    659   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    660   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    661 
    662   scoped_refptr<DecoderBuffer> second_file =
    663       ReadTestDataFile("bear-640x360-av_enc-av.webm");
    664 
    665   source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec),
    666                       second_file->data(), second_file->data_size());
    667 
    668   source.EndOfStream();
    669 
    670   message_loop_.Run();
    671   EXPECT_EQ(PIPELINE_ERROR_DECODE, pipeline_status_);
    672 
    673   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    674   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    675   // The second video was not added, so its time has not been added.
    676   EXPECT_EQ(k320WebMFileDurationMs,
    677             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    678 
    679   Play();
    680 
    681   EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError());
    682   source.Abort();
    683 }
    684 
    685 // Config changes from clear to encrypted are not currently supported.
    686 TEST_F(PipelineIntegrationTest,
    687        MediaSource_ConfigChange_EncryptedThenClear_WebM) {
    688   MockMediaSource source("bear-320x240-16x9-aspect-av_enc-av.webm", kWebM,
    689                          kAppendWholeFile);
    690   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    691   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    692 
    693   scoped_refptr<DecoderBuffer> second_file =
    694       ReadTestDataFile("bear-640x360.webm");
    695 
    696   source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec),
    697                       second_file->data(), second_file->data_size());
    698 
    699   source.EndOfStream();
    700 
    701   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    702   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    703   // The second video was not added, so its time has not been added.
    704   EXPECT_EQ(k320WebMFileDurationMs,
    705             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    706 
    707   Play();
    708 
    709   EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError());
    710   source.Abort();
    711 }
    712 
    713 #if defined(USE_PROPRIETARY_CODECS)
    714 TEST_F(PipelineIntegrationTest, MediaSource_MP3) {
    715   MockMediaSource source("sfx.mp3", kMP3, kAppendWholeFile);
    716   StartPipelineWithMediaSource(&source);
    717   source.EndOfStream();
    718 
    719   Play();
    720 
    721   EXPECT_TRUE(WaitUntilOnEnded());
    722 }
    723 
    724 
    725 TEST_F(PipelineIntegrationTest, MediaSource_MP3_Icecast) {
    726   MockMediaSource source("icy_sfx.mp3", kMP3, kAppendWholeFile);
    727   StartPipelineWithMediaSource(&source);
    728   source.EndOfStream();
    729 
    730   Play();
    731 
    732   EXPECT_TRUE(WaitUntilOnEnded());
    733 }
    734 
    735 TEST_F(PipelineIntegrationTest, MediaSource_ConfigChange_MP4) {
    736   MockMediaSource source("bear-640x360-av_frag.mp4", kMP4, kAppendWholeFile);
    737   StartPipelineWithMediaSource(&source);
    738 
    739   scoped_refptr<DecoderBuffer> second_file =
    740       ReadTestDataFile("bear-1280x720-av_frag.mp4");
    741 
    742   source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec),
    743                       second_file->data(), second_file->data_size());
    744 
    745   source.EndOfStream();
    746 
    747   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    748   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    749   EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs,
    750             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    751 
    752   Play();
    753 
    754   EXPECT_TRUE(WaitUntilOnEnded());
    755   source.Abort();
    756   Stop();
    757 }
    758 
    759 TEST_F(PipelineIntegrationTest,
    760        MediaSource_ConfigChange_Encrypted_MP4_CENC_VideoOnly) {
    761   MockMediaSource source("bear-640x360-v_frag-cenc.mp4",
    762                          kMP4Video, kAppendWholeFile);
    763   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    764   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    765 
    766   scoped_refptr<DecoderBuffer> second_file =
    767       ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4");
    768 
    769   source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec),
    770                       second_file->data(), second_file->data_size());
    771 
    772   source.EndOfStream();
    773 
    774   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    775   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    776   EXPECT_EQ(kAppendTimeMs + k1280IsoFileDurationMs,
    777             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    778 
    779   Play();
    780 
    781   EXPECT_TRUE(WaitUntilOnEnded());
    782   source.Abort();
    783   Stop();
    784 }
    785 
    786 // Config changes from clear to encrypted are not currently supported.
    787 // TODO(ddorwin): Figure out why this CHECKs in AppendAtTime().
    788 TEST_F(PipelineIntegrationTest,
    789        DISABLED_MediaSource_ConfigChange_ClearThenEncrypted_MP4_CENC) {
    790   MockMediaSource source("bear-640x360-av_frag.mp4", kMP4Video,
    791                          kAppendWholeFile);
    792   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    793   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    794 
    795   scoped_refptr<DecoderBuffer> second_file =
    796       ReadTestDataFile("bear-1280x720-v_frag-cenc.mp4");
    797 
    798   source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec),
    799                       second_file->data(), second_file->data_size());
    800 
    801   source.EndOfStream();
    802 
    803   message_loop_.Run();
    804   EXPECT_EQ(PIPELINE_ERROR_DECODE, pipeline_status_);
    805 
    806   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    807   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    808   // The second video was not added, so its time has not been added.
    809   EXPECT_EQ(k640IsoFileDurationMs,
    810             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    811 
    812   Play();
    813 
    814   EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError());
    815   source.Abort();
    816 }
    817 
    818 // Config changes from encrypted to clear are not currently supported.
    819 TEST_F(PipelineIntegrationTest,
    820        MediaSource_ConfigChange_EncryptedThenClear_MP4_CENC) {
    821   MockMediaSource source("bear-640x360-v_frag-cenc.mp4",
    822                          kMP4Video, kAppendWholeFile);
    823   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    824   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    825 
    826   scoped_refptr<DecoderBuffer> second_file =
    827       ReadTestDataFile("bear-1280x720-av_frag.mp4");
    828 
    829   source.AppendAtTime(base::TimeDelta::FromSeconds(kAppendTimeSec),
    830                       second_file->data(), second_file->data_size());
    831 
    832   source.EndOfStream();
    833 
    834   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    835   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    836   // The second video was not added, so its time has not been added.
    837   EXPECT_EQ(k640IsoCencFileDurationMs,
    838             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    839 
    840   Play();
    841 
    842   EXPECT_EQ(PIPELINE_ERROR_DECODE, WaitUntilEndedOrError());
    843   source.Abort();
    844 }
    845 
    846 // Verify files which change configuration midstream fail gracefully.
    847 TEST_F(PipelineIntegrationTest, MidStreamConfigChangesFail) {
    848   ASSERT_TRUE(Start(
    849       GetTestDataFilePath("midstream_config_change.mp3"), PIPELINE_OK));
    850   Play();
    851   ASSERT_EQ(WaitUntilEndedOrError(), PIPELINE_ERROR_DECODE);
    852 }
    853 
    854 #endif
    855 
    856 TEST_F(PipelineIntegrationTest, BasicPlayback_16x9AspectRatio) {
    857   ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240-16x9-aspect.webm"),
    858                     PIPELINE_OK));
    859   Play();
    860   ASSERT_TRUE(WaitUntilOnEnded());
    861 }
    862 
    863 TEST_F(PipelineIntegrationTest, EncryptedPlayback_WebM) {
    864   MockMediaSource source("bear-320x240-av_enc-av.webm", kWebM, 219816);
    865   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    866   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    867 
    868   source.EndOfStream();
    869   ASSERT_EQ(PIPELINE_OK, pipeline_status_);
    870 
    871   Play();
    872 
    873   ASSERT_TRUE(WaitUntilOnEnded());
    874   source.Abort();
    875   Stop();
    876 }
    877 
    878 TEST_F(PipelineIntegrationTest, EncryptedPlayback_ClearStart_WebM) {
    879   MockMediaSource source("bear-320x240-av_enc-av_clear-1s.webm",
    880                          kWebM, kAppendWholeFile);
    881   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    882   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    883 
    884   source.EndOfStream();
    885   ASSERT_EQ(PIPELINE_OK, pipeline_status_);
    886 
    887   Play();
    888 
    889   ASSERT_TRUE(WaitUntilOnEnded());
    890   source.Abort();
    891   Stop();
    892 }
    893 
    894 TEST_F(PipelineIntegrationTest, EncryptedPlayback_NoEncryptedFrames_WebM) {
    895   MockMediaSource source("bear-320x240-av_enc-av_clear-all.webm",
    896                          kWebM, kAppendWholeFile);
    897   FakeEncryptedMedia encrypted_media(new NoResponseApp());
    898   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    899 
    900   source.EndOfStream();
    901   ASSERT_EQ(PIPELINE_OK, pipeline_status_);
    902 
    903   Play();
    904 
    905   ASSERT_TRUE(WaitUntilOnEnded());
    906   source.Abort();
    907   Stop();
    908 }
    909 
    910 #if defined(USE_PROPRIETARY_CODECS)
    911 TEST_F(PipelineIntegrationTest, EncryptedPlayback_MP4_CENC_VideoOnly) {
    912   MockMediaSource source("bear-1280x720-v_frag-cenc.mp4",
    913                          kMP4Video, kAppendWholeFile);
    914   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    915   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    916 
    917   source.EndOfStream();
    918   ASSERT_EQ(PIPELINE_OK, pipeline_status_);
    919 
    920   Play();
    921 
    922   ASSERT_TRUE(WaitUntilOnEnded());
    923   source.Abort();
    924   Stop();
    925 }
    926 
    927 TEST_F(PipelineIntegrationTest, EncryptedPlayback_MP4_CENC_AudioOnly) {
    928   MockMediaSource source("bear-1280x720-a_frag-cenc.mp4",
    929                          kMP4Audio, kAppendWholeFile);
    930   FakeEncryptedMedia encrypted_media(new KeyProvidingApp());
    931   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    932 
    933   source.EndOfStream();
    934   ASSERT_EQ(PIPELINE_OK, pipeline_status_);
    935 
    936   Play();
    937 
    938   ASSERT_TRUE(WaitUntilOnEnded());
    939   source.Abort();
    940   Stop();
    941 }
    942 
    943 TEST_F(PipelineIntegrationTest,
    944        EncryptedPlayback_NoEncryptedFrames_MP4_CENC_VideoOnly) {
    945   MockMediaSource source("bear-1280x720-v_frag-cenc_clear-all.mp4",
    946                          kMP4Video, kAppendWholeFile);
    947   FakeEncryptedMedia encrypted_media(new NoResponseApp());
    948   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    949 
    950   source.EndOfStream();
    951   ASSERT_EQ(PIPELINE_OK, pipeline_status_);
    952 
    953   Play();
    954 
    955   ASSERT_TRUE(WaitUntilOnEnded());
    956   source.Abort();
    957   Stop();
    958 }
    959 
    960 TEST_F(PipelineIntegrationTest,
    961        EncryptedPlayback_NoEncryptedFrames_MP4_CENC_AudioOnly) {
    962   MockMediaSource source("bear-1280x720-a_frag-cenc_clear-all.mp4",
    963                          kMP4Audio, kAppendWholeFile);
    964   FakeEncryptedMedia encrypted_media(new NoResponseApp());
    965   StartPipelineWithEncryptedMedia(&source, &encrypted_media);
    966 
    967   source.EndOfStream();
    968   ASSERT_EQ(PIPELINE_OK, pipeline_status_);
    969 
    970   Play();
    971 
    972   ASSERT_TRUE(WaitUntilOnEnded());
    973   source.Abort();
    974   Stop();
    975 }
    976 
    977 TEST_F(PipelineIntegrationTest, BasicPlayback_MediaSource_VideoOnly_MP4_AVC3) {
    978   MockMediaSource source("bear-1280x720-v_frag-avc3.mp4", kMP4VideoAVC3,
    979                          kAppendWholeFile);
    980   StartPipelineWithMediaSource(&source);
    981   source.EndOfStream();
    982 
    983   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
    984   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
    985   EXPECT_EQ(k1280IsoAVC3FileDurationMs,
    986             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
    987 
    988   Play();
    989 
    990   ASSERT_TRUE(WaitUntilOnEnded());
    991   source.Abort();
    992   Stop();
    993 }
    994 
    995 #endif
    996 
    997 // TODO(acolwell): Fix flakiness http://crbug.com/117921
    998 TEST_F(PipelineIntegrationTest, DISABLED_SeekWhilePaused) {
    999   ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240.webm"), PIPELINE_OK));
   1000 
   1001   base::TimeDelta duration(pipeline_->GetMediaDuration());
   1002   base::TimeDelta start_seek_time(duration / 4);
   1003   base::TimeDelta seek_time(duration * 3 / 4);
   1004 
   1005   Play();
   1006   ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time));
   1007   Pause();
   1008   ASSERT_TRUE(Seek(seek_time));
   1009   EXPECT_EQ(pipeline_->GetMediaTime(), seek_time);
   1010   Play();
   1011   ASSERT_TRUE(WaitUntilOnEnded());
   1012 
   1013   // Make sure seeking after reaching the end works as expected.
   1014   Pause();
   1015   ASSERT_TRUE(Seek(seek_time));
   1016   EXPECT_EQ(pipeline_->GetMediaTime(), seek_time);
   1017   Play();
   1018   ASSERT_TRUE(WaitUntilOnEnded());
   1019 }
   1020 
   1021 // TODO(acolwell): Fix flakiness http://crbug.com/117921
   1022 TEST_F(PipelineIntegrationTest, DISABLED_SeekWhilePlaying) {
   1023   ASSERT_TRUE(Start(GetTestDataFilePath("bear-320x240.webm"), PIPELINE_OK));
   1024 
   1025   base::TimeDelta duration(pipeline_->GetMediaDuration());
   1026   base::TimeDelta start_seek_time(duration / 4);
   1027   base::TimeDelta seek_time(duration * 3 / 4);
   1028 
   1029   Play();
   1030   ASSERT_TRUE(WaitUntilCurrentTimeIsAfter(start_seek_time));
   1031   ASSERT_TRUE(Seek(seek_time));
   1032   EXPECT_GE(pipeline_->GetMediaTime(), seek_time);
   1033   ASSERT_TRUE(WaitUntilOnEnded());
   1034 
   1035   // Make sure seeking after reaching the end works as expected.
   1036   ASSERT_TRUE(Seek(seek_time));
   1037   EXPECT_GE(pipeline_->GetMediaTime(), seek_time);
   1038   ASSERT_TRUE(WaitUntilOnEnded());
   1039 }
   1040 
   1041 // Verify audio decoder & renderer can handle aborted demuxer reads.
   1042 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_AudioOnly) {
   1043   ASSERT_TRUE(TestSeekDuringRead("bear-320x240-audio-only.webm", kAudioOnlyWebM,
   1044                                  8192,
   1045                                  base::TimeDelta::FromMilliseconds(464),
   1046                                  base::TimeDelta::FromMilliseconds(617),
   1047                                  0x10CA, 19730));
   1048 }
   1049 
   1050 // Verify video decoder & renderer can handle aborted demuxer reads.
   1051 TEST_F(PipelineIntegrationTest, ChunkDemuxerAbortRead_VideoOnly) {
   1052   ASSERT_TRUE(TestSeekDuringRead("bear-320x240-video-only.webm", kVideoOnlyWebM,
   1053                                  32768,
   1054                                  base::TimeDelta::FromMilliseconds(200),
   1055                                  base::TimeDelta::FromMilliseconds(1668),
   1056                                  0x1C896, 65536));
   1057 }
   1058 
   1059 // Verify that Opus audio in WebM containers can be played back.
   1060 TEST_F(PipelineIntegrationTest, BasicPlayback_AudioOnly_Opus_WebM) {
   1061   ASSERT_TRUE(Start(GetTestDataFilePath("bear-opus-end-trimming.webm"),
   1062                     PIPELINE_OK));
   1063   EXPECT_EQ(1u, pipeline_->GetBufferedTimeRanges().size());
   1064   EXPECT_EQ(0, pipeline_->GetBufferedTimeRanges().start(0).InMilliseconds());
   1065   EXPECT_EQ(kOpusEndTrimmingWebMFileDurationMs,
   1066             pipeline_->GetBufferedTimeRanges().end(0).InMilliseconds());
   1067   Play();
   1068   ASSERT_TRUE(WaitUntilOnEnded());
   1069 }
   1070 
   1071 // Verify that VP9 video in WebM containers can be played back.
   1072 // TODO(fgalligan): Enable after new vp9 files are landed.
   1073 // http://crbug.com/259116
   1074 TEST_F(PipelineIntegrationTest, DISABLED_BasicPlayback_VideoOnly_VP9_WebM) {
   1075   ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp9.webm"),
   1076                     PIPELINE_OK));
   1077   Play();
   1078   ASSERT_TRUE(WaitUntilOnEnded());
   1079 }
   1080 
   1081 // Verify that VP9 video and Opus audio in the same WebM container can be played
   1082 // back.
   1083 // TODO(fgalligan): Enable after new vp9 files are landed.
   1084 // http://crbug.com/259116
   1085 TEST_F(PipelineIntegrationTest, DISABLED_BasicPlayback_VP9_Opus_WebM) {
   1086   ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp9-opus.webm"),
   1087                     PIPELINE_OK));
   1088   Play();
   1089   ASSERT_TRUE(WaitUntilOnEnded());
   1090 }
   1091 
   1092 // Verify that VP8 video with alpha channel can be played back.
   1093 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8A_WebM) {
   1094   EXPECT_CALL(*this, OnSetOpaque(false)).Times(AnyNumber());
   1095   ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8a.webm"),
   1096                     PIPELINE_OK));
   1097   Play();
   1098   ASSERT_TRUE(WaitUntilOnEnded());
   1099   EXPECT_EQ(last_video_frame_format_, VideoFrame::YV12A);
   1100 }
   1101 
   1102 // Verify that VP8A video with odd width/height can be played back.
   1103 TEST_F(PipelineIntegrationTest, BasicPlayback_VP8A_Odd_WebM) {
   1104   EXPECT_CALL(*this, OnSetOpaque(false)).Times(AnyNumber());
   1105   ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8a-odd-dimensions.webm"),
   1106                     PIPELINE_OK));
   1107   Play();
   1108   ASSERT_TRUE(WaitUntilOnEnded());
   1109   EXPECT_EQ(last_video_frame_format_, VideoFrame::YV12A);
   1110 }
   1111 
   1112 // Verify that VP8 video with inband text track can be played back.
   1113 TEST_F(PipelineIntegrationTest,
   1114        BasicPlayback_VP8_WebVTT_WebM) {
   1115   ASSERT_TRUE(Start(GetTestDataFilePath("bear-vp8-webvtt.webm"),
   1116                     PIPELINE_OK));
   1117   Play();
   1118   ASSERT_TRUE(WaitUntilOnEnded());
   1119 }
   1120 
   1121 }  // namespace media
   1122