summaryrefslogtreecommitdiffstats
path: root/media/filters/test_video_frame_scheduler.h
blob: 9ed082e69ec05a38675c154cde314bd0b18618ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// 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.

#ifndef MEDIA_FILTERS_TEST_VIDEO_FRAME_SCHEDULER_H_
#define MEDIA_FILTERS_TEST_VIDEO_FRAME_SCHEDULER_H_

#include <vector>

#include "media/filters/video_frame_scheduler.h"

namespace media {

// A scheduler that queues frames until told otherwise.
class TestVideoFrameScheduler : public VideoFrameScheduler {
 public:
  struct ScheduledFrame {
    ScheduledFrame(const scoped_refptr<VideoFrame> frame,
                   base::TimeTicks wall_ticks,
                   const DoneCB& done_cb);
    ~ScheduledFrame();

    scoped_refptr<VideoFrame> frame;
    base::TimeTicks wall_ticks;
    DoneCB done_cb;
  };

  TestVideoFrameScheduler();
  ~TestVideoFrameScheduler() override;

  // VideoFrameScheduler implementation.
  void ScheduleVideoFrame(const scoped_refptr<VideoFrame>& frame,
                          base::TimeTicks wall_ticks,
                          const DoneCB& done_cb) override;
  void Reset() override;

  // Displays all frames with scheduled times <= |wall_ticks|.
  void DisplayFramesUpTo(base::TimeTicks wall_ticks);

  // Drops all frames with scheduled times <= |wall_ticks|.
  void DropFramesUpTo(base::TimeTicks wall_ticks);

  const std::vector<ScheduledFrame>& scheduled_frames() const {
    return scheduled_frames_;
  }

 private:
  void RunDoneCBForFramesUpTo(base::TimeTicks wall_ticks, Reason reason);

  std::vector<ScheduledFrame> scheduled_frames_;

  DISALLOW_COPY_AND_ASSIGN(TestVideoFrameScheduler);
};

}  // namespace media

#endif  // MEDIA_FILTERS_TEST_VIDEO_FRAME_SCHEDULER_H_