diff options
author | Heinrich Fink <hfink@toolsonair.com> | 2016-06-01 13:43:32 +0200 |
---|---|---|
committer | Sebastian Dröge <sebastian@centricular.com> | 2016-06-02 11:22:09 +0300 |
commit | ab70d79c4303319ce0a7da72bf11e0eb60b0912c (patch) | |
tree | 2343e11e77541cea598db00ba1a554d32862393d /sys/applemedia/vtenc.c | |
parent | 3d8d60baa87442b5a38383309481bc15c3fade15 (diff) | |
download | gstreamer-plugins-bad-ab70d79c4303319ce0a7da72bf11e0eb60b0912c.tar.gz |
applemedia: vtenc: Register a hardware-only vtenc_h264_hw element on OSX
Similar to vtdec_hw, this commit adds a vtenc_h264_hw element that fails
caps negotiation unless a hardware encoder could actually be acquired.
This is useful in situations where a fallback to a software encoder
other than the vtenc_h264 software encoder is desired (e.g. to x264enc).
https://bugzilla.gnome.org/show_bug.cgi?id=767104
Diffstat (limited to 'sys/applemedia/vtenc.c')
-rw-r--r-- | sys/applemedia/vtenc.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/sys/applemedia/vtenc.c b/sys/applemedia/vtenc.c index 5c0c6ca62..39b7813be 100644 --- a/sys/applemedia/vtenc.c +++ b/sys/applemedia/vtenc.c @@ -47,6 +47,9 @@ GST_DEBUG_CATEGORY (gst_vtenc_debug); const CFStringRef kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder = CFSTR ("EnableHardwareAcceleratedVideoEncoder"); +const CFStringRef + kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder = +CFSTR ("RequireHardwareAcceleratedVideoEncoder"); const CFStringRef kVTCompressionPropertyKey_ProfileLevel = CFSTR ("ProfileLevel"); const CFStringRef kVTProfileLevel_H264_Baseline_AutoLevel = @@ -648,7 +651,7 @@ gst_vtenc_set_format (GstVideoEncoder * enc, GstVideoCodecState * state) self->session = session; GST_OBJECT_UNLOCK (self); - return TRUE; + return session != NULL; } static gboolean @@ -786,6 +789,8 @@ gst_vtenc_create_session (GstVTEnc * self) VTCompressionSessionRef session = NULL; CFMutableDictionaryRef encoder_spec = NULL, pb_attrs; OSStatus status; + const GstVTEncoderDetails *codec_details = + GST_VTENC_CLASS_GET_CODEC_DETAILS (G_OBJECT_GET_CLASS (self)); #if !HAVE_IOS encoder_spec = @@ -793,6 +798,10 @@ gst_vtenc_create_session (GstVTEnc * self) &kCFTypeDictionaryValueCallBacks); gst_vtutil_dict_set_boolean (encoder_spec, kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder, true); + if (codec_details->require_hardware) + gst_vtutil_dict_set_boolean (encoder_spec, + kVTVideoEncoderSpecification_RequireHardwareAcceleratedVideoEncoder, + TRUE); #endif pb_attrs = CFDictionaryCreateMutable (NULL, 0, &kCFTypeDictionaryKeyCallBacks, @@ -1398,7 +1407,10 @@ gst_vtenc_register (GstPlugin * plugin, } static const GstVTEncoderDetails gst_vtenc_codecs[] = { - {"H.264", "h264", "video/x-h264", kCMVideoCodecType_H264}, + {"H.264", "h264", "video/x-h264", kCMVideoCodecType_H264, FALSE}, +#ifndef HAVE_IOS + {"H.264 (HW only)", "h264_hw", "video/x-h264", kCMVideoCodecType_H264, TRUE}, +#endif }; void |