Пример #1
1
 public CMVideoFormatDescription(CMVideoCodecType codecType, CMVideoDimensions size)
     : base(CreateCMVideoFormatDescription (codecType, size), true)
 {
 }
 static extern /* OSStatus */ CMFormatDescriptionError CMVideoFormatDescriptionCreate(
     /* CFAllocatorRef */ IntPtr allocator,
     CMVideoCodecType codecType,
     /* int32_t */ int width,
     /* int32_t */ int height,
     /* CFDictionaryRef */ IntPtr extensions,
     /* CMVideoFormatDescriptionRef* */ out IntPtr outDesc);
Пример #3
0
		public static VTCompressionSession Create (int width, int height, CMVideoCodecType codecType,
			VTCompressionOutputCallback compressionOutputCallback,
			VTVideoEncoderSpecification encoderSpecification = null, // hardware acceleration is default behavior on iOS. no opt-in required.
			NSDictionary sourceImageBufferAttributes = null)
		{
			return Create (width, height, codecType, compressionOutputCallback, encoderSpecification, sourceImageBufferAttributes, static_newCompressionOutputCallback);
		}
Пример #4
0
        private static void ExploreProperties(AVAsset asset)
        {
            AVMediaSelection[] aVMediaSelections = asset.AllMediaSelections;
            string[]           mDataFormats      = asset.AvailableMetadataFormats;
            string             description       = asset.Description;

            AVAssetTrack[] avAssetVideoTracks = asset.GetTracks(AVMediaTypes.Video);
            foreach (AVAssetTrack avAssetVideoTrack in avAssetVideoTracks)
            {
                string     cDescription = avAssetVideoTrack.Description;
                string     dDescription = avAssetVideoTrack.DebugDescription;
                NSObject[] nsObjects    = avAssetVideoTrack.FormatDescriptionsAsObjects;
                string     descr        = nsObjects[0].Description;
                //NSObject nsoDimension = avAssetVideoTrack.ValueForKey(new NSString("dimension"));
                AVMetadataItem[]      avCommonMetadataItems = avAssetVideoTrack.CommonMetadata;
                AVMetadataItem[]      avMetadataItems       = avAssetVideoTrack.Metadata;
                CMFormatDescription[] cmFormatDescriptions  = avAssetVideoTrack.FormatDescriptions;
                foreach (CMFormatDescription cmFormatDescription in cmFormatDescriptions)
                {
                    CMVideoCodecType           cmVideoCodecType     = cmFormatDescription.VideoCodecType;
                    CMSubtitleFormatType       cmSubtitleFormatType = cmFormatDescription.SubtitleFormatType;
                    CMMetadataFormatType       cmMetadataFormatType = cmFormatDescription.MetadataFormatType;
                    AudioToolbox.AudioFormat[] atAudioFormats       = cmFormatDescription.AudioFormats;
                }
            }
        }
 public void TestRegisterSupplementalVideoDecoder(CMVideoCodecType codec)
 {
     TestRuntime.AssertXcodeVersion(12, TestRuntime.MinorXcode12APIMismatch);
     // ensure that the call does not crash, we do not have anyother thing to test since there is
     // no way to know if it was a success
     VTUtilities.RegisterSupplementalVideoDecoder(codec);
 }
Пример #6
0
 public static VTCompressionSession Create(int width, int height, CMVideoCodecType codecType,
                                           VTVideoEncoderSpecification encoderSpecification = null,
                                           NSDictionary sourceImageBufferAttributes         = null)
 {
     return(Create(width, height, codecType, null,
                   encoderSpecification, sourceImageBufferAttributes));
 }
Пример #7
0
 public static VTCompressionSession Create(int width, int height, CMVideoCodecType codecType,
                                           VTCompressionOutputCallback compressionOutputCallback,
                                           VTVideoEncoderSpecification encoderSpecification, // hardware acceleration is default behavior on iOS. no opt-in required.
                                           CVPixelBufferAttributes sourceImageBufferAttributes)
 {
     return(Create(width, height, codecType, compressionOutputCallback, encoderSpecification, sourceImageBufferAttributes == null ? null : sourceImageBufferAttributes.Dictionary, static_CompressionOutputCallback));
 }
Пример #8
0
 static extern /* OSStatus */ VTStatus VTCopySupportedPropertyDictionaryForEncoder(
     /* int32_t */ int width,
     /* int32_t */ int height,
     /* CMVideoCodecType */ CMVideoCodecType codecType,
     /* CFDictionaryRef */ IntPtr encoderSpecification,
     /* CFStringRef */ out IntPtr outEncoderId,
     /* CFDictionaryRef */ out IntPtr outSupportedProperties
     );
 unsafe extern static VTStatus VTCompressionSessionCreate(
     /* CFAllocatorRef */ IntPtr allocator,             /* can be null */
     /* int32_t */ int width,
     /* int32_t */ int height,
     /* CMVideoCodecType */ CMVideoCodecType codecType,
     /* CFDictionaryRef */ IntPtr dictionaryEncoderSpecification,        /* can be null */
     /* CFDictionaryRef */ IntPtr dictionarySourceImageBufferAttributes, /* can be null */
     /* CFDictionaryRef */ IntPtr compressedDataAllocator,               /* can be null */
        public CMVideoFormatDescription(CMVideoCodecType codecType, Size size)
            : base(IntPtr.Zero)
        {
            var error = CMVideoFormatDescriptionCreate(IntPtr.Zero, codecType, size.Width, size.Height, IntPtr.Zero, out handle);

            if (error != CMFormatDescriptionError.None)
            {
                throw new ArgumentException(error.ToString());
            }
        }
Пример #11
0
 extern static VTStatus VTCompressionSessionCreate(
     /* CFAllocatorRef */ IntPtr allocator,             /* can be null */
     /* int32_t */ int width,
     /* int32_t */ int height,
     /* CMVideoCodecType */ CMVideoCodecType codecType,
     /* CFDictionaryRef */ IntPtr dictionaryEncoderSpecification,        /* can be null */
     /* CFDictionaryRef */ IntPtr dictionarySourceImageBufferAttributes, /* can be null */
     /* CFDictionaryRef */ IntPtr compressedDataAllocator,               /* can be null */
     /* VTCompressionOutputCallback */ CompressionOutputCallback outputCallback,
     /* void* */ IntPtr outputCallbackClosure,
     /* VTCompressionSessionRef* */ out IntPtr compressionSessionOut);
        static IntPtr CreateCMVideoFormatDescription(CMVideoCodecType codecType, CMVideoDimensions size)
        {
            IntPtr handle;
            var    error = CMVideoFormatDescriptionCreate(IntPtr.Zero, codecType, size.Width, size.Height, IntPtr.Zero, out handle);

            if (error != CMFormatDescriptionError.None)
            {
                throw new ArgumentException(error.ToString());
            }
            return(handle);
        }
        public static VTCompressionSession?Create(int width, int height, CMVideoCodecType codecType,
                                                  VTCompressionOutputCallback compressionOutputCallback,
                                                  VTVideoEncoderSpecification?encoderSpecification = null, // hardware acceleration is default behavior on iOS. no opt-in required.
                                                  NSDictionary?sourceImageBufferAttributes         = null)
        {
#if NET
            unsafe {
                return(Create(width, height, codecType, compressionOutputCallback, encoderSpecification, sourceImageBufferAttributes, &NewCompressionCallback));
            }
#else
            return(Create(width, height, codecType, compressionOutputCallback, encoderSpecification, sourceImageBufferAttributes, static_newCompressionOutputCallback));
#endif
        }
Пример #14
0
        static VTCompressionSession Create(int width, int height, CMVideoCodecType codecType,
                                           VTCompressionOutputCallback compressionOutputCallback,
                                           VTVideoEncoderSpecification encoderSpecification,                                // hardware acceleration is default behavior on iOS. no opt-in required.
                                           NSDictionary sourceImageBufferAttributes, CompressionOutputCallback staticCback) // Undocumented options, probably always null
        {
            var callbackHandle = default(GCHandle);

            if (compressionOutputCallback != null)
            {
                callbackHandle = GCHandle.Alloc(compressionOutputCallback);
            }

            IntPtr ret;

            var result = VTCompressionSessionCreate(IntPtr.Zero, width, height, codecType,
                                                    encoderSpecification != null ? encoderSpecification.Dictionary.Handle : IntPtr.Zero,
                                                    sourceImageBufferAttributes != null ? sourceImageBufferAttributes.Handle : IntPtr.Zero,
                                                    IntPtr.Zero,
                                                    callbackHandle.IsAllocated ? (staticCback) : null,
                                                    GCHandle.ToIntPtr(callbackHandle),
                                                    out ret);

            if (result == VTStatus.Ok && ret != IntPtr.Zero)
            {
                return new VTCompressionSession(ret, true)
                       {
                           callbackHandle = callbackHandle
                       }
            }
            ;

            if (callbackHandle.IsAllocated)
            {
                callbackHandle.Free();
            }

            return(null);
        }
Пример #15
0
 public CMVideoFormatDescription(CMVideoCodecType codecType, Size size)
     : base(IntPtr.Zero)
 {
     var error = CMVideoFormatDescriptionCreate (IntPtr.Zero, codecType, size.Width, size.Height, IntPtr.Zero, out handle);
     if (error != CMFormatDescriptionError.None)
         throw new ArgumentException (error.ToString ());
 }
Пример #16
0
		extern static VTStatus VTCompressionSessionCreate (
			/* CFAllocatorRef */ IntPtr allocator, /* can be null */
			/* int32_t */ int width,
			/* int32_t */ int height,
			/* CMVideoCodecType */ CMVideoCodecType codecType,
			/* CFDictionaryRef */ IntPtr dictionaryEncoderSpecification, /* can be null */
			/* CFDictionaryRef */ IntPtr dictionarySourceImageBufferAttributes, /* can be null */
			/* CFDictionaryRef */ IntPtr compressedDataAllocator, /* can be null */
			/* VTCompressionOutputCallback */ CompressionOutputCallback outputCallback,
			/* void* */ IntPtr outputCallbackClosure,
			/* VTCompressionSessionRef* */ out IntPtr compressionSessionOut);
Пример #17
0
		static VTCompressionSession Create (int width, int height, CMVideoCodecType codecType,
			VTCompressionOutputCallback compressionOutputCallback,
			VTVideoEncoderSpecification encoderSpecification, // hardware acceleration is default behavior on iOS. no opt-in required.
		        NSDictionary sourceImageBufferAttributes, CompressionOutputCallback staticCback) // Undocumented options, probably always null
		{
			var callbackHandle = default (GCHandle);
			if (compressionOutputCallback != null)
				callbackHandle = GCHandle.Alloc (compressionOutputCallback);

			IntPtr ret;

			var result = VTCompressionSessionCreate (IntPtr.Zero, width, height, codecType,
				encoderSpecification != null ? encoderSpecification.Dictionary.Handle : IntPtr.Zero,
				sourceImageBufferAttributes != null ? sourceImageBufferAttributes.Handle : IntPtr.Zero,
				IntPtr.Zero,
				callbackHandle.IsAllocated ? (staticCback) : null,
				GCHandle.ToIntPtr (callbackHandle),
	            out ret);

			if (result == VTStatus.Ok && ret != IntPtr.Zero)
				return new VTCompressionSession (ret, true) {
					callbackHandle = callbackHandle
				};

			if (callbackHandle.IsAllocated)
				callbackHandle.Free ();

			return null;
		}
Пример #18
0
		public static VTCompressionSession Create (int width, int height, CMVideoCodecType codecType,
			VTVideoEncoderSpecification encoderSpecification = null,
			NSDictionary sourceImageBufferAttributes = null)
		{
			return Create (width, height, codecType, null,
				encoderSpecification, sourceImageBufferAttributes);
		}
Пример #19
0
 public static void RegisterSupplementalVideoDecoder(CMVideoCodecType codecType)
 => VTRegisterSupplementalVideoDecoderIfAvailable((uint)codecType);
Пример #20
0
        public static VTSupportedEncoderProperties GetSupportedEncoderProperties(int width, int height, CMVideoCodecType codecType, NSDictionary encoderSpecification = null)
        {
            IntPtr encoderIdPtr           = IntPtr.Zero;
            IntPtr supportedPropertiesPtr = IntPtr.Zero;
            var    result = VTCopySupportedPropertyDictionaryForEncoder(width, height, codecType, encoderSpecification == null ? IntPtr.Zero : encoderSpecification.Handle, out encoderIdPtr, out supportedPropertiesPtr);

            if (result != VTStatus.Ok)
            {
                if (encoderIdPtr != IntPtr.Zero)
                {
                    CFObject.CFRelease(encoderIdPtr);
                }
                if (supportedPropertiesPtr != IntPtr.Zero)
                {
                    CFObject.CFRelease(supportedPropertiesPtr);
                }

                return(null);
            }

            // The caller must CFRelease the returned supported properties and encoder ID.
            var ret = new VTSupportedEncoderProperties {
                EncoderId           = CFString.FromHandle(encoderIdPtr, releaseHandle: true),
                SupportedProperties = Runtime.GetNSObject <NSDictionary> (supportedPropertiesPtr, owns: true)
            };

            return(ret);
        }
 public static bool IsHardwareDecodeSupported(CMVideoCodecType codecType)
 {
     return(VTIsHardwareDecodeSupported(codecType));
 }
 extern static bool VTIsHardwareDecodeSupported(CMVideoCodecType codecType);
 static extern CMFormatDescriptionError CMVideoFormatDescriptionCreate(IntPtr allocator,
                                                                       CMVideoCodecType codecType,
                                                                       int width, int height,
                                                                       IntPtr extensions,
                                                                       out IntPtr outDesc);
Пример #24
0
 static IntPtr CreateCMVideoFormatDescription(CMVideoCodecType codecType, CMVideoDimensions size)
 {
     IntPtr handle;
     var error = CMVideoFormatDescriptionCreate (IntPtr.Zero, codecType, size.Width, size.Height, IntPtr.Zero, out handle);
     if (error != CMFormatDescriptionError.None)
         throw new ArgumentException (error.ToString ());
     return handle;
 }
Пример #25
0
        static extern CMFormatDescriptionError CMVideoFormatDescriptionCreate(IntPtr allocator,
			CMVideoCodecType codecType,
			int width, int height,
			IntPtr extensions,
			out IntPtr outDesc);
 public CMVideoFormatDescription(CMVideoCodecType codecType, CMVideoDimensions size)
     : base(CreateCMVideoFormatDescription(codecType, size), true)
 {
 }
Пример #27
0
 static extern CMFormatDescriptionError CMVideoFormatDescriptionCreate(
     /* CFAllocatorRef */ IntPtr allocator,
     CMVideoCodecType codecType,
     /* int32_t */ int width,
     /* int32_t */ int height,
     /* CFDictionaryRef */ IntPtr extensions,
     /* CMVideoFormatDescriptionRef* */ out IntPtr outDesc);