| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 class WebAudioSourceProviderImpl; | 74 class WebAudioSourceProviderImpl; |
| 75 class WebMediaPlayerDelegate; | 75 class WebMediaPlayerDelegate; |
| 76 class WebTextTrackImpl; | 76 class WebTextTrackImpl; |
| 77 | 77 |
| 78 // The canonical implementation of blink::WebMediaPlayer that's backed by | 78 // The canonical implementation of blink::WebMediaPlayer that's backed by |
| 79 // Pipeline. Handles normal resource loading, Media Source, and | 79 // Pipeline. Handles normal resource loading, Media Source, and |
| 80 // Encrypted Media. | 80 // Encrypted Media. |
| 81 class MEDIA_BLINK_EXPORT WebMediaPlayerImpl | 81 class MEDIA_BLINK_EXPORT WebMediaPlayerImpl |
| 82 : public NON_EXPORTED_BASE(blink::WebMediaPlayer), | 82 : public NON_EXPORTED_BASE(blink::WebMediaPlayer), |
| 83 public NON_EXPORTED_BASE(WebMediaPlayerDelegate::Observer), | 83 public NON_EXPORTED_BASE(WebMediaPlayerDelegate::Observer), |
| 84 public NON_EXPORTED_BASE(Pipeline::Client), |
| 84 public base::SupportsWeakPtr<WebMediaPlayerImpl> { | 85 public base::SupportsWeakPtr<WebMediaPlayerImpl> { |
| 85 public: | 86 public: |
| 86 // Constructs a WebMediaPlayer implementation using Chromium's media stack. | 87 // Constructs a WebMediaPlayer implementation using Chromium's media stack. |
| 87 // |delegate| may be null. |renderer_factory| must not be null. | 88 // |delegate| may be null. |renderer_factory| must not be null. |
| 88 WebMediaPlayerImpl( | 89 WebMediaPlayerImpl( |
| 89 blink::WebLocalFrame* frame, | 90 blink::WebLocalFrame* frame, |
| 90 blink::WebMediaPlayerClient* client, | 91 blink::WebMediaPlayerClient* client, |
| 91 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, | 92 blink::WebMediaPlayerEncryptedMediaClient* encrypted_client, |
| 92 base::WeakPtr<WebMediaPlayerDelegate> delegate, | 93 base::WeakPtr<WebMediaPlayerDelegate> delegate, |
| 93 std::unique_ptr<RendererFactory> renderer_factory, | 94 std::unique_ptr<RendererFactory> renderer_factory, |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 struct PlayState { | 217 struct PlayState { |
| 217 DelegateState delegate_state; | 218 DelegateState delegate_state; |
| 218 bool is_memory_reporting_enabled; | 219 bool is_memory_reporting_enabled; |
| 219 bool is_suspended; | 220 bool is_suspended; |
| 220 }; | 221 }; |
| 221 | 222 |
| 222 private: | 223 private: |
| 223 friend class WebMediaPlayerImplTest; | 224 friend class WebMediaPlayerImplTest; |
| 224 | 225 |
| 225 void OnPipelineSuspended(); | 226 void OnPipelineSuspended(); |
| 226 void OnPipelineEnded(); | |
| 227 void OnPipelineError(PipelineStatus error); | |
| 228 void OnPipelineMetadata(PipelineMetadata metadata); | |
| 229 void OnPipelineBufferingStateChanged(BufferingState buffering_state); | |
| 230 void OnDemuxerOpened(); | 227 void OnDemuxerOpened(); |
| 228 |
| 229 // Pipeline::Client overrides. |
| 230 void OnError(PipelineStatus status) override; |
| 231 void OnEnded() override; |
| 232 void OnMetadata(PipelineMetadata metadata) override; |
| 233 void OnBufferingStateChange(BufferingState state) override; |
| 234 void OnDurationChange() override; |
| 231 void OnAddTextTrack(const TextTrackConfig& config, | 235 void OnAddTextTrack(const TextTrackConfig& config, |
| 232 const AddTextTrackDoneCB& done_cb); | 236 const AddTextTrackDoneCB& done_cb) override; |
| 237 void OnWaitingForDecryptionKey() override; |
| 233 | 238 |
| 234 // Actually seek. Avoids causing |should_notify_time_changed_| to be set when | 239 // Actually seek. Avoids causing |should_notify_time_changed_| to be set when |
| 235 // |time_updated| is false. | 240 // |time_updated| is false. |
| 236 void DoSeek(base::TimeDelta time, bool time_updated); | 241 void DoSeek(base::TimeDelta time, bool time_updated); |
| 237 | 242 |
| 238 // Ask for the renderer to be restarted (destructed and recreated). | 243 // Ask for the renderer to be restarted (destructed and recreated). |
| 239 void ScheduleRestart(); | 244 void ScheduleRestart(); |
| 240 | 245 |
| 241 // Called after |defer_load_cb_| has decided to allow the load. If | 246 // Called after |defer_load_cb_| has decided to allow the load. If |
| 242 // |defer_load_cb_| is null this is called immediately. | 247 // |defer_load_cb_| is null this is called immediately. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 260 | 265 |
| 261 // Helpers that set the network/ready state and notifies the client if | 266 // Helpers that set the network/ready state and notifies the client if |
| 262 // they've changed. | 267 // they've changed. |
| 263 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); | 268 void SetNetworkState(blink::WebMediaPlayer::NetworkState state); |
| 264 void SetReadyState(blink::WebMediaPlayer::ReadyState state); | 269 void SetReadyState(blink::WebMediaPlayer::ReadyState state); |
| 265 | 270 |
| 266 // Gets the duration value reported by the pipeline. | 271 // Gets the duration value reported by the pipeline. |
| 267 double GetPipelineDuration() const; | 272 double GetPipelineDuration() const; |
| 268 | 273 |
| 269 // Callbacks from |pipeline_| that are forwarded to |client_|. | 274 // Callbacks from |pipeline_| that are forwarded to |client_|. |
| 270 void OnDurationChanged(); | |
| 271 void OnNaturalSizeChanged(gfx::Size size); | 275 void OnNaturalSizeChanged(gfx::Size size); |
| 272 void OnOpacityChanged(bool opaque); | 276 void OnOpacityChanged(bool opaque); |
| 273 | 277 |
| 274 // Called by VideoRendererImpl on its internal thread with the new frame to be | 278 // Called by VideoRendererImpl on its internal thread with the new frame to be |
| 275 // painted. | 279 // painted. |
| 276 void FrameReady(const scoped_refptr<VideoFrame>& frame); | 280 void FrameReady(const scoped_refptr<VideoFrame>& frame); |
| 277 | 281 |
| 278 // Returns the current video frame from |compositor_|. Blocks until the | 282 // Returns the current video frame from |compositor_|. Blocks until the |
| 279 // compositor can return the frame. | 283 // compositor can return the frame. |
| 280 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor(); | 284 scoped_refptr<VideoFrame> GetCurrentFrameFromCompositor(); |
| 281 | 285 |
| 282 // Called when the demuxer encounters encrypted streams. | 286 // Called when the demuxer encounters encrypted streams. |
| 283 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, | 287 void OnEncryptedMediaInitData(EmeInitDataType init_data_type, |
| 284 const std::vector<uint8_t>& init_data); | 288 const std::vector<uint8_t>& init_data); |
| 285 | 289 |
| 286 // Called when the FFmpegDemuxer encounters new media tracks. This is only | 290 // Called when the FFmpegDemuxer encounters new media tracks. This is only |
| 287 // invoked when using FFmpegDemuxer, since MSE/ChunkDemuxer handle media | 291 // invoked when using FFmpegDemuxer, since MSE/ChunkDemuxer handle media |
| 288 // tracks separately in WebSourceBufferImpl. | 292 // tracks separately in WebSourceBufferImpl. |
| 289 void OnFFmpegMediaTracksUpdated(std::unique_ptr<MediaTracks> tracks); | 293 void OnFFmpegMediaTracksUpdated(std::unique_ptr<MediaTracks> tracks); |
| 290 | 294 |
| 291 // Called when a decoder detects that the key needed to decrypt the stream | |
| 292 // is not available. | |
| 293 void OnWaitingForDecryptionKey(); | |
| 294 | |
| 295 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. | 295 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. |
| 296 // Parameter order is reversed for easy binding. | 296 // Parameter order is reversed for easy binding. |
| 297 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); | 297 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); |
| 298 | 298 |
| 299 // Called when a CDM has been attached to the |pipeline_|. | 299 // Called when a CDM has been attached to the |pipeline_|. |
| 300 void OnCdmAttached(bool success); | 300 void OnCdmAttached(bool success); |
| 301 | 301 |
| 302 // Inspects the current playback state and: | 302 // Inspects the current playback state and: |
| 303 // - notifies |delegate_|, | 303 // - notifies |delegate_|, |
| 304 // - toggles the memory usage reporting timer, and | 304 // - toggles the memory usage reporting timer, and |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 // state will be set to YES or NO respectively if a frame is available. | 496 // state will be set to YES or NO respectively if a frame is available. |
| 497 enum class CanSuspendState { UNKNOWN, YES, NO }; | 497 enum class CanSuspendState { UNKNOWN, YES, NO }; |
| 498 CanSuspendState can_suspend_state_; | 498 CanSuspendState can_suspend_state_; |
| 499 | 499 |
| 500 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); | 500 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); |
| 501 }; | 501 }; |
| 502 | 502 |
| 503 } // namespace media | 503 } // namespace media |
| 504 | 504 |
| 505 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ | 505 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ |
| OLD | NEW |