diff --git a/sys/applemedia/vtenc.c b/sys/applemedia/vtenc.c index 5c0c6ca625..39b7813bea 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 diff --git a/sys/applemedia/vtenc.h b/sys/applemedia/vtenc.h index 3bbe3c69fe..4c6100016f 100644 --- a/sys/applemedia/vtenc.h +++ b/sys/applemedia/vtenc.h @@ -44,6 +44,7 @@ struct _GstVTEncoderDetails const gchar * element_name; const gchar * mimetype; CMVideoCodecType format_id; + gboolean require_hardware; }; struct _GstVTEncClass