Exemplo n.º 1
0
        public void H264ParameterSetsTest()
        {
            if (!TestRuntime.CheckXcodeVersion(5, 0, 1))
            {
                Assert.Inconclusive("CMVideoFormatDescription.FromH264ParameterSets is iOS7+ and macOS 10.9+");
            }

            var arr0 = new byte[] { 0x67, 0x64, 0x00, 0x29, 0xAC, 0x56, 0x80, 0x78, 0x02, 0x27, 0xE5, 0x9A, 0x80, 0x80, 0x80, 0x81 };
            var arr1 = new byte[] { 0x28, 0xEE, 0x04, 0xF2, 0xC0 };

            var props = new List <byte[]> {
                arr0, arr1
            };
            CMFormatDescriptionError error;
            var desc = CMVideoFormatDescription.FromH264ParameterSets(props, 4, out error);

            props = null;
            Assert.That(error == CMFormatDescriptionError.None, "H264ParameterSetsTest");
            Assert.NotNull(desc, "H264ParameterSetsTest");
            Assert.That(desc.Dimensions.Height == 1080 && desc.Dimensions.Width == 1920, "H264ParameterSetsTest");

            CMFormatDescriptionError err;
            nuint paramCount;
            int   nalCount;
            var   bytes = desc.GetH264ParameterSet(0, out paramCount, out nalCount, out err);

            Assert.That(err == CMFormatDescriptionError.None, "H264ParameterSetsTest");
            Assert.NotNull(bytes, "H264ParameterSetsTest");
            Assert.True(nalCount == 4 && paramCount == 2);
            Assert.That(arr0, Is.EqualTo(bytes), "H264ParameterSetsTest roundtrip");

            bytes = desc.GetH264ParameterSet(1, out paramCount, out nalCount, out err);
            Assert.That(err == CMFormatDescriptionError.None, "H264ParameterSetsTest");
            Assert.NotNull(bytes, "H264ParameterSetsTest");
            Assert.True(nalCount == 4 && paramCount == 2);
            Assert.That(arr1, Is.EqualTo(bytes), "H264ParameterSetsTest roundtrip");
        }