Exemplo n.º 1
0
        public void CreateEmpty()
        {
            CMBlockBufferError err;

            using (var bb = CMBlockBuffer.CreateEmpty(16, CMBlockBufferFlags.AssureMemoryNow, out err)) {
                Assert.That(err, Is.EqualTo(CMBlockBufferError.None), "error");
                Assert.That(bb.DataLength, Is.EqualTo((nuint)0), "DataLength");
            }
        }
Exemplo n.º 2
0
        public void CreateReady()
        {
            TestRuntime.AssertSystemVersion(PlatformName.iOS, 8, 0, throwIfOtherPlatform: false);
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 10, throwIfOtherPlatform: false);

            CMBlockBufferError bbe;

            using (var bb = CMBlockBuffer.CreateEmpty(0, CMBlockBufferFlags.AlwaysCopyData, out bbe)) {
                CMSampleBufferError sbe;
                using (var sb = CMSampleBuffer.CreateReady(bb, null, 0, null, null, out sbe)) {
                    Assert.That(sb.Handle, Is.Not.EqualTo(IntPtr.Zero), "CMSampleBuffer");
                    Assert.That(sbe, Is.EqualTo(CMSampleBufferError.None), "CMSampleBufferError");
                }
            }
        }
Exemplo n.º 3
0
        public void CreateReady()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(8, 0))
            {
                Assert.Inconclusive("Requires iOS8");
            }

            CMBlockBufferError bbe;

            using (var bb = CMBlockBuffer.CreateEmpty(0, CMBlockBufferFlags.AlwaysCopyData, out bbe)) {
                CMSampleBufferError sbe;
                using (var sb = CMSampleBuffer.CreateReady(bb, null, 0, null, null, out sbe)) {
                    Assert.That(sb.Handle, Is.Not.EqualTo(IntPtr.Zero), "CMSampleBuffer");
                    Assert.That(sbe, Is.EqualTo(CMSampleBufferError.None), "CMSampleBufferError");
                }
            }
        }
Exemplo n.º 4
0
        protected ICMAttachmentBearer GetInstance(Type t)
        {
            if (!CMAttachmentInterfaceType.IsAssignableFrom(t))
            {
                throw new ArgumentException("t");
            }
            switch (t.Name)
            {
            case "CMBlockBuffer":
                CMBlockBufferError bbe;
                var result = CMBlockBuffer.CreateEmpty(0, CMBlockBufferFlags.AssureMemoryNow, out bbe);
                if (bbe == CMBlockBufferError.None)
                {
                    return(result);
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Could not create the new instance {0}.", bbe.ToString()));
                }

            case "CMSampleBuffer":
                var pixelBuffer = new CVPixelBuffer(20, 10, CVPixelFormatType.CV24RGB);

                CMFormatDescriptionError fde;
                var desc = CMVideoFormatDescription.CreateForImageBuffer(pixelBuffer, out fde);

                var sampleTiming = new CMSampleTimingInfo();

                CMSampleBufferError sbe;
                var sb = CMSampleBuffer.CreateForImageBuffer(pixelBuffer, true, desc, sampleTiming, out sbe);
                if (sbe == CMSampleBufferError.None)
                {
                    return(sb);
                }
                else
                {
                    throw new InvalidOperationException(string.Format("Could not create the new instance {0}.", sbe.ToString()));
                }

            default:
                throw new InvalidOperationException(string.Format("Could not create the new instance for type {0}.", t.Name));
            }
        }
Exemplo n.º 5
0
        public void CreateReadyWithPacketDescriptions()
        {
            TestRuntime.AssertSystemVersion(PlatformName.iOS, 8, 0, throwIfOtherPlatform: false);
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 10, throwIfOtherPlatform: false);

            CMBlockBufferError bbe;

            using (var bb = CMBlockBuffer.CreateEmpty(0, CMBlockBufferFlags.AlwaysCopyData, out bbe)) {
                CMFormatDescriptionError fde;
                using (var fd = CMFormatDescription.Create(CMMediaType.ClosedCaption, (uint)CMClosedCaptionFormatType.CEA608, out fde)) {
                    CMSampleBufferError sbe;
                    using (var sb = CMSampleBuffer.CreateReadyWithPacketDescriptions(bb, fd, 1, CMTime.Indefinite, null, out sbe)) {
                        Assert.Null(sb, "CMSampleBuffer");
                        // the `null` does not match format description (but I lack a better test, at least it's callable)
                        Assert.That(sbe, Is.EqualTo(CMSampleBufferError.RequiredParameterMissing), "CMSampleBufferError");
                    }
                }
            }
        }
Exemplo n.º 6
0
        public void CreateReadyWithPacketDescriptions()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(8, 0))
            {
                Assert.Inconclusive("Requires iOS8");
            }

            CMBlockBufferError bbe;

            using (var bb = CMBlockBuffer.CreateEmpty(0, CMBlockBufferFlags.AlwaysCopyData, out bbe)) {
                CMFormatDescriptionError fde;
                using (var fd = CMFormatDescription.Create(CMMediaType.ClosedCaption, (uint)CMClosedCaptionFormatType.CEA608, out fde)) {
                    CMSampleBufferError sbe;
                    using (var sb = CMSampleBuffer.CreateReadyWithPacketDescriptions(bb, fd, 1, CMTime.Indefinite, null, out sbe)) {
                        Assert.Null(sb, "CMSampleBuffer");
                        // the `null` does not match format description (but I lack a better test, at least it's callable)
                        Assert.That(sbe, Is.EqualTo(CMSampleBufferError.RequiredParameterMissing), "CMSampleBufferError");
                    }
                }
            }
        }