OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 }; | 175 }; |
176 | 176 |
177 // Fake class for mocking out WebRtcVideoEncoderFactory. | 177 // Fake class for mocking out WebRtcVideoEncoderFactory. |
178 class FakeWebRtcVideoEncoderFactory : public WebRtcVideoEncoderFactory { | 178 class FakeWebRtcVideoEncoderFactory : public WebRtcVideoEncoderFactory { |
179 public: | 179 public: |
180 FakeWebRtcVideoEncoderFactory() | 180 FakeWebRtcVideoEncoderFactory() |
181 : created_video_encoder_event_(false, false), | 181 : created_video_encoder_event_(false, false), |
182 num_created_encoders_(0), | 182 num_created_encoders_(0), |
183 encoders_have_internal_sources_(false) {} | 183 encoders_have_internal_sources_(false) {} |
184 | 184 |
185 webrtc::VideoEncoder* CreateVideoEncoder( | 185 virtual webrtc::VideoEncoder* CreateVideoEncoder( |
186 webrtc::VideoCodecType type) override { | 186 webrtc::VideoCodecType type) { |
187 rtc::CritScope lock(&crit_); | 187 rtc::CritScope lock(&crit_); |
188 if (supported_codec_types_.count(type) == 0) { | 188 if (supported_codec_types_.count(type) == 0) { |
189 return NULL; | 189 return NULL; |
190 } | 190 } |
191 FakeWebRtcVideoEncoder* encoder = new FakeWebRtcVideoEncoder(); | 191 FakeWebRtcVideoEncoder* encoder = new FakeWebRtcVideoEncoder(); |
192 encoders_.push_back(encoder); | 192 encoders_.push_back(encoder); |
193 num_created_encoders_++; | 193 num_created_encoders_++; |
194 created_video_encoder_event_.Set(); | 194 created_video_encoder_event_.Set(); |
195 return encoder; | 195 return encoder; |
196 } | 196 } |
197 | 197 |
198 bool WaitForCreatedVideoEncoders(int num_encoders) { | 198 bool WaitForCreatedVideoEncoders(int num_encoders) { |
199 while (created_video_encoder_event_.Wait(kEventTimeoutMs)) { | 199 while (created_video_encoder_event_.Wait(kEventTimeoutMs)) { |
200 if (GetNumCreatedEncoders() >= num_encoders) | 200 if (GetNumCreatedEncoders() >= num_encoders) |
201 return true; | 201 return true; |
202 } | 202 } |
203 return false; | 203 return false; |
204 } | 204 } |
205 | 205 |
206 void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) override { | 206 virtual void DestroyVideoEncoder(webrtc::VideoEncoder* encoder) { |
207 rtc::CritScope lock(&crit_); | 207 rtc::CritScope lock(&crit_); |
208 encoders_.erase( | 208 encoders_.erase( |
209 std::remove(encoders_.begin(), encoders_.end(), encoder), | 209 std::remove(encoders_.begin(), encoders_.end(), encoder), |
210 encoders_.end()); | 210 encoders_.end()); |
211 delete encoder; | 211 delete encoder; |
212 } | 212 } |
213 | 213 |
214 const std::vector<WebRtcVideoEncoderFactory::VideoCodec>& codecs() | 214 virtual const std::vector<WebRtcVideoEncoderFactory::VideoCodec>& codecs() |
215 const override { | 215 const { |
216 return codecs_; | 216 return codecs_; |
217 } | 217 } |
218 | 218 |
219 bool EncoderTypeHasInternalSource( | 219 virtual bool EncoderTypeHasInternalSource( |
220 webrtc::VideoCodecType type) const override { | 220 webrtc::VideoCodecType type) const override { |
221 return encoders_have_internal_sources_; | 221 return encoders_have_internal_sources_; |
222 } | 222 } |
223 | 223 |
224 void set_encoders_have_internal_sources(bool internal_source) { | 224 void set_encoders_have_internal_sources(bool internal_source) { |
225 encoders_have_internal_sources_ = internal_source; | 225 encoders_have_internal_sources_ = internal_source; |
226 } | 226 } |
227 | 227 |
228 void AddSupportedVideoCodecType(webrtc::VideoCodecType type, | 228 void AddSupportedVideoCodecType(webrtc::VideoCodecType type, |
229 const std::string& name) { | 229 const std::string& name) { |
(...skipping 18 matching lines...) Expand all Loading... |
248 std::set<webrtc::VideoCodecType> supported_codec_types_; | 248 std::set<webrtc::VideoCodecType> supported_codec_types_; |
249 std::vector<WebRtcVideoEncoderFactory::VideoCodec> codecs_; | 249 std::vector<WebRtcVideoEncoderFactory::VideoCodec> codecs_; |
250 std::vector<FakeWebRtcVideoEncoder*> encoders_ GUARDED_BY(crit_); | 250 std::vector<FakeWebRtcVideoEncoder*> encoders_ GUARDED_BY(crit_); |
251 int num_created_encoders_ GUARDED_BY(crit_); | 251 int num_created_encoders_ GUARDED_BY(crit_); |
252 bool encoders_have_internal_sources_; | 252 bool encoders_have_internal_sources_; |
253 }; | 253 }; |
254 | 254 |
255 } // namespace cricket | 255 } // namespace cricket |
256 | 256 |
257 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVIDEOENGINE_H_ | 257 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVIDEOENGINE_H_ |
OLD | NEW |