Beispiel #1
0
 public static Mp4Box CreateMp4Box(byte[] buffer, int offset)
 {
     if ((buffer != null) &&
         (offset + 8 < buffer.Length))
     {
         Mp4Box box = new Mp4Box();
         if (box != null)
         {
             box.Length = ReadMp4BoxLength(buffer, offset);
             if ((offset + box.Length <= buffer.Length) && (box.Length > 8))
             {
                 box.Type = ReadMp4BoxType(buffer, offset);
                 box.Data = ReadMp4BoxData(buffer, offset, box.Length);
                 List <Mp4Box> list = box.GetChildren();
                 if ((list != null) && (list.Count > 0))
                 {
                     foreach (var b in list)
                     {
                         box.AddMp4Box(box);
                     }
                 }
                 return(box);
             }
         }
     }
     return(null);
 }
Beispiel #2
0
        public static string GetBoxChildrenString(int level, Mp4Box box)
        {
            string result     = string.Empty;
            int    locallevel = level + 1;

            if (box != null)
            {
                List <Mp4Box> list = box.GetChildren();
                if ((list != null) && (list.Count > 0))
                {
                    foreach (var m in list)
                    {
                        string prefix = string.Empty;
                        for (int i = 0; i < locallevel; i++)
                        {
                            prefix += "\t\t";
                        }
                        result += prefix + m.ToString() + "\r\n";
                        result += GetBoxChildrenString(locallevel, m);
                    }
                }
            }
            return(result);
        }