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

Side by Side Diff: media/blink/webmediaplayer_impl.h

Issue 1830913005: Convert WMPI state management to level-triggered. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use EXPECT_TRUE/EXPECT_FALSE. 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
« no previous file with comments | « no previous file | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <string> 10 #include <string>
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame, 192 void DisplayCastFrameAfterSuspend(const scoped_refptr<VideoFrame>& new_frame,
193 PipelineStatus status); 193 PipelineStatus status);
194 gfx::Size GetCanvasSize() const; 194 gfx::Size GetCanvasSize() const;
195 void SetDeviceScaleFactor(float scale_factor); 195 void SetDeviceScaleFactor(float scale_factor);
196 #endif 196 #endif
197 197
198 // Called from WebMediaPlayerCast. 198 // Called from WebMediaPlayerCast.
199 // TODO(hubbe): WMPI_CAST make private. 199 // TODO(hubbe): WMPI_CAST make private.
200 void OnPipelineSeeked(bool time_updated); 200 void OnPipelineSeeked(bool time_updated);
201 201
202 // Distinct states that |delegate_| can be in.
203 // TODO(sandersd): This should move into WebMediaPlayerDelegate.
204 // (Public for testing.)
205 enum class DelegateState {
206 GONE,
207 PLAYING,
208 PAUSED,
209 ENDED,
210 };
211
212 // Playback state variables computed together in UpdatePlayState().
213 // (Public for testing.)
214 struct PlayState {
215 DelegateState delegate_state;
216 bool is_memory_reporting_enabled;
217 bool is_suspended;
218 };
219
202 private: 220 private:
221 friend class WebMediaPlayerImplTest;
222
203 void OnPipelineSuspended(); 223 void OnPipelineSuspended();
204 void OnPipelineResumed();
205 void OnPipelineEnded(); 224 void OnPipelineEnded();
206 void OnPipelineError(PipelineStatus error); 225 void OnPipelineError(PipelineStatus error);
207 void OnPipelineMetadata(PipelineMetadata metadata); 226 void OnPipelineMetadata(PipelineMetadata metadata);
208 void OnPipelineBufferingStateChanged(BufferingState buffering_state); 227 void OnPipelineBufferingStateChanged(BufferingState buffering_state);
209 void OnDemuxerOpened(); 228 void OnDemuxerOpened();
210 void OnAddTextTrack(const TextTrackConfig& config, 229 void OnAddTextTrack(const TextTrackConfig& config,
211 const AddTextTrackDoneCB& done_cb); 230 const AddTextTrackDoneCB& done_cb);
212 231
213 // Actually seek. Avoids causing |should_notify_time_changed_| to be set when 232 // Actually seek. Avoids causing |should_notify_time_changed_| to be set when
214 // |time_updated| is false. 233 // |time_updated| is false.
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 // is not available. 290 // is not available.
272 void OnWaitingForDecryptionKey(); 291 void OnWaitingForDecryptionKey();
273 292
274 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done. 293 // Sets |cdm_context| on the pipeline and fires |cdm_attached_cb| when done.
275 // Parameter order is reversed for easy binding. 294 // Parameter order is reversed for easy binding.
276 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context); 295 void SetCdm(const CdmAttachedCB& cdm_attached_cb, CdmContext* cdm_context);
277 296
278 // Called when a CDM has been attached to the |pipeline_|. 297 // Called when a CDM has been attached to the |pipeline_|.
279 void OnCdmAttached(bool success); 298 void OnCdmAttached(bool success);
280 299
281 // Notifies |delegate_| that playback has started or was paused; also starts 300 // Inspects the current playback state and:
282 // or stops the memory usage reporting timer respectively. 301 // - notifies |delegate_|,
283 void NotifyPlaybackStarted(); 302 // - toggles the memory usage reporting timer, and
284 void NotifyPlaybackPaused(); 303 // - toggles suspend/resume as necessary.
304 //
305 // This method should be called any time its dependent values change. These
306 // are:
307 // - isRemote(),
308 // - hasVideo(),
309 // - delegate_->IsHidden(),
310 // - network_state_, ready_state_,
311 // - is_idle_, must_suspend_,
312 // - paused_, ended_,
313 // - pending_suspend_resume_cycle_.
314 void UpdatePlayState();
315
316 // Methods internal to UpdatePlayState().
317 PlayState UpdatePlayState_ComputePlayState(bool is_remote,
318 bool is_backgrounded);
319 void SetDelegateState(DelegateState new_state);
320 void SetMemoryReportingState(bool is_memory_reporting_enabled);
321 void SetSuspendState(bool is_suspended);
285 322
286 // Called at low frequency to tell external observers how much memory we're 323 // Called at low frequency to tell external observers how much memory we're
287 // using for video playback. Called by |memory_usage_reporting_timer_|. 324 // using for video playback. Called by |memory_usage_reporting_timer_|.
288 // Memory usage reporting is done in two steps, because |demuxer_| must be 325 // Memory usage reporting is done in two steps, because |demuxer_| must be
289 // accessed on the media thread. 326 // accessed on the media thread.
290 void ReportMemoryUsage(); 327 void ReportMemoryUsage();
291 void FinishMemoryUsageReport(int64_t demuxer_memory_usage); 328 void FinishMemoryUsageReport(int64_t demuxer_memory_usage);
292 329
293 // Indicates if automatic resumption of a suspended playback is allowed.
294 bool IsAutomaticResumeAllowed();
295
296 blink::WebLocalFrame* frame_; 330 blink::WebLocalFrame* frame_;
297 331
298 // TODO(hclam): get rid of these members and read from the pipeline directly. 332 // The playback state last reported to |delegate_|, to avoid setting duplicate
333 // states. (Which can have undesired effects like resetting the idle timer.)
334 DelegateState delegate_state_;
335
336 // Set when OnSuspendRequested() is called with |must_suspend| unset.
337 bool is_idle_;
338
339 // Set when OnSuspendRequested() is called with |must_suspend| set.
340 bool must_suspend_;
341
299 blink::WebMediaPlayer::NetworkState network_state_; 342 blink::WebMediaPlayer::NetworkState network_state_;
300 blink::WebMediaPlayer::ReadyState ready_state_; 343 blink::WebMediaPlayer::ReadyState ready_state_;
344 blink::WebMediaPlayer::ReadyState highest_ready_state_;
301 345
302 // Preload state for when |data_source_| is created after setPreload(). 346 // Preload state for when |data_source_| is created after setPreload().
303 BufferedDataSource::Preload preload_; 347 BufferedDataSource::Preload preload_;
304 348
305 // Buffering strategy for when |data_source_| is created after 349 // Buffering strategy for when |data_source_| is created after
306 // setBufferingStrategy(). 350 // setBufferingStrategy().
307 BufferedDataSource::BufferingStrategy buffering_strategy_; 351 BufferedDataSource::BufferingStrategy buffering_strategy_;
308 352
309 // Task runner for posting tasks on Chrome's main thread. Also used 353 // Task runner for posting tasks on Chrome's main thread. Also used
310 // for DCHECKs so methods calls won't execute in the wrong thread. 354 // for DCHECKs so methods calls won't execute in the wrong thread.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 // started; prevents us from spuriously logging errors that are transient or 487 // started; prevents us from spuriously logging errors that are transient or
444 // unimportant. 488 // unimportant.
445 bool suppress_destruction_errors_; 489 bool suppress_destruction_errors_;
446 490
447 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl); 491 DISALLOW_COPY_AND_ASSIGN(WebMediaPlayerImpl);
448 }; 492 };
449 493
450 } // namespace media 494 } // namespace media
451 495
452 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_ 496 #endif // MEDIA_BLINK_WEBMEDIAPLAYER_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | media/blink/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698