Beispiel #1
0
        public Mp4Track(Mp4TrakBox box, Mp4Stream stream, uint movieTimeScale)
        {
            this.TrakBox = box;
            Mp4HdlrBox box2 = box.FindChild <Mp4HdlrBox>("mdia/hdlr");

            if (box2 != null)
            {
                uint handlerType = box2.HandlerType;
                if (handlerType == Mp4HandlerType.SOUN)
                {
                    this.Type = Mp4TrackType.AUDIO;
                }
                else if (handlerType == Mp4HandlerType.VIDE)
                {
                    this.Type = Mp4TrackType.VIDEO;
                }
                else if (handlerType == Mp4HandlerType.HINT)
                {
                    this.Type = Mp4TrackType.HINT;
                }
                else if ((handlerType == Mp4HandlerType.ODSM) || (handlerType == Mp4HandlerType.SDSM))
                {
                    this.Type = Mp4TrackType.SYSTEM;
                }
                else if ((handlerType == Mp4HandlerType.TEXT) || (handlerType == Mp4HandlerType.TX3G))
                {
                    this.Type = Mp4TrackType.TEXT;
                }
                else if (handlerType == Mp4HandlerType.JPEG)
                {
                    this.Type = Mp4TrackType.JPEG;
                }
            }
            Mp4ContainerBox stbl = box.FindChild <Mp4ContainerBox>("mdia/minf/stbl");

            if (stbl != null)
            {
                this.SampleTable = new Mp4BoxSampleTable(stbl, stream);
            }
        }
Beispiel #2
0
        public Mp4TrakBox(Mp4SampleTable sampleTable, uint hdlrType, string hdlrName, uint trackId, DateTime creationTime, DateTime modificationTime, ulong trackDuration, uint mediaTimeScale, ulong mediaDuration, ushort volume, string language, uint width, uint height) : base(8, Mp4BoxType.TRAK)
        {
            Mp4Box box4;

            this.TkhdBox = new Mp4TkhdBox(creationTime, modificationTime, trackId, trackDuration, volume, width, height);
            Mp4MdiaBox      child = new Mp4MdiaBox();
            Mp4HdlrBox      box2  = new Mp4HdlrBox(hdlrType, hdlrName);
            Mp4ContainerBox box3  = new Mp4ContainerBox(8, Mp4BoxType.MINF);

            if (hdlrType == Mp4HandlerType.VIDE)
            {
                box4 = new Mp4VmhdBox(0, 0, 0, 0);
            }
            else if (hdlrType == Mp4HandlerType.SOUN)
            {
                box4 = new Mp4SmhdBox(0);
            }
            else
            {
                box4 = new Mp4NmhdBox();
            }
            Mp4ContainerBox box5 = new Mp4ContainerBox(8, Mp4BoxType.DINF);
            Mp4Box          box6 = new Mp4UrlBox();
            Mp4DrefBox      box7 = new Mp4DrefBox(new Mp4Box[] { box6 });
            Mp4ContainerBox box8 = sampleTable?.GenerateStblAtom();

            box5.AddChild(box7);
            box3.AddChild(box4);
            box3.AddChild(box5);
            if (box8 != null)
            {
                box3.AddChild(box8);
            }
            this.MdhdBox = new Mp4MdhdBox(creationTime, modificationTime, mediaTimeScale, mediaDuration, language);
            child.AddChild(this.MdhdBox);
            child.AddChild(box2);
            child.AddChild(box3);
            base.AddChild(this.TkhdBox);
            base.AddChild(child);
        }