Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 rotation_ = inputFrame.rotation(); | 146 rotation_ = inputFrame.rotation(); |
| 147 | 147 |
| 148 if (vcm_encoded_frame_callback_) { | 148 if (vcm_encoded_frame_callback_) { |
| 149 // Keep track of the current frame rotation and apply to the output of the | 149 // Keep track of the current frame rotation and apply to the output of the |
| 150 // encoder. There might not be exact as the encoder could have one frame | 150 // encoder. There might not be exact as the encoder could have one frame |
| 151 // delay but it should be close enough. | 151 // delay but it should be close enough. |
| 152 vcm_encoded_frame_callback_->SetRotation(rotation_); | 152 vcm_encoded_frame_callback_->SetRotation(rotation_); |
| 153 } | 153 } |
| 154 | 154 |
| 155 int32_t result = encoder_->Encode(inputFrame, codecSpecificInfo, &frameTypes); | 155 int32_t result = encoder_->Encode(inputFrame, codecSpecificInfo, &frameTypes); |
| 156 | |
| 157 if (vcm_encoded_frame_callback_) { | |
| 158 vcm_encoded_frame_callback_->LastEncoderImplementationUsed( | |
| 159 encoder_->ImplementationName()); | |
| 160 } | |
| 161 | |
| 156 if (is_screenshare_ && | 162 if (is_screenshare_ && |
| 157 result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) { | 163 result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) { |
| 158 // Target bitrate exceeded, encoder state has been reset - try again. | 164 // Target bitrate exceeded, encoder state has been reset - try again. |
| 159 return encoder_->Encode(inputFrame, codecSpecificInfo, &frameTypes); | 165 return encoder_->Encode(inputFrame, codecSpecificInfo, &frameTypes); |
| 160 } | 166 } |
| 161 | 167 |
| 162 return result; | 168 return result; |
| 163 } | 169 } |
| 164 | 170 |
| 165 int32_t | 171 int32_t |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 248 | 254 |
| 249 int VCMGenericEncoder::GetTargetFramerate() { | 255 int VCMGenericEncoder::GetTargetFramerate() { |
| 250 return encoder_->GetTargetFramerate(); | 256 return encoder_->GetTargetFramerate(); |
| 251 } | 257 } |
| 252 | 258 |
| 253 /*************************** | 259 /*************************** |
| 254 * Callback Implementation | 260 * Callback Implementation |
| 255 ***************************/ | 261 ***************************/ |
| 256 VCMEncodedFrameCallback::VCMEncodedFrameCallback( | 262 VCMEncodedFrameCallback::VCMEncodedFrameCallback( |
| 257 EncodedImageCallback* post_encode_callback) | 263 EncodedImageCallback* post_encode_callback) |
| 258 : _sendCallback(), | 264 : send_callback_(), |
| 259 _mediaOpt(NULL), | 265 _mediaOpt(NULL), |
| 260 _payloadType(0), | 266 _payloadType(0), |
| 261 _internalSource(false), | 267 _internalSource(false), |
| 262 _rotation(kVideoRotation_0), | 268 _rotation(kVideoRotation_0), |
| 263 post_encode_callback_(post_encode_callback) | 269 post_encode_callback_(post_encode_callback) |
| 264 #ifdef DEBUG_ENCODER_BIT_STREAM | 270 #ifdef DEBUG_ENCODER_BIT_STREAM |
| 265 , | 271 , |
| 266 _bitStreamAfterEncoder(NULL) | 272 _bitStreamAfterEncoder(NULL) |
| 267 #endif | 273 #endif |
| 268 { | 274 { |
| 269 #ifdef DEBUG_ENCODER_BIT_STREAM | 275 #ifdef DEBUG_ENCODER_BIT_STREAM |
| 270 _bitStreamAfterEncoder = fopen("encoderBitStream.bit", "wb"); | 276 _bitStreamAfterEncoder = fopen("encoderBitStream.bit", "wb"); |
| 271 #endif | 277 #endif |
| 272 } | 278 } |
| 273 | 279 |
| 274 VCMEncodedFrameCallback::~VCMEncodedFrameCallback() | 280 VCMEncodedFrameCallback::~VCMEncodedFrameCallback() |
| 275 { | 281 { |
| 276 #ifdef DEBUG_ENCODER_BIT_STREAM | 282 #ifdef DEBUG_ENCODER_BIT_STREAM |
| 277 fclose(_bitStreamAfterEncoder); | 283 fclose(_bitStreamAfterEncoder); |
| 278 #endif | 284 #endif |
| 279 } | 285 } |
| 280 | 286 |
| 281 int32_t | 287 int32_t |
| 282 VCMEncodedFrameCallback::SetTransportCallback(VCMPacketizationCallback* transpor t) | 288 VCMEncodedFrameCallback::SetTransportCallback(VCMPacketizationCallback* transpor t) |
| 283 { | 289 { |
| 284 _sendCallback = transport; | 290 send_callback_ = transport; |
| 285 return VCM_OK; | 291 return VCM_OK; |
| 286 } | 292 } |
| 287 | 293 |
| 288 int32_t VCMEncodedFrameCallback::Encoded( | 294 int32_t VCMEncodedFrameCallback::Encoded( |
| 289 const EncodedImage& encodedImage, | 295 const EncodedImage& encoded_image, |
| 290 const CodecSpecificInfo* codecSpecificInfo, | 296 const CodecSpecificInfo* codecSpecificInfo, |
| 291 const RTPFragmentationHeader* fragmentationHeader) { | 297 const RTPFragmentationHeader* fragmentationHeader) { |
| 292 RTC_DCHECK(encodedImage._frameType == kVideoFrameKey || | 298 RTC_DCHECK(encoded_image._frameType == kVideoFrameKey || |
| 293 encodedImage._frameType == kVideoFrameDelta); | 299 encoded_image._frameType == kVideoFrameDelta); |
| 294 post_encode_callback_->Encoded(encodedImage, NULL, NULL); | 300 post_encode_callback_->Encoded(encoded_image, NULL, NULL); |
| 295 | 301 |
| 296 if (_sendCallback == NULL) { | 302 if (send_callback_ == NULL) { |
| 297 return VCM_UNINITIALIZED; | 303 return VCM_UNINITIALIZED; |
| 298 } | 304 } |
| 299 | 305 |
| 300 #ifdef DEBUG_ENCODER_BIT_STREAM | 306 #ifdef DEBUG_ENCODER_BIT_STREAM |
| 301 if (_bitStreamAfterEncoder != NULL) { | 307 if (_bitStreamAfterEncoder != NULL) { |
| 302 fwrite(encodedImage._buffer, 1, encodedImage._length, | 308 fwrite(encoded_image._buffer, 1, encoded_image._length, |
| 303 _bitStreamAfterEncoder); | 309 _bitStreamAfterEncoder); |
| 304 } | 310 } |
| 305 #endif | 311 #endif |
| 306 | 312 |
| 307 RTPVideoHeader rtpVideoHeader; | 313 RTPVideoHeader rtpVideoHeader; |
| 308 memset(&rtpVideoHeader, 0, sizeof(RTPVideoHeader)); | 314 memset(&rtpVideoHeader, 0, sizeof(RTPVideoHeader)); |
| 309 RTPVideoHeader* rtpVideoHeaderPtr = &rtpVideoHeader; | 315 RTPVideoHeader* rtpVideoHeaderPtr = &rtpVideoHeader; |
| 310 if (codecSpecificInfo) { | 316 if (codecSpecificInfo) { |
| 311 CopyCodecSpecific(codecSpecificInfo, rtpVideoHeaderPtr); | 317 CopyCodecSpecific(codecSpecificInfo, rtpVideoHeaderPtr); |
| 312 } | 318 } |
| 313 rtpVideoHeader.rotation = _rotation; | 319 rtpVideoHeader.rotation = _rotation; |
| 314 | 320 |
| 315 int32_t callbackReturn = _sendCallback->SendData( | 321 int32_t callbackReturn = send_callback_->SendData( |
| 316 _payloadType, encodedImage, *fragmentationHeader, rtpVideoHeaderPtr); | 322 _payloadType, encoded_image, *fragmentationHeader, rtpVideoHeaderPtr); |
| 317 if (callbackReturn < 0) { | 323 if (callbackReturn < 0) { |
| 318 return callbackReturn; | 324 return callbackReturn; |
| 319 } | 325 } |
| 320 | 326 |
| 321 if (_mediaOpt != NULL) { | 327 if (_mediaOpt != NULL) { |
| 322 _mediaOpt->UpdateWithEncodedData(encodedImage); | 328 _mediaOpt->UpdateWithEncodedData(encoded_image); |
| 323 if (_internalSource) | 329 if (_internalSource) |
| 324 return _mediaOpt->DropFrame(); // Signal to encoder to drop next frame. | 330 return _mediaOpt->DropFrame(); // Signal to encoder to drop next frame. |
| 325 } | 331 } |
| 326 return VCM_OK; | 332 return VCM_OK; |
| 327 } | 333 } |
| 328 | 334 |
| 329 void | 335 void VCMEncodedFrameCallback::SetMediaOpt( |
| 330 VCMEncodedFrameCallback::SetMediaOpt( | 336 media_optimization::MediaOptimization* mediaOpt) { |
| 331 media_optimization::MediaOptimization *mediaOpt) | 337 _mediaOpt = mediaOpt; |
| 332 { | 338 } |
| 333 _mediaOpt = mediaOpt; | 339 |
| 340 void VCMEncodedFrameCallback::LastEncoderImplementationUsed( | |
|
stefan-webrtc
2015/10/27 08:31:53
SetLast...?
pbos-webrtc
2015/10/27 12:16:59
SignalLast.. done.
| |
| 341 const char* implementation_name) { | |
| 342 if (send_callback_) | |
| 343 send_callback_->OnEncoderImplementationName(implementation_name); | |
| 334 } | 344 } |
| 335 | 345 |
| 336 } // namespace webrtc | 346 } // namespace webrtc |
| OLD | NEW |