Beispiel #1
0
        public void ClosedCaption()
        {
            CMFormatDescriptionError fde;

            using (var fd = CMFormatDescription.Create(CMMediaType.ClosedCaption, (uint)CMClosedCaptionFormatType.CEA608, out fde))
            {
                Assert.AreEqual(CMFormatDescriptionError.None, fde, "#1");
                Assert.AreEqual((CMMuxedStreamType)0, fd.MuxedStreamType, "#2");
                Assert.AreEqual(CMMediaType.ClosedCaption, fd.MediaType, "#3");
                Assert.AreEqual(CMClosedCaptionFormatType.CEA608, fd.ClosedCaptionFormatType, "#4");
            }
        }
Beispiel #2
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");
                    }
                }
            }
        }
Beispiel #3
0
        public void Video()
        {
            TestRuntime.AssertSystemVersion(PlatformName.iOS, 7, 0, throwIfOtherPlatform: false);

            CMFormatDescriptionError fde;

            var auth = AVCaptureDevice.GetAuthorizationStatus(AVMediaType.Video);

            switch (auth)
            {
            case AVAuthorizationStatus.Restricted:
            case AVAuthorizationStatus.Denied:
            case AVAuthorizationStatus.NotDetermined:
                // We can't test the below, since the some other tests may have initialized whatever we need for the API to work correctly.
//				Assert.Null (CMFormatDescription.Create (CMMediaType.Video, (uint) CMVideoCodecType.H264, out fde), "null ({0})", auth);
//				Assert.That (fde, Is.EqualTo (CMFormatDescriptionError.InvalidParameter), "CMFormatDescriptionError");
                break;

            case AVAuthorizationStatus.Authorized:
                // We can't test the below, since the some other tests may have initialized whatever we need for the API to work correctly.
//				Assert.Null (CMFormatDescription.Create (CMMediaType.Video, (uint) CMVideoCodecType.H264, out fde), "null (authorized)");
//				Assert.That (fde, Is.EqualTo (CMFormatDescriptionError.InvalidParameter), "CMFormatDescriptionError (authorized)");

                using (var captureSession = new AVCaptureSession()) {
                    using (var videoDevice = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video)) {
                        if (videoDevice == null)
                        {
                            Assert.Inconclusive("Failed to create a video device for testing");
                        }
                        NSError error;
                        using (var videoInput = new AVCaptureDeviceInput(videoDevice, out error)) {
                            // this seems to initialize something.
                        }
                    }
                }

                Assert.IsNotNull(CMFormatDescription.Create(CMMediaType.Video, (uint)CMVideoCodecType.H264, out fde), "not null (authorized)");
                Assert.That(fde, Is.EqualTo(CMFormatDescriptionError.None), "CMFormatDescriptionError #2 (authorized)");
                break;
            }
        }
Beispiel #4
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");
                    }
                }
            }
        }
Beispiel #5
0
        public void Video()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(7, 0))
            {
                Assert.Ignore("This test fails on iOS 6 (even though the API exists).");
            }

            CMFormatDescriptionError fde;

            var auth = AVCaptureDevice.GetAuthorizationStatus(AVMediaType.Video);

            switch (auth)
            {
            case AVAuthorizationStatus.Restricted:
            case AVAuthorizationStatus.Denied:
            case AVAuthorizationStatus.NotDetermined:
                // We can't test the below, since the some other tests may have initialized whatever we need for the API to work correctly.
//				Assert.Null (CMFormatDescription.Create (CMMediaType.Video, (uint) CMVideoCodecType.H264, out fde), "null ({0})", auth);
//				Assert.That (fde, Is.EqualTo (CMFormatDescriptionError.InvalidParameter), "CMFormatDescriptionError");
                break;

            case AVAuthorizationStatus.Authorized:
                // We can't test the below, since the some other tests may have initialized whatever we need for the API to work correctly.
//				Assert.Null (CMFormatDescription.Create (CMMediaType.Video, (uint) CMVideoCodecType.H264, out fde), "null (authorized)");
//				Assert.That (fde, Is.EqualTo (CMFormatDescriptionError.InvalidParameter), "CMFormatDescriptionError (authorized)");

                using (var captureSession = new AVCaptureSession()) {
                    using (var videoDevice = AVCaptureDevice.DefaultDeviceWithMediaType(AVMediaType.Video)) {
                        NSError error;
                        using (var videoInput = new AVCaptureDeviceInput(videoDevice, out error)) {
                            // this seems to initialize something.
                        }
                    }
                }

                Assert.IsNotNull(CMFormatDescription.Create(CMMediaType.Video, (uint)CMVideoCodecType.H264, out fde), "not null (authorized)");
                Assert.That(fde, Is.EqualTo(CMFormatDescriptionError.None), "CMFormatDescriptionError #2 (authorized)");
                break;
            }
        }