| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 case kVideoCodecGeneric: | 84 case kVideoCodecGeneric: |
| 85 rtp->codec = kRtpVideoGeneric; | 85 rtp->codec = kRtpVideoGeneric; |
| 86 rtp->simulcastIdx = info->codecSpecific.generic.simulcast_idx; | 86 rtp->simulcastIdx = info->codecSpecific.generic.simulcast_idx; |
| 87 return; | 87 return; |
| 88 default: | 88 default: |
| 89 return; | 89 return; |
| 90 } | 90 } |
| 91 } | 91 } |
| 92 } // namespace | 92 } // namespace |
| 93 | 93 |
| 94 // #define DEBUG_ENCODER_BIT_STREAM | |
| 95 | |
| 96 VCMGenericEncoder::VCMGenericEncoder( | 94 VCMGenericEncoder::VCMGenericEncoder( |
| 97 VideoEncoder* encoder, | 95 VideoEncoder* encoder, |
| 98 VideoEncoderRateObserver* rate_observer, | 96 VideoEncoderRateObserver* rate_observer, |
| 99 VCMEncodedFrameCallback* encoded_frame_callback, | 97 VCMEncodedFrameCallback* encoded_frame_callback, |
| 100 bool internalSource) | 98 bool internalSource) |
| 101 : encoder_(encoder), | 99 : encoder_(encoder), |
| 102 rate_observer_(rate_observer), | 100 rate_observer_(rate_observer), |
| 103 vcm_encoded_frame_callback_(encoded_frame_callback), | 101 vcm_encoded_frame_callback_(encoded_frame_callback), |
| 104 internal_source_(internalSource), | 102 internal_source_(internalSource), |
| 105 encoder_params_({0, 0, 0, 0}), | 103 encoder_params_({0, 0, 0, 0}), |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 /*************************** | 225 /*************************** |
| 228 * Callback Implementation | 226 * Callback Implementation |
| 229 ***************************/ | 227 ***************************/ |
| 230 VCMEncodedFrameCallback::VCMEncodedFrameCallback( | 228 VCMEncodedFrameCallback::VCMEncodedFrameCallback( |
| 231 EncodedImageCallback* post_encode_callback) | 229 EncodedImageCallback* post_encode_callback) |
| 232 : send_callback_(), | 230 : send_callback_(), |
| 233 _mediaOpt(NULL), | 231 _mediaOpt(NULL), |
| 234 _payloadType(0), | 232 _payloadType(0), |
| 235 _internalSource(false), | 233 _internalSource(false), |
| 236 _rotation(kVideoRotation_0), | 234 _rotation(kVideoRotation_0), |
| 237 post_encode_callback_(post_encode_callback) | 235 post_encode_callback_(post_encode_callback) {} |
| 238 #ifdef DEBUG_ENCODER_BIT_STREAM | |
| 239 , | |
| 240 _bitStreamAfterEncoder(NULL) | |
| 241 #endif | |
| 242 { | |
| 243 #ifdef DEBUG_ENCODER_BIT_STREAM | |
| 244 _bitStreamAfterEncoder = fopen("encoderBitStream.bit", "wb"); | |
| 245 #endif | |
| 246 } | |
| 247 | 236 |
| 248 VCMEncodedFrameCallback::~VCMEncodedFrameCallback() { | 237 VCMEncodedFrameCallback::~VCMEncodedFrameCallback() {} |
| 249 #ifdef DEBUG_ENCODER_BIT_STREAM | |
| 250 fclose(_bitStreamAfterEncoder); | |
| 251 #endif | |
| 252 } | |
| 253 | 238 |
| 254 int32_t VCMEncodedFrameCallback::SetTransportCallback( | 239 int32_t VCMEncodedFrameCallback::SetTransportCallback( |
| 255 VCMPacketizationCallback* transport) { | 240 VCMPacketizationCallback* transport) { |
| 256 send_callback_ = transport; | 241 send_callback_ = transport; |
| 257 return VCM_OK; | 242 return VCM_OK; |
| 258 } | 243 } |
| 259 | 244 |
| 260 int32_t VCMEncodedFrameCallback::Encoded( | 245 int32_t VCMEncodedFrameCallback::Encoded( |
| 261 const EncodedImage& encoded_image, | 246 const EncodedImage& encoded_image, |
| 262 const CodecSpecificInfo* codecSpecificInfo, | 247 const CodecSpecificInfo* codecSpecificInfo, |
| 263 const RTPFragmentationHeader* fragmentationHeader) { | 248 const RTPFragmentationHeader* fragmentationHeader) { |
| 264 TRACE_EVENT_INSTANT1("webrtc", "VCMEncodedFrameCallback::Encoded", | 249 TRACE_EVENT_INSTANT1("webrtc", "VCMEncodedFrameCallback::Encoded", |
| 265 "timestamp", encoded_image._timeStamp); | 250 "timestamp", encoded_image._timeStamp); |
| 266 post_encode_callback_->Encoded(encoded_image, NULL, NULL); | 251 post_encode_callback_->Encoded(encoded_image, NULL, NULL); |
| 267 | 252 |
| 268 if (send_callback_ == NULL) { | 253 if (send_callback_ == NULL) { |
| 269 return VCM_UNINITIALIZED; | 254 return VCM_UNINITIALIZED; |
| 270 } | 255 } |
| 271 | 256 |
| 272 #ifdef DEBUG_ENCODER_BIT_STREAM | |
| 273 if (_bitStreamAfterEncoder != NULL) { | |
| 274 fwrite(encoded_image._buffer, 1, encoded_image._length, | |
| 275 _bitStreamAfterEncoder); | |
| 276 } | |
| 277 #endif | |
| 278 | |
| 279 RTPVideoHeader rtpVideoHeader; | 257 RTPVideoHeader rtpVideoHeader; |
| 280 memset(&rtpVideoHeader, 0, sizeof(RTPVideoHeader)); | 258 memset(&rtpVideoHeader, 0, sizeof(RTPVideoHeader)); |
| 281 RTPVideoHeader* rtpVideoHeaderPtr = &rtpVideoHeader; | 259 RTPVideoHeader* rtpVideoHeaderPtr = &rtpVideoHeader; |
| 282 if (codecSpecificInfo) { | 260 if (codecSpecificInfo) { |
| 283 CopyCodecSpecific(codecSpecificInfo, rtpVideoHeaderPtr); | 261 CopyCodecSpecific(codecSpecificInfo, rtpVideoHeaderPtr); |
| 284 } | 262 } |
| 285 rtpVideoHeader.rotation = _rotation; | 263 rtpVideoHeader.rotation = _rotation; |
| 286 | 264 |
| 287 int32_t callbackReturn = send_callback_->SendData( | 265 int32_t callbackReturn = send_callback_->SendData( |
| 288 _payloadType, encoded_image, fragmentationHeader, rtpVideoHeaderPtr); | 266 _payloadType, encoded_image, fragmentationHeader, rtpVideoHeaderPtr); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 301 void VCMEncodedFrameCallback::SetMediaOpt( | 279 void VCMEncodedFrameCallback::SetMediaOpt( |
| 302 media_optimization::MediaOptimization* mediaOpt) { | 280 media_optimization::MediaOptimization* mediaOpt) { |
| 303 _mediaOpt = mediaOpt; | 281 _mediaOpt = mediaOpt; |
| 304 } | 282 } |
| 305 | 283 |
| 306 void VCMEncodedFrameCallback::SignalLastEncoderImplementationUsed( | 284 void VCMEncodedFrameCallback::SignalLastEncoderImplementationUsed( |
| 307 const char* implementation_name) { | 285 const char* implementation_name) { |
| 308 if (send_callback_) | 286 if (send_callback_) |
| 309 send_callback_->OnEncoderImplementationName(implementation_name); | 287 send_callback_->OnEncoderImplementationName(implementation_name); |
| 310 } | 288 } |
| 311 | |
| 312 } // namespace webrtc | 289 } // namespace webrtc |
| OLD | NEW |