Changeset 231167 in webkit


Ignore:
Timestamp:
Apr 30, 2018 1:28:22 PM (6 years ago)
Author:
youenn@apple.com
Message:

Mandate H264 hardware encoder for Mac in libwebrtc
https://bugs.webkit.org/show_bug.cgi?id=184835

Reviewed by Eric Carlson.

Tested manually through console traces that hardware VCP encoder code path is actually used instead of software VCP encoder code path.

  • Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm:

(-[RTCVideoEncoderH264 resetCompressionSessionWithPixelFormat:]):

  • WebKit/0001-Update-RTCVideoEncoderH264.mm-for-WebKit.patch: Added to cover this change and changes made in bug 184668 and 183961.
Location:
trunk/Source/ThirdParty/libwebrtc
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/ThirdParty/libwebrtc/ChangeLog

    r230871 r231167  
     12018-04-30  Youenn Fablet  <youenn@apple.com>
     2
     3        Mandate H264 hardware encoder for Mac in libwebrtc
     4        https://bugs.webkit.org/show_bug.cgi?id=184835
     5
     6        Reviewed by Eric Carlson.
     7
     8        Tested manually through console traces that hardware VCP encoder code path is actually used instead of software VCP encoder code path.
     9
     10        * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm:
     11        (-[RTCVideoEncoderH264 resetCompressionSessionWithPixelFormat:]):
     12        * WebKit/0001-Update-RTCVideoEncoderH264.mm-for-WebKit.patch: Added to cover this change and changes made in bug 184668 and 183961.
     13
    1142018-04-20  Commit Queue  <commit-queue@webkit.org>
    215
  • trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm

    r230871 r231167  
    608608    pixelFormat = nullptr;
    609609  }
    610   CFMutableDictionaryRef encoder_specs = nullptr;
     610  CFDictionaryRef encoderSpecs = nullptr;
    611611#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
     612  auto useHardwareEncoder = webrtc::isH264HardwareEncoderAllowed() ? kCFBooleanTrue : kCFBooleanFalse;
    612613  // Currently hw accl is supported above 360p on mac, below 360p
    613614  // the compression session will be created with hw accl disabled.
    614   encoder_specs = CFDictionaryCreateMutable(
    615       nullptr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    616   CFDictionarySetValue(encoder_specs,
    617                        kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder,
    618                        webrtc::isH264HardwareEncoderAllowed() ? kCFBooleanTrue : kCFBooleanFalse);
     615  CFTypeRef sessionKeys[] = {kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder, kVTCompressionPropertyKey_RealTime };
     616  CFTypeRef sessionValues[] = {  useHardwareEncoder, useHardwareEncoder, kCFBooleanTrue };
     617  encoderSpecs = CFDictionaryCreate(kCFAllocatorDefault, sessionKeys, sessionValues, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
    619618#endif
    620619  OSStatus status =
     
    623622                                 _height,
    624623                                 kCodecTypeH264,
    625                                  encoder_specs,  // use hardware accelerated encoder if available
     624                                 encoderSpecs,  // use hardware accelerated encoder if available
    626625                                 sourceAttributes,
    627626                                 nullptr,  // use default compressed data allocator
     
    633632    sourceAttributes = nullptr;
    634633  }
    635   if (encoder_specs) {
    636     CFRelease(encoder_specs);
    637     encoder_specs = nullptr;
    638   }
     634  if (encoderSpecs) {
     635    CFRelease(encoderSpecs);
     636    encoderSpecs = nullptr;
     637  }
     638
     639#if ENABLE_VCP_ENCODER || defined(WEBRTC_IOS)
    639640  if (status != noErr) {
    640641    RTC_LOG(LS_ERROR) << "Failed to create compression session: " << status;
    641642    return WEBRTC_VIDEO_CODEC_ERROR;
    642643  }
     644#endif
    643645#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
    644646  CFBooleanRef hwaccl_enabled = nullptr;
    645   status = VTSessionCopyProperty(_compressionSession,
     647  if (status == noErr) {
     648    status = VTSessionCopyProperty(_compressionSession,
    646649                                 kVTCompressionPropertyKey_UsingHardwareAcceleratedVideoEncoder,
    647650                                 nullptr,
    648651                                 &hwaccl_enabled);
     652  }
    649653  if (status == noErr && (CFBooleanGetValue(hwaccl_enabled))) {
    650654    RTC_LOG(LS_INFO) << "Compression session created with hw accl enabled";
     
    715719      sourceAttributes = nullptr;
    716720    }
    717     if (encoder_specs) {
    718       CFRelease(encoder_specs);
    719       encoder_specs = nullptr;
     721    if (encoderSpecs) {
     722      CFRelease(encoderSpecs);
     723      encoderSpecs = nullptr;
    720724    }
    721725    if (status != noErr) {
Note: See TracChangeset for help on using the changeset viewer.