OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2011 Google Inc. | 3 * Copyright 2011 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 // Faked video renderer that has a callback for actions on rendering. | 38 // Faked video renderer that has a callback for actions on rendering. |
39 class FakeVideoRenderer : public VideoRenderer { | 39 class FakeVideoRenderer : public VideoRenderer { |
40 public: | 40 public: |
41 FakeVideoRenderer() | 41 FakeVideoRenderer() |
42 : errors_(0), | 42 : errors_(0), |
43 width_(0), | 43 width_(0), |
44 height_(0), | 44 height_(0), |
45 num_set_sizes_(0), | 45 num_set_sizes_(0), |
46 num_rendered_frames_(0), | 46 num_rendered_frames_(0), |
47 black_frame_(false), | 47 black_frame_(false) { |
48 last_frame_elapsed_time_ns_(-1) { | |
49 } | 48 } |
50 | 49 |
51 virtual bool SetSize(int width, int height, int reserved) { | 50 virtual bool SetSize(int width, int height, int reserved) { |
52 rtc::CritScope cs(&crit_); | 51 rtc::CritScope cs(&crit_); |
53 width_ = width; | 52 width_ = width; |
54 height_ = height; | 53 height_ = height; |
55 ++num_set_sizes_; | 54 ++num_set_sizes_; |
56 SignalSetSize(width, height, reserved); | 55 SignalSetSize(width, height, reserved); |
57 return true; | 56 return true; |
58 } | 57 } |
(...skipping 10 matching lines...) Expand all Loading... |
69 if (!frame) { | 68 if (!frame) { |
70 LOG(LS_WARNING) << "RenderFrame expected non-null frame."; | 69 LOG(LS_WARNING) << "RenderFrame expected non-null frame."; |
71 } else { | 70 } else { |
72 LOG(LS_WARNING) << "RenderFrame expected frame of size " << width_ | 71 LOG(LS_WARNING) << "RenderFrame expected frame of size " << width_ |
73 << "x" << height_ << " but received frame of size " | 72 << "x" << height_ << " but received frame of size " |
74 << frame->GetWidth() << "x" << frame->GetHeight(); | 73 << frame->GetWidth() << "x" << frame->GetHeight(); |
75 } | 74 } |
76 ++errors_; | 75 ++errors_; |
77 return false; | 76 return false; |
78 } | 77 } |
79 last_frame_elapsed_time_ns_ = frame->GetElapsedTime(); | |
80 ++num_rendered_frames_; | 78 ++num_rendered_frames_; |
81 SignalRenderFrame(frame); | 79 SignalRenderFrame(frame); |
82 return true; | 80 return true; |
83 } | 81 } |
84 | 82 |
85 int errors() const { return errors_; } | 83 int errors() const { return errors_; } |
86 int width() const { | 84 int width() const { |
87 rtc::CritScope cs(&crit_); | 85 rtc::CritScope cs(&crit_); |
88 return width_; | 86 return width_; |
89 } | 87 } |
90 int height() const { | 88 int height() const { |
91 rtc::CritScope cs(&crit_); | 89 rtc::CritScope cs(&crit_); |
92 return height_; | 90 return height_; |
93 } | 91 } |
94 int num_set_sizes() const { | 92 int num_set_sizes() const { |
95 rtc::CritScope cs(&crit_); | 93 rtc::CritScope cs(&crit_); |
96 return num_set_sizes_; | 94 return num_set_sizes_; |
97 } | 95 } |
98 int num_rendered_frames() const { | 96 int num_rendered_frames() const { |
99 rtc::CritScope cs(&crit_); | 97 rtc::CritScope cs(&crit_); |
100 return num_rendered_frames_; | 98 return num_rendered_frames_; |
101 } | 99 } |
102 bool black_frame() const { | 100 bool black_frame() const { |
103 rtc::CritScope cs(&crit_); | 101 rtc::CritScope cs(&crit_); |
104 return black_frame_; | 102 return black_frame_; |
105 } | 103 } |
106 | 104 |
107 int64_t last_frame_elapsed_time_ns() const { | |
108 rtc::CritScope cs(&crit_); | |
109 return last_frame_elapsed_time_ns_; | |
110 } | |
111 | |
112 sigslot::signal3<int, int, int> SignalSetSize; | 105 sigslot::signal3<int, int, int> SignalSetSize; |
113 sigslot::signal1<const VideoFrame*> SignalRenderFrame; | 106 sigslot::signal1<const VideoFrame*> SignalRenderFrame; |
114 | 107 |
115 private: | 108 private: |
116 static bool CheckFrameColorYuv(uint8 y_min, uint8 y_max, | 109 static bool CheckFrameColorYuv(uint8 y_min, uint8 y_max, |
117 uint8 u_min, uint8 u_max, | 110 uint8 u_min, uint8 u_max, |
118 uint8 v_min, uint8 v_max, | 111 uint8 v_min, uint8 v_max, |
119 const cricket::VideoFrame* frame) { | 112 const cricket::VideoFrame* frame) { |
120 if (!frame) { | 113 if (!frame) { |
121 return false; | 114 return false; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 } | 153 } |
161 return true; | 154 return true; |
162 } | 155 } |
163 | 156 |
164 int errors_; | 157 int errors_; |
165 int width_; | 158 int width_; |
166 int height_; | 159 int height_; |
167 int num_set_sizes_; | 160 int num_set_sizes_; |
168 int num_rendered_frames_; | 161 int num_rendered_frames_; |
169 bool black_frame_; | 162 bool black_frame_; |
170 int64_t last_frame_elapsed_time_ns_; | |
171 mutable rtc::CriticalSection crit_; | 163 mutable rtc::CriticalSection crit_; |
172 }; | 164 }; |
173 | 165 |
174 } // namespace cricket | 166 } // namespace cricket |
175 | 167 |
176 #endif // TALK_MEDIA_BASE_FAKEVIDEORENDERER_H_ | 168 #endif // TALK_MEDIA_BASE_FAKEVIDEORENDERER_H_ |
OLD | NEW |