Changeset 255564 in webkit
- Timestamp:
- Feb 3, 2020 8:38:29 AM (4 years ago)
- Location:
- trunk/Source/ThirdParty/libwebrtc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/ThirdParty/libwebrtc/ChangeLog
r254815 r255564 1 2020-02-03 youenn fablet <youenn@apple.com> 2 3 Make sure RTCVideoEncoderH264 generate a keyframe even if the frame that was supposed to be a key frame was dropped 4 https://bugs.webkit.org/show_bug.cgi?id=207108 5 6 Reviewed by Eric Carlson. 7 8 Add a parameter telling whether a frame to be encoded should be a key frame. 9 In encoder callback, if the frame is expected to be a key frame, set a flag to force the next frame to be a key frame. 10 This ensures that keyframe sending is not delayed in case encoding is dropping or failing to encode frames. 11 12 * Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm: 13 (-[RTCVideoEncoderH264 initWithCodecInfo:]): 14 (-[RTCVideoEncoderH264 encode:codecSpecificInfo:frameTypes:]): 15 (-[RTCVideoEncoderH264 frameWasEncoded:flags:sampleBuffer:codecSpecificInfo:width:height:renderTimeMs:timestamp:rotation:isKeyFrameRequired:]): 16 1 17 2020-01-20 youenn fablet <youenn@apple.com> 2 18 -
trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH264.mm
r252472 r255564 87 87 renderTimeMs:(int64_t)renderTimeMs 88 88 timestamp:(uint32_t)timestamp 89 rotation:(RTCVideoRotation)rotation; 89 rotation:(RTCVideoRotation)rotation 90 isKeyFrameRequired:(bool)isKeyFrameRequired; 90 91 91 92 @end … … 113 114 int64_t rtms, 114 115 uint32_t ts, 115 RTCVideoRotation r) 116 : encoder(e), width(w), height(h), render_time_ms(rtms), timestamp(ts), rotation(r) { 116 RTCVideoRotation r, 117 bool isKeyFrameRequired) 118 : encoder(e), width(w), height(h), render_time_ms(rtms), timestamp(ts), rotation(r), isKeyFrameRequired(isKeyFrameRequired) { 117 119 if (csi) { 118 120 codecSpecificInfo = csi; … … 129 131 uint32_t timestamp; 130 132 RTCVideoRotation rotation; 133 bool isKeyFrameRequired; 131 134 }; 132 135 … … 207 210 renderTimeMs:encodeParams->render_time_ms 208 211 timestamp:encodeParams->timestamp 209 rotation:encodeParams->rotation]; 212 rotation:encodeParams->rotation 213 isKeyFrameRequired:encodeParams->isKeyFrameRequired]; 210 214 } 211 215 … … 371 375 std::vector<uint8_t> _frameScaleBuffer; 372 376 bool _disableEncoding; 377 bool _isKeyFrameRequired; 373 378 } 374 379 … … 401 406 RTC_CHECK([codecInfo.name isEqualToString:kRTCVideoCodecH264Name]); 402 407 } 408 _isKeyFrameRequired = false; 409 403 410 return self; 404 411 } … … 451 458 return WEBRTC_VIDEO_CODEC_UNINITIALIZED; 452 459 } 453 BOOL isKeyframeRequired = NO; 460 BOOL isKeyframeRequired = _isKeyFrameRequired; 461 _isKeyFrameRequired = false; 454 462 455 463 // Get a pixel buffer from the pool and copy frame data over. … … 514 522 for (NSNumber *frameType in frameTypes) { 515 523 if ((RTCFrameType)frameType.intValue == RTCFrameTypeVideoFrameKey) { 524 RTC_LOG(LS_INFO) << "keyframe requested"; 516 525 isKeyframeRequired = YES; 517 526 break; … … 535 544 frame.timeStampNs / rtc::kNumNanosecsPerMillisec, 536 545 frame.timeStamp, 537 frame.rotation)); 546 frame.rotation, 547 isKeyframeRequired)); 538 548 encodeParams->codecSpecificInfo.packetizationMode = _packetizationMode; 539 549 … … 948 958 renderTimeMs:(int64_t)renderTimeMs 949 959 timestamp:(uint32_t)timestamp 950 rotation:(RTCVideoRotation)rotation { 960 rotation:(RTCVideoRotation)rotation 961 isKeyFrameRequired:(bool)isKeyFrameRequired { 951 962 if (status != noErr) { 952 963 RTC_LOG(LS_ERROR) << "H264 encode failed with code: " << status; 964 if (isKeyFrameRequired) 965 _isKeyFrameRequired = true; 953 966 return; 954 967 } 955 968 if (infoFlags & kVTEncodeInfo_FrameDropped) { 969 if (isKeyFrameRequired) 970 _isKeyFrameRequired = true; 956 971 RTC_LOG(LS_INFO) << "H264 encode dropped frame."; 957 972 return; 958 973 } 974 _isKeyFrameRequired = false; 959 975 960 976 BOOL isKeyframe = NO; … … 1005 1021 if (!res) { 1006 1022 RTC_LOG(LS_ERROR) << "Encode callback failed"; 1023 if (isKeyFrameRequired) 1024 _isKeyFrameRequired = true; 1007 1025 return; 1008 1026 }
Note: See TracChangeset
for help on using the changeset viewer.