summaryrefslogtreecommitdiffstats
path: root/remoting/protocol/fake_video_renderer.h
blob: 60a7088817d2c6903924548a0336f2ab4a1dd08f (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Copyright 2016 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 REMOTING_PROTOCOL_FAKE_VIDEO_RENDERER_H_
#define REMOTING_PROTOCOL_FAKE_VIDEO_RENDERER_H_

#include <list>

#include "base/callback.h"
#include "base/memory/scoped_ptr.h"
#include "base/threading/thread_checker.h"
#include "remoting/protocol/frame_consumer.h"
#include "remoting/protocol/video_renderer.h"
#include "remoting/protocol/video_stub.h"

namespace remoting {
namespace protocol {

class FakeVideoStub : public VideoStub {
 public:
  FakeVideoStub();
  ~FakeVideoStub() override;

  const std::list<scoped_ptr<VideoPacket>>& received_packets() {
    return received_packets_;
  }

  void set_on_frame_callback(base::Closure on_frame_callback);

  // VideoStub interface.
  void ProcessVideoPacket(scoped_ptr<VideoPacket> video_packet,
                          const base::Closure& done) override;
 private:
  base::ThreadChecker thread_checker_;

  std::list<scoped_ptr<VideoPacket>> received_packets_;
  base::Closure on_frame_callback_;
};

class FakeFrameConsumer : public FrameConsumer {
 public:
  FakeFrameConsumer();
  ~FakeFrameConsumer() override;

  const std::list<scoped_ptr<webrtc::DesktopFrame>>& received_frames() {
    return received_frames_;
  }

  void set_on_frame_callback(base::Closure on_frame_callback);

  // FrameConsumer interface.
  scoped_ptr<webrtc::DesktopFrame> AllocateFrame(
      const webrtc::DesktopSize& size) override;
  void DrawFrame(scoped_ptr<webrtc::DesktopFrame> frame,
                 const base::Closure& done) override;
  PixelFormat GetPixelFormat() override;

 private:
  base::ThreadChecker thread_checker_;

  std::list<scoped_ptr<webrtc::DesktopFrame>> received_frames_;
  base::Closure on_frame_callback_;
};

class FakeVideoRenderer : public VideoRenderer {
 public:
  FakeVideoRenderer();
  ~FakeVideoRenderer() override;

  // VideoRenderer interface.
  void OnSessionConfig(const SessionConfig& config) override;
  FakeVideoStub* GetVideoStub() override;
  FakeFrameConsumer* GetFrameConsumer() override;

 private:
  base::ThreadChecker thread_checker_;

  FakeVideoStub video_stub_;
  FakeFrameConsumer frame_consumer_;
};

}  // namespace protocol
}  // namespace remoting

#endif  // REMOTING_PROTOCOL_FAKE_VIDEO_RENDERER_H_