Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Unified Diff: webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm

Issue 3003653002: Enable the HW VideoToolbox encoder on mac. (Closed)
Patch Set: Make sure to compile this only on mac Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
diff --git a/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm b/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
index 7ac8c1823741897ff700ec6fed51d44ee82f7059..44983beb6a8e09dd8ec18241e356e0063ed84c5f 100644
--- a/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
+++ b/webrtc/sdk/objc/Framework/Classes/VideoToolbox/RTCVideoEncoderH264.mm
@@ -509,24 +509,51 @@ CFStringRef ExtractProfile(const cricket::VideoCodec &codec) {
CFRelease(pixelFormat);
pixelFormat = nullptr;
}
- OSStatus status = VTCompressionSessionCreate(nullptr, // use default allocator
- _width,
- _height,
- kCMVideoCodecType_H264,
- nullptr, // use default encoder
- sourceAttributes,
- nullptr, // use default compressed data allocator
- compressionOutputCallback,
- nullptr,
- &_compressionSession);
+ CFMutableDictionaryRef encoder_specs = nullptr;
+#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
+ // Currently hw accl is supported above 360p on mac, below 360p
+ // the compression session will be created with hw accl disabled.
+ encoder_specs = CFDictionaryCreateMutable(
+ nullptr, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ CFDictionarySetValue(encoder_specs,
+ kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder,
+ kCFBooleanTrue);
+#endif
+ OSStatus status =
+ VTCompressionSessionCreate(nullptr, // use default allocator
+ _width,
+ _height,
+ kCMVideoCodecType_H264,
+ encoder_specs, // use hardware accelerated encoder if available
+ sourceAttributes,
+ nullptr, // use default compressed data allocator
+ compressionOutputCallback,
+ nullptr,
+ &_compressionSession);
if (sourceAttributes) {
CFRelease(sourceAttributes);
sourceAttributes = nullptr;
}
+ if (encoder_specs) {
+ CFRelease(encoder_specs);
+ encoder_specs = nullptr;
+ }
if (status != noErr) {
LOG(LS_ERROR) << "Failed to create compression session: " << status;
return WEBRTC_VIDEO_CODEC_ERROR;
}
+#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
+ CFBooleanRef hwaccl_enabled = nullptr;
+ status = VTSessionCopyProperty(_compressionSession,
+ kVTCompressionPropertyKey_UsingHardwareAcceleratedVideoEncoder,
+ nullptr,
+ &hwaccl_enabled);
+ if (status == noErr && (CFBooleanGetValue(hwaccl_enabled))) {
+ LOG(LS_INFO) << "Compression session created with hw accl enabled";
+ } else {
+ LOG(LS_INFO) << "Compression session created with hw accl disabled";
+ }
+#endif
[self configureCompressionSession];
return WEBRTC_VIDEO_CODEC_OK;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698