| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <memory> | 5 #include <memory> |
| 6 #include <vector> | 6 #include <vector> |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "chromecast/media/base/decrypt_context_impl.h" | 13 #include "chromecast/media/base/decrypt_context_impl.h" |
| 14 #include "chromecast/media/cdm/cast_cdm_context.h" | 14 #include "chromecast/media/cdm/cast_cdm_context.h" |
| 15 #include "chromecast/media/cma/backend/audio_decoder_default.h" | |
| 16 #include "chromecast/media/cma/backend/media_pipeline_backend_default.h" | |
| 17 #include "chromecast/media/cma/backend/video_decoder_default.h" | |
| 18 #include "chromecast/media/cma/pipeline/av_pipeline_client.h" | 15 #include "chromecast/media/cma/pipeline/av_pipeline_client.h" |
| 19 #include "chromecast/media/cma/pipeline/media_pipeline_impl.h" | 16 #include "chromecast/media/cma/pipeline/media_pipeline_impl.h" |
| 20 #include "chromecast/media/cma/pipeline/video_pipeline_client.h" | 17 #include "chromecast/media/cma/pipeline/video_pipeline_client.h" |
| 21 #include "chromecast/media/cma/test/frame_generator_for_test.h" | 18 #include "chromecast/media/cma/test/frame_generator_for_test.h" |
| 22 #include "chromecast/media/cma/test/mock_frame_provider.h" | 19 #include "chromecast/media/cma/test/mock_frame_provider.h" |
| 20 #include "chromecast/media/cma/test/mock_media_pipeline_backend.h" |
| 21 #include "chromecast/public/media/cast_decoder_buffer.h" |
| 23 #include "media/base/audio_decoder_config.h" | 22 #include "media/base/audio_decoder_config.h" |
| 24 #include "media/base/media_util.h" | 23 #include "media/base/media_util.h" |
| 25 #include "media/base/video_decoder_config.h" | 24 #include "media/base/video_decoder_config.h" |
| 26 #include "media/cdm/player_tracker_impl.h" | 25 #include "media/cdm/player_tracker_impl.h" |
| 27 #include "testing/gtest/include/gtest/gtest.h" | 26 #include "testing/gtest/include/gtest/gtest.h" |
| 28 | 27 |
| 28 using testing::_; |
| 29 using testing::Invoke; |
| 30 using testing::NiceMock; |
| 31 using testing::Return; |
| 32 using testing::SaveArg; |
| 33 |
| 29 namespace { | 34 namespace { |
| 30 // Total number of frames generated by CodedFrameProvider. | 35 // Total number of frames generated by CodedFrameProvider. |
| 31 // The first frame has config, while the last one is EOS. | 36 // The first frame has config, while the last one is EOS. |
| 32 const int kNumFrames = 100; | 37 const int kNumFrames = 100; |
| 33 const int kFrameSize = 512; | 38 const int kFrameSize = 512; |
| 34 const int kFrameDurationUs = 40 * 1000; | 39 const int kFrameDurationUs = 40 * 1000; |
| 35 const int kLastFrameTimestamp = (kNumFrames - 2) * kFrameDurationUs; | 40 const int kLastFrameTimestamp = (kNumFrames - 2) * kFrameDurationUs; |
| 36 } // namespace | 41 } // namespace |
| 37 | 42 |
| 38 namespace chromecast { | 43 namespace chromecast { |
| 39 namespace media { | 44 namespace media { |
| 40 | 45 |
| 46 ACTION_P2(PushBuffer, delegate, buffer_pts) { |
| 47 if (arg0->end_of_stream()) { |
| 48 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 49 FROM_HERE, |
| 50 base::Bind(&MediaPipelineBackend::Decoder::Delegate::OnEndOfStream, |
| 51 base::Unretained(*delegate))); |
| 52 } else { |
| 53 *buffer_pts = arg0->timestamp(); |
| 54 } |
| 55 return MediaPipelineBackend::kBufferSuccess; |
| 56 } |
| 57 |
| 41 class CastCdmContextForTest : public CastCdmContext { | 58 class CastCdmContextForTest : public CastCdmContext { |
| 42 public: | 59 public: |
| 43 CastCdmContextForTest() : license_installed_(false) {} | 60 CastCdmContextForTest() : license_installed_(false) {} |
| 44 void SetLicenseInstalled() { | 61 void SetLicenseInstalled() { |
| 45 license_installed_ = true; | 62 license_installed_ = true; |
| 46 player_tracker_.NotifyNewKey(); | 63 player_tracker_.NotifyNewKey(); |
| 47 } | 64 } |
| 48 | 65 |
| 49 // CastCdmContext implementation: | 66 // CastCdmContext implementation: |
| 50 int RegisterPlayer(const base::Closure& new_key_cb, | 67 int RegisterPlayer(const base::Closure& new_key_cb, |
| (...skipping 24 matching lines...) Expand all Loading... |
| 75 base::Closure new_key_cb_; | 92 base::Closure new_key_cb_; |
| 76 ::media::PlayerTrackerImpl player_tracker_; | 93 ::media::PlayerTrackerImpl player_tracker_; |
| 77 | 94 |
| 78 DISALLOW_COPY_AND_ASSIGN(CastCdmContextForTest); | 95 DISALLOW_COPY_AND_ASSIGN(CastCdmContextForTest); |
| 79 }; | 96 }; |
| 80 | 97 |
| 81 // Helper class for managing pipeline setup, teardown, feeding data, stop/start | 98 // Helper class for managing pipeline setup, teardown, feeding data, stop/start |
| 82 // etc in a simple API for tests to use. | 99 // etc in a simple API for tests to use. |
| 83 class PipelineHelper { | 100 class PipelineHelper { |
| 84 public: | 101 public: |
| 85 PipelineHelper(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 102 enum Stream { STREAM_AUDIO, STREAM_VIDEO }; |
| 86 bool audio, | 103 |
| 87 bool video, | 104 PipelineHelper(bool audio, bool video, bool encrypted) |
| 88 bool encrypted) | |
| 89 : have_audio_(audio), | 105 : have_audio_(audio), |
| 90 have_video_(video), | 106 have_video_(video), |
| 91 encrypted_(encrypted), | 107 encrypted_(encrypted), |
| 92 pipeline_backend_(nullptr) { | 108 pipeline_backend_(nullptr), |
| 93 eos_[STREAM_AUDIO] = eos_[STREAM_VIDEO] = false; | 109 audio_decoder_delegate_(nullptr), |
| 94 } | 110 video_decoder_delegate_(nullptr) {} |
| 95 | 111 |
| 96 void Setup() { | 112 void Setup() { |
| 97 if (encrypted_) { | 113 if (encrypted_) { |
| 98 cdm_context_.reset(new CastCdmContextForTest()); | 114 cdm_context_.reset(new CastCdmContextForTest()); |
| 99 } | 115 } |
| 100 std::unique_ptr<MediaPipelineBackendDefault> backend = | 116 |
| 101 base::MakeUnique<MediaPipelineBackendDefault>(); | 117 pipeline_backend_ = new MockMediaPipelineBackend(); |
| 102 pipeline_backend_ = backend.get(); | 118 ON_CALL(*pipeline_backend_, SetPlaybackRate(_)).WillByDefault(Return(true)); |
| 119 ON_CALL(audio_decoder_, SetConfig(_)).WillByDefault(Return(true)); |
| 120 ON_CALL(audio_decoder_, PushBuffer(_)) |
| 121 .WillByDefault(PushBuffer(&audio_decoder_delegate_, |
| 122 &last_push_pts_[STREAM_AUDIO])); |
| 123 ON_CALL(video_decoder_, SetConfig(_)).WillByDefault(Return(true)); |
| 124 ON_CALL(video_decoder_, PushBuffer(_)) |
| 125 .WillByDefault(PushBuffer(&video_decoder_delegate_, |
| 126 &last_push_pts_[STREAM_VIDEO])); |
| 127 |
| 103 media_pipeline_ = base::MakeUnique<MediaPipelineImpl>(); | 128 media_pipeline_ = base::MakeUnique<MediaPipelineImpl>(); |
| 104 media_pipeline_->Initialize(kLoadTypeURL, std::move(backend)); | 129 media_pipeline_->Initialize(kLoadTypeURL, |
| 130 base::WrapUnique(pipeline_backend_)); |
| 105 | 131 |
| 106 if (have_audio_) { | 132 if (have_audio_) { |
| 107 ::media::AudioDecoderConfig audio_config( | 133 ::media::AudioDecoderConfig audio_config( |
| 108 ::media::kCodecMP3, ::media::kSampleFormatS16, | 134 ::media::kCodecMP3, ::media::kSampleFormatS16, |
| 109 ::media::CHANNEL_LAYOUT_STEREO, 44100, ::media::EmptyExtraData(), | 135 ::media::CHANNEL_LAYOUT_STEREO, 44100, ::media::EmptyExtraData(), |
| 110 ::media::Unencrypted()); | 136 ::media::Unencrypted()); |
| 111 AvPipelineClient client; | 137 AvPipelineClient client; |
| 112 client.eos_cb = base::Bind(&PipelineHelper::OnEos, base::Unretained(this), | 138 client.eos_cb = base::Bind(&PipelineHelper::OnEos, base::Unretained(this), |
| 113 STREAM_AUDIO); | 139 STREAM_AUDIO); |
| 140 EXPECT_CALL(*pipeline_backend_, CreateAudioDecoder()) |
| 141 .Times(1) |
| 142 .WillOnce(Return(&audio_decoder_)); |
| 143 EXPECT_CALL(audio_decoder_, SetDelegate(_)) |
| 144 .Times(1) |
| 145 .WillOnce(SaveArg<0>(&audio_decoder_delegate_)); |
| 114 ::media::PipelineStatus status = media_pipeline_->InitializeAudio( | 146 ::media::PipelineStatus status = media_pipeline_->InitializeAudio( |
| 115 audio_config, client, CreateFrameProvider()); | 147 audio_config, client, CreateFrameProvider()); |
| 116 ASSERT_EQ(::media::PIPELINE_OK, status); | 148 ASSERT_EQ(::media::PIPELINE_OK, status); |
| 117 } | 149 } |
| 118 if (have_video_) { | 150 if (have_video_) { |
| 119 std::vector<::media::VideoDecoderConfig> video_configs; | 151 std::vector<::media::VideoDecoderConfig> video_configs; |
| 120 video_configs.push_back(::media::VideoDecoderConfig( | 152 video_configs.push_back(::media::VideoDecoderConfig( |
| 121 ::media::kCodecH264, ::media::H264PROFILE_MAIN, | 153 ::media::kCodecH264, ::media::H264PROFILE_MAIN, |
| 122 ::media::PIXEL_FORMAT_I420, ::media::COLOR_SPACE_UNSPECIFIED, | 154 ::media::PIXEL_FORMAT_I420, ::media::COLOR_SPACE_UNSPECIFIED, |
| 123 gfx::Size(640, 480), gfx::Rect(0, 0, 640, 480), gfx::Size(640, 480), | 155 gfx::Size(640, 480), gfx::Rect(0, 0, 640, 480), gfx::Size(640, 480), |
| 124 ::media::EmptyExtraData(), ::media::EncryptionScheme())); | 156 ::media::EmptyExtraData(), ::media::EncryptionScheme())); |
| 125 VideoPipelineClient client; | 157 VideoPipelineClient client; |
| 126 client.av_pipeline_client.eos_cb = base::Bind( | 158 client.av_pipeline_client.eos_cb = base::Bind( |
| 127 &PipelineHelper::OnEos, base::Unretained(this), STREAM_VIDEO); | 159 &PipelineHelper::OnEos, base::Unretained(this), STREAM_VIDEO); |
| 160 EXPECT_CALL(*pipeline_backend_, CreateVideoDecoder()) |
| 161 .Times(1) |
| 162 .WillOnce(Return(&video_decoder_)); |
| 163 EXPECT_CALL(video_decoder_, SetDelegate(_)) |
| 164 .Times(1) |
| 165 .WillOnce(SaveArg<0>(&video_decoder_delegate_)); |
| 128 ::media::PipelineStatus status = media_pipeline_->InitializeVideo( | 166 ::media::PipelineStatus status = media_pipeline_->InitializeVideo( |
| 129 video_configs, client, CreateFrameProvider()); | 167 video_configs, client, CreateFrameProvider()); |
| 130 ASSERT_EQ(::media::PIPELINE_OK, status); | 168 ASSERT_EQ(::media::PIPELINE_OK, status); |
| 131 } | 169 } |
| 132 } | 170 } |
| 133 | 171 |
| 134 void Start(const base::Closure& eos_cb) { | 172 void Start(const base::Closure& eos_cb) { |
| 135 eos_cb_ = eos_cb; | 173 eos_cb_ = eos_cb; |
| 136 eos_[STREAM_AUDIO] = !media_pipeline_->HasAudio(); | 174 eos_[STREAM_AUDIO] = !media_pipeline_->HasAudio(); |
| 137 eos_[STREAM_VIDEO] = !media_pipeline_->HasVideo(); | 175 eos_[STREAM_VIDEO] = !media_pipeline_->HasVideo(); |
| 138 base::TimeDelta start_time = base::TimeDelta::FromMilliseconds(0); | 176 last_push_pts_[STREAM_AUDIO] = std::numeric_limits<int64_t>::min(); |
| 139 media_pipeline_->StartPlayingFrom(start_time); | 177 last_push_pts_[STREAM_VIDEO] = std::numeric_limits<int64_t>::min(); |
| 140 media_pipeline_->SetPlaybackRate(1.0); | 178 int64_t start_pts = 0; |
| 179 |
| 180 EXPECT_CALL(*pipeline_backend_, Initialize()) |
| 181 .Times(1) |
| 182 .WillOnce(Return(true)); |
| 183 EXPECT_CALL(*pipeline_backend_, Start(start_pts)) |
| 184 .Times(1) |
| 185 .WillOnce(Return(true)); |
| 186 |
| 187 media_pipeline_->StartPlayingFrom( |
| 188 base::TimeDelta::FromMilliseconds(start_pts)); |
| 189 media_pipeline_->SetPlaybackRate(1.0f); |
| 141 } | 190 } |
| 142 void SetCdm() { media_pipeline_->SetCdm(cdm_context_.get()); } | 191 void SetCdm() { media_pipeline_->SetCdm(cdm_context_.get()); } |
| 143 void Flush(const base::Closure& flush_cb) { | 192 void Flush(const base::Closure& flush_cb) { |
| 193 EXPECT_CALL(*pipeline_backend_, Stop()).Times(1); |
| 144 media_pipeline_->Flush(flush_cb); | 194 media_pipeline_->Flush(flush_cb); |
| 145 } | 195 } |
| 146 void Stop() { | 196 void Stop() { |
| 147 media_pipeline_.reset(); | 197 media_pipeline_.reset(); |
| 148 base::MessageLoop::current()->QuitWhenIdle(); | 198 base::MessageLoop::current()->QuitWhenIdle(); |
| 149 } | 199 } |
| 150 void SetCdmLicenseInstalled() { cdm_context_->SetLicenseInstalled(); } | 200 void SetCdmLicenseInstalled() { cdm_context_->SetLicenseInstalled(); } |
| 151 | 201 |
| 152 MediaPipelineBackendDefault* pipeline_backend() { return pipeline_backend_; } | 202 bool have_audio() const { return have_audio_; } |
| 203 bool have_video() const { return have_video_; } |
| 204 int64_t last_push_pts(Stream stream) const { return last_push_pts_[stream]; } |
| 153 | 205 |
| 154 private: | 206 private: |
| 155 enum Stream { STREAM_AUDIO, STREAM_VIDEO }; | |
| 156 | |
| 157 std::unique_ptr<CodedFrameProvider> CreateFrameProvider() { | 207 std::unique_ptr<CodedFrameProvider> CreateFrameProvider() { |
| 158 std::vector<FrameGeneratorForTest::FrameSpec> frame_specs; | 208 std::vector<FrameGeneratorForTest::FrameSpec> frame_specs; |
| 159 frame_specs.resize(kNumFrames); | 209 frame_specs.resize(kNumFrames); |
| 160 for (size_t k = 0; k < frame_specs.size() - 1; k++) { | 210 for (size_t k = 0; k < frame_specs.size() - 1; k++) { |
| 161 frame_specs[k].has_config = (k == 0); | 211 frame_specs[k].has_config = (k == 0); |
| 162 frame_specs[k].timestamp = | 212 frame_specs[k].timestamp = |
| 163 base::TimeDelta::FromMicroseconds(kFrameDurationUs) * k; | 213 base::TimeDelta::FromMicroseconds(kFrameDurationUs) * k; |
| 164 frame_specs[k].size = kFrameSize; | 214 frame_specs[k].size = kFrameSize; |
| 165 frame_specs[k].has_decrypt_config = encrypted_; | 215 frame_specs[k].has_decrypt_config = encrypted_; |
| 166 } | 216 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 182 void OnEos(Stream stream) { | 232 void OnEos(Stream stream) { |
| 183 eos_[stream] = true; | 233 eos_[stream] = true; |
| 184 if (eos_[STREAM_AUDIO] && eos_[STREAM_VIDEO] && !eos_cb_.is_null()) | 234 if (eos_[STREAM_AUDIO] && eos_[STREAM_VIDEO] && !eos_cb_.is_null()) |
| 185 eos_cb_.Run(); | 235 eos_cb_.Run(); |
| 186 } | 236 } |
| 187 | 237 |
| 188 bool have_audio_; | 238 bool have_audio_; |
| 189 bool have_video_; | 239 bool have_video_; |
| 190 bool encrypted_; | 240 bool encrypted_; |
| 191 bool eos_[2]; | 241 bool eos_[2]; |
| 242 int64_t last_push_pts_[2]; |
| 192 base::Closure eos_cb_; | 243 base::Closure eos_cb_; |
| 193 std::unique_ptr<CastCdmContextForTest> cdm_context_; | 244 std::unique_ptr<CastCdmContextForTest> cdm_context_; |
| 245 MockMediaPipelineBackend* pipeline_backend_; |
| 246 NiceMock<MockAudioDecoder> audio_decoder_; |
| 247 NiceMock<MockVideoDecoder> video_decoder_; |
| 248 MediaPipelineBackend::Decoder::Delegate* audio_decoder_delegate_; |
| 249 MediaPipelineBackend::Decoder::Delegate* video_decoder_delegate_; |
| 194 std::unique_ptr<MediaPipelineImpl> media_pipeline_; | 250 std::unique_ptr<MediaPipelineImpl> media_pipeline_; |
| 195 MediaPipelineBackendDefault* pipeline_backend_; | |
| 196 | 251 |
| 197 DISALLOW_COPY_AND_ASSIGN(PipelineHelper); | 252 DISALLOW_COPY_AND_ASSIGN(PipelineHelper); |
| 198 }; | 253 }; |
| 199 | 254 |
| 200 using AudioVideoTuple = ::testing::tuple<bool, bool>; | 255 using AudioVideoTuple = ::testing::tuple<bool, bool>; |
| 201 | 256 |
| 202 class AudioVideoPipelineImplTest | 257 class AudioVideoPipelineImplTest |
| 203 : public ::testing::TestWithParam<AudioVideoTuple> { | 258 : public ::testing::TestWithParam<AudioVideoTuple> { |
| 204 public: | 259 public: |
| 205 AudioVideoPipelineImplTest() {} | 260 AudioVideoPipelineImplTest() {} |
| 206 | 261 |
| 207 protected: | 262 protected: |
| 208 void SetUp() override { | 263 void SetUp() override { |
| 209 pipeline_helper_.reset(new PipelineHelper( | 264 pipeline_helper_.reset(new PipelineHelper( |
| 210 message_loop_.task_runner(), ::testing::get<0>(GetParam()), | 265 ::testing::get<0>(GetParam()), ::testing::get<1>(GetParam()), false)); |
| 211 ::testing::get<1>(GetParam()), false)); | |
| 212 pipeline_helper_->Setup(); | 266 pipeline_helper_->Setup(); |
| 213 } | 267 } |
| 214 | 268 |
| 215 base::MessageLoop message_loop_; | 269 base::MessageLoop message_loop_; |
| 216 std::unique_ptr<PipelineHelper> pipeline_helper_; | 270 std::unique_ptr<PipelineHelper> pipeline_helper_; |
| 217 | 271 |
| 218 DISALLOW_COPY_AND_ASSIGN(AudioVideoPipelineImplTest); | 272 DISALLOW_COPY_AND_ASSIGN(AudioVideoPipelineImplTest); |
| 219 }; | 273 }; |
| 220 | 274 |
| 221 static void VerifyPlay(PipelineHelper* pipeline_helper) { | 275 static void VerifyPlay(PipelineHelper* pipeline_helper) { |
| 222 // The backend must still be running. | 276 // The decoders must have received the last frame. |
| 223 MediaPipelineBackendDefault* backend = pipeline_helper->pipeline_backend(); | 277 if (pipeline_helper->have_audio()) |
| 224 EXPECT_TRUE(backend->running()); | 278 EXPECT_EQ(kLastFrameTimestamp, |
| 225 | 279 pipeline_helper->last_push_pts(PipelineHelper::STREAM_AUDIO)); |
| 226 // The decoders must have received a few frames. | 280 if (pipeline_helper->have_video()) |
| 227 const AudioDecoderDefault* audio_decoder = backend->audio_decoder(); | 281 EXPECT_EQ(kLastFrameTimestamp, |
| 228 const VideoDecoderDefault* video_decoder = backend->video_decoder(); | 282 pipeline_helper->last_push_pts(PipelineHelper::STREAM_VIDEO)); |
| 229 ASSERT_TRUE(audio_decoder || video_decoder); | |
| 230 if (audio_decoder) | |
| 231 EXPECT_EQ(kLastFrameTimestamp, audio_decoder->last_push_pts()); | |
| 232 if (video_decoder) | |
| 233 EXPECT_EQ(kLastFrameTimestamp, video_decoder->last_push_pts()); | |
| 234 | 283 |
| 235 pipeline_helper->Stop(); | 284 pipeline_helper->Stop(); |
| 236 } | 285 } |
| 237 | 286 |
| 238 TEST_P(AudioVideoPipelineImplTest, Play) { | 287 TEST_P(AudioVideoPipelineImplTest, Play) { |
| 239 base::Closure verify_task = | 288 base::Closure verify_task = |
| 240 base::Bind(&VerifyPlay, base::Unretained(pipeline_helper_.get())); | 289 base::Bind(&VerifyPlay, base::Unretained(pipeline_helper_.get())); |
| 241 message_loop_.task_runner()->PostTask( | 290 message_loop_.task_runner()->PostTask( |
| 242 FROM_HERE, | 291 FROM_HERE, |
| 243 base::Bind(&PipelineHelper::Start, | 292 base::Bind(&PipelineHelper::Start, |
| 244 base::Unretained(pipeline_helper_.get()), verify_task)); | 293 base::Unretained(pipeline_helper_.get()), verify_task)); |
| 245 base::RunLoop().Run(); | 294 base::RunLoop().Run(); |
| 246 } | 295 } |
| 247 | 296 |
| 248 static void VerifyFlush(PipelineHelper* pipeline_helper) { | 297 static void VerifyFlush(PipelineHelper* pipeline_helper) { |
| 249 // The backend must have been stopped. | |
| 250 MediaPipelineBackendDefault* backend = pipeline_helper->pipeline_backend(); | |
| 251 EXPECT_FALSE(backend->running()); | |
| 252 | |
| 253 // The decoders must not have received any frame. | 298 // The decoders must not have received any frame. |
| 254 const AudioDecoderDefault* audio_decoder = backend->audio_decoder(); | 299 if (pipeline_helper->have_audio()) |
| 255 const VideoDecoderDefault* video_decoder = backend->video_decoder(); | 300 EXPECT_LT(pipeline_helper->last_push_pts(PipelineHelper::STREAM_AUDIO), 0); |
| 256 ASSERT_TRUE(audio_decoder || video_decoder); | 301 if (pipeline_helper->have_video()) |
| 257 if (audio_decoder) | 302 EXPECT_LT(pipeline_helper->last_push_pts(PipelineHelper::STREAM_VIDEO), 0); |
| 258 EXPECT_LT(audio_decoder->last_push_pts(), 0); | |
| 259 if (video_decoder) | |
| 260 EXPECT_LT(video_decoder->last_push_pts(), 0); | |
| 261 | 303 |
| 262 pipeline_helper->Stop(); | 304 pipeline_helper->Stop(); |
| 263 } | 305 } |
| 264 | 306 |
| 265 static void VerifyNotReached() { | 307 static void VerifyNotReached() { |
| 266 EXPECT_TRUE(false); | 308 EXPECT_TRUE(false); |
| 267 } | 309 } |
| 268 | 310 |
| 269 TEST_P(AudioVideoPipelineImplTest, Flush) { | 311 TEST_P(AudioVideoPipelineImplTest, Flush) { |
| 270 base::Closure verify_task = | 312 base::Closure verify_task = |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 303 AudioVideoTuple(true, true))); // Audio and Video. | 345 AudioVideoTuple(true, true))); // Audio and Video. |
| 304 | 346 |
| 305 // These tests verify that the pipeline handles encrypted media playback | 347 // These tests verify that the pipeline handles encrypted media playback |
| 306 // events (in particular, CDM and license installation) correctly. | 348 // events (in particular, CDM and license installation) correctly. |
| 307 class EncryptedAVPipelineImplTest : public ::testing::Test { | 349 class EncryptedAVPipelineImplTest : public ::testing::Test { |
| 308 public: | 350 public: |
| 309 EncryptedAVPipelineImplTest() {} | 351 EncryptedAVPipelineImplTest() {} |
| 310 | 352 |
| 311 protected: | 353 protected: |
| 312 void SetUp() override { | 354 void SetUp() override { |
| 313 pipeline_helper_.reset( | 355 pipeline_helper_.reset(new PipelineHelper(true, true, true)); |
| 314 new PipelineHelper(message_loop_.task_runner(), true, true, true)); | |
| 315 pipeline_helper_->Setup(); | 356 pipeline_helper_->Setup(); |
| 316 } | 357 } |
| 317 | 358 |
| 318 base::MessageLoop message_loop_; | 359 base::MessageLoop message_loop_; |
| 319 std::unique_ptr<PipelineHelper> pipeline_helper_; | 360 std::unique_ptr<PipelineHelper> pipeline_helper_; |
| 320 | 361 |
| 321 DISALLOW_COPY_AND_ASSIGN(EncryptedAVPipelineImplTest); | 362 DISALLOW_COPY_AND_ASSIGN(EncryptedAVPipelineImplTest); |
| 322 }; | 363 }; |
| 323 | 364 |
| 324 // Sets a CDM with license already installed before starting the pipeline. | 365 // Sets a CDM with license already installed before starting the pipeline. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 | 412 |
| 372 base::RunLoop().RunUntilIdle(); | 413 base::RunLoop().RunUntilIdle(); |
| 373 message_loop_.task_runner()->PostTask( | 414 message_loop_.task_runner()->PostTask( |
| 374 FROM_HERE, base::Bind(&PipelineHelper::SetCdmLicenseInstalled, | 415 FROM_HERE, base::Bind(&PipelineHelper::SetCdmLicenseInstalled, |
| 375 base::Unretained(pipeline_helper_.get()))); | 416 base::Unretained(pipeline_helper_.get()))); |
| 376 base::RunLoop().Run(); | 417 base::RunLoop().Run(); |
| 377 } | 418 } |
| 378 | 419 |
| 379 } // namespace media | 420 } // namespace media |
| 380 } // namespace chromecast | 421 } // namespace chromecast |
| OLD | NEW |