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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 packet_manipulator_(packet_manipulator), | 52 packet_manipulator_(packet_manipulator), |
53 config_(config), | 53 config_(config), |
54 stats_(stats), | 54 stats_(stats), |
55 encode_callback_(NULL), | 55 encode_callback_(NULL), |
56 decode_callback_(NULL), | 56 decode_callback_(NULL), |
57 source_buffer_(NULL), | 57 source_buffer_(NULL), |
58 first_key_frame_has_been_excluded_(false), | 58 first_key_frame_has_been_excluded_(false), |
59 last_frame_missing_(false), | 59 last_frame_missing_(false), |
60 initialized_(false), | 60 initialized_(false), |
61 encoded_frame_size_(0), | 61 encoded_frame_size_(0), |
62 encoded_frame_type_(kKeyFrame), | 62 encoded_frame_type_(kVideoFrameKey), |
63 prev_time_stamp_(0), | 63 prev_time_stamp_(0), |
64 num_dropped_frames_(0), | 64 num_dropped_frames_(0), |
65 num_spatial_resizes_(0), | 65 num_spatial_resizes_(0), |
66 last_encoder_frame_width_(0), | 66 last_encoder_frame_width_(0), |
67 last_encoder_frame_height_(0), | 67 last_encoder_frame_height_(0), |
68 scaler_() { | 68 scaler_() { |
69 assert(encoder); | 69 assert(encoder); |
70 assert(decoder); | 70 assert(decoder); |
71 assert(frame_reader); | 71 assert(frame_reader); |
72 assert(frame_writer); | 72 assert(frame_writer); |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 kVideoRotation_0); | 192 kVideoRotation_0); |
193 | 193 |
194 // Ensure we have a new statistics data object we can fill: | 194 // Ensure we have a new statistics data object we can fill: |
195 FrameStatistic& stat = stats_->NewFrame(frame_number); | 195 FrameStatistic& stat = stats_->NewFrame(frame_number); |
196 | 196 |
197 encode_start_ = TickTime::Now(); | 197 encode_start_ = TickTime::Now(); |
198 // Use the frame number as "timestamp" to identify frames | 198 // Use the frame number as "timestamp" to identify frames |
199 source_frame_.set_timestamp(frame_number); | 199 source_frame_.set_timestamp(frame_number); |
200 | 200 |
201 // Decide if we're going to force a keyframe: | 201 // Decide if we're going to force a keyframe: |
202 std::vector<FrameType> frame_types(1, kDeltaFrame); | 202 std::vector<FrameType> frame_types(1, kVideoFrameDelta); |
203 if (config_.keyframe_interval > 0 && | 203 if (config_.keyframe_interval > 0 && |
204 frame_number % config_.keyframe_interval == 0) { | 204 frame_number % config_.keyframe_interval == 0) { |
205 frame_types[0] = kKeyFrame; | 205 frame_types[0] = kVideoFrameKey; |
206 } | 206 } |
207 | 207 |
208 // For dropped frames, we regard them as zero size encoded frames. | 208 // For dropped frames, we regard them as zero size encoded frames. |
209 encoded_frame_size_ = 0; | 209 encoded_frame_size_ = 0; |
210 encoded_frame_type_ = kDeltaFrame; | 210 encoded_frame_type_ = kVideoFrameDelta; |
211 | 211 |
212 int32_t encode_result = encoder_->Encode(source_frame_, NULL, &frame_types); | 212 int32_t encode_result = encoder_->Encode(source_frame_, NULL, &frame_types); |
213 | 213 |
214 if (encode_result != WEBRTC_VIDEO_CODEC_OK) { | 214 if (encode_result != WEBRTC_VIDEO_CODEC_OK) { |
215 fprintf(stderr, "Failed to encode frame %d, return code: %d\n", | 215 fprintf(stderr, "Failed to encode frame %d, return code: %d\n", |
216 frame_number, encode_result); | 216 frame_number, encode_result); |
217 } | 217 } |
218 stat.encode_return_code = encode_result; | 218 stat.encode_return_code = encode_result; |
219 return true; | 219 return true; |
220 } else { | 220 } else { |
(...skipping 29 matching lines...) Expand all Loading... |
250 stat.encoded_frame_length_in_bytes = encoded_image._length; | 250 stat.encoded_frame_length_in_bytes = encoded_image._length; |
251 stat.frame_number = encoded_image._timeStamp; | 251 stat.frame_number = encoded_image._timeStamp; |
252 stat.frame_type = encoded_image._frameType; | 252 stat.frame_type = encoded_image._frameType; |
253 stat.bit_rate_in_kbps = encoded_image._length * bit_rate_factor_; | 253 stat.bit_rate_in_kbps = encoded_image._length * bit_rate_factor_; |
254 stat.total_packets = encoded_image._length / | 254 stat.total_packets = encoded_image._length / |
255 config_.networking_config.packet_size_in_bytes + 1; | 255 config_.networking_config.packet_size_in_bytes + 1; |
256 | 256 |
257 // Perform packet loss if criteria is fullfilled: | 257 // Perform packet loss if criteria is fullfilled: |
258 bool exclude_this_frame = false; | 258 bool exclude_this_frame = false; |
259 // Only keyframes can be excluded | 259 // Only keyframes can be excluded |
260 if (encoded_image._frameType == kKeyFrame) { | 260 if (encoded_image._frameType == kVideoFrameKey) { |
261 switch (config_.exclude_frame_types) { | 261 switch (config_.exclude_frame_types) { |
262 case kExcludeOnlyFirstKeyFrame: | 262 case kExcludeOnlyFirstKeyFrame: |
263 if (!first_key_frame_has_been_excluded_) { | 263 if (!first_key_frame_has_been_excluded_) { |
264 first_key_frame_has_been_excluded_ = true; | 264 first_key_frame_has_been_excluded_ = true; |
265 exclude_this_frame = true; | 265 exclude_this_frame = true; |
266 } | 266 } |
267 break; | 267 break; |
268 case kExcludeAllKeyFrames: | 268 case kExcludeAllKeyFrames: |
269 exclude_this_frame = true; | 269 exclude_this_frame = true; |
270 break; | 270 break; |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 return 0; | 413 return 0; |
414 } | 414 } |
415 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded( | 415 int32_t VideoProcessorImpl::VideoProcessorDecodeCompleteCallback::Decoded( |
416 VideoFrame& image) { | 416 VideoFrame& image) { |
417 video_processor_->FrameDecoded(image); // forward to parent class | 417 video_processor_->FrameDecoded(image); // forward to parent class |
418 return 0; | 418 return 0; |
419 } | 419 } |
420 | 420 |
421 } // namespace test | 421 } // namespace test |
422 } // namespace webrtc | 422 } // namespace webrtc |
OLD | NEW |