Skip to content

Commit d7ef486

Browse files
committed
Try using low latency for WebRTC HEVC encoder if available
https://bugs.webkit.org/show_bug.cgi?id=250824 rdar://problem/104416138 Reviewed by Eric Carlson. Try using low latency mode and if failing use regular mode. * Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH265.mm: (-[RTCVideoEncoderH265 resetCompressionSession]): Canonical link: https://commits.webkit.org/259128@main
1 parent 61cec39 commit d7ef486

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/components/video_codec/RTCVideoEncoderH265.mm

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#include "sdk/objc/Framework/Classes/VideoToolbox/nalu_rewriter.h"
3737
#include "system_wrappers/include/clock.h"
3838

39+
VT_EXPORT const CFStringRef kVTVideoEncoderSpecification_RequiredLowLatency;
40+
3941
@interface RTCVideoEncoderH265 ()
4042

4143
- (void)frameWasEncoded:(OSStatus)status
@@ -407,8 +409,7 @@ - (int)resetCompressionSession {
407409
CFDictionarySetValue(encoder_specs, kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, kCFBooleanTrue);
408410
#endif
409411
#if HAVE_VTB_REQUIREDLOWLATENCY
410-
// We will want to enable this property once working.
411-
// CFDictionarySetValue(encoder_specs, kVTVideoEncoderSpecification_RequiredLowLatency, kCFBooleanTrue);
412+
CFDictionarySetValue(encoder_specs, kVTVideoEncoderSpecification_RequiredLowLatency, kCFBooleanTrue);
412413
#endif
413414
OSStatus status = VTCompressionSessionCreate(
414415
nullptr, // use default allocator
@@ -417,6 +418,17 @@ - (int)resetCompressionSession {
417418
sourceAttributes,
418419
nullptr, // use default compressed data allocator
419420
compressionOutputCallback, nullptr, &_compressionSession);
421+
if (status != noErr) {
422+
if (encoder_specs)
423+
CFDictionaryRemoveValue(encoder_specs, kVTVideoEncoderSpecification_RequiredLowLatency);
424+
status = VTCompressionSessionCreate(
425+
nullptr, // use default allocator
426+
_width, _height, kCMVideoCodecType_HEVC,
427+
encoder_specs, // use hardware accelerated encoder if available
428+
sourceAttributes,
429+
nullptr, // use default compressed data allocator
430+
compressionOutputCallback, nullptr, &_compressionSession);
431+
}
420432
if (sourceAttributes) {
421433
CFRelease(sourceAttributes);
422434
sourceAttributes = nullptr;

0 commit comments

Comments
 (0)