public override void Read(BoxReader reader)
        {
            using (new SizeChecker(this, reader)) {
            base.Read(reader);
            EntryCount = reader.ReadUInt32();
            Entries = new SampleEntry[EntryCount];
            for (int i=0; i<EntryCount; i++) {
              string FormatType = parent.parent.parent.HandlerReferenceBox.HandlerType;

              long pos = reader.BaseStream.Position;
              Box test = new Box(BoxTypes.Any);
              test.Read(reader);
              reader.BaseStream.Position = pos;

              switch (FormatType) {
            case "soun":
              AudioSampleEntry ase = new AudioSampleEntry(test.Type);
              ase.Read(reader);
              Entries[i] = ase;
              break;
            case "vide":
              VisualSampleEntry vse = new VisualSampleEntry(test.Type); // usually 'mp4v'
              vse.Read(reader);
              Entries[i] = vse;
              break;
            case "hint":
              HintSampleEntry hse = new HintSampleEntry(test.Type);
              hse.Read(reader);
              Entries[i] = hse;
              break;
            case "meta":
              switch (test.Type.ToString()) {
                case "metx":
                  XMLMetaDataSampleEntry xse = new XMLMetaDataSampleEntry();
                  xse.Read(reader);
                  Entries[i] = xse;
                  break;
                case "mett":
                  TextMetaDataSampleEntry tds = new TextMetaDataSampleEntry();
                  tds.Read(reader);
                  Entries[i] = tds;
                  break;
                default:
                  throw new Exception("Invalid Metadata Sample Entry in track");
              }
              break;
            //case "avcC":
            //    break;
            case "sdsm": // Apple MPEG-4 Scene Media Handler
              UnknownEntry ue = new UnknownEntry(test.Type);
              ue.Read(reader);
              Entries[i] = ue;
              break;
            case "odsm": // Apple MPEG-4 ODSM Media Handler
              UnknownEntry ue2 = new UnknownEntry(test.Type);
              ue2.Read(reader);
              Entries[i] = ue2;
              break;
            case "alis": // Apple iPhone
              UnknownEntry ue3 = new UnknownEntry(test.Type);
              ue3.Read(reader);
              Entries[i] = ue3;
              break;
            default:
              UnknownEntry ue4 = new UnknownEntry(test.Type);
              ue4.Read(reader);
              Entries[i] = ue4;
              break;
              }
            }
              }
        }
 public SampleDescriptionsBox(SampleTableBox inParent, IsochronousTrackInfo trackInfo)
     : this(inParent)
 {
     EntryCount = 1; // FIXME: assume only one sample entry
       Entries = new SampleEntry[EntryCount];
       this.Size += 4UL;
       BoxType btype;
       if (trackInfo is RawAudioTrackInfo)
       {
     RawAudioTrackInfo rati = (RawAudioTrackInfo)trackInfo;
     switch (rati.PayloadType)
     {
       case AudioPayloadType.aac:
       case AudioPayloadType.mp4a:
     btype = BoxTypes.Mp4a;
     break;
       case AudioPayloadType.wma:
     btype = BoxTypes.Wma;
     break;
       case AudioPayloadType.samr: // 3gp audio
     btype = BoxTypes.Samr;
     break;
       default:
     throw new Exception(string.Format("Unknown audio track payload type: {0}", rati.PayloadType));
     }
     //btype = (rati.PayloadType == AudioPayloadType.wma) ? BoxTypes.Wma : ((rati.PayloadType == AudioPayloadType.mp4a) ? BoxTypes.Mp4a : BoxTypes.AudioSampleEntry);
     Entries[0] = new AudioSampleEntry(btype, (RawAudioTrackInfo)trackInfo);
     this.Size += Entries[0].Size;
       }
       else if (trackInfo is RawVideoTrackInfo)
       {
     RawVideoTrackInfo rvti = (RawVideoTrackInfo)trackInfo;
     switch (rvti.PayloadType)
     {
       case VideoPayloadType.vc1:
     btype = BoxTypes.Vc1;
     break;
       case VideoPayloadType.mp4v:
     btype = BoxTypes.Mp4v;
     break;
       case VideoPayloadType.mjpeg:
     btype = BoxTypes.VisualSampleEntry; // FIXME: this is not correct
     break;
       case VideoPayloadType.jpeg:
     btype = BoxTypes.VisualSampleEntry; // FIXME: this is not correct
     break;
       case VideoPayloadType.avc1:
     btype = BoxTypes.Avc1;
     break;
       default:
     btype = BoxTypes.Any;
     break;
     }
     Entries[0] = new VisualSampleEntry(btype, (RawVideoTrackInfo)trackInfo);
     this.Size += Entries[0].Size;
       }
       else //Entries[0] = new UnknownEntry(BoxTypes.UnknownSampleEntry);
     throw new Exception("unknown track type"); // error out instead of constructing an unknwon entry
 }