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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 int num_created_decoders_; | 125 int num_created_decoders_; |
126 std::vector<VideoDecoderParams> params_; | 126 std::vector<VideoDecoderParams> params_; |
127 }; | 127 }; |
128 | 128 |
129 // Fake class for mocking out webrtc::VideoEnoder | 129 // Fake class for mocking out webrtc::VideoEnoder |
130 class FakeWebRtcVideoEncoder : public webrtc::VideoEncoder { | 130 class FakeWebRtcVideoEncoder : public webrtc::VideoEncoder { |
131 public: | 131 public: |
132 FakeWebRtcVideoEncoder() | 132 FakeWebRtcVideoEncoder() |
133 : init_encode_event_(false, false), num_frames_encoded_(0) {} | 133 : init_encode_event_(false, false), num_frames_encoded_(0) {} |
134 | 134 |
135 int32_t InitEncode(const webrtc::VideoCodec* codecSettings, | 135 virtual int32_t InitEncode(const webrtc::VideoCodec* codecSettings, |
136 int32_t numberOfCores, | 136 int32_t numberOfCores, |
137 size_t maxPayloadSize) override { | 137 size_t maxPayloadSize) { |
138 rtc::CritScope lock(&crit_); | 138 rtc::CritScope lock(&crit_); |
139 codec_settings_ = *codecSettings; | 139 codec_settings_ = *codecSettings; |
140 init_encode_event_.Set(); | 140 init_encode_event_.Set(); |
141 return WEBRTC_VIDEO_CODEC_OK; | 141 return WEBRTC_VIDEO_CODEC_OK; |
142 } | 142 } |
143 | 143 |
144 bool WaitForInitEncode() { return init_encode_event_.Wait(kEventTimeoutMs); } | 144 bool WaitForInitEncode() { return init_encode_event_.Wait(kEventTimeoutMs); } |
145 | 145 |
146 webrtc::VideoCodec GetCodecSettings() { | 146 webrtc::VideoCodec GetCodecSettings() { |
147 rtc::CritScope lock(&crit_); | 147 rtc::CritScope lock(&crit_); |
148 return codec_settings_; | 148 return codec_settings_; |
149 } | 149 } |
150 | 150 |
151 int32_t Encode(const webrtc::VideoFrame& inputImage, | 151 virtual int32_t Encode(const webrtc::VideoFrame& inputImage, |
152 const webrtc::CodecSpecificInfo* codecSpecificInfo, | 152 const webrtc::CodecSpecificInfo* codecSpecificInfo, |
153 const std::vector<webrtc::FrameType>* frame_types) override { | 153 const std::vector<webrtc::FrameType>* frame_types) { |
154 rtc::CritScope lock(&crit_); | 154 rtc::CritScope lock(&crit_); |
155 ++num_frames_encoded_; | 155 ++num_frames_encoded_; |
156 init_encode_event_.Set(); | 156 init_encode_event_.Set(); |
157 return WEBRTC_VIDEO_CODEC_OK; | 157 return WEBRTC_VIDEO_CODEC_OK; |
158 } | 158 } |
159 | 159 |
160 int32_t RegisterEncodeCompleteCallback( | 160 virtual int32_t RegisterEncodeCompleteCallback( |
161 webrtc::EncodedImageCallback* callback) override { | 161 webrtc::EncodedImageCallback* callback) { |
162 return WEBRTC_VIDEO_CODEC_OK; | 162 return WEBRTC_VIDEO_CODEC_OK; |
163 } | 163 } |
164 | 164 |
165 int32_t Release() override { return WEBRTC_VIDEO_CODEC_OK; } | 165 virtual int32_t Release() { return WEBRTC_VIDEO_CODEC_OK; } |
166 | 166 |
167 int32_t SetChannelParameters(uint32_t packetLoss, int64_t rtt) override { | 167 virtual int32_t SetChannelParameters(uint32_t packetLoss, int64_t rtt) { |
168 return WEBRTC_VIDEO_CODEC_OK; | 168 return WEBRTC_VIDEO_CODEC_OK; |
169 } | 169 } |
170 | 170 |
171 int32_t SetRateAllocation(const webrtc::BitrateAllocation& allocation, | 171 virtual int32_t SetRates(uint32_t newBitRate, uint32_t frameRate) { |
172 uint32_t framerate) override { | |
173 return WEBRTC_VIDEO_CODEC_OK; | 172 return WEBRTC_VIDEO_CODEC_OK; |
174 } | 173 } |
175 | 174 |
176 int GetNumEncodedFrames() { | 175 int GetNumEncodedFrames() { |
177 rtc::CritScope lock(&crit_); | 176 rtc::CritScope lock(&crit_); |
178 return num_frames_encoded_; | 177 return num_frames_encoded_; |
179 } | 178 } |
180 | 179 |
181 private: | 180 private: |
182 rtc::CriticalSection crit_; | 181 rtc::CriticalSection crit_; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 rtc::Event created_video_encoder_event_; | 256 rtc::Event created_video_encoder_event_; |
258 std::vector<cricket::VideoCodec> codecs_; | 257 std::vector<cricket::VideoCodec> codecs_; |
259 std::vector<FakeWebRtcVideoEncoder*> encoders_ GUARDED_BY(crit_); | 258 std::vector<FakeWebRtcVideoEncoder*> encoders_ GUARDED_BY(crit_); |
260 int num_created_encoders_ GUARDED_BY(crit_); | 259 int num_created_encoders_ GUARDED_BY(crit_); |
261 bool encoders_have_internal_sources_; | 260 bool encoders_have_internal_sources_; |
262 }; | 261 }; |
263 | 262 |
264 } // namespace cricket | 263 } // namespace cricket |
265 | 264 |
266 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVIDEOENGINE_H_ | 265 #endif // WEBRTC_MEDIA_ENGINE_FAKEWEBRTCVIDEOENGINE_H_ |
OLD | NEW |