1 /*
2 * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10
11 #include "test/pc/e2e/analyzer/video/simulcast_dummy_buffer_helper.h"
12
13 #include "api/video/i420_buffer.h"
14 #include "api/video/video_frame.h"
15 #include "api/video/video_frame_buffer.h"
16
17 namespace webrtc {
18 namespace webrtc_pc_e2e {
19 namespace {
20
21 constexpr char kIrrelatedSimulcastStreamFrameData[] = "Dummy!";
22
23 } // namespace
24
CreateDummyFrameBuffer()25 rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateDummyFrameBuffer() {
26 // Use i420 buffer here as default one and supported by all codecs.
27 rtc::scoped_refptr<webrtc::I420Buffer> buffer =
28 webrtc::I420Buffer::Create(2, 2);
29 memcpy(buffer->MutableDataY(), kIrrelatedSimulcastStreamFrameData, 2);
30 memcpy(buffer->MutableDataY() + buffer->StrideY(),
31 kIrrelatedSimulcastStreamFrameData + 2, 2);
32 memcpy(buffer->MutableDataU(), kIrrelatedSimulcastStreamFrameData + 4, 1);
33 memcpy(buffer->MutableDataV(), kIrrelatedSimulcastStreamFrameData + 5, 1);
34 return buffer;
35 }
36
IsDummyFrame(const webrtc::VideoFrame & video_frame)37 bool IsDummyFrame(const webrtc::VideoFrame& video_frame) {
38 if (video_frame.width() != 2 || video_frame.height() != 2) {
39 return false;
40 }
41 rtc::scoped_refptr<webrtc::I420BufferInterface> buffer =
42 video_frame.video_frame_buffer()->ToI420();
43 if (memcmp(buffer->DataY(), kIrrelatedSimulcastStreamFrameData, 2) != 0) {
44 return false;
45 }
46 if (memcmp(buffer->DataY() + buffer->StrideY(),
47 kIrrelatedSimulcastStreamFrameData + 2, 2) != 0) {
48 return false;
49 }
50 if (memcmp(buffer->DataU(), kIrrelatedSimulcastStreamFrameData + 4, 1) != 0) {
51 return false;
52 }
53 if (memcmp(buffer->DataV(), kIrrelatedSimulcastStreamFrameData + 5, 1) != 0) {
54 return false;
55 }
56 return true;
57 }
58
59 } // namespace webrtc_pc_e2e
60 } // namespace webrtc
61