• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2018 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 "media/base/fake_video_renderer.h"
12 
13 namespace cricket {
14 
15 FakeVideoRenderer::FakeVideoRenderer() = default;
16 
OnFrame(const webrtc::VideoFrame & frame)17 void FakeVideoRenderer::OnFrame(const webrtc::VideoFrame& frame) {
18   webrtc::MutexLock lock(&mutex_);
19   // TODO(zhurunz) Check with VP8 team to see if we can remove this
20   // tolerance on Y values. Some unit tests produce Y values close
21   // to 16 rather than close to zero, for supposedly black frames.
22   // Largest value observed is 34, e.g., running
23   // PeerConnectionIntegrationTest.SendAndReceive16To9AspectRatio.
24   black_frame_ = CheckFrameColorYuv(0, 48, 128, 128, 128, 128, &frame);
25   // Treat unexpected frame size as error.
26   ++num_rendered_frames_;
27   width_ = frame.width();
28   height_ = frame.height();
29   rotation_ = frame.rotation();
30   timestamp_us_ = frame.timestamp_us();
31   ntp_timestamp_ms_ = frame.ntp_time_ms();
32   color_space_ = frame.color_space();
33   packet_infos_ = frame.packet_infos();
34   frame_rendered_event_.Set();
35 }
36 
WaitForRenderedFrame(int64_t timeout_ms)37 bool FakeVideoRenderer::WaitForRenderedFrame(int64_t timeout_ms) {
38   return frame_rendered_event_.Wait(timeout_ms);
39 }
40 
41 }  // namespace cricket
42