OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 : FakeEncoder(clock), callback_(NULL), idr_counter_(0) { | 141 : FakeEncoder(clock), callback_(NULL), idr_counter_(0) { |
142 FakeEncoder::RegisterEncodeCompleteCallback(this); | 142 FakeEncoder::RegisterEncodeCompleteCallback(this); |
143 } | 143 } |
144 | 144 |
145 int32_t FakeH264Encoder::RegisterEncodeCompleteCallback( | 145 int32_t FakeH264Encoder::RegisterEncodeCompleteCallback( |
146 EncodedImageCallback* callback) { | 146 EncodedImageCallback* callback) { |
147 callback_ = callback; | 147 callback_ = callback; |
148 return 0; | 148 return 0; |
149 } | 149 } |
150 | 150 |
151 EncodedImageCallback::Result FakeH264Encoder::OnEncodedImage( | 151 int32_t FakeH264Encoder::Encoded(const EncodedImage& encoded_image, |
152 const EncodedImage& encoded_image, | 152 const CodecSpecificInfo* codec_specific_info, |
153 const CodecSpecificInfo* codec_specific_info, | 153 const RTPFragmentationHeader* fragments) { |
154 const RTPFragmentationHeader* fragments) { | |
155 const size_t kSpsSize = 8; | 154 const size_t kSpsSize = 8; |
156 const size_t kPpsSize = 11; | 155 const size_t kPpsSize = 11; |
157 const int kIdrFrequency = 10; | 156 const int kIdrFrequency = 10; |
158 RTPFragmentationHeader fragmentation; | 157 RTPFragmentationHeader fragmentation; |
159 if (idr_counter_++ % kIdrFrequency == 0 && | 158 if (idr_counter_++ % kIdrFrequency == 0 && |
160 encoded_image._length > kSpsSize + kPpsSize + 1) { | 159 encoded_image._length > kSpsSize + kPpsSize + 1) { |
161 const size_t kNumSlices = 3; | 160 const size_t kNumSlices = 3; |
162 fragmentation.VerifyAndAllocateFragmentationHeader(kNumSlices); | 161 fragmentation.VerifyAndAllocateFragmentationHeader(kNumSlices); |
163 fragmentation.fragmentationOffset[0] = 0; | 162 fragmentation.fragmentationOffset[0] = 0; |
164 fragmentation.fragmentationLength[0] = kSpsSize; | 163 fragmentation.fragmentationLength[0] = kSpsSize; |
(...skipping 19 matching lines...) Expand all Loading... |
184 uint8_t value = 0; | 183 uint8_t value = 0; |
185 int fragment_counter = 0; | 184 int fragment_counter = 0; |
186 for (size_t i = 0; i < encoded_image._length; ++i) { | 185 for (size_t i = 0; i < encoded_image._length; ++i) { |
187 if (fragment_counter == fragmentation.fragmentationVectorSize || | 186 if (fragment_counter == fragmentation.fragmentationVectorSize || |
188 i != fragmentation.fragmentationOffset[fragment_counter]) { | 187 i != fragmentation.fragmentationOffset[fragment_counter]) { |
189 encoded_image._buffer[i] = value++; | 188 encoded_image._buffer[i] = value++; |
190 } else { | 189 } else { |
191 ++fragment_counter; | 190 ++fragment_counter; |
192 } | 191 } |
193 } | 192 } |
194 return callback_->OnEncodedImage(encoded_image, NULL, &fragmentation); | 193 return callback_->Encoded(encoded_image, NULL, &fragmentation); |
195 } | 194 } |
196 | 195 |
197 DelayedEncoder::DelayedEncoder(Clock* clock, int delay_ms) | 196 DelayedEncoder::DelayedEncoder(Clock* clock, int delay_ms) |
198 : test::FakeEncoder(clock), | 197 : test::FakeEncoder(clock), |
199 delay_ms_(delay_ms) {} | 198 delay_ms_(delay_ms) {} |
200 | 199 |
201 int32_t DelayedEncoder::Encode(const VideoFrame& input_image, | 200 int32_t DelayedEncoder::Encode(const VideoFrame& input_image, |
202 const CodecSpecificInfo* codec_specific_info, | 201 const CodecSpecificInfo* codec_specific_info, |
203 const std::vector<FrameType>* frame_types) { | 202 const std::vector<FrameType>* frame_types) { |
204 SleepMs(delay_ms_); | 203 SleepMs(delay_ms_); |
205 return FakeEncoder::Encode(input_image, codec_specific_info, frame_types); | 204 return FakeEncoder::Encode(input_image, codec_specific_info, frame_types); |
206 } | 205 } |
207 } // namespace test | 206 } // namespace test |
208 } // namespace webrtc | 207 } // namespace webrtc |
OLD | NEW |