Changeset 230451 in webkit
- Timestamp:
- Apr 9, 2018 2:09:54 PM (6 years ago)
- Location:
- trunk/Source/ThirdParty/libwebrtc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/ThirdParty/libwebrtc/ChangeLog
r230297 r230451 1 2018-04-09 Youenn Fablet <youenn@apple.com> 2 3 Use special software encoder mode in case there is no VCP not hardware encoder 4 https://bugs.webkit.org/show_bug.cgi?id=183961 5 6 Reviewed by Eric Carlson. 7 8 In case a compression session is not using a hardware encoder and VCP is not active 9 use a specific mode if the resolution is standard. 10 11 * Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.cpp: 12 * Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm: 13 1 14 2018-04-05 Alejandro G. Castro <alex@igalia.com> 2 15 -
trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/WebKit/VideoProcessingSoftLink.h
r229980 r230451 44 44 #endif 45 45 46 #if ENABLE_VCP_ENCODER47 48 #include <VideoProcessing/VideoProcessing.h>49 50 46 #define ALWAYS_INLINE inline 51 47 … … 84 80 } 85 81 82 #define SOFT_LINK_FRAMEWORK_OPTIONAL(framework) \ 83 static void* framework##Library() \ 84 { \ 85 static void* frameworkLibrary = dlopen("/System/Library/Frameworks/" #framework ".framework/" #framework, RTLD_NOW); \ 86 return frameworkLibrary; \ 87 } 88 89 #define SOFT_LINK_POINTER_OPTIONAL(framework, name, type) \ 90 static type init##name(); \ 91 static type (*get##name)() = init##name; \ 92 static type pointer##name; \ 93 \ 94 static type name##Function() \ 95 { \ 96 return pointer##name; \ 97 } \ 98 \ 99 static type init##name() \ 100 { \ 101 void** pointer = static_cast<void**>(dlsym(framework##Library(), #name)); \ 102 if (pointer) \ 103 pointer##name = static_cast<type>(*pointer); \ 104 get##name = name##Function; \ 105 return pointer##name; \ 106 } 107 108 #if ENABLE_VCP_ENCODER 109 110 #include <VideoProcessing/VideoProcessing.h> 111 86 112 SOFT_LINK_FRAMEWORK_FOR_HEADER(webrtc, VideoProcessing) 87 113 -
trunk/Source/ThirdParty/libwebrtc/Source/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
r229920 r230451 38 38 #include "sdk/WebKit/EncoderUtilities.h" 39 39 #include "sdk/WebKit/WebKitUtilities.h" 40 41 #if !ENABLE_VCP_ENCODER && !defined(WEBRTC_IOS) 42 #import <dlfcn.h> 43 #import <objc/runtime.h> 44 45 SOFT_LINK_FRAMEWORK_OPTIONAL(VideoToolBox) 46 SOFT_LINK_POINTER_OPTIONAL(VideoToolBox, kVTVideoEncoderSpecification_Usage, NSString *) 47 48 static inline bool isStandardFrameSize(int32_t width, int32_t height) 49 { 50 // FIXME: Envision relaxing this rule, something like width and height dividable by 4 or 8 should be good enough. 51 if (width == 1280) 52 return height == 720; 53 if (width == 720) 54 return height == 1280; 55 if (width == 960) 56 return height == 540; 57 if (width == 540) 58 return height == 960; 59 if (width == 640) 60 return height == 480; 61 if (width == 480) 62 return height == 640; 63 if (width == 288) 64 return height == 352; 65 if (width == 352) 66 return height == 288; 67 if (width == 320) 68 return height == 240; 69 if (width == 240) 70 return height == 320; 71 return false; 72 } 73 #endif 40 74 41 75 @interface RTCVideoEncoderH264 () … … 617 651 } else { 618 652 RTC_LOG(LS_INFO) << "Compression session created with hw accl disabled"; 653 654 #if !ENABLE_VCP_ENCODER && !defined(WEBRTC_IOS) 655 if (!isStandardFrameSize(_width, _height)) { 656 RTC_LOG(LS_ERROR) << "Using H264 software encoder with non standard size is not supported"; 657 return WEBRTC_VIDEO_CODEC_ERROR; 658 } 659 660 if (!getkVTVideoEncoderSpecification_Usage()) { 661 RTC_LOG(LS_ERROR) << "RTCVideoEncoderH264 cannot create a H264 software encoder"; 662 return WEBRTC_VIDEO_CODEC_ERROR; 663 } 664 665 CFDictionaryRef ioSurfaceValue = CreateCFTypeDictionary(nullptr, nullptr, 0); 666 int64_t pixelFormatType = framePixelFormat; 667 CFNumberRef pixelFormat = CFNumberCreate(nullptr, kCFNumberLongType, &pixelFormatType); 668 669 const size_t attributesSize = 3; 670 CFTypeRef keys[attributesSize] = { 671 kCVPixelBufferOpenGLCompatibilityKey, 672 kCVPixelBufferIOSurfacePropertiesKey, 673 kCVPixelBufferPixelFormatTypeKey 674 }; 675 CFTypeRef values[attributesSize] = { 676 kCFBooleanTrue, 677 ioSurfaceValue, 678 pixelFormat}; 679 CFDictionaryRef sourceAttributes = CreateCFTypeDictionary(keys, values, attributesSize); 680 681 if (ioSurfaceValue) { 682 CFRelease(ioSurfaceValue); 683 ioSurfaceValue = nullptr; 684 } 685 if (pixelFormat) { 686 CFRelease(pixelFormat); 687 pixelFormat = nullptr; 688 } 689 690 CFMutableDictionaryRef encoderSpecs = CFDictionaryCreateMutable(nullptr, 2, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); 691 CFDictionarySetValue(encoderSpecs, kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, kCFBooleanFalse); 692 int usageValue = 1; 693 CFNumberRef usage = CFNumberCreate(nullptr, kCFNumberIntType, &usageValue); 694 CFDictionarySetValue(encoderSpecs, getkVTVideoEncoderSpecification_Usage(), usage); 695 if (usage) { 696 CFRelease(usage); 697 usage = nullptr; 698 } 699 700 [self destroyCompressionSession]; 701 702 OSStatus status = 703 CompressionSessionCreate(nullptr, // use default allocator 704 _width, 705 _height, 706 kCodecTypeH264, 707 encoderSpecs, 708 sourceAttributes, 709 nullptr, // use default compressed data allocator 710 compressionOutputCallback, 711 nullptr, 712 &_compressionSession); 713 if (sourceAttributes) { 714 CFRelease(sourceAttributes); 715 sourceAttributes = nullptr; 716 } 717 if (encoder_specs) { 718 CFRelease(encoder_specs); 719 encoder_specs = nullptr; 720 } 721 if (status != noErr) { 722 return WEBRTC_VIDEO_CODEC_ERROR; 723 } 724 #endif 619 725 } 620 726 #endif
Note: See TracChangeset
for help on using the changeset viewer.