OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // } else if (width * height > 1280 * 960 && number_of_cores >= 6) { | 43 // } else if (width * height > 1280 * 960 && number_of_cores >= 6) { |
44 // return 3; // 3 threads for 1080p. | 44 // return 3; // 3 threads for 1080p. |
45 // } else if (width * height > 640 * 480 && number_of_cores >= 3) { | 45 // } else if (width * height > 640 * 480 && number_of_cores >= 3) { |
46 // return 2; // 2 threads for qHD/HD. | 46 // return 2; // 2 threads for qHD/HD. |
47 // } else { | 47 // } else { |
48 // return 1; // 1 thread for VGA or less. | 48 // return 1; // 1 thread for VGA or less. |
49 // } | 49 // } |
50 return 1; | 50 return 1; |
51 } | 51 } |
52 | 52 |
53 FrameType ConvertToVideoFrameType(EVideoFrameType type) { | 53 } // namespace |
| 54 |
| 55 static FrameType EVideoFrameType_to_FrameType(EVideoFrameType type) { |
54 switch (type) { | 56 switch (type) { |
| 57 case videoFrameTypeInvalid: |
| 58 return kEmptyFrame; |
55 case videoFrameTypeIDR: | 59 case videoFrameTypeIDR: |
56 return kVideoFrameKey; | 60 return kVideoFrameKey; |
57 case videoFrameTypeSkip: | 61 case videoFrameTypeSkip: |
58 case videoFrameTypeI: | 62 case videoFrameTypeI: |
59 case videoFrameTypeP: | 63 case videoFrameTypeP: |
60 case videoFrameTypeIPMixed: | 64 case videoFrameTypeIPMixed: |
61 return kVideoFrameDelta; | 65 return kVideoFrameDelta; |
62 case videoFrameTypeInvalid: | 66 default: |
63 break; | 67 LOG(LS_WARNING) << "Unknown EVideoFrameType: " << type; |
| 68 return kVideoFrameDelta; |
64 } | 69 } |
65 RTC_NOTREACHED() << "Unexpected/invalid frame type: " << type; | |
66 return kEmptyFrame; | |
67 } | 70 } |
68 | 71 |
69 } // namespace | |
70 | |
71 // Helper method used by H264EncoderImpl::Encode. | 72 // Helper method used by H264EncoderImpl::Encode. |
72 // Copies the encoded bytes from |info| to |encoded_image| and updates the | 73 // Copies the encoded bytes from |info| to |encoded_image| and updates the |
73 // fragmentation information of |frag_header|. The |encoded_image->_buffer| may | 74 // fragmentation information of |frag_header|. The |encoded_image->_buffer| may |
74 // be deleted and reallocated if a bigger buffer is required. | 75 // be deleted and reallocated if a bigger buffer is required. |
75 // | 76 // |
76 // After OpenH264 encoding, the encoded bytes are stored in |info| spread out | 77 // After OpenH264 encoding, the encoded bytes are stored in |info| spread out |
77 // over a number of layers and "NAL units". Each NAL unit is a fragment starting | 78 // over a number of layers and "NAL units". Each NAL unit is a fragment starting |
78 // with the four-byte start code {0,0,0,1}. All of this data (including the | 79 // with the four-byte start code {0,0,0,1}. All of this data (including the |
79 // start codes) is copied to the |encoded_image->_buffer| and the |frag_header| | 80 // start codes) is copied to the |encoded_image->_buffer| and the |frag_header| |
80 // is updated to point to each fragment, with offsets and lengths set as to | 81 // is updated to point to each fragment, with offsets and lengths set as to |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 ReportError(); | 379 ReportError(); |
379 return WEBRTC_VIDEO_CODEC_ERROR; | 380 return WEBRTC_VIDEO_CODEC_ERROR; |
380 } | 381 } |
381 | 382 |
382 encoded_image_._encodedWidth = frame.width(); | 383 encoded_image_._encodedWidth = frame.width(); |
383 encoded_image_._encodedHeight = frame.height(); | 384 encoded_image_._encodedHeight = frame.height(); |
384 encoded_image_._timeStamp = frame.timestamp(); | 385 encoded_image_._timeStamp = frame.timestamp(); |
385 encoded_image_.ntp_time_ms_ = frame.ntp_time_ms(); | 386 encoded_image_.ntp_time_ms_ = frame.ntp_time_ms(); |
386 encoded_image_.capture_time_ms_ = frame.render_time_ms(); | 387 encoded_image_.capture_time_ms_ = frame.render_time_ms(); |
387 encoded_image_.rotation_ = frame.rotation(); | 388 encoded_image_.rotation_ = frame.rotation(); |
388 encoded_image_._frameType = ConvertToVideoFrameType(info.eFrameType); | 389 encoded_image_._frameType = EVideoFrameType_to_FrameType(info.eFrameType); |
389 | 390 |
390 // Split encoded image up into fragments. This also updates |encoded_image_|. | 391 // Split encoded image up into fragments. This also updates |encoded_image_|. |
391 RTPFragmentationHeader frag_header; | 392 RTPFragmentationHeader frag_header; |
392 RtpFragmentize(&encoded_image_, &encoded_image_buffer_, frame, &info, | 393 RtpFragmentize(&encoded_image_, &encoded_image_buffer_, frame, &info, |
393 &frag_header); | 394 &frag_header); |
394 | 395 |
395 // Encoder can skip frames to save bandwidth in which case | 396 // Encoder can skip frames to save bandwidth in which case |
396 // |encoded_image_._length| == 0. | 397 // |encoded_image_._length| == 0. |
397 if (encoded_image_._length > 0) { | 398 if (encoded_image_._length > 0) { |
398 // Deliver encoded image. | 399 // Deliver encoded image. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
433 } | 434 } |
434 | 435 |
435 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { | 436 int32_t H264EncoderImpl::SetPeriodicKeyFrames(bool enable) { |
436 return WEBRTC_VIDEO_CODEC_OK; | 437 return WEBRTC_VIDEO_CODEC_OK; |
437 } | 438 } |
438 | 439 |
439 void H264EncoderImpl::OnDroppedFrame() { | 440 void H264EncoderImpl::OnDroppedFrame() { |
440 } | 441 } |
441 | 442 |
442 } // namespace webrtc | 443 } // namespace webrtc |
OLD | NEW |