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

Side by Side Diff: media/filters/video_frame_scheduler.h

Issue 237353007: Refactor VideoRendererImpl to use VideoFrameScheduler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_FILTERS_VIDEO_FRAME_SCHEDULER_H_ 5 #ifndef MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_H_
6 #define MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_H_ 6 #define MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/time/time.h"
10 #include "media/base/media_export.h" 11 #include "media/base/media_export.h"
11 12
12 namespace media { 13 namespace media {
13 14
14 class VideoFrame; 15 class VideoFrame;
15 16
16 // Defines an abstract video frame scheduler that is capable of managing the 17 // Defines an abstract video frame scheduler that is capable of managing the
17 // display of video frames at explicit times. 18 // display of video frames at explicit times.
18 class MEDIA_EXPORT VideoFrameScheduler { 19 class MEDIA_EXPORT VideoFrameScheduler {
19 public: 20 public:
20 VideoFrameScheduler() {} 21 VideoFrameScheduler() {}
21 virtual ~VideoFrameScheduler() {} 22 virtual ~VideoFrameScheduler() {}
22 23
23 enum Reason { 24 enum Reason {
24 DISPLAYED, // Frame was displayed. 25 DISPLAYED, // Frame was displayed.
25 DROPPED, // Frame was dropped. 26 DROPPED, // Frame was dropped.
26 RESET, // Scheduler was reset before frame was scheduled for display.
27 }; 27 };
28 typedef base::Callback<void(const scoped_refptr<VideoFrame>&, Reason)> DoneCB; 28 typedef base::Callback<void(const scoped_refptr<VideoFrame>&, Reason)> DoneCB;
29 29
30 // Schedule |frame| to be displayed at |wall_ticks|, firing |done_cb| when 30 // Schedule |frame| to be displayed at |wall_ticks|, firing |done_cb| when
31 // the scheduler has finished with the frame. 31 // the scheduler has finished with the frame.
32 //
33 // To avoid reentrancy issues, |done_cb| is run on a separate calling stack.
32 virtual void ScheduleVideoFrame(const scoped_refptr<VideoFrame>& frame, 34 virtual void ScheduleVideoFrame(const scoped_refptr<VideoFrame>& frame,
33 base::TimeTicks wall_ticks, 35 base::TimeTicks wall_ticks,
34 const DoneCB& done_cb) = 0; 36 const DoneCB& done_cb) = 0;
35 37
36 // Causes the scheduler to release all previously scheduled frames. Frames 38 // Causes the scheduler to cancel any previously scheduled frames.
37 // will be returned as RESET. 39 //
40 // There is no guarantee that |done_cb|'s for previously scheduled frames
41 // will not be run. Clients should implement callback tracking/cancellation
42 // if they are sensitive to old callbacks being run.
38 virtual void Reset() = 0; 43 virtual void Reset() = 0;
scherkus (not reviewing) 2014/04/25 02:04:47 I do like this style of API as it makes less guara
xhwang 2014/04/25 05:44:47 Note to myself: How does the caller know which fra
39 }; 44 };
40 45
41 } // namespace media 46 } // namespace media
42 47
43 #endif // MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_H_ 48 #endif // MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698