Пример #1
0
 /// <summary>
 /// CreateNewChunkGroup
 /// There is no rule about how many chunks there can be in  chunk group. A chunk group may contain ALL chunks
 /// in a media file. There's a tradeoff between the resulting size of this SampleToChunkBox, and the size of
 /// ChunkOffsetBox. Reducing the size of this SampleToChunkBox (by having less chunk groups) must necessarily
 /// increase the size of ChunkOffsetBox. In the degenerate case in which there is one slice in every chunk, all
 /// chunks maybe put in a single chunk group, but there would be an entry in the ChunkOffsetBox for every slice.
 /// In the other extreme case in which all slices are in one single chunk, there would also be only one chunk group
 /// and there would also be only one entry in the ChunkOffsetBox.
 ///
 /// Every chunk group entry created is written out to the ChunkGroupStream. See the Write method also.
 /// </summary>
 /// <param name="sampleCount"></param>
 void CreateNewChunkGroup(uint sampleCount)
 {
     if (ChunkGroupWriter == null)
     {
         ChunkGroupFileName = Path.GetTempFileName();
         ChunkGroupStream   = File.Create(ChunkGroupFileName);
         ChunkGroupWriter   = new BinaryWriter(ChunkGroupStream);
     }
     chunk                        = new ChunkEntry();
     chunk.firstChunk             = parent.ChunkOffSetBox.EntryCount + 1; // the ChunkOffsetBox is also being built on the fly
     chunk.sampleDescriptionIndex = 1;                                    // FIXME: this assumes that for every track there's only one sample description
     chunk.samplesPerChunk        = sampleCount;                          // in this chunk group, every chunk has this many slices
     ChunkGroupWriter.Write(chunk.firstChunk);
     ChunkGroupWriter.Write(chunk.samplesPerChunk);
     ChunkGroupWriter.Write(chunk.sampleDescriptionIndex);
     EntryCount++;
 }
Пример #2
0
        public override void Read(BoxReader reader)
        {
            using (new SizeChecker(this, reader)) {
                base.Read(reader);

                EntryCount   = reader.ReadUInt32();
                ChunkEntries = new ChunkEntry[EntryCount];

                for (int i = 0; i < EntryCount; i++)
                {
                    ChunkEntries[i]                        = new ChunkEntry();
                    ChunkEntries[i].firstChunk             = reader.ReadUInt32();
                    ChunkEntries[i].samplesPerChunk        = reader.ReadUInt32();
                    ChunkEntries[i].sampleDescriptionIndex = reader.ReadUInt32();
                }
            }
            if (parent.ChunkOffSetBox != null)
            {
                TotalChunks = parent.ChunkOffSetBox.EntryCount;
            }
        }
Пример #3
0
 /// <summary>
 /// CreateNewChunkGroup
 /// There is no rule about how many chunks there can be in  chunk group. A chunk group may contain ALL chunks 
 /// in a media file. There's a tradeoff between the resulting size of this SampleToChunkBox, and the size of
 /// ChunkOffsetBox. Reducing the size of this SampleToChunkBox (by having less chunk groups) must necessarily 
 /// increase the size of ChunkOffsetBox. In the degenerate case in which there is one slice in every chunk, all
 /// chunks maybe put in a single chunk group, but there would be an entry in the ChunkOffsetBox for every slice. 
 /// In the other extreme case in which all slices are in one single chunk, there would also be only one chunk group 
 /// and there would also be only one entry in the ChunkOffsetBox.
 /// 
 /// Every chunk group entry created is written out to the ChunkGroupStream. See the Write method also.
 /// </summary>
 /// <param name="sampleCount"></param>
 void CreateNewChunkGroup(uint sampleCount)
 {
     if (ChunkGroupWriter == null)
       {
     ChunkGroupFileName = Path.GetTempFileName();
     ChunkGroupStream = File.Create(ChunkGroupFileName);
     ChunkGroupWriter = new BinaryWriter(ChunkGroupStream);
       }
       chunk = new ChunkEntry();
       chunk.firstChunk = parent.ChunkOffSetBox.EntryCount + 1; // the ChunkOffsetBox is also being built on the fly
       chunk.sampleDescriptionIndex = 1; // FIXME: this assumes that for every track there's only one sample description
       chunk.samplesPerChunk = sampleCount; // in this chunk group, every chunk has this many slices
       ChunkGroupWriter.Write(chunk.firstChunk);
       ChunkGroupWriter.Write(chunk.samplesPerChunk);
       ChunkGroupWriter.Write(chunk.sampleDescriptionIndex);
       EntryCount++;
 }
Пример #4
0
        public override void Read(BoxReader reader)
        {
            using (new SizeChecker(this, reader)) {
            base.Read(reader);

            EntryCount = reader.ReadUInt32();
            ChunkEntries = new ChunkEntry[EntryCount];

            for (int i = 0; i < EntryCount; i++) {
              ChunkEntries[i] = new ChunkEntry();
              ChunkEntries[i].firstChunk = reader.ReadUInt32();
              ChunkEntries[i].samplesPerChunk = reader.ReadUInt32();
              ChunkEntries[i].sampleDescriptionIndex = reader.ReadUInt32();
            }
              }
              if (parent.ChunkOffSetBox != null)
              TotalChunks = parent.ChunkOffSetBox.EntryCount;
        }