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

Side by Side Diff: webrtc/modules/video_coding/main/source/generic_encoder.cc

Issue 1406903002: Expose codec implementation names in stats. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 2 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
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 148
149 if (vcm_encoded_frame_callback_) { 149 if (vcm_encoded_frame_callback_) {
150 // Keep track of the current frame rotation and apply to the output of the 150 // Keep track of the current frame rotation and apply to the output of the
151 // encoder. There might not be exact as the encoder could have one frame 151 // encoder. There might not be exact as the encoder could have one frame
152 // delay but it should be close enough. 152 // delay but it should be close enough.
153 vcm_encoded_frame_callback_->SetRotation(rotation_); 153 vcm_encoded_frame_callback_->SetRotation(rotation_);
154 } 154 }
155 155
156 int32_t result = 156 int32_t result =
157 encoder_->Encode(inputFrame, codecSpecificInfo, &video_frame_types); 157 encoder_->Encode(inputFrame, codecSpecificInfo, &video_frame_types);
158
159 if (vcm_encoded_frame_callback_) {
160 vcm_encoded_frame_callback_->LastEncoderImplementationUsed(
161 encoder_->ImplementationName());
162 }
163
158 if (is_screenshare_ && 164 if (is_screenshare_ &&
159 result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) { 165 result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) {
160 // Target bitrate exceeded, encoder state has been reset - try again. 166 // Target bitrate exceeded, encoder state has been reset - try again.
161 return encoder_->Encode(inputFrame, codecSpecificInfo, &video_frame_types); 167 return encoder_->Encode(inputFrame, codecSpecificInfo, &video_frame_types);
162 } 168 }
163 169
164 return result; 170 return result;
165 } 171 }
166 172
167 int32_t 173 int32_t
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 } 290 }
285 291
286 int32_t 292 int32_t
287 VCMEncodedFrameCallback::SetTransportCallback(VCMPacketizationCallback* transpor t) 293 VCMEncodedFrameCallback::SetTransportCallback(VCMPacketizationCallback* transpor t)
288 { 294 {
289 _sendCallback = transport; 295 _sendCallback = transport;
290 return VCM_OK; 296 return VCM_OK;
291 } 297 }
292 298
293 int32_t VCMEncodedFrameCallback::Encoded( 299 int32_t VCMEncodedFrameCallback::Encoded(
294 const EncodedImage& encodedImage, 300 const EncodedImage& encoded_image,
295 const CodecSpecificInfo* codecSpecificInfo, 301 const CodecSpecificInfo* codecSpecificInfo,
296 const RTPFragmentationHeader* fragmentationHeader) { 302 const RTPFragmentationHeader* fragmentationHeader) {
297 post_encode_callback_->Encoded(encodedImage, NULL, NULL); 303 // TODO(pbos): Investigate thread safety, this Encoded callback doesn't have
304 // to be on the same thread as ::Encode or SetTransportCallback. This is
305 // especially the case on hardware encoders.
306 post_encode_callback_->Encoded(encoded_image, NULL, NULL);
298 307
299 if (_sendCallback == NULL) { 308 if (_sendCallback == NULL) {
300 return VCM_UNINITIALIZED; 309 return VCM_UNINITIALIZED;
301 } 310 }
302 311
303 #ifdef DEBUG_ENCODER_BIT_STREAM 312 #ifdef DEBUG_ENCODER_BIT_STREAM
304 if (_bitStreamAfterEncoder != NULL) { 313 if (_bitStreamAfterEncoder != NULL) {
305 fwrite(encodedImage._buffer, 1, encodedImage._length, 314 fwrite(encoded_image._buffer, 1, encoded_image._length,
306 _bitStreamAfterEncoder); 315 _bitStreamAfterEncoder);
307 } 316 }
308 #endif 317 #endif
309 318
310 RTPVideoHeader rtpVideoHeader; 319 RTPVideoHeader rtpVideoHeader;
311 memset(&rtpVideoHeader, 0, sizeof(RTPVideoHeader)); 320 memset(&rtpVideoHeader, 0, sizeof(RTPVideoHeader));
312 RTPVideoHeader* rtpVideoHeaderPtr = &rtpVideoHeader; 321 RTPVideoHeader* rtpVideoHeaderPtr = &rtpVideoHeader;
313 if (codecSpecificInfo) { 322 if (codecSpecificInfo) {
314 CopyCodecSpecific(codecSpecificInfo, rtpVideoHeaderPtr); 323 CopyCodecSpecific(codecSpecificInfo, rtpVideoHeaderPtr);
315 } 324 }
316 rtpVideoHeader.rotation = _rotation; 325 rtpVideoHeader.rotation = _rotation;
317 326
318 int32_t callbackReturn = _sendCallback->SendData( 327 int32_t callbackReturn = _sendCallback->SendData(
319 _payloadType, encodedImage, *fragmentationHeader, rtpVideoHeaderPtr); 328 _payloadType, encoded_image, *fragmentationHeader, rtpVideoHeaderPtr);
320 if (callbackReturn < 0) { 329 if (callbackReturn < 0) {
321 return callbackReturn; 330 return callbackReturn;
322 } 331 }
323 332
324 if (_mediaOpt != NULL) { 333 if (_mediaOpt != NULL) {
325 _mediaOpt->UpdateWithEncodedData(encodedImage); 334 _mediaOpt->UpdateWithEncodedData(encoded_image);
326 if (_internalSource) 335 if (_internalSource)
327 return _mediaOpt->DropFrame(); // Signal to encoder to drop next frame. 336 return _mediaOpt->DropFrame(); // Signal to encoder to drop next frame.
328 } 337 }
329 return VCM_OK; 338 return VCM_OK;
330 } 339 }
331 340
332 void 341 void VCMEncodedFrameCallback::SetMediaOpt(
333 VCMEncodedFrameCallback::SetMediaOpt( 342 media_optimization::MediaOptimization* mediaOpt) {
334 media_optimization::MediaOptimization *mediaOpt) 343 _mediaOpt = mediaOpt;
335 { 344 }
336 _mediaOpt = mediaOpt; 345
346 void VCMEncodedFrameCallback::LastEncoderImplementationUsed(
347 const char* implementation_name) {
348 if (_sendCallback)
349 _sendCallback->OnEncoderImplementationName(implementation_name);
stefan-webrtc 2015/10/16 07:47:03 feel free to fix _sendCallback -> send_callback_
pbos-webrtc 2015/10/16 13:12:05 Done.
337 } 350 }
338 351
339 } // namespace webrtc 352 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698