Example #1
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));
 }
        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
        }
Example #3
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);
        }
Example #4
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);
		}
Example #5
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;
		}