| 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" | |
| 16 #include "webrtc/media/base/videoframe.h" | 15 #include "webrtc/media/base/videoframe.h" |
| 17 #include "webrtc/media/base/videosinkinterface.h" | 16 #include "webrtc/media/base/videosinkinterface.h" |
| 18 | 17 |
| 19 namespace cricket { | 18 namespace cricket { |
| 20 | 19 |
| 21 // Faked video renderer that has a callback for actions on rendering. | 20 // Faked video renderer that has a callback for actions on rendering. |
| 22 class FakeVideoRenderer : public rtc::VideoSinkInterface<cricket::VideoFrame> { | 21 class FakeVideoRenderer : public rtc::VideoSinkInterface<cricket::VideoFrame> { |
| 23 public: | 22 public: |
| 24 FakeVideoRenderer() | 23 FakeVideoRenderer() |
| 25 : errors_(0), | 24 : errors_(0), |
| (...skipping 11 matching lines...) Expand all Loading... |
| 37 // to 16 rather than close to zero, for supposedly black frames. | 36 // to 16 rather than close to zero, for supposedly black frames. |
| 38 // Largest value observed is 34, e.g., running | 37 // Largest value observed is 34, e.g., running |
| 39 // P2PTestConductor.LocalP2PTest16To9 (peerconnection_unittests). | 38 // P2PTestConductor.LocalP2PTest16To9 (peerconnection_unittests). |
| 40 black_frame_ = CheckFrameColorYuv(0, 48, 128, 128, 128, 128, &frame); | 39 black_frame_ = CheckFrameColorYuv(0, 48, 128, 128, 128, 128, &frame); |
| 41 // Treat unexpected frame size as error. | 40 // Treat unexpected frame size as error. |
| 42 ++num_rendered_frames_; | 41 ++num_rendered_frames_; |
| 43 width_ = frame.width(); | 42 width_ = frame.width(); |
| 44 height_ = frame.height(); | 43 height_ = frame.height(); |
| 45 rotation_ = frame.rotation(); | 44 rotation_ = frame.rotation(); |
| 46 timestamp_us_ = frame.timestamp_us(); | 45 timestamp_us_ = frame.timestamp_us(); |
| 47 SignalRenderFrame(&frame); | |
| 48 } | 46 } |
| 49 | 47 |
| 50 int errors() const { return errors_; } | 48 int errors() const { return errors_; } |
| 51 int width() const { | 49 int width() const { |
| 52 rtc::CritScope cs(&crit_); | 50 rtc::CritScope cs(&crit_); |
| 53 return width_; | 51 return width_; |
| 54 } | 52 } |
| 55 int height() const { | 53 int height() const { |
| 56 rtc::CritScope cs(&crit_); | 54 rtc::CritScope cs(&crit_); |
| 57 return height_; | 55 return height_; |
| 58 } | 56 } |
| 59 webrtc::VideoRotation rotation() const { | 57 webrtc::VideoRotation rotation() const { |
| 60 rtc::CritScope cs(&crit_); | 58 rtc::CritScope cs(&crit_); |
| 61 return rotation_; | 59 return rotation_; |
| 62 } | 60 } |
| 63 | 61 |
| 64 int64_t timestamp_us() const { | 62 int64_t timestamp_us() const { |
| 65 rtc::CritScope cs(&crit_); | 63 rtc::CritScope cs(&crit_); |
| 66 return timestamp_us_; | 64 return timestamp_us_; |
| 67 } | 65 } |
| 68 int num_rendered_frames() const { | 66 int num_rendered_frames() const { |
| 69 rtc::CritScope cs(&crit_); | 67 rtc::CritScope cs(&crit_); |
| 70 return num_rendered_frames_; | 68 return num_rendered_frames_; |
| 71 } | 69 } |
| 72 bool black_frame() const { | 70 bool black_frame() const { |
| 73 rtc::CritScope cs(&crit_); | 71 rtc::CritScope cs(&crit_); |
| 74 return black_frame_; | 72 return black_frame_; |
| 75 } | 73 } |
| 76 | 74 |
| 77 sigslot::signal3<int, int, int> SignalSetSize; | |
| 78 sigslot::signal1<const VideoFrame*> SignalRenderFrame; | |
| 79 | |
| 80 private: | 75 private: |
| 81 static bool CheckFrameColorYuv(uint8_t y_min, | 76 static bool CheckFrameColorYuv(uint8_t y_min, |
| 82 uint8_t y_max, | 77 uint8_t y_max, |
| 83 uint8_t u_min, | 78 uint8_t u_min, |
| 84 uint8_t u_max, | 79 uint8_t u_max, |
| 85 uint8_t v_min, | 80 uint8_t v_min, |
| 86 uint8_t v_max, | 81 uint8_t v_max, |
| 87 const cricket::VideoFrame* frame) { | 82 const cricket::VideoFrame* frame) { |
| 88 if (!frame || !frame->video_frame_buffer()) { | 83 if (!frame || !frame->video_frame_buffer()) { |
| 89 return false; | 84 return false; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 webrtc::VideoRotation rotation_; | 130 webrtc::VideoRotation rotation_; |
| 136 int64_t timestamp_us_; | 131 int64_t timestamp_us_; |
| 137 int num_rendered_frames_; | 132 int num_rendered_frames_; |
| 138 bool black_frame_; | 133 bool black_frame_; |
| 139 rtc::CriticalSection crit_; | 134 rtc::CriticalSection crit_; |
| 140 }; | 135 }; |
| 141 | 136 |
| 142 } // namespace cricket | 137 } // namespace cricket |
| 143 | 138 |
| 144 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_ | 139 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEORENDERER_H_ |
| OLD | NEW |