• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cstring>
14 
15 namespace webrtc {
16 namespace webrtc_pc_e2e {
17 namespace {
18 
19 constexpr char kIrrelatedSimulcastStreamFrameData[] = "Dummy!";
20 
21 }  // namespace
22 
CreateDummyFrameBuffer()23 rtc::scoped_refptr<webrtc::VideoFrameBuffer> CreateDummyFrameBuffer() {
24   // Use i420 buffer here as default one and supported by all codecs.
25   rtc::scoped_refptr<webrtc::I420Buffer> buffer =
26       webrtc::I420Buffer::Create(2, 2);
27   memcpy(buffer->MutableDataY(), kIrrelatedSimulcastStreamFrameData, 2);
28   memcpy(buffer->MutableDataY() + buffer->StrideY(),
29          kIrrelatedSimulcastStreamFrameData + 2, 2);
30   memcpy(buffer->MutableDataU(), kIrrelatedSimulcastStreamFrameData + 4, 1);
31   memcpy(buffer->MutableDataV(), kIrrelatedSimulcastStreamFrameData + 5, 1);
32   return buffer;
33 }
34 
IsDummyFrameBuffer(rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer)35 bool IsDummyFrameBuffer(
36     rtc::scoped_refptr<webrtc::VideoFrameBuffer> video_frame_buffer) {
37   if (video_frame_buffer->width() != 2 || video_frame_buffer->height() != 2) {
38     return false;
39   }
40   rtc::scoped_refptr<webrtc::I420BufferInterface> buffer =
41       video_frame_buffer->ToI420();
42   if (memcmp(buffer->DataY(), kIrrelatedSimulcastStreamFrameData, 2) != 0) {
43     return false;
44   }
45   if (memcmp(buffer->DataY() + buffer->StrideY(),
46              kIrrelatedSimulcastStreamFrameData + 2, 2) != 0) {
47     return false;
48   }
49   if (memcmp(buffer->DataU(), kIrrelatedSimulcastStreamFrameData + 4, 1) != 0) {
50     return false;
51   }
52   if (memcmp(buffer->DataV(), kIrrelatedSimulcastStreamFrameData + 5, 1) != 0) {
53     return false;
54   }
55   return true;
56 }
57 
58 }  // namespace webrtc_pc_e2e
59 }  // namespace webrtc
60