| 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 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 96 } |
| 97 | 97 |
| 98 void set_is_autoplaying_muted(bool value) { is_autoplaying_muted_ = value; } | 98 void set_is_autoplaying_muted(bool value) { is_autoplaying_muted_ = value; } |
| 99 | 99 |
| 100 private: | 100 private: |
| 101 bool is_autoplaying_muted_ = false; | 101 bool is_autoplaying_muted_ = false; |
| 102 | 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(DummyWebMediaPlayerClient); | 103 DISALLOW_COPY_AND_ASSIGN(DummyWebMediaPlayerClient); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 class MockWebMediaPlayerDelegate | 106 class MockWebMediaPlayerDelegate : public WebMediaPlayerDelegate { |
| 107 : public WebMediaPlayerDelegate, | |
| 108 public base::SupportsWeakPtr<MockWebMediaPlayerDelegate> { | |
| 109 public: | 107 public: |
| 110 MockWebMediaPlayerDelegate() = default; | 108 MockWebMediaPlayerDelegate() = default; |
| 111 ~MockWebMediaPlayerDelegate() = default; | 109 ~MockWebMediaPlayerDelegate() = default; |
| 112 | 110 |
| 113 // WebMediaPlayerDelegate implementation. | 111 // WebMediaPlayerDelegate implementation. |
| 114 int AddObserver(Observer* observer) override { | 112 int AddObserver(Observer* observer) override { |
| 115 DCHECK_EQ(nullptr, observer_); | 113 DCHECK_EQ(nullptr, observer_); |
| 116 observer_ = observer; | 114 observer_ = observer; |
| 117 return player_id_; | 115 return player_id_; |
| 118 } | 116 } |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, | 190 blink::WebLocalFrame::create(blink::WebTreeScopeType::Document, |
| 193 &web_frame_client_)), | 191 &web_frame_client_)), |
| 194 media_log_(new MediaLog()), | 192 media_log_(new MediaLog()), |
| 195 audio_parameters_(TestAudioParameters::Normal()) { | 193 audio_parameters_(TestAudioParameters::Normal()) { |
| 196 web_view_->setMainFrame(web_local_frame_); | 194 web_view_->setMainFrame(web_local_frame_); |
| 197 media_thread_.StartAndWaitForTesting(); | 195 media_thread_.StartAndWaitForTesting(); |
| 198 } | 196 } |
| 199 | 197 |
| 200 void InitializeWebMediaPlayerImpl() { | 198 void InitializeWebMediaPlayerImpl() { |
| 201 wmpi_.reset(new WebMediaPlayerImpl( | 199 wmpi_.reset(new WebMediaPlayerImpl( |
| 202 web_local_frame_, &client_, nullptr, delegate_.AsWeakPtr(), | 200 web_local_frame_, &client_, nullptr, &delegate_, |
| 203 base::MakeUnique<DefaultRendererFactory>( | 201 base::MakeUnique<DefaultRendererFactory>( |
| 204 media_log_, nullptr, DefaultRendererFactory::GetGpuFactoriesCB()), | 202 media_log_, nullptr, DefaultRendererFactory::GetGpuFactoriesCB()), |
| 205 url_index_, | 203 url_index_, |
| 206 WebMediaPlayerParams( | 204 WebMediaPlayerParams( |
| 207 WebMediaPlayerParams::DeferLoadCB(), | 205 WebMediaPlayerParams::DeferLoadCB(), |
| 208 scoped_refptr<SwitchableAudioRendererSink>(), media_log_, | 206 scoped_refptr<SwitchableAudioRendererSink>(), media_log_, |
| 209 media_thread_.task_runner(), message_loop_.task_runner(), | 207 media_thread_.task_runner(), message_loop_.task_runner(), |
| 210 message_loop_.task_runner(), WebMediaPlayerParams::Context3DCB(), | 208 message_loop_.task_runner(), WebMediaPlayerParams::Context3DCB(), |
| 211 base::Bind(&OnAdjustAllocatedMemory), nullptr, nullptr, nullptr))); | 209 base::Bind(&OnAdjustAllocatedMemory), nullptr, nullptr, nullptr))); |
| 212 } | 210 } |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 | 757 |
| 760 // Average keyframe distance is too big. | 758 // Average keyframe distance is too big. |
| 761 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100)); | 759 SetVideoKeyframeDistanceAverage(base::TimeDelta::FromSeconds(100)); |
| 762 SetDuration(base::TimeDelta::FromSeconds(300)); | 760 SetDuration(base::TimeDelta::FromSeconds(300)); |
| 763 EXPECT_FALSE(IsBackgroundOptimizationCandidate()); | 761 EXPECT_FALSE(IsBackgroundOptimizationCandidate()); |
| 764 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); | 762 EXPECT_FALSE(ShouldPauseVideoWhenHidden()); |
| 765 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); | 763 EXPECT_FALSE(ShouldDisableVideoWhenHidden()); |
| 766 } | 764 } |
| 767 | 765 |
| 768 } // namespace media | 766 } // namespace media |
| OLD | NEW |