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
3 // found in the LICENSE file.
5 #ifndef MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_
6 #define MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_
8 #include "base/memory/weak_ptr.h"
9 #include "media/filters/video_frame_scheduler.h"
12 class SingleThreadTaskRunner
;
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
19 // display and provide a proxy on the task runner responsible for background
21 class MEDIA_EXPORT VideoFrameSchedulerProxy
: public VideoFrameScheduler
{
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.
25 // |scheduler| will be deleted on |scheduler_runner|.
26 VideoFrameSchedulerProxy(
27 const scoped_refptr
<base::SingleThreadTaskRunner
>& task_runner
,
28 const scoped_refptr
<base::SingleThreadTaskRunner
>& scheduler_runner
,
29 scoped_ptr
<VideoFrameScheduler
> scheduler
);
30 virtual ~VideoFrameSchedulerProxy();
32 // VideoFrameScheduler implementation.
33 virtual void ScheduleVideoFrame(const scoped_refptr
<VideoFrame
>& frame
,
34 base::TimeTicks wall_ticks
,
35 const DoneCB
& done_cb
) override
;
36 virtual void Reset() override
;
39 scoped_refptr
<base::SingleThreadTaskRunner
> task_runner_
;
40 scoped_refptr
<base::SingleThreadTaskRunner
> scheduler_runner_
;
41 scoped_ptr
<VideoFrameScheduler
> scheduler_
;
43 // NOTE: Weak pointers must be invalidated before all other member variables.
44 base::WeakPtrFactory
<VideoFrameSchedulerProxy
> weak_factory_
;
46 DISALLOW_COPY_AND_ASSIGN(VideoFrameSchedulerProxy
);
51 #endif // MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_