1*d9f75844SAndroid Build Coastguard Worker /* 2*d9f75844SAndroid Build Coastguard Worker * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 3*d9f75844SAndroid Build Coastguard Worker * 4*d9f75844SAndroid Build Coastguard Worker * Use of this source code is governed by a BSD-style license 5*d9f75844SAndroid Build Coastguard Worker * that can be found in the LICENSE file in the root of the source 6*d9f75844SAndroid Build Coastguard Worker * tree. An additional intellectual property rights grant can be found 7*d9f75844SAndroid Build Coastguard Worker * in the file PATENTS. All contributing project authors may 8*d9f75844SAndroid Build Coastguard Worker * be found in the AUTHORS file in the root of the source tree. 9*d9f75844SAndroid Build Coastguard Worker */ 10*d9f75844SAndroid Build Coastguard Worker 11*d9f75844SAndroid Build Coastguard Worker #ifndef MEDIA_BASE_FAKE_VIDEO_RENDERER_H_ 12*d9f75844SAndroid Build Coastguard Worker #define MEDIA_BASE_FAKE_VIDEO_RENDERER_H_ 13*d9f75844SAndroid Build Coastguard Worker 14*d9f75844SAndroid Build Coastguard Worker #include <stdint.h> 15*d9f75844SAndroid Build Coastguard Worker 16*d9f75844SAndroid Build Coastguard Worker #include "api/scoped_refptr.h" 17*d9f75844SAndroid Build Coastguard Worker #include "api/video/video_frame.h" 18*d9f75844SAndroid Build Coastguard Worker #include "api/video/video_frame_buffer.h" 19*d9f75844SAndroid Build Coastguard Worker #include "api/video/video_rotation.h" 20*d9f75844SAndroid Build Coastguard Worker #include "api/video/video_sink_interface.h" 21*d9f75844SAndroid Build Coastguard Worker #include "rtc_base/synchronization/mutex.h" 22*d9f75844SAndroid Build Coastguard Worker 23*d9f75844SAndroid Build Coastguard Worker namespace cricket { 24*d9f75844SAndroid Build Coastguard Worker 25*d9f75844SAndroid Build Coastguard Worker // Faked video renderer that has a callback for actions on rendering. 26*d9f75844SAndroid Build Coastguard Worker class FakeVideoRenderer : public rtc::VideoSinkInterface<webrtc::VideoFrame> { 27*d9f75844SAndroid Build Coastguard Worker public: 28*d9f75844SAndroid Build Coastguard Worker FakeVideoRenderer(); 29*d9f75844SAndroid Build Coastguard Worker 30*d9f75844SAndroid Build Coastguard Worker void OnFrame(const webrtc::VideoFrame& frame) override; 31*d9f75844SAndroid Build Coastguard Worker width()32*d9f75844SAndroid Build Coastguard Worker int width() const { 33*d9f75844SAndroid Build Coastguard Worker webrtc::MutexLock lock(&mutex_); 34*d9f75844SAndroid Build Coastguard Worker return width_; 35*d9f75844SAndroid Build Coastguard Worker } height()36*d9f75844SAndroid Build Coastguard Worker int height() const { 37*d9f75844SAndroid Build Coastguard Worker webrtc::MutexLock lock(&mutex_); 38*d9f75844SAndroid Build Coastguard Worker return height_; 39*d9f75844SAndroid Build Coastguard Worker } 40*d9f75844SAndroid Build Coastguard Worker rotation()41*d9f75844SAndroid Build Coastguard Worker webrtc::VideoRotation rotation() const { 42*d9f75844SAndroid Build Coastguard Worker webrtc::MutexLock lock(&mutex_); 43*d9f75844SAndroid Build Coastguard Worker return rotation_; 44*d9f75844SAndroid Build Coastguard Worker } 45*d9f75844SAndroid Build Coastguard Worker timestamp_us()46*d9f75844SAndroid Build Coastguard Worker int64_t timestamp_us() const { 47*d9f75844SAndroid Build Coastguard Worker webrtc::MutexLock lock(&mutex_); 48*d9f75844SAndroid Build Coastguard Worker return timestamp_us_; 49*d9f75844SAndroid Build Coastguard Worker } 50*d9f75844SAndroid Build Coastguard Worker num_rendered_frames()51*d9f75844SAndroid Build Coastguard Worker int num_rendered_frames() const { 52*d9f75844SAndroid Build Coastguard Worker webrtc::MutexLock lock(&mutex_); 53*d9f75844SAndroid Build Coastguard Worker return num_rendered_frames_; 54*d9f75844SAndroid Build Coastguard Worker } 55*d9f75844SAndroid Build Coastguard Worker black_frame()56*d9f75844SAndroid Build Coastguard Worker bool black_frame() const { 57*d9f75844SAndroid Build Coastguard Worker webrtc::MutexLock lock(&mutex_); 58*d9f75844SAndroid Build Coastguard Worker return black_frame_; 59*d9f75844SAndroid Build Coastguard Worker } 60*d9f75844SAndroid Build Coastguard Worker 61*d9f75844SAndroid Build Coastguard Worker private: 62*d9f75844SAndroid Build Coastguard Worker int width_ = 0; 63*d9f75844SAndroid Build Coastguard Worker int height_ = 0; 64*d9f75844SAndroid Build Coastguard Worker webrtc::VideoRotation rotation_ = webrtc::kVideoRotation_0; 65*d9f75844SAndroid Build Coastguard Worker int64_t timestamp_us_ = 0; 66*d9f75844SAndroid Build Coastguard Worker int num_rendered_frames_ = 0; 67*d9f75844SAndroid Build Coastguard Worker bool black_frame_ = false; 68*d9f75844SAndroid Build Coastguard Worker mutable webrtc::Mutex mutex_; 69*d9f75844SAndroid Build Coastguard Worker }; 70*d9f75844SAndroid Build Coastguard Worker 71*d9f75844SAndroid Build Coastguard Worker } // namespace cricket 72*d9f75844SAndroid Build Coastguard Worker 73*d9f75844SAndroid Build Coastguard Worker #endif // MEDIA_BASE_FAKE_VIDEO_RENDERER_H_ 74