Example #1
0
        public void MethodsTest()
        {
            CMTime v, w, x, y;

            v = new CMTime(1, 2);
            w = new CMTime(1, 2);
            x = new CMTime(2, 1);
            y = new CMTime(2, 2);

            // equality operators
            Assert.That(v == w, "Equality #1");
            Assert.That(!(v == x), "Equality #2");
            Assert.That(v != x, "Inequality #1");
            Assert.That(!(v != w), "Inequality #2");
            Assert.That(CMTime.Compare(v, w), Is.EqualTo(0), "Compare #1");
            Assert.That(CMTime.Compare(v, x) != 0, "Compare #2");
            Assert.That(v.Equals(w), "Equals #1");
            Assert.That(!x.Equals(v), "Equals #2");

            // addition operator
            Assert.That(v + w == new CMTime(2, 2), "Addition #1");
            Assert.That(CMTime.Add(v, w) == new CMTime(2, 2), "Addition #2");

            // subtraction operator
            Assert.That(v - w == new CMTime(0, 2), "Subtraction #1");
            Assert.That(CMTime.Subtract(v, w) == new CMTime(0, 2), "Subtraction #2");

            // multiplication operators
            Assert.That(v * 2 == new CMTime(2, 2), "Multiplication * int, #1");
            Assert.That(CMTime.Multiply(v, 3) == new CMTime(3, 2), "Multiplication * int, #2");
            Assert.That(v * 4.0 == new CMTime(4, 2), "Multiplication * double, #1");
            Assert.That(CMTime.Multiply(v, 5.0) == new CMTime(5, 2), "Multiplication * double, #2");

            // ConvertScale
            Assert.That(new CMTime(10, 2).ConvertScale(1, CMTimeRoundingMethod.Default) == new CMTime(5, 1), "ConvertScale #1");

            // FromSeconds
            Assert.That(CMTime.FromSeconds(20, 1) == new CMTime(20, 1), "FromSeconds #1");

            // GetMaximum
            Assert.That(CMTime.GetMaximum(v, y) == y, "GetMaximum #1");

            // GetMinimum
            Assert.That(CMTime.GetMinimum(v, y) == v, "GetMinimum #1");

#if XAMCORE_2_0
            using (var d = x.ToDictionary()) {
                Assert.That(d.RetainCount, Is.EqualTo((nint)1), "RetainCount");
                Assert.That(d.Count, Is.EqualTo((nuint)4), "Count");

                var time = CMTime.FromDictionary(d);
                Assert.That(time, Is.EqualTo(x), "FromDictionary");
            }
#endif
        }
        private void ProcessComposition(AVMutableComposition composition)
        {
            var tracks = new List <List <APLCompositionTrackSegmentInfo> > ();

            foreach (AVCompositionTrack track in composition.Tracks)
            {
                var segmentInfos = new List <APLCompositionTrackSegmentInfo> ();
                foreach (AVCompositionTrackSegment segment in track.Segments)
                {
                    var segmentInfo = new APLCompositionTrackSegmentInfo(segment, track.MediaType);
                    segmentInfos.Add(segmentInfo);
                }

                tracks.Add(segmentInfos);
            }

            compositionTracks = tracks;
            duration          = CMTime.GetMaximum(duration, composition.Duration);
        }