OLD | NEW |
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_PROXY_H_ | 5 #ifndef MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_ |
6 #define MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_ | 6 #define MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_ |
7 | 7 |
8 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "media/filters/video_frame_scheduler.h" | 9 #include "media/filters/video_frame_scheduler.h" |
10 | 10 |
11 namespace base { | 11 namespace base { |
12 class SingleThreadTaskRunner; | 12 class SingleThreadTaskRunner; |
13 } | 13 } |
14 | 14 |
15 namespace media { | 15 namespace media { |
16 | 16 |
17 // Provides a thread-safe proxy for a VideoFrameScheduler. Typical use is to | 17 // Provides a thread-safe proxy for a VideoFrameScheduler. Typical use is to |
18 // use a real VideoFrameScheduler on the task runner responsible for graphics | 18 // use a real VideoFrameScheduler on the task runner responsible for graphics |
19 // display and provide a proxy on the task runner responsible for background | 19 // display and provide a proxy on the task runner responsible for background |
20 // video decoding. | 20 // video decoding. |
21 class MEDIA_EXPORT VideoFrameSchedulerProxy : public VideoFrameScheduler { | 21 class MEDIA_EXPORT VideoFrameSchedulerProxy : public VideoFrameScheduler { |
22 public: | 22 public: |
23 // |task_runner| is the runner that this object will be called on. | 23 // |task_runner| is the runner that this object will be called on. |
24 // |scheduler_runner| is the runner that |scheduler| will be called on. | 24 // |scheduler_runner| is the runner that |scheduler| will be called on. |
25 // |scheduler| must out-live the lifetime of this object. | 25 // |scheduler| will be deleted on |scheduler_runner|. |
26 VideoFrameSchedulerProxy( | 26 VideoFrameSchedulerProxy( |
27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
28 const scoped_refptr<base::SingleThreadTaskRunner>& scheduler_runner, | 28 const scoped_refptr<base::SingleThreadTaskRunner>& scheduler_runner, |
29 VideoFrameScheduler* scheduler); | 29 scoped_ptr<VideoFrameScheduler> scheduler); |
30 virtual ~VideoFrameSchedulerProxy(); | 30 virtual ~VideoFrameSchedulerProxy(); |
31 | 31 |
32 // VideoFrameScheduler implementation. | 32 // VideoFrameScheduler implementation. |
33 virtual void ScheduleVideoFrame(const scoped_refptr<VideoFrame>& frame, | 33 virtual void ScheduleVideoFrame(const scoped_refptr<VideoFrame>& frame, |
34 base::TimeTicks wall_ticks, | 34 base::TimeTicks wall_ticks, |
35 const DoneCB& done_cb) OVERRIDE; | 35 const DoneCB& done_cb) OVERRIDE; |
36 virtual void Reset() OVERRIDE; | 36 virtual void Reset() OVERRIDE; |
37 | 37 |
38 private: | 38 private: |
39 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 39 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
40 scoped_refptr<base::SingleThreadTaskRunner> scheduler_runner_; | 40 scoped_refptr<base::SingleThreadTaskRunner> scheduler_runner_; |
41 VideoFrameScheduler* scheduler_; // Not owned. | 41 scoped_ptr<VideoFrameScheduler> scheduler_; |
42 | 42 |
43 // NOTE: Weak pointers must be invalidated before all other member variables. | 43 // NOTE: Weak pointers must be invalidated before all other member variables. |
44 base::WeakPtrFactory<VideoFrameSchedulerProxy> weak_factory_; | 44 base::WeakPtrFactory<VideoFrameSchedulerProxy> weak_factory_; |
45 | 45 |
46 DISALLOW_COPY_AND_ASSIGN(VideoFrameSchedulerProxy); | 46 DISALLOW_COPY_AND_ASSIGN(VideoFrameSchedulerProxy); |
47 }; | 47 }; |
48 | 48 |
49 } // namespace media | 49 } // namespace media |
50 | 50 |
51 #endif // MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_ | 51 #endif // MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_ |
OLD | NEW |