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

Side by Side Diff: chromecast/media/cma/backend/audio_video_pipeline_device_unittest.cc

Issue 1875623002: Convert //chromecast from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h> 5 #include <stdint.h>
6 6
7 #include <limits> 7 #include <limits>
8 #include <memory>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/bind.h" 11 #include "base/bind.h"
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/files/memory_mapped_file.h" 14 #include "base/files/memory_mapped_file.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
17 #include "base/memory/ptr_util.h"
16 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/scoped_vector.h" 19 #include "base/memory/scoped_vector.h"
19 #include "base/message_loop/message_loop.h" 20 #include "base/message_loop/message_loop.h"
20 #include "base/path_service.h" 21 #include "base/path_service.h"
21 #include "base/single_thread_task_runner.h" 22 #include "base/single_thread_task_runner.h"
22 #include "base/thread_task_runner_handle.h" 23 #include "base/thread_task_runner_handle.h"
23 #include "base/threading/thread.h" 24 #include "base/threading/thread.h"
24 #include "base/threading/thread_checker.h" 25 #include "base/threading/thread_checker.h"
25 #include "base/time/time.h" 26 #include "base/time/time.h"
26 #include "chromecast/base/task_runner_impl.h" 27 #include "chromecast/base/task_runner_impl.h"
27 #include "chromecast/media/cma/base/decoder_buffer_adapter.h" 28 #include "chromecast/media/cma/base/decoder_buffer_adapter.h"
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 .Append(FILE_PATH_LITERAL("test")).Append(FILE_PATH_LITERAL("data")) 84 .Append(FILE_PATH_LITERAL("test")).Append(FILE_PATH_LITERAL("data"))
84 .AppendASCII(name); 85 .AppendASCII(name);
85 return file_path; 86 return file_path;
86 } 87 }
87 88
88 class BufferFeeder : public MediaPipelineBackend::Decoder::Delegate { 89 class BufferFeeder : public MediaPipelineBackend::Decoder::Delegate {
89 public: 90 public:
90 explicit BufferFeeder(const base::Closure& eos_cb); 91 explicit BufferFeeder(const base::Closure& eos_cb);
91 ~BufferFeeder() override {} 92 ~BufferFeeder() override {}
92 93
93 static scoped_ptr<BufferFeeder> LoadAudio(MediaPipelineBackend* backend, 94 static std::unique_ptr<BufferFeeder> LoadAudio(MediaPipelineBackend* backend,
94 const std::string& filename, 95 const std::string& filename,
95 const base::Closure& eos_cb); 96 const base::Closure& eos_cb);
96 static scoped_ptr<BufferFeeder> LoadVideo(MediaPipelineBackend* backend, 97 static std::unique_ptr<BufferFeeder> LoadVideo(MediaPipelineBackend* backend,
97 const std::string& filename, 98 const std::string& filename,
98 bool raw_h264, 99 bool raw_h264,
99 const base::Closure& eos_cb); 100 const base::Closure& eos_cb);
100 101
101 bool eos() const { return eos_; } 102 bool eos() const { return eos_; }
102 MediaPipelineBackend::Decoder* decoder() const { return decoder_; } 103 MediaPipelineBackend::Decoder* decoder() const { return decoder_; }
103 int64_t last_pushed_pts() const { return last_pushed_pts_; } 104 int64_t last_pushed_pts() const { return last_pushed_pts_; }
104 105
105 void SetAudioConfig(const AudioConfig& config) { audio_config_ = config; } 106 void SetAudioConfig(const AudioConfig& config) { audio_config_ = config; }
106 void SetVideoConfig(const VideoConfig& config) { video_config_ = config; } 107 void SetVideoConfig(const VideoConfig& config) { video_config_ = config; }
107 108
108 void FeedContinuousPcm(); 109 void FeedContinuousPcm();
109 void PauseBeforeEos(); 110 void PauseBeforeEos();
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 bool feed_continuous_pcm_; 144 bool feed_continuous_pcm_;
144 MediaPipelineBackend* backend_; 145 MediaPipelineBackend* backend_;
145 MediaPipelineBackend::Decoder* decoder_; 146 MediaPipelineBackend::Decoder* decoder_;
146 BufferList buffers_; 147 BufferList buffers_;
147 BufferList buffers_copy_; 148 BufferList buffers_copy_;
148 scoped_refptr<DecoderBufferBase> pending_buffer_; 149 scoped_refptr<DecoderBufferBase> pending_buffer_;
149 base::ThreadChecker thread_checker_; 150 base::ThreadChecker thread_checker_;
150 AudioConfig audio_config_; 151 AudioConfig audio_config_;
151 VideoConfig video_config_; 152 VideoConfig video_config_;
152 int64_t last_pushed_pts_; 153 int64_t last_pushed_pts_;
153 scoped_ptr<::media::AudioTimestampHelper> timestamp_helper_; 154 std::unique_ptr<::media::AudioTimestampHelper> timestamp_helper_;
154 155
155 DISALLOW_COPY_AND_ASSIGN(BufferFeeder); 156 DISALLOW_COPY_AND_ASSIGN(BufferFeeder);
156 }; 157 };
157 158
158 } // namespace 159 } // namespace
159 160
160 class AudioVideoPipelineDeviceTest : public testing::Test { 161 class AudioVideoPipelineDeviceTest : public testing::Test {
161 public: 162 public:
162 struct PauseInfo { 163 struct PauseInfo {
163 PauseInfo() {} 164 PauseInfo() {}
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 202
202 // Adds a pause to the end of pause pattern 203 // Adds a pause to the end of pause pattern
203 void AddPause(base::TimeDelta delay, base::TimeDelta length); 204 void AddPause(base::TimeDelta delay, base::TimeDelta length);
204 void PauseBeforeEos(); 205 void PauseBeforeEos();
205 void AddEffectsStreams(); 206 void AddEffectsStreams();
206 207
207 void Initialize(); 208 void Initialize();
208 void Start(); 209 void Start();
209 void OnEndOfStream(); 210 void OnEndOfStream();
210 211
211 void SetAudioFeeder(scoped_ptr<BufferFeeder> audio_feeder) { 212 void SetAudioFeeder(std::unique_ptr<BufferFeeder> audio_feeder) {
212 audio_feeder_ = std::move(audio_feeder); 213 audio_feeder_ = std::move(audio_feeder);
213 } 214 }
214 void SetVideoFeeder(scoped_ptr<BufferFeeder> video_feeder) { 215 void SetVideoFeeder(std::unique_ptr<BufferFeeder> video_feeder) {
215 video_feeder_ = std::move(video_feeder); 216 video_feeder_ = std::move(video_feeder);
216 } 217 }
217 218
218 void RunStoppedChecks(); 219 void RunStoppedChecks();
219 void RunPlaybackChecks(); 220 void RunPlaybackChecks();
220 void TestBackendStates(); 221 void TestBackendStates();
221 void StartImmediateEosTest(); 222 void StartImmediateEosTest();
222 void EndImmediateEosTest(); 223 void EndImmediateEosTest();
223 224
224 private: 225 private:
225 void MonitorLoop(); 226 void MonitorLoop();
226 227
227 void OnPauseCompleted(); 228 void OnPauseCompleted();
228 229
229 MediaPipelineDeviceParams::MediaSyncType sync_type_; 230 MediaPipelineDeviceParams::MediaSyncType sync_type_;
230 MediaPipelineDeviceParams::AudioStreamType audio_type_; 231 MediaPipelineDeviceParams::AudioStreamType audio_type_;
231 scoped_ptr<TaskRunnerImpl> task_runner_; 232 std::unique_ptr<TaskRunnerImpl> task_runner_;
232 scoped_ptr<MediaPipelineBackend> backend_; 233 std::unique_ptr<MediaPipelineBackend> backend_;
233 std::vector<scoped_ptr<MediaPipelineBackend>> effects_backends_; 234 std::vector<std::unique_ptr<MediaPipelineBackend>> effects_backends_;
234 std::vector<scoped_ptr<BufferFeeder>> effects_feeders_; 235 std::vector<std::unique_ptr<BufferFeeder>> effects_feeders_;
235 scoped_ptr<BufferFeeder> audio_feeder_; 236 std::unique_ptr<BufferFeeder> audio_feeder_;
236 scoped_ptr<BufferFeeder> video_feeder_; 237 std::unique_ptr<BufferFeeder> video_feeder_;
237 bool stopped_; 238 bool stopped_;
238 bool ran_playing_playback_checks_; 239 bool ran_playing_playback_checks_;
239 bool backwards_pts_change_; 240 bool backwards_pts_change_;
240 int64_t last_pts_; 241 int64_t last_pts_;
241 242
242 // Current media time. 243 // Current media time.
243 base::TimeDelta pause_time_; 244 base::TimeDelta pause_time_;
244 245
245 // Pause settings 246 // Pause settings
246 std::vector<PauseInfo> pause_pattern_; 247 std::vector<PauseInfo> pause_pattern_;
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 static_cast<MediaPipelineBackend::VideoDecoder*>(decoder_); 520 static_cast<MediaPipelineBackend::VideoDecoder*>(decoder_);
520 VideoConfig config; 521 VideoConfig config;
521 config.codec = kVideoCodecUnknown; 522 config.codec = kVideoCodecUnknown;
522 // Set invalid config first, to test that the decoder still accepts valid 523 // Set invalid config first, to test that the decoder still accepts valid
523 // config after an invalid config. 524 // config after an invalid config.
524 video_decoder->SetConfig(config); 525 video_decoder->SetConfig(config);
525 EXPECT_TRUE(video_decoder->SetConfig(video_config_)); 526 EXPECT_TRUE(video_decoder->SetConfig(video_config_));
526 } 527 }
527 528
528 // static 529 // static
529 scoped_ptr<BufferFeeder> BufferFeeder::LoadAudio(MediaPipelineBackend* backend, 530 std::unique_ptr<BufferFeeder> BufferFeeder::LoadAudio(
530 const std::string& filename, 531 MediaPipelineBackend* backend,
531 const base::Closure& eos_cb) { 532 const std::string& filename,
533 const base::Closure& eos_cb) {
532 CHECK(backend); 534 CHECK(backend);
533 base::FilePath file_path = GetTestDataFilePath(filename); 535 base::FilePath file_path = GetTestDataFilePath(filename);
534 DemuxResult demux_result = FFmpegDemuxForTest(file_path, true /* audio */); 536 DemuxResult demux_result = FFmpegDemuxForTest(file_path, true /* audio */);
535 537
536 MediaPipelineBackend::AudioDecoder* decoder = backend->CreateAudioDecoder(); 538 MediaPipelineBackend::AudioDecoder* decoder = backend->CreateAudioDecoder();
537 CHECK(decoder); 539 CHECK(decoder);
538 AudioConfig config = DecoderConfigAdapter::ToCastAudioConfig( 540 AudioConfig config = DecoderConfigAdapter::ToCastAudioConfig(
539 kPrimary, demux_result.audio_config); 541 kPrimary, demux_result.audio_config);
540 bool success = decoder->SetConfig(config); 542 bool success = decoder->SetConfig(config);
541 CHECK(success); 543 CHECK(success);
542 544
543 VLOG(2) << "Got " << demux_result.frames.size() << " audio input frames"; 545 VLOG(2) << "Got " << demux_result.frames.size() << " audio input frames";
544 scoped_ptr<BufferFeeder> feeder(new BufferFeeder(eos_cb)); 546 std::unique_ptr<BufferFeeder> feeder(new BufferFeeder(eos_cb));
545 feeder->audio_config_ = config; 547 feeder->audio_config_ = config;
546 feeder->Initialize(backend, decoder, demux_result.frames); 548 feeder->Initialize(backend, decoder, demux_result.frames);
547 return feeder; 549 return feeder;
548 } 550 }
549 551
550 // static 552 // static
551 scoped_ptr<BufferFeeder> BufferFeeder::LoadVideo(MediaPipelineBackend* backend, 553 std::unique_ptr<BufferFeeder> BufferFeeder::LoadVideo(
552 const std::string& filename, 554 MediaPipelineBackend* backend,
553 bool raw_h264, 555 const std::string& filename,
554 const base::Closure& eos_cb) { 556 bool raw_h264,
557 const base::Closure& eos_cb) {
555 CHECK(backend); 558 CHECK(backend);
556 559
557 VideoConfig video_config; 560 VideoConfig video_config;
558 BufferList buffers; 561 BufferList buffers;
559 if (raw_h264) { 562 if (raw_h264) {
560 base::FilePath file_path = GetTestDataFilePath(filename); 563 base::FilePath file_path = GetTestDataFilePath(filename);
561 base::MemoryMappedFile video_stream; 564 base::MemoryMappedFile video_stream;
562 CHECK(video_stream.Initialize(file_path)) << "Couldn't open stream file: " 565 CHECK(video_stream.Initialize(file_path)) << "Couldn't open stream file: "
563 << file_path.MaybeAsASCII(); 566 << file_path.MaybeAsASCII();
564 buffers = H264SegmenterForTest(video_stream.data(), video_stream.length()); 567 buffers = H264SegmenterForTest(video_stream.data(), video_stream.length());
(...skipping 11 matching lines...) Expand all
576 kPrimary, demux_result.video_config); 579 kPrimary, demux_result.video_config);
577 } 580 }
578 581
579 MediaPipelineBackend::VideoDecoder* decoder = backend->CreateVideoDecoder(); 582 MediaPipelineBackend::VideoDecoder* decoder = backend->CreateVideoDecoder();
580 CHECK(decoder); 583 CHECK(decoder);
581 584
582 bool success = decoder->SetConfig(video_config); 585 bool success = decoder->SetConfig(video_config);
583 CHECK(success); 586 CHECK(success);
584 587
585 VLOG(2) << "Got " << buffers.size() << " video input frames"; 588 VLOG(2) << "Got " << buffers.size() << " video input frames";
586 scoped_ptr<BufferFeeder> feeder(new BufferFeeder(eos_cb)); 589 std::unique_ptr<BufferFeeder> feeder(new BufferFeeder(eos_cb));
587 feeder->video_config_ = video_config; 590 feeder->video_config_ = video_config;
588 feeder->Initialize(backend, decoder, buffers); 591 feeder->Initialize(backend, decoder, buffers);
589 return feeder; 592 return feeder;
590 } 593 }
591 594
592 } // namespace 595 } // namespace
593 596
594 AudioVideoPipelineDeviceTest::AudioVideoPipelineDeviceTest() 597 AudioVideoPipelineDeviceTest::AudioVideoPipelineDeviceTest()
595 : sync_type_(MediaPipelineDeviceParams::kModeSyncPts), 598 : sync_type_(MediaPipelineDeviceParams::kModeSyncPts),
596 audio_type_(MediaPipelineDeviceParams::kAudioStreamNormal), 599 audio_type_(MediaPipelineDeviceParams::kAudioStreamNormal),
(...skipping 28 matching lines...) Expand all
625 void AudioVideoPipelineDeviceTest::AddEffectsStreams() { 628 void AudioVideoPipelineDeviceTest::AddEffectsStreams() {
626 const int kNumEffectsStreams = 3; 629 const int kNumEffectsStreams = 3;
627 for (int i = 0; i < kNumEffectsStreams; ++i) { 630 for (int i = 0; i < kNumEffectsStreams; ++i) {
628 MediaPipelineDeviceParams params( 631 MediaPipelineDeviceParams params(
629 MediaPipelineDeviceParams::kModeIgnorePts, 632 MediaPipelineDeviceParams::kModeIgnorePts,
630 MediaPipelineDeviceParams::kAudioStreamSoundEffects, 633 MediaPipelineDeviceParams::kAudioStreamSoundEffects,
631 task_runner_.get()); 634 task_runner_.get());
632 MediaPipelineBackend* effects_backend = 635 MediaPipelineBackend* effects_backend =
633 CastMediaShlib::CreateMediaPipelineBackend(params); 636 CastMediaShlib::CreateMediaPipelineBackend(params);
634 CHECK(effects_backend); 637 CHECK(effects_backend);
635 effects_backends_.push_back(make_scoped_ptr(effects_backend)); 638 effects_backends_.push_back(base::WrapUnique(effects_backend));
636 639
637 MediaPipelineBackend::AudioDecoder* audio_decoder = 640 MediaPipelineBackend::AudioDecoder* audio_decoder =
638 effects_backend->CreateAudioDecoder(); 641 effects_backend->CreateAudioDecoder();
639 audio_decoder->SetConfig(DefaultAudioConfig()); 642 audio_decoder->SetConfig(DefaultAudioConfig());
640 643
641 scoped_ptr<BufferFeeder> feeder(new BufferFeeder(base::Bind(&IgnoreEos))); 644 std::unique_ptr<BufferFeeder> feeder(
645 new BufferFeeder(base::Bind(&IgnoreEos)));
642 feeder->FeedContinuousPcm(); 646 feeder->FeedContinuousPcm();
643 feeder->Initialize(effects_backend, audio_decoder, BufferList()); 647 feeder->Initialize(effects_backend, audio_decoder, BufferList());
644 feeder->SetAudioConfig(DefaultAudioConfig()); 648 feeder->SetAudioConfig(DefaultAudioConfig());
645 effects_feeders_.push_back(std::move(feeder)); 649 effects_feeders_.push_back(std::move(feeder));
646 ASSERT_TRUE(effects_backend->Initialize()); 650 ASSERT_TRUE(effects_backend->Initialize());
647 } 651 }
648 } 652 }
649 653
650 void AudioVideoPipelineDeviceTest::SetPausePattern( 654 void AudioVideoPipelineDeviceTest::SetPausePattern(
651 const std::vector<PauseInfo> pattern) { 655 const std::vector<PauseInfo> pattern) {
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
887 891
888 ASSERT_TRUE(backend_->Stop()); 892 ASSERT_TRUE(backend_->Stop());
889 base::MessageLoop::current()->RunUntilIdle(); 893 base::MessageLoop::current()->RunUntilIdle();
890 894
891 RunStoppedChecks(); 895 RunStoppedChecks();
892 896
893 base::MessageLoop::current()->QuitWhenIdle(); 897 base::MessageLoop::current()->QuitWhenIdle();
894 } 898 }
895 899
896 TEST_F(AudioVideoPipelineDeviceTest, Mp3Playback) { 900 TEST_F(AudioVideoPipelineDeviceTest, Mp3Playback) {
897 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 901 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
898 902
899 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 903 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
900 ConfigureForAudioOnly("sfx.mp3"); 904 ConfigureForAudioOnly("sfx.mp3");
901 PauseBeforeEos(); 905 PauseBeforeEos();
902 Start(); 906 Start();
903 message_loop->Run(); 907 message_loop->Run();
904 } 908 }
905 909
906 TEST_F(AudioVideoPipelineDeviceTest, AacPlayback) { 910 TEST_F(AudioVideoPipelineDeviceTest, AacPlayback) {
907 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 911 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
908 912
909 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 913 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
910 ConfigureForAudioOnly("sfx.m4a"); 914 ConfigureForAudioOnly("sfx.m4a");
911 PauseBeforeEos(); 915 PauseBeforeEos();
912 Start(); 916 Start();
913 message_loop->Run(); 917 message_loop->Run();
914 } 918 }
915 919
916 TEST_F(AudioVideoPipelineDeviceTest, VorbisPlayback) { 920 TEST_F(AudioVideoPipelineDeviceTest, VorbisPlayback) {
917 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 921 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
918 922
919 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePts); 923 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePts);
920 ConfigureForAudioOnly("sfx.ogg"); 924 ConfigureForAudioOnly("sfx.ogg");
921 Start(); 925 Start();
922 message_loop->Run(); 926 message_loop->Run();
923 } 927 }
924 928
925 // TODO(kmackay) FFmpegDemuxForTest can't handle AC3 or EAC3. 929 // TODO(kmackay) FFmpegDemuxForTest can't handle AC3 or EAC3.
926 930
927 TEST_F(AudioVideoPipelineDeviceTest, OpusPlayback_Optional) { 931 TEST_F(AudioVideoPipelineDeviceTest, OpusPlayback_Optional) {
928 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 932 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
929 933
930 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 934 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
931 ConfigureForAudioOnly("bear-opus.ogg"); 935 ConfigureForAudioOnly("bear-opus.ogg");
932 PauseBeforeEos(); 936 PauseBeforeEos();
933 Start(); 937 Start();
934 message_loop->Run(); 938 message_loop->Run();
935 } 939 }
936 940
937 TEST_F(AudioVideoPipelineDeviceTest, FlacPlayback_Optional) { 941 TEST_F(AudioVideoPipelineDeviceTest, FlacPlayback_Optional) {
938 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 942 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
939 943
940 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 944 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
941 ConfigureForAudioOnly("bear.flac"); 945 ConfigureForAudioOnly("bear.flac");
942 PauseBeforeEos(); 946 PauseBeforeEos();
943 Start(); 947 Start();
944 message_loop->Run(); 948 message_loop->Run();
945 } 949 }
946 950
947 TEST_F(AudioVideoPipelineDeviceTest, H264Playback) { 951 TEST_F(AudioVideoPipelineDeviceTest, H264Playback) {
948 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 952 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
949 953
950 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePtsAndVSync); 954 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePtsAndVSync);
951 ConfigureForVideoOnly("bear.h264", true /* raw_h264 */); 955 ConfigureForVideoOnly("bear.h264", true /* raw_h264 */);
952 PauseBeforeEos(); 956 PauseBeforeEos();
953 Start(); 957 Start();
954 message_loop->Run(); 958 message_loop->Run();
955 } 959 }
956 960
957 TEST_F(AudioVideoPipelineDeviceTest, WebmPlaybackWithPause) { 961 TEST_F(AudioVideoPipelineDeviceTest, WebmPlaybackWithPause) {
958 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 962 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
959 963
960 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 964 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
961 // Setup to pause for 100ms every 500ms 965 // Setup to pause for 100ms every 500ms
962 AddPause(base::TimeDelta::FromMilliseconds(500), 966 AddPause(base::TimeDelta::FromMilliseconds(500),
963 base::TimeDelta::FromMilliseconds(100)); 967 base::TimeDelta::FromMilliseconds(100));
964 968
965 ConfigureForVideoOnly("bear-640x360.webm", false /* raw_h264 */); 969 ConfigureForVideoOnly("bear-640x360.webm", false /* raw_h264 */);
966 Start(); 970 Start();
967 message_loop->Run(); 971 message_loop->Run();
968 } 972 }
969 973
970 TEST_F(AudioVideoPipelineDeviceTest, Vp8Playback) { 974 TEST_F(AudioVideoPipelineDeviceTest, Vp8Playback) {
971 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 975 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
972 976
973 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 977 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
974 ConfigureForVideoOnly("bear-vp8a.webm", false /* raw_h264 */); 978 ConfigureForVideoOnly("bear-vp8a.webm", false /* raw_h264 */);
975 Start(); 979 Start();
976 message_loop->Run(); 980 message_loop->Run();
977 } 981 }
978 982
979 TEST_F(AudioVideoPipelineDeviceTest, WebmPlayback) { 983 TEST_F(AudioVideoPipelineDeviceTest, WebmPlayback) {
980 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 984 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
981 985
982 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePtsAndVSync); 986 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePtsAndVSync);
983 ConfigureForFile("bear-640x360.webm"); 987 ConfigureForFile("bear-640x360.webm");
984 PauseBeforeEos(); 988 PauseBeforeEos();
985 Start(); 989 Start();
986 message_loop->Run(); 990 message_loop->Run();
987 } 991 }
988 992
989 // TODO(kmackay) FFmpegDemuxForTest can't handle HEVC or VP9. 993 // TODO(kmackay) FFmpegDemuxForTest can't handle HEVC or VP9.
990 994
991 TEST_F(AudioVideoPipelineDeviceTest, AudioBackendStates) { 995 TEST_F(AudioVideoPipelineDeviceTest, AudioBackendStates) {
992 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 996 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
993 Initialize(); 997 Initialize();
994 MediaPipelineBackend::AudioDecoder* audio_decoder = 998 MediaPipelineBackend::AudioDecoder* audio_decoder =
995 backend()->CreateAudioDecoder(); 999 backend()->CreateAudioDecoder();
996 1000
997 // Test setting config before Initialize(). 1001 // Test setting config before Initialize().
998 scoped_ptr<BufferFeeder> feeder(new BufferFeeder(base::Bind(&IgnoreEos))); 1002 std::unique_ptr<BufferFeeder> feeder(
1003 new BufferFeeder(base::Bind(&IgnoreEos)));
999 feeder->Initialize(backend(), audio_decoder, BufferList()); 1004 feeder->Initialize(backend(), audio_decoder, BufferList());
1000 feeder->SetAudioConfig(DefaultAudioConfig()); 1005 feeder->SetAudioConfig(DefaultAudioConfig());
1001 feeder->TestAudioConfigs(); 1006 feeder->TestAudioConfigs();
1002 1007
1003 SetAudioFeeder(std::move(feeder)); 1008 SetAudioFeeder(std::move(feeder));
1004 TestBackendStates(); 1009 TestBackendStates();
1005 } 1010 }
1006 1011
1007 TEST_F(AudioVideoPipelineDeviceTest, AudioEffectsBackendStates) { 1012 TEST_F(AudioVideoPipelineDeviceTest, AudioEffectsBackendStates) {
1008 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1013 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1009 set_audio_type(MediaPipelineDeviceParams::kAudioStreamSoundEffects); 1014 set_audio_type(MediaPipelineDeviceParams::kAudioStreamSoundEffects);
1010 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePts); 1015 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePts);
1011 Initialize(); 1016 Initialize();
1012 MediaPipelineBackend::AudioDecoder* audio_decoder = 1017 MediaPipelineBackend::AudioDecoder* audio_decoder =
1013 backend()->CreateAudioDecoder(); 1018 backend()->CreateAudioDecoder();
1014 1019
1015 scoped_ptr<BufferFeeder> feeder(new BufferFeeder(base::Bind(&IgnoreEos))); 1020 std::unique_ptr<BufferFeeder> feeder(
1021 new BufferFeeder(base::Bind(&IgnoreEos)));
1016 feeder->Initialize(backend(), audio_decoder, BufferList()); 1022 feeder->Initialize(backend(), audio_decoder, BufferList());
1017 feeder->SetAudioConfig(DefaultAudioConfig()); 1023 feeder->SetAudioConfig(DefaultAudioConfig());
1018 ASSERT_TRUE(audio_decoder->SetConfig(DefaultAudioConfig())); 1024 ASSERT_TRUE(audio_decoder->SetConfig(DefaultAudioConfig()));
1019 1025
1020 SetAudioFeeder(std::move(feeder)); 1026 SetAudioFeeder(std::move(feeder));
1021 TestBackendStates(); 1027 TestBackendStates();
1022 } 1028 }
1023 1029
1024 TEST_F(AudioVideoPipelineDeviceTest, VideoBackendStates) { 1030 TEST_F(AudioVideoPipelineDeviceTest, VideoBackendStates) {
1025 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1031 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1026 Initialize(); 1032 Initialize();
1027 MediaPipelineBackend::VideoDecoder* video_decoder = 1033 MediaPipelineBackend::VideoDecoder* video_decoder =
1028 backend()->CreateVideoDecoder(); 1034 backend()->CreateVideoDecoder();
1029 1035
1030 // Test setting config before Initialize(). 1036 // Test setting config before Initialize().
1031 scoped_ptr<BufferFeeder> feeder(new BufferFeeder(base::Bind(&IgnoreEos))); 1037 std::unique_ptr<BufferFeeder> feeder(
1038 new BufferFeeder(base::Bind(&IgnoreEos)));
1032 feeder->Initialize(backend(), video_decoder, BufferList()); 1039 feeder->Initialize(backend(), video_decoder, BufferList());
1033 feeder->SetVideoConfig(DefaultVideoConfig()); 1040 feeder->SetVideoConfig(DefaultVideoConfig());
1034 feeder->TestVideoConfigs(); 1041 feeder->TestVideoConfigs();
1035 1042
1036 SetVideoFeeder(std::move(feeder)); 1043 SetVideoFeeder(std::move(feeder));
1037 TestBackendStates(); 1044 TestBackendStates();
1038 } 1045 }
1039 1046
1040 TEST_F(AudioVideoPipelineDeviceTest, AudioImmediateEos) { 1047 TEST_F(AudioVideoPipelineDeviceTest, AudioImmediateEos) {
1041 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1048 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1042 Initialize(); 1049 Initialize();
1043 MediaPipelineBackend::AudioDecoder* audio_decoder = 1050 MediaPipelineBackend::AudioDecoder* audio_decoder =
1044 backend()->CreateAudioDecoder(); 1051 backend()->CreateAudioDecoder();
1045 1052
1046 scoped_ptr<BufferFeeder> feeder(new BufferFeeder( 1053 std::unique_ptr<BufferFeeder> feeder(new BufferFeeder(
1047 base::Bind(&AudioVideoPipelineDeviceTest::EndImmediateEosTest, 1054 base::Bind(&AudioVideoPipelineDeviceTest::EndImmediateEosTest,
1048 base::Unretained(this)))); 1055 base::Unretained(this))));
1049 feeder->Initialize(backend(), audio_decoder, BufferList()); 1056 feeder->Initialize(backend(), audio_decoder, BufferList());
1050 feeder->SetAudioConfig(DefaultAudioConfig()); 1057 feeder->SetAudioConfig(DefaultAudioConfig());
1051 SetAudioFeeder(std::move(feeder)); 1058 SetAudioFeeder(std::move(feeder));
1052 1059
1053 StartImmediateEosTest(); 1060 StartImmediateEosTest();
1054 } 1061 }
1055 1062
1056 TEST_F(AudioVideoPipelineDeviceTest, VideoImmediateEos) { 1063 TEST_F(AudioVideoPipelineDeviceTest, VideoImmediateEos) {
1057 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1064 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1058 Initialize(); 1065 Initialize();
1059 MediaPipelineBackend::VideoDecoder* video_decoder = 1066 MediaPipelineBackend::VideoDecoder* video_decoder =
1060 backend()->CreateVideoDecoder(); 1067 backend()->CreateVideoDecoder();
1061 1068
1062 scoped_ptr<BufferFeeder> feeder(new BufferFeeder( 1069 std::unique_ptr<BufferFeeder> feeder(new BufferFeeder(
1063 base::Bind(&AudioVideoPipelineDeviceTest::EndImmediateEosTest, 1070 base::Bind(&AudioVideoPipelineDeviceTest::EndImmediateEosTest,
1064 base::Unretained(this)))); 1071 base::Unretained(this))));
1065 feeder->Initialize(backend(), video_decoder, BufferList()); 1072 feeder->Initialize(backend(), video_decoder, BufferList());
1066 feeder->SetVideoConfig(DefaultVideoConfig()); 1073 feeder->SetVideoConfig(DefaultVideoConfig());
1067 SetVideoFeeder(std::move(feeder)); 1074 SetVideoFeeder(std::move(feeder));
1068 1075
1069 StartImmediateEosTest(); 1076 StartImmediateEosTest();
1070 } 1077 }
1071 1078
1072 TEST_F(AudioVideoPipelineDeviceTest, Mp3Playback_WithEffectsStreams) { 1079 TEST_F(AudioVideoPipelineDeviceTest, Mp3Playback_WithEffectsStreams) {
1073 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1080 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1074 1081
1075 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 1082 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
1076 ConfigureForAudioOnly("sfx.mp3"); 1083 ConfigureForAudioOnly("sfx.mp3");
1077 PauseBeforeEos(); 1084 PauseBeforeEos();
1078 AddEffectsStreams(); 1085 AddEffectsStreams();
1079 Start(); 1086 Start();
1080 message_loop->Run(); 1087 message_loop->Run();
1081 } 1088 }
1082 1089
1083 TEST_F(AudioVideoPipelineDeviceTest, AacPlayback_WithEffectsStreams) { 1090 TEST_F(AudioVideoPipelineDeviceTest, AacPlayback_WithEffectsStreams) {
1084 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1091 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1085 1092
1086 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 1093 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
1087 ConfigureForAudioOnly("sfx.m4a"); 1094 ConfigureForAudioOnly("sfx.m4a");
1088 PauseBeforeEos(); 1095 PauseBeforeEos();
1089 AddEffectsStreams(); 1096 AddEffectsStreams();
1090 Start(); 1097 Start();
1091 message_loop->Run(); 1098 message_loop->Run();
1092 } 1099 }
1093 1100
1094 TEST_F(AudioVideoPipelineDeviceTest, VorbisPlayback_WithEffectsStreams) { 1101 TEST_F(AudioVideoPipelineDeviceTest, VorbisPlayback_WithEffectsStreams) {
1095 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1102 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1096 1103
1097 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePts); 1104 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePts);
1098 ConfigureForAudioOnly("sfx.ogg"); 1105 ConfigureForAudioOnly("sfx.ogg");
1099 AddEffectsStreams(); 1106 AddEffectsStreams();
1100 Start(); 1107 Start();
1101 message_loop->Run(); 1108 message_loop->Run();
1102 } 1109 }
1103 1110
1104 // TODO(kmackay) FFmpegDemuxForTest can't handle AC3 or EAC3. 1111 // TODO(kmackay) FFmpegDemuxForTest can't handle AC3 or EAC3.
1105 1112
1106 TEST_F(AudioVideoPipelineDeviceTest, OpusPlayback_WithEffectsStreams_Optional) { 1113 TEST_F(AudioVideoPipelineDeviceTest, OpusPlayback_WithEffectsStreams_Optional) {
1107 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1114 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1108 1115
1109 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 1116 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
1110 ConfigureForAudioOnly("bear-opus.ogg"); 1117 ConfigureForAudioOnly("bear-opus.ogg");
1111 PauseBeforeEos(); 1118 PauseBeforeEos();
1112 AddEffectsStreams(); 1119 AddEffectsStreams();
1113 Start(); 1120 Start();
1114 message_loop->Run(); 1121 message_loop->Run();
1115 } 1122 }
1116 1123
1117 TEST_F(AudioVideoPipelineDeviceTest, FlacPlayback_WithEffectsStreams_Optional) { 1124 TEST_F(AudioVideoPipelineDeviceTest, FlacPlayback_WithEffectsStreams_Optional) {
1118 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1125 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1119 1126
1120 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 1127 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
1121 ConfigureForAudioOnly("bear.flac"); 1128 ConfigureForAudioOnly("bear.flac");
1122 PauseBeforeEos(); 1129 PauseBeforeEos();
1123 AddEffectsStreams(); 1130 AddEffectsStreams();
1124 Start(); 1131 Start();
1125 message_loop->Run(); 1132 message_loop->Run();
1126 } 1133 }
1127 1134
1128 TEST_F(AudioVideoPipelineDeviceTest, H264Playback_WithEffectsStreams) { 1135 TEST_F(AudioVideoPipelineDeviceTest, H264Playback_WithEffectsStreams) {
1129 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1136 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1130 1137
1131 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePtsAndVSync); 1138 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePtsAndVSync);
1132 ConfigureForVideoOnly("bear.h264", true /* raw_h264 */); 1139 ConfigureForVideoOnly("bear.h264", true /* raw_h264 */);
1133 PauseBeforeEos(); 1140 PauseBeforeEos();
1134 AddEffectsStreams(); 1141 AddEffectsStreams();
1135 Start(); 1142 Start();
1136 message_loop->Run(); 1143 message_loop->Run();
1137 } 1144 }
1138 1145
1139 TEST_F(AudioVideoPipelineDeviceTest, WebmPlaybackWithPause_WithEffectsStreams) { 1146 TEST_F(AudioVideoPipelineDeviceTest, WebmPlaybackWithPause_WithEffectsStreams) {
1140 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1147 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1141 1148
1142 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 1149 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
1143 // Setup to pause for 100ms every 500ms 1150 // Setup to pause for 100ms every 500ms
1144 AddPause(base::TimeDelta::FromMilliseconds(500), 1151 AddPause(base::TimeDelta::FromMilliseconds(500),
1145 base::TimeDelta::FromMilliseconds(100)); 1152 base::TimeDelta::FromMilliseconds(100));
1146 1153
1147 ConfigureForVideoOnly("bear-640x360.webm", false /* raw_h264 */); 1154 ConfigureForVideoOnly("bear-640x360.webm", false /* raw_h264 */);
1148 AddEffectsStreams(); 1155 AddEffectsStreams();
1149 Start(); 1156 Start();
1150 message_loop->Run(); 1157 message_loop->Run();
1151 } 1158 }
1152 1159
1153 TEST_F(AudioVideoPipelineDeviceTest, Vp8Playback_WithEffectsStreams) { 1160 TEST_F(AudioVideoPipelineDeviceTest, Vp8Playback_WithEffectsStreams) {
1154 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1161 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1155 1162
1156 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts); 1163 set_sync_type(MediaPipelineDeviceParams::kModeSyncPts);
1157 ConfigureForVideoOnly("bear-vp8a.webm", false /* raw_h264 */); 1164 ConfigureForVideoOnly("bear-vp8a.webm", false /* raw_h264 */);
1158 AddEffectsStreams(); 1165 AddEffectsStreams();
1159 Start(); 1166 Start();
1160 message_loop->Run(); 1167 message_loop->Run();
1161 } 1168 }
1162 1169
1163 TEST_F(AudioVideoPipelineDeviceTest, WebmPlayback_WithEffectsStreams) { 1170 TEST_F(AudioVideoPipelineDeviceTest, WebmPlayback_WithEffectsStreams) {
1164 scoped_ptr<base::MessageLoop> message_loop(new base::MessageLoop()); 1171 std::unique_ptr<base::MessageLoop> message_loop(new base::MessageLoop());
1165 1172
1166 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePtsAndVSync); 1173 set_sync_type(MediaPipelineDeviceParams::kModeIgnorePtsAndVSync);
1167 ConfigureForFile("bear-640x360.webm"); 1174 ConfigureForFile("bear-640x360.webm");
1168 PauseBeforeEos(); 1175 PauseBeforeEos();
1169 AddEffectsStreams(); 1176 AddEffectsStreams();
1170 Start(); 1177 Start();
1171 message_loop->Run(); 1178 message_loop->Run();
1172 } 1179 }
1173 1180
1174 } // namespace media 1181 } // namespace media
1175 } // namespace chromecast 1182 } // namespace chromecast
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698