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. | |
26 VideoFrameSchedulerProxy( | 25 VideoFrameSchedulerProxy( |
27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 26 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
28 const scoped_refptr<base::SingleThreadTaskRunner>& scheduler_runner, | 27 const scoped_refptr<base::SingleThreadTaskRunner>& scheduler_runner, |
29 VideoFrameScheduler* scheduler); | 28 scoped_ptr<VideoFrameScheduler> scheduler); |
30 virtual ~VideoFrameSchedulerProxy(); | 29 virtual ~VideoFrameSchedulerProxy(); |
31 | 30 |
32 // VideoFrameScheduler implementation. | 31 // VideoFrameScheduler implementation. |
33 virtual void ScheduleVideoFrame(const scoped_refptr<VideoFrame>& frame, | 32 virtual void ScheduleVideoFrame(const scoped_refptr<VideoFrame>& frame, |
34 base::TimeTicks wall_ticks, | 33 base::TimeTicks wall_ticks, |
35 const DoneCB& done_cb) OVERRIDE; | 34 const DoneCB& done_cb) OVERRIDE; |
36 virtual void Reset() OVERRIDE; | 35 virtual void Reset() OVERRIDE; |
37 | 36 |
38 private: | 37 private: |
39 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 38 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
40 scoped_refptr<base::SingleThreadTaskRunner> scheduler_runner_; | 39 scoped_refptr<base::SingleThreadTaskRunner> scheduler_runner_; |
41 VideoFrameScheduler* scheduler_; // Not owned. | 40 scoped_ptr<VideoFrameScheduler> scheduler_; |
42 | 41 |
43 // NOTE: Weak pointers must be invalidated before all other member variables. | 42 // NOTE: Weak pointers must be invalidated before all other member variables. |
44 base::WeakPtrFactory<VideoFrameSchedulerProxy> weak_factory_; | 43 base::WeakPtrFactory<VideoFrameSchedulerProxy> weak_factory_; |
45 | 44 |
46 DISALLOW_COPY_AND_ASSIGN(VideoFrameSchedulerProxy); | 45 DISALLOW_COPY_AND_ASSIGN(VideoFrameSchedulerProxy); |
47 }; | 46 }; |
48 | 47 |
49 } // namespace media | 48 } // namespace media |
50 | 49 |
51 #endif // MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_ | 50 #endif // MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_ |
OLD | NEW |