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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 LOG(LS_ERROR) << "Failed to initialize the encoder associated with " | 133 LOG(LS_ERROR) << "Failed to initialize the encoder associated with " |
134 "payload name: " << settings->plName; | 134 "payload name: " << settings->plName; |
135 return -1; | 135 return -1; |
136 } | 136 } |
137 return 0; | 137 return 0; |
138 } | 138 } |
139 | 139 |
140 int32_t VCMGenericEncoder::Encode(const VideoFrame& inputFrame, | 140 int32_t VCMGenericEncoder::Encode(const VideoFrame& inputFrame, |
141 const CodecSpecificInfo* codecSpecificInfo, | 141 const CodecSpecificInfo* codecSpecificInfo, |
142 const std::vector<FrameType>& frameTypes) { | 142 const std::vector<FrameType>& frameTypes) { |
143 std::vector<VideoFrameType> video_frame_types(frameTypes.size(), | 143 for (FrameType frame_type : frameTypes) |
144 kDeltaFrame); | 144 RTC_DCHECK(frame_type == kVideoFrameKey || frame_type == kVideoFrameDelta); |
145 VCMEncodedFrame::ConvertFrameTypes(frameTypes, &video_frame_types); | |
146 | 145 |
147 rotation_ = inputFrame.rotation(); | 146 rotation_ = inputFrame.rotation(); |
148 | 147 |
149 if (vcm_encoded_frame_callback_) { | 148 if (vcm_encoded_frame_callback_) { |
150 // 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 |
151 // 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 |
152 // delay but it should be close enough. | 151 // delay but it should be close enough. |
153 vcm_encoded_frame_callback_->SetRotation(rotation_); | 152 vcm_encoded_frame_callback_->SetRotation(rotation_); |
154 } | 153 } |
155 | 154 |
156 int32_t result = | 155 int32_t result = encoder_->Encode(inputFrame, codecSpecificInfo, &frameTypes); |
157 encoder_->Encode(inputFrame, codecSpecificInfo, &video_frame_types); | |
158 if (is_screenshare_ && | 156 if (is_screenshare_ && |
159 result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) { | 157 result == WEBRTC_VIDEO_CODEC_TARGET_BITRATE_OVERSHOOT) { |
160 // Target bitrate exceeded, encoder state has been reset - try again. | 158 // Target bitrate exceeded, encoder state has been reset - try again. |
161 return encoder_->Encode(inputFrame, codecSpecificInfo, &video_frame_types); | 159 return encoder_->Encode(inputFrame, codecSpecificInfo, &frameTypes); |
162 } | 160 } |
163 | 161 |
164 return result; | 162 return result; |
165 } | 163 } |
166 | 164 |
167 int32_t | 165 int32_t |
168 VCMGenericEncoder::SetChannelParameters(int32_t packetLoss, int64_t rtt) | 166 VCMGenericEncoder::SetChannelParameters(int32_t packetLoss, int64_t rtt) |
169 { | 167 { |
170 return encoder_->SetChannelParameters(packetLoss, rtt); | 168 return encoder_->SetChannelParameters(packetLoss, rtt); |
171 } | 169 } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 214 |
217 int32_t | 215 int32_t |
218 VCMGenericEncoder::SetPeriodicKeyFrames(bool enable) | 216 VCMGenericEncoder::SetPeriodicKeyFrames(bool enable) |
219 { | 217 { |
220 return encoder_->SetPeriodicKeyFrames(enable); | 218 return encoder_->SetPeriodicKeyFrames(enable); |
221 } | 219 } |
222 | 220 |
223 int32_t VCMGenericEncoder::RequestFrame( | 221 int32_t VCMGenericEncoder::RequestFrame( |
224 const std::vector<FrameType>& frame_types) { | 222 const std::vector<FrameType>& frame_types) { |
225 VideoFrame image; | 223 VideoFrame image; |
226 std::vector<VideoFrameType> video_frame_types(frame_types.size(), | 224 return encoder_->Encode(image, NULL, &frame_types); |
227 kDeltaFrame); | |
228 VCMEncodedFrame::ConvertFrameTypes(frame_types, &video_frame_types); | |
229 return encoder_->Encode(image, NULL, &video_frame_types); | |
230 } | 225 } |
231 | 226 |
232 int32_t | 227 int32_t |
233 VCMGenericEncoder::RegisterEncodeCallback(VCMEncodedFrameCallback* VCMencodedFra
meCallback) | 228 VCMGenericEncoder::RegisterEncodeCallback(VCMEncodedFrameCallback* VCMencodedFra
meCallback) |
234 { | 229 { |
235 VCMencodedFrameCallback->SetInternalSource(internal_source_); | 230 VCMencodedFrameCallback->SetInternalSource(internal_source_); |
236 vcm_encoded_frame_callback_ = VCMencodedFrameCallback; | 231 vcm_encoded_frame_callback_ = VCMencodedFrameCallback; |
237 return encoder_->RegisterEncodeCompleteCallback(VCMencodedFrameCallback); | 232 return encoder_->RegisterEncodeCompleteCallback(VCMencodedFrameCallback); |
238 } | 233 } |
239 | 234 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 VCMEncodedFrameCallback::SetTransportCallback(VCMPacketizationCallback* transpor
t) | 282 VCMEncodedFrameCallback::SetTransportCallback(VCMPacketizationCallback* transpor
t) |
288 { | 283 { |
289 _sendCallback = transport; | 284 _sendCallback = transport; |
290 return VCM_OK; | 285 return VCM_OK; |
291 } | 286 } |
292 | 287 |
293 int32_t VCMEncodedFrameCallback::Encoded( | 288 int32_t VCMEncodedFrameCallback::Encoded( |
294 const EncodedImage& encodedImage, | 289 const EncodedImage& encodedImage, |
295 const CodecSpecificInfo* codecSpecificInfo, | 290 const CodecSpecificInfo* codecSpecificInfo, |
296 const RTPFragmentationHeader* fragmentationHeader) { | 291 const RTPFragmentationHeader* fragmentationHeader) { |
| 292 RTC_DCHECK(encodedImage._frameType == kVideoFrameKey || |
| 293 encodedImage._frameType == kVideoFrameDelta); |
297 post_encode_callback_->Encoded(encodedImage, NULL, NULL); | 294 post_encode_callback_->Encoded(encodedImage, NULL, NULL); |
298 | 295 |
299 if (_sendCallback == NULL) { | 296 if (_sendCallback == NULL) { |
300 return VCM_UNINITIALIZED; | 297 return VCM_UNINITIALIZED; |
301 } | 298 } |
302 | 299 |
303 #ifdef DEBUG_ENCODER_BIT_STREAM | 300 #ifdef DEBUG_ENCODER_BIT_STREAM |
304 if (_bitStreamAfterEncoder != NULL) { | 301 if (_bitStreamAfterEncoder != NULL) { |
305 fwrite(encodedImage._buffer, 1, encodedImage._length, | 302 fwrite(encodedImage._buffer, 1, encodedImage._length, |
306 _bitStreamAfterEncoder); | 303 _bitStreamAfterEncoder); |
(...skipping 23 matching lines...) Expand all Loading... |
330 } | 327 } |
331 | 328 |
332 void | 329 void |
333 VCMEncodedFrameCallback::SetMediaOpt( | 330 VCMEncodedFrameCallback::SetMediaOpt( |
334 media_optimization::MediaOptimization *mediaOpt) | 331 media_optimization::MediaOptimization *mediaOpt) |
335 { | 332 { |
336 _mediaOpt = mediaOpt; | 333 _mediaOpt = mediaOpt; |
337 } | 334 } |
338 | 335 |
339 } // namespace webrtc | 336 } // namespace webrtc |
OLD | NEW |