xref: /aosp_15_r20/external/webrtc/media/base/fake_video_renderer.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2011 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 #ifndef MEDIA_BASE_FAKE_VIDEO_RENDERER_H_
12 #define MEDIA_BASE_FAKE_VIDEO_RENDERER_H_
13 
14 #include <stdint.h>
15 
16 #include "api/scoped_refptr.h"
17 #include "api/video/video_frame.h"
18 #include "api/video/video_frame_buffer.h"
19 #include "api/video/video_rotation.h"
20 #include "api/video/video_sink_interface.h"
21 #include "rtc_base/synchronization/mutex.h"
22 
23 namespace cricket {
24 
25 // Faked video renderer that has a callback for actions on rendering.
26 class FakeVideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> {
27  public:
28   FakeVideoRenderer();
29 
30   void OnFrame(const webrtc::VideoFrame& frame) override;
31 
width()32   int width() const {
33     webrtc::MutexLock lock(&mutex_);
34     return width_;
35   }
height()36   int height() const {
37     webrtc::MutexLock lock(&mutex_);
38     return height_;
39   }
40 
rotation()41   webrtc::VideoRotation rotation() const {
42     webrtc::MutexLock lock(&mutex_);
43     return rotation_;
44   }
45 
timestamp_us()46   int64_t timestamp_us() const {
47     webrtc::MutexLock lock(&mutex_);
48     return timestamp_us_;
49   }
50 
num_rendered_frames()51   int num_rendered_frames() const {
52     webrtc::MutexLock lock(&mutex_);
53     return num_rendered_frames_;
54   }
55 
black_frame()56   bool black_frame() const {
57     webrtc::MutexLock lock(&mutex_);
58     return black_frame_;
59   }
60 
61  private:
62   int width_ = 0;
63   int height_ = 0;
64   webrtc::VideoRotation rotation_ = webrtc::kVideoRotation_0;
65   int64_t timestamp_us_ = 0;
66   int num_rendered_frames_ = 0;
67   bool black_frame_ = false;
68   mutable webrtc::Mutex mutex_;
69 };
70 
71 }  // namespace cricket
72 
73 #endif  // MEDIA_BASE_FAKE_VIDEO_RENDERER_H_
74