OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 5 #ifndef MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 6 #define MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 class WebAudioSourceProviderImpl; | 81 class WebAudioSourceProviderImpl; |
82 class WebMediaPlayerDelegate; | 82 class WebMediaPlayerDelegate; |
83 | 83 |
84 // The canonical implementation of blink::WebMediaPlayer that's backed by | 84 // The canonical implementation of blink::WebMediaPlayer that's backed by |
85 // Pipeline. Handles normal resource loading, Media Source, and | 85 // Pipeline. Handles normal resource loading, Media Source, and |
86 // Encrypted Media. | 86 // Encrypted Media. |
87 class MEDIA_BLINK_EXPORT WebMediaPlayerImpl | 87 class MEDIA_BLINK_EXPORT WebMediaPlayerImpl |
88 : public NON_EXPORTED_BASE(blink::WebMediaPlayer), | 88 : public NON_EXPORTED_BASE(blink::WebMediaPlayer), |
89 public NON_EXPORTED_BASE(WebMediaPlayerDelegate::Observer), | 89 public NON_EXPORTED_BASE(WebMediaPlayerDelegate::Observer), |
90 public NON_EXPORTED_BASE(Pipeline::Client), | 90 public NON_EXPORTED_BASE(Pipeline::Client), |
| 91 public MediaObserverClient, |
91 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 92 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
92 public: | 93 public: |
93 // Constructs a WebMediaPlayer implementation using Chromium's media stack. | 94 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
94 // |delegate| and |renderer_factory| must not be null. | 95 // |delegate| and |renderer_factory| must not be null. |
95 WebMediaPlayerImpl( | 96 WebMediaPlayerImpl( |
96 blink::WebLocalFrame* frame, | 97 blink::WebLocalFrame* frame, |
97 blink::WebMediaPlayerClient* client, | 98 blink::WebMediaPlayerClient* client, |
98 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | 99 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
99 WebMediaPlayerDelegate* delegate, | 100 WebMediaPlayerDelegate* delegate, |
100 std::unique_ptr<RendererFactory> renderer_factory, | 101 std::unique_ptr<RendererFactory> renderer_factory, |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 void OnRemotePlaybackEnded(); | 208 void OnRemotePlaybackEnded(); |
208 void OnDisconnectedFromRemoteDevice(double t); | 209 void OnDisconnectedFromRemoteDevice(double t); |
209 void SuspendForRemote(); | 210 void SuspendForRemote(); |
210 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, | 211 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, |
211 PipelineStatus status); | 212 PipelineStatus status); |
212 gfx::Size GetCanvasSize() const; | 213 gfx::Size GetCanvasSize() const; |
213 void SetDeviceScaleFactor(float scale_factor); | 214 void SetDeviceScaleFactor(float scale_factor); |
214 void SetUseFallbackPath(bool use_fallback_path); | 215 void SetUseFallbackPath(bool use_fallback_path); |
215 #endif | 216 #endif |
216 | 217 |
| 218 // MediaObserverClient implementation. |
| 219 void SwitchRenderer() override; |
| 220 void ActivateViewportIntersectionMonitoring(bool activate) override; |
| 221 void DisablePipelineAutoSuspend(bool disable) override; |
| 222 |
217 // Called from WebMediaPlayerCast. | 223 // Called from WebMediaPlayerCast. |
218 // TODO(hubbe): WMPI_CAST make private. | 224 // TODO(hubbe): WMPI_CAST make private. |
219 void OnPipelineSeeked(bool time_updated); | 225 void OnPipelineSeeked(bool time_updated); |
220 | 226 |
221 // Restart the player/pipeline as soon as possible. This will destroy the | |
222 // current renderer, if any, and create a new one via the RendererFactory; and | |
223 // then seek to resume playback at the current position. | |
224 void ScheduleRestart(); | |
225 | |
226 // Called when requests to activate monitoring changes on viewport | |
227 // intersection. | |
228 void ActivateViewportIntersectionMonitoring(bool activate); | |
229 | |
230 // Distinct states that |delegate_| can be in. (Public for testing.) | 227 // Distinct states that |delegate_| can be in. (Public for testing.) |
231 enum class DelegateState { | 228 enum class DelegateState { |
232 GONE, | 229 GONE, |
233 PLAYING, | 230 PLAYING, |
234 PAUSED, | 231 PAUSED, |
235 }; | 232 }; |
236 | 233 |
237 // Playback state variables computed together in UpdatePlayState(). | 234 // Playback state variables computed together in UpdatePlayState(). |
238 // (Public for testing.) | 235 // (Public for testing.) |
239 struct PlayState { | 236 struct PlayState { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 // necessary). | 286 // necessary). |
290 void OnSurfaceRequested(bool decoder_requires_restart_for_overlay, | 287 void OnSurfaceRequested(bool decoder_requires_restart_for_overlay, |
291 const SurfaceCreatedCB& surface_created_cb); | 288 const SurfaceCreatedCB& surface_created_cb); |
292 | 289 |
293 // Creates a Renderer via the |renderer_factory_|. | 290 // Creates a Renderer via the |renderer_factory_|. |
294 std::unique_ptr<Renderer> CreateRenderer(); | 291 std::unique_ptr<Renderer> CreateRenderer(); |
295 | 292 |
296 // Finishes starting the pipeline due to a call to load(). | 293 // Finishes starting the pipeline due to a call to load(). |
297 void StartPipeline(); | 294 void StartPipeline(); |
298 | 295 |
| 296 // Restart the player/pipeline as soon as possible. This will destroy the |
| 297 // current renderer, if any, and create a new one via the RendererFactory; and |
| 298 // then seek to resume playback at the current position. |
| 299 void ScheduleRestart(); |
| 300 |
299 // Helpers that set the network/ready state and notifies the client if | 301 // Helpers that set the network/ready state and notifies the client if |
300 // they've changed. | 302 // they've changed. |
301 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); | 303 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); |
302 void SetReadyState(blink::WebMediaPlayer::ReadyState state); | 304 void SetReadyState(blink::WebMediaPlayer::ReadyState state); |
303 | 305 |
304 // Returns the current video frame from |compositor_|. Blocks until the | 306 // Returns the current video frame from |compositor_|. Blocks until the |
305 // compositor can return the frame. | 307 // compositor can return the frame. |
306 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor(); | 308 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor(); |
307 | 309 |
308 // Called when the demuxer encounters encrypted streams. | 310 // Called when the demuxer encounters encrypted streams. |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 // immediately on memory pressure notification or during the next SourceBuffer | 684 // immediately on memory pressure notification or during the next SourceBuffer |
683 // append (slower, but MSE spec compliant). | 685 // append (slower, but MSE spec compliant). |
684 bool enable_instant_source_buffer_gc_ = false; | 686 bool enable_instant_source_buffer_gc_ = false; |
685 | 687 |
686 // Whether disabled the video track as an optimization. | 688 // Whether disabled the video track as an optimization. |
687 bool video_track_disabled_ = false; | 689 bool video_track_disabled_ = false; |
688 | 690 |
689 // Whether the pipeline is being resumed at the moment. | 691 // Whether the pipeline is being resumed at the moment. |
690 bool is_pipeline_resuming_ = false; | 692 bool is_pipeline_resuming_ = false; |
691 | 693 |
| 694 // When this is true, pipeline will not be auto suspended. |
| 695 bool disable_pipeline_auto_suspend_ = false; |
| 696 |
692 // Pipeline statistics overridden by tests. | 697 // Pipeline statistics overridden by tests. |
693 base::Optional<PipelineStatistics> pipeline_statistics_for_test_; | 698 base::Optional<PipelineStatistics> pipeline_statistics_for_test_; |
694 | 699 |
695 // Pipeline media duration overridden by tests. | 700 // Pipeline media duration overridden by tests. |
696 base::Optional<base::TimeDelta> pipeline_media_duration_for_test_; | 701 base::Optional<base::TimeDelta> pipeline_media_duration_for_test_; |
697 | 702 |
698 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 703 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
699 }; | 704 }; |
700 | 705 |
701 } // namespace media | 706 } // namespace media |
702 | 707 |
703 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 708 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
OLD | NEW |