Ejemplo n.º 1
0
        public void moov_trak_mdia_mdhd_test()
        {
            MediaHeaderBox mediaHeaderBox = new MediaHeaderBox(0, 0);

            mediaHeaderBox.CreationTime     = 0;
            mediaHeaderBox.ModificationTime = 0;
            mediaHeaderBox.Timescale        = 0x00124f80;
            mediaHeaderBox.Duration         = 0;
            mediaHeaderBox.Language         = "und";
            FMp4MessagePackWriter writer = new MessagePack.FMp4MessagePackWriter(new byte[10240]);

            mediaHeaderBox.ToBuffer(ref writer);
            var hex = writer.FlushAndGetArray().ToHexString();

            //000000206d64686400000000000000000000000000124f800000000055c40000
            //00000020
            //6d646864
            //00000000
            //00000000
            //00000000
            //00124f80
            //00000000
            //55c4
            //0000
            Assert.Equal("000000206d64686400000000000000000000000000124f800000000055c40000".ToUpper(), hex);
        }
Ejemplo n.º 2
0
        public void Test1()
        {
            //00 00 00 20--box size 32
            //6d 64 68 64--box type mdhd
            //00--version
            //00 00 00--flags
            //d9 3e 0b 8e--creation_time
            //d9 3e 0b 8e--modification_time
            //00 00 bb 80--timescale
            //00 05 28 00--duration
            //55 c4--(pad(1) + language(15))
            //00 00--pre_defined
            MediaHeaderBox movieHeaderBox = new MediaHeaderBox(version: 0);

            movieHeaderBox.CreationTime     = 0xd93e0b8e;
            movieHeaderBox.ModificationTime = 0xd93e0b8e;
            movieHeaderBox.Timescale        = 0x0000bb80;
            movieHeaderBox.Duration         = 0x00052800;
            FMp4MessagePackWriter writer = new MessagePack.FMp4MessagePackWriter(new byte[0x6c]);

            movieHeaderBox.ToBuffer(ref writer);
            var hex = writer.FlushAndGetArray().ToHexString();

            Assert.Equal("000000206d64686400000000d93e0b8ed93e0b8e0000bb800005280055c40000".ToUpper(), hex);
        }
Ejemplo n.º 3
0
        public void CanRoundtrip()
        {
            var box = new MediaHeaderBox
            {
                CreationTime     = new DateTime(2015, 10, 01, 12, 45, 13, DateTimeKind.Utc),
                ModificationTime = new DateTime(2018, 01, 18, 12, 5, 0, DateTimeKind.Utc),
                TimeScale        = 48000,
                Duration         = 34560,
                Language         = "und"
            };

            var deserialized = (MediaHeaderBox)TestHelper.Decode(TestHelper.Encode(box));

            Assert.Equal(box.CreationTime, deserialized.CreationTime);
            Assert.Equal(box.ModificationTime, deserialized.ModificationTime);

            Assert.Equal(box.TimeScale, deserialized.TimeScale);
            Assert.Equal(box.Duration, deserialized.Duration);
            Assert.Equal(box.Language, deserialized.Language);
        }