video_frame_scheduler_proxy.h revision 0529e5d033099cbfc42635f6f6183833b09dff6e
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. 4 5#ifndef MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_ 6#define MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_ 7 8#include "base/memory/weak_ptr.h" 9#include "media/filters/video_frame_scheduler.h" 10 11namespace base { 12class SingleThreadTaskRunner; 13} 14 15namespace media { 16 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 20// video decoding. 21class MEDIA_EXPORT VideoFrameSchedulerProxy : public VideoFrameScheduler { 22 public: 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| must out-live the lifetime of this object. 26 VideoFrameSchedulerProxy( 27 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 28 const scoped_refptr<base::SingleThreadTaskRunner>& scheduler_runner, 29 VideoFrameScheduler* scheduler); 30 virtual ~VideoFrameSchedulerProxy(); 31 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; 37 38 private: 39 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 40 scoped_refptr<base::SingleThreadTaskRunner> scheduler_runner_; 41 VideoFrameScheduler* scheduler_; // Not owned. 42 43 // NOTE: Weak pointers must be invalidated before all other member variables. 44 base::WeakPtrFactory<VideoFrameSchedulerProxy> weak_factory_; 45 46 DISALLOW_COPY_AND_ASSIGN(VideoFrameSchedulerProxy); 47}; 48 49} // namespace media 50 51#endif // MEDIA_FILTERS_VIDEO_FRAME_SCHEDULER_PROXY_H_ 52