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

cc / test / fake_video_frame_provider.h [blame]

// Copyright 2012 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_TEST_FAKE_VIDEO_FRAME_PROVIDER_H_
#define CC_TEST_FAKE_VIDEO_FRAME_PROVIDER_H_

#include <utility>

#include "base/memory/raw_ptr.h"
#include "cc/layers/video_frame_provider.h"
#include "media/base/video_frame.h"

namespace cc {

// Fake video frame provider that always provides the same VideoFrame.
class FakeVideoFrameProvider : public VideoFrameProvider {
 public:
  FakeVideoFrameProvider();
  ~FakeVideoFrameProvider() override;

  void SetVideoFrameProviderClient(Client* client) override;
  bool UpdateCurrentFrame(base::TimeTicks deadline_min,
                          base::TimeTicks deadline_max) override;
  bool HasCurrentFrame() override;
  scoped_refptr<media::VideoFrame> GetCurrentFrame() override;
  void PutCurrentFrame() override;
  base::TimeDelta GetPreferredRenderInterval() override;
  void OnContextLost() override {}

  Client* client() { return client_; }

  void set_frame(scoped_refptr<media::VideoFrame> frame) {
    frame_ = std::move(frame);
  }

  int put_current_frame_count() const { return put_current_frame_count_; }

 private:
  scoped_refptr<media::VideoFrame> frame_;
  raw_ptr<Client> client_;
  int put_current_frame_count_;
};

}  // namespace cc

#endif  // CC_TEST_FAKE_VIDEO_FRAME_PROVIDER_H_