henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1 | /* |
kjellander | 1afca73 | 2016-02-08 04:46:45 | [diff] [blame] | 2 | * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 3 | * |
kjellander | 1afca73 | 2016-02-08 04:46:45 | [diff] [blame] | 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. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 11 | #ifndef MEDIA_BASE_FAKE_VIDEO_RENDERER_H_ |
| 12 | #define MEDIA_BASE_FAKE_VIDEO_RENDERER_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 13 | |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 14 | #include <stdint.h> |
| 15 | |
Mirko Bonadei | d970807 | 2019-01-25 19:26:48 | [diff] [blame] | 16 | #include "api/scoped_refptr.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 17 | #include "api/video/video_frame.h" |
Yves Gerey | 3e70781 | 2018-11-28 15:47:49 | [diff] [blame] | 18 | #include "api/video/video_frame_buffer.h" |
| 19 | #include "api/video/video_rotation.h" |
Niels Möller | c6ce9c5 | 2018-05-11 09:15:30 | [diff] [blame] | 20 | #include "api/video/video_sink_interface.h" |
Markus Handell | 1e257ca | 2020-07-07 13:43:11 | [diff] [blame] | 21 | #include "rtc_base/synchronization/mutex.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 22 | |
| 23 | namespace cricket { |
| 24 | |
| 25 | // Faked video renderer that has a callback for actions on rendering. |
nisse | acd935b | 2016-11-11 11:55:13 | [diff] [blame] | 26 | class FakeVideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 27 | public: |
Mirko Bonadei | 17aff35 | 2018-07-26 10:20:40 | [diff] [blame] | 28 | FakeVideoRenderer(); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 29 | |
Mirko Bonadei | 17aff35 | 2018-07-26 10:20:40 | [diff] [blame] | 30 | void OnFrame(const webrtc::VideoFrame& frame) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 31 | |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 32 | int width() const { |
Markus Handell | 1e257ca | 2020-07-07 13:43:11 | [diff] [blame] | 33 | webrtc::MutexLock lock(&mutex_); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 34 | return width_; |
| 35 | } |
| 36 | int height() const { |
Markus Handell | 1e257ca | 2020-07-07 13:43:11 | [diff] [blame] | 37 | webrtc::MutexLock lock(&mutex_); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 38 | return height_; |
| 39 | } |
Ilya Nikolaevskiy | 2ebf523 | 2019-05-13 14:13:36 | [diff] [blame] | 40 | |
perkj | caafdba | 2016-03-20 14:34:29 | [diff] [blame] | 41 | webrtc::VideoRotation rotation() const { |
Markus Handell | 1e257ca | 2020-07-07 13:43:11 | [diff] [blame] | 42 | webrtc::MutexLock lock(&mutex_); |
Per | a509241 | 2016-02-12 12:30:57 | [diff] [blame] | 43 | return rotation_; |
| 44 | } |
perkj | d6c3954 | 2016-03-17 09:35:23 | [diff] [blame] | 45 | |
nisse | 306d52b | 2016-09-06 14:52:40 | [diff] [blame] | 46 | int64_t timestamp_us() const { |
Markus Handell | 1e257ca | 2020-07-07 13:43:11 | [diff] [blame] | 47 | webrtc::MutexLock lock(&mutex_); |
nisse | 306d52b | 2016-09-06 14:52:40 | [diff] [blame] | 48 | return timestamp_us_; |
perkj | d6c3954 | 2016-03-17 09:35:23 | [diff] [blame] | 49 | } |
Ilya Nikolaevskiy | 2ebf523 | 2019-05-13 14:13:36 | [diff] [blame] | 50 | |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 51 | int num_rendered_frames() const { |
Markus Handell | 1e257ca | 2020-07-07 13:43:11 | [diff] [blame] | 52 | webrtc::MutexLock lock(&mutex_); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 53 | return num_rendered_frames_; |
| 54 | } |
Ilya Nikolaevskiy | 2ebf523 | 2019-05-13 14:13:36 | [diff] [blame] | 55 | |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 56 | bool black_frame() const { |
Markus Handell | 1e257ca | 2020-07-07 13:43:11 | [diff] [blame] | 57 | webrtc::MutexLock lock(&mutex_); |
henrika@webrtc.org | aebb1ad | 2014-01-14 10:00:58 | [diff] [blame] | 58 | return black_frame_; |
| 59 | } |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 60 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 61 | private: |
Mirko Bonadei | 17aff35 | 2018-07-26 10:20:40 | [diff] [blame] | 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; |
Markus Handell | 1e257ca | 2020-07-07 13:43:11 | [diff] [blame] | 68 | mutable webrtc::Mutex mutex_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 69 | }; |
| 70 | |
| 71 | } // namespace cricket |
| 72 | |
Steve Anton | 10542f2 | 2019-01-11 17:11:00 | [diff] [blame] | 73 | #endif // MEDIA_BASE_FAKE_VIDEO_RENDERER_H_ |