| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/blink/webmediaplayer_impl.h" | 5 #include "media/blink/webmediaplayer_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| 11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/callback_helpers.h" | 12 #include "base/callback_helpers.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/memory/ptr_util.h" | 14 #include "base/memory/ptr_util.h" |
| 15 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "base/message_loop/message_loop.h" | 17 #include "base/message_loop/message_loop.h" |
| 18 #include "base/run_loop.h" | 18 #include "base/run_loop.h" |
| 19 #include "base/test/scoped_feature_list.h" | 19 #include "base/test/scoped_feature_list.h" |
| 20 #include "base/test/simple_test_tick_clock.h" | 20 #include "base/test/simple_test_tick_clock.h" |
| 21 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
| 22 #include "base/threading/thread_task_runner_handle.h" | 22 #include "base/threading/thread_task_runner_handle.h" |
| 23 #include "media/base/media_log.h" | 23 #include "media/base/media_log.h" |
| 24 #include "media/base/media_switches.h" | 24 #include "media/base/media_switches.h" |
| 25 #include "media/base/test_helpers.h" | 25 #include "media/base/test_helpers.h" |
| 26 #include "media/base/video_frame_provider_factory.h" |
| 26 #include "media/blink/webmediaplayer_delegate.h" | 27 #include "media/blink/webmediaplayer_delegate.h" |
| 27 #include "media/blink/webmediaplayer_params.h" | 28 #include "media/blink/webmediaplayer_params.h" |
| 28 #include "media/renderers/default_renderer_factory.h" | 29 #include "media/renderers/default_renderer_factory.h" |
| 29 #include "testing/gmock/include/gmock/gmock.h" | 30 #include "testing/gmock/include/gmock/gmock.h" |
| 30 #include "testing/gtest/include/gtest/gtest.h" | 31 #include "testing/gtest/include/gtest/gtest.h" |
| 31 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" | 32 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" |
| 32 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 33 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 33 #include "third_party/WebKit/public/platform/WebSize.h" | 34 #include "third_party/WebKit/public/platform/WebSize.h" |
| 34 #include "third_party/WebKit/public/web/WebFrameClient.h" | 35 #include "third_party/WebKit/public/web/WebFrameClient.h" |
| 35 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 36 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 media_log_(new MediaLog()), | 195 media_log_(new MediaLog()), |
| 195 audio_parameters_(TestAudioParameters::Normal()) { | 196 audio_parameters_(TestAudioParameters::Normal()) { |
| 196 web_view_->setMainFrame(web_local_frame_); | 197 web_view_->setMainFrame(web_local_frame_); |
| 197 media_thread_.StartAndWaitForTesting(); | 198 media_thread_.StartAndWaitForTesting(); |
| 198 } | 199 } |
| 199 | 200 |
| 200 void InitializeWebMediaPlayerImpl(bool allow_suspend) { | 201 void InitializeWebMediaPlayerImpl(bool allow_suspend) { |
| 201 wmpi_ = base::MakeUnique<WebMediaPlayerImpl>( | 202 wmpi_ = base::MakeUnique<WebMediaPlayerImpl>( |
| 202 web_local_frame_, &client_, nullptr, &delegate_, | 203 web_local_frame_, &client_, nullptr, &delegate_, |
| 203 base::MakeUnique<DefaultRendererFactory>( | 204 base::MakeUnique<DefaultRendererFactory>( |
| 204 media_log_, nullptr, DefaultRendererFactory::GetGpuFactoriesCB()), | 205 media_log_, nullptr, DefaultRendererFactory::GetGpuFactoriesCB(), |
| 206 nullptr), |
| 205 url_index_, | 207 url_index_, |
| 206 WebMediaPlayerParams( | 208 WebMediaPlayerParams( |
| 207 WebMediaPlayerParams::DeferLoadCB(), | 209 WebMediaPlayerParams::DeferLoadCB(), |
| 208 scoped_refptr<SwitchableAudioRendererSink>(), media_log_, | 210 scoped_refptr<SwitchableAudioRendererSink>(), media_log_, |
| 209 media_thread_.task_runner(), message_loop_.task_runner(), | 211 media_thread_.task_runner(), message_loop_.task_runner(), |
| 210 message_loop_.task_runner(), WebMediaPlayerParams::Context3DCB(), | 212 message_loop_.task_runner(), WebMediaPlayerParams::Context3DCB(), |
| 211 base::Bind(&OnAdjustAllocatedMemory), nullptr, nullptr, nullptr, | 213 base::Bind(&OnAdjustAllocatedMemory), nullptr, nullptr, nullptr, |
| 212 base::TimeDelta::FromSeconds(10), false, allow_suspend)); | 214 base::TimeDelta::FromSeconds(10), false, allow_suspend)); |
| 213 } | 215 } |
| 214 | 216 |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 | 783 |
| 782 // Average keyframe distance is too big. | 784 // Average keyframe distance is too big. |
| 783 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100)); | 785 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100)); |
| 784 SetDuration(base::TimeDelta::FromSeconds(300)); | 786 SetDuration(base::TimeDelta::FromSeconds(300)); |
| 785 EXPECT_FALSE(IsBackgroundOptimizationCandidate()); | 787 EXPECT_FALSE(IsBackgroundOptimizationCandidate()); |
| 786 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); | 788 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); |
| 787 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); | 789 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); |
| 788 } | 790 } |
| 789 | 791 |
| 790 } // namespace media | 792 } // namespace media |
| OLD | NEW |