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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
media / capture / video / mock_video_capture_device_client.h [blame]
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_CAPTURE_VIDEO_MOCK_VIDEO_CAPTURE_DEVICE_CLIENT_H_
#define MEDIA_CAPTURE_VIDEO_MOCK_VIDEO_CAPTURE_DEVICE_CLIENT_H_
#include <memory>
#include "media/capture/video/video_capture_device.h"
#include "testing/gmock/include/gmock/gmock.h"
namespace media {
using FakeFrameCapturedCallback =
base::RepeatingCallback<void(const VideoCaptureFormat&)>;
class MockVideoCaptureDeviceClient : public VideoCaptureDevice::Client {
public:
MockVideoCaptureDeviceClient();
~MockVideoCaptureDeviceClient() override;
MOCK_METHOD(void, OnCaptureConfigurationChanged, (), (override));
MOCK_METHOD(void,
OnIncomingCapturedData,
(const uint8_t* data,
int length,
const VideoCaptureFormat& frame_format,
const gfx::ColorSpace& color_space,
int rotation,
bool flip_y,
base::TimeTicks reference_time,
base::TimeDelta timestamp,
std::optional<base::TimeTicks> capture_begin_time,
const std::optional<VideoFrameMetadata>& metadata,
int frame_feedback_id),
(override));
MOCK_METHOD(void,
OnIncomingCapturedGfxBuffer,
(gfx::GpuMemoryBuffer * buffer,
const VideoCaptureFormat& frame_format,
int clockwise_rotation,
base::TimeTicks reference_time,
base::TimeDelta timestamp,
std::optional<base::TimeTicks> capture_begin_time,
const std::optional<VideoFrameMetadata>& metadata,
int frame_feedback_id),
(override));
MOCK_METHOD(void,
OnIncomingCapturedExternalBuffer,
(CapturedExternalVideoBuffer buffer,
base::TimeTicks reference_time,
base::TimeDelta timestamp,
std::optional<base::TimeTicks> capture_begin_time,
const gfx::Rect& visible_rect,
const std::optional<VideoFrameMetadata>& additional_metadata),
(override));
MOCK_METHOD(ReserveResult,
ReserveOutputBuffer,
(const gfx::Size&, VideoPixelFormat, int, Buffer*, int*, int*),
(override));
MOCK_METHOD(void,
OnError,
(media::VideoCaptureError error,
const base::Location& from_here,
const std::string& reason),
(override));
MOCK_METHOD(void,
OnFrameDropped,
(VideoCaptureFrameDropReason reason),
(override));
MOCK_METHOD(void, OnStarted, (), (override));
MOCK_METHOD(double, GetBufferPoolUtilization, (), (const override));
void OnIncomingCapturedBuffer(
Buffer buffer,
const VideoCaptureFormat& format,
base::TimeTicks reference_time,
base::TimeDelta timestamp,
std::optional<base::TimeTicks> capture_begin_time,
const std::optional<VideoFrameMetadata>& metadata) override;
void OnIncomingCapturedBufferExt(
Buffer buffer,
const VideoCaptureFormat& format,
const gfx::ColorSpace& color_space,
base::TimeTicks reference_time,
base::TimeDelta timestamp,
std::optional<base::TimeTicks> capture_begin_time,
gfx::Rect visible_rect,
const std::optional<VideoFrameMetadata>& additional_metadata) override;
MOCK_METHOD(
void,
DoOnIncomingCapturedBuffer,
(Buffer&, const VideoCaptureFormat&, base::TimeTicks, base::TimeDelta),
());
MOCK_METHOD(void,
DoOnIncomingCapturedBufferExt,
(Buffer & buffer,
const VideoCaptureFormat& format,
const gfx::ColorSpace& color_space,
base::TimeTicks reference_time,
base::TimeDelta timestamp,
gfx::Rect visible_rect,
const std::optional<VideoFrameMetadata>& additional_metadata),
());
static std::unique_ptr<MockVideoCaptureDeviceClient>
CreateMockClientWithBufferAllocator(
FakeFrameCapturedCallback frame_captured_callback);
protected:
FakeFrameCapturedCallback fake_frame_captured_callback_;
};
using NiceMockVideoCaptureDeviceClient =
::testing::NiceMock<MockVideoCaptureDeviceClient>;
} // namespace media
#endif // MEDIA_CAPTURE_VIDEO_MOCK_VIDEO_CAPTURE_DEVICE_CLIENT_H_