blob: 1c25ff81ee8705f2296e1c65eeff09a24586b1cf [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "base/memory/weak_ptr.h"
#include "media/filters/video_frame_scheduler.h"
namespace base {
class SingleThreadTaskRunner;
namespace media {
// Provides a thread-safe proxy for a VideoFrameScheduler. Typical use is to
// use a real VideoFrameScheduler on the task runner responsible for graphics
// display and provide a proxy on the task runner responsible for background
// video decoding.
class MEDIA_EXPORT VideoFrameSchedulerProxy : public VideoFrameScheduler {
// |task_runner| is the runner that this object will be called on.
// |scheduler_runner| is the runner that |scheduler| will be called on.
// |scheduler| will be deleted on |scheduler_runner|.
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
const scoped_refptr<base::SingleThreadTaskRunner>& scheduler_runner,
scoped_ptr<VideoFrameScheduler> scheduler);
~VideoFrameSchedulerProxy() override;
// VideoFrameScheduler implementation.
void ScheduleVideoFrame(const scoped_refptr<VideoFrame>& frame,
base::TimeTicks wall_ticks,
const DoneCB& done_cb) override;
void Reset() override;
scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
scoped_refptr<base::SingleThreadTaskRunner> scheduler_runner_;
scoped_ptr<VideoFrameScheduler> scheduler_;
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtrFactory<VideoFrameSchedulerProxy> weak_factory_;
} // namespace media