Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(339)

Side by Side Diff: webrtc/test/fake_encoder.cc

Issue 2089773002: Add EncodedImageCallback::OnEncodedImage(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: . Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/test/fake_encoder.h ('k') | webrtc/video/payload_router.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 int32_t FakeH264Encoder::Encoded(const EncodedImage& encoded_image, 151 EncodedImageCallback::Result FakeH264Encoder::OnEncodedImage(
152 const CodecSpecificInfo* codec_specific_info, 152 const EncodedImage& encoded_image,
153 const RTPFragmentationHeader* fragments) { 153 const CodecSpecificInfo* codec_specific_info,
154 const RTPFragmentationHeader* fragments) {
154 const size_t kSpsSize = 8; 155 const size_t kSpsSize = 8;
155 const size_t kPpsSize = 11; 156 const size_t kPpsSize = 11;
156 const int kIdrFrequency = 10; 157 const int kIdrFrequency = 10;
157 RTPFragmentationHeader fragmentation; 158 RTPFragmentationHeader fragmentation;
158 if (idr_counter_++ % kIdrFrequency == 0 && 159 if (idr_counter_++ % kIdrFrequency == 0 &&
159 encoded_image._length > kSpsSize + kPpsSize + 1) { 160 encoded_image._length > kSpsSize + kPpsSize + 1) {
160 const size_t kNumSlices = 3; 161 const size_t kNumSlices = 3;
161 fragmentation.VerifyAndAllocateFragmentationHeader(kNumSlices); 162 fragmentation.VerifyAndAllocateFragmentationHeader(kNumSlices);
162 fragmentation.fragmentationOffset[0] = 0; 163 fragmentation.fragmentationOffset[0] = 0;
163 fragmentation.fragmentationLength[0] = kSpsSize; 164 fragmentation.fragmentationLength[0] = kSpsSize;
(...skipping 19 matching lines...) Expand all
183 uint8_t value = 0; 184 uint8_t value = 0;
184 int fragment_counter = 0; 185 int fragment_counter = 0;
185 for (size_t i = 0; i < encoded_image._length; ++i) { 186 for (size_t i = 0; i < encoded_image._length; ++i) {
186 if (fragment_counter == fragmentation.fragmentationVectorSize || 187 if (fragment_counter == fragmentation.fragmentationVectorSize ||
187 i != fragmentation.fragmentationOffset[fragment_counter]) { 188 i != fragmentation.fragmentationOffset[fragment_counter]) {
188 encoded_image._buffer[i] = value++; 189 encoded_image._buffer[i] = value++;
189 } else { 190 } else {
190 ++fragment_counter; 191 ++fragment_counter;
191 } 192 }
192 } 193 }
193 return callback_->Encoded(encoded_image, NULL, &fragmentation); 194 return callback_->OnEncodedImage(encoded_image, NULL, &fragmentation);
194 } 195 }
195 196
196 DelayedEncoder::DelayedEncoder(Clock* clock, int delay_ms) 197 DelayedEncoder::DelayedEncoder(Clock* clock, int delay_ms)
197 : test::FakeEncoder(clock), 198 : test::FakeEncoder(clock),
198 delay_ms_(delay_ms) {} 199 delay_ms_(delay_ms) {}
199 200
200 int32_t DelayedEncoder::Encode(const VideoFrame& input_image, 201 int32_t DelayedEncoder::Encode(const VideoFrame& input_image,
201 const CodecSpecificInfo* codec_specific_info, 202 const CodecSpecificInfo* codec_specific_info,
202 const std::vector<FrameType>* frame_types) { 203 const std::vector<FrameType>* frame_types) {
203 SleepMs(delay_ms_); 204 SleepMs(delay_ms_);
204 return FakeEncoder::Encode(input_image, codec_specific_info, frame_types); 205 return FakeEncoder::Encode(input_image, codec_specific_info, frame_types);
205 } 206 }
206 } // namespace test 207 } // namespace test
207 } // namespace webrtc 208 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/test/fake_encoder.h ('k') | webrtc/video/payload_router.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698