| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_ | 11 #ifndef WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_ |
| 12 #define WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_ | 12 #define WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_ |
| 13 | 13 |
| 14 #include "webrtc/base/logging.h" | 14 #include "webrtc/base/logging.h" |
| 15 #include "webrtc/base/sigslot.h" | 15 #include "webrtc/base/sigslot.h" |
| 16 #include "webrtc/media/base/videoframe.h" | 16 #include "webrtc/media/base/videoframe.h" |
| 17 #include "webrtc/media/base/videorenderer.h" | 17 #include "webrtc/media/base/videorenderer.h" |
| 18 | 18 |
| 19 namespace cricket { | 19 namespace cricket { |
| 20 | 20 |
| 21 // Faked video renderer that has a callback for actions on rendering. | 21 // Faked video renderer that has a callback for actions on rendering. |
| 22 class FakeVideoRenderer : public VideoRenderer { | 22 class FakeVideoRenderer : public VideoRenderer { |
| 23 public: | 23 public: |
| 24 FakeVideoRenderer() | 24 FakeVideoRenderer() |
| 25 : errors_(0), | 25 : errors_(0), |
| 26 width_(0), | 26 width_(0), |
| 27 height_(0), | 27 height_(0), |
| 28 rotation_(webrtc::kVideoRotation_0), |
| 29 timestamp_(0), |
| 28 num_rendered_frames_(0), | 30 num_rendered_frames_(0), |
| 29 black_frame_(false) { | 31 black_frame_(false) {} |
| 30 } | |
| 31 | 32 |
| 32 virtual bool RenderFrame(const VideoFrame* frame) { | 33 virtual bool RenderFrame(const VideoFrame* frame) { |
| 33 rtc::CritScope cs(&crit_); | 34 rtc::CritScope cs(&crit_); |
| 34 // TODO(zhurunz) Check with VP8 team to see if we can remove this | 35 // TODO(zhurunz) Check with VP8 team to see if we can remove this |
| 35 // tolerance on Y values. | 36 // tolerance on Y values. |
| 36 black_frame_ = CheckFrameColorYuv(6, 48, 128, 128, 128, 128, frame); | 37 black_frame_ = CheckFrameColorYuv(6, 48, 128, 128, 128, 128, frame); |
| 37 // Treat unexpected frame size as error. | 38 // Treat unexpected frame size as error. |
| 38 if (!frame) { | 39 if (!frame) { |
| 39 LOG(LS_WARNING) << "RenderFrame expected non-null frame."; | 40 LOG(LS_WARNING) << "RenderFrame expected non-null frame."; |
| 40 ++errors_; | 41 ++errors_; |
| 41 return false; | 42 return false; |
| 42 } | 43 } |
| 43 ++num_rendered_frames_; | 44 ++num_rendered_frames_; |
| 44 width_ = static_cast<int>(frame->GetWidth()); | 45 width_ = static_cast<int>(frame->GetWidth()); |
| 45 height_ = static_cast<int>(frame->GetHeight()); | 46 height_ = static_cast<int>(frame->GetHeight()); |
| 46 rotation_ = frame->GetVideoRotation(); | 47 rotation_ = frame->GetVideoRotation(); |
| 48 timestamp_ = frame->GetTimeStamp(); |
| 47 SignalRenderFrame(frame); | 49 SignalRenderFrame(frame); |
| 48 return true; | 50 return true; |
| 49 } | 51 } |
| 50 | 52 |
| 51 int errors() const { return errors_; } | 53 int errors() const { return errors_; } |
| 52 int width() const { | 54 int width() const { |
| 53 rtc::CritScope cs(&crit_); | 55 rtc::CritScope cs(&crit_); |
| 54 return width_; | 56 return width_; |
| 55 } | 57 } |
| 56 int height() const { | 58 int height() const { |
| 57 rtc::CritScope cs(&crit_); | 59 rtc::CritScope cs(&crit_); |
| 58 return height_; | 60 return height_; |
| 59 } | 61 } |
| 60 int rotation() const { | 62 int rotation() const { |
| 61 rtc::CritScope cs(&crit_); | 63 rtc::CritScope cs(&crit_); |
| 62 return rotation_; | 64 return rotation_; |
| 63 } | 65 } |
| 66 |
| 67 int64_t timestamp() const { |
| 68 rtc::CritScope cs(&crit_); |
| 69 return timestamp_; |
| 70 } |
| 64 int num_rendered_frames() const { | 71 int num_rendered_frames() const { |
| 65 rtc::CritScope cs(&crit_); | 72 rtc::CritScope cs(&crit_); |
| 66 return num_rendered_frames_; | 73 return num_rendered_frames_; |
| 67 } | 74 } |
| 68 bool black_frame() const { | 75 bool black_frame() const { |
| 69 rtc::CritScope cs(&crit_); | 76 rtc::CritScope cs(&crit_); |
| 70 return black_frame_; | 77 return black_frame_; |
| 71 } | 78 } |
| 72 | 79 |
| 73 sigslot::signal3<int, int, int> SignalSetSize; | 80 sigslot::signal3<int, int, int> SignalSetSize; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 u_pos += u_pitch; | 129 u_pos += u_pitch; |
| 123 v_pos += v_pitch; | 130 v_pos += v_pitch; |
| 124 } | 131 } |
| 125 return true; | 132 return true; |
| 126 } | 133 } |
| 127 | 134 |
| 128 int errors_; | 135 int errors_; |
| 129 int width_; | 136 int width_; |
| 130 int height_; | 137 int height_; |
| 131 webrtc::VideoRotation rotation_; | 138 webrtc::VideoRotation rotation_; |
| 139 int64_t timestamp_; |
| 132 int num_rendered_frames_; | 140 int num_rendered_frames_; |
| 133 bool black_frame_; | 141 bool black_frame_; |
| 134 rtc::CriticalSection crit_; | 142 rtc::CriticalSection crit_; |
| 135 }; | 143 }; |
| 136 | 144 |
| 137 } // namespace cricket | 145 } // namespace cricket |
| 138 | 146 |
| 139 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_ | 147 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_ |
| OLD | NEW |