public void Write(BoxWriter writer) { for (int i = 0; i < 9; i++) { writer.WriteUInt32(matrix[i]); } }
/// <summary> /// Write - write the ChunkOffsetBox to output file. /// For every chunk offset written out, add fixup. /// ChunkOffset data is either stored in a temp file, or in the chunkOffsetArray. /// Data is in the temp file if we are using PrepareSampleWriting, and in the chunkOffsetArray /// if we are simply copying boxes as they are, no recoding. /// </summary> /// <param name="writer"></param> public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(entryCount); if (entryCount > 0) { if (ChunkOffsetReader != null) { ChunkOffsetReader.BaseStream.Position = 0L; for (int i = 0; i < entryCount; i++) { uint offs = (uint)(ChunkOffsetReader.ReadUInt32() + fixup); writer.WriteUInt32(offs); } } else if ((chunkOffsetArray != null) && (entryCount == chunkOffsetArray.Length)) { for (int i = 0; i < entryCount; i++) { writer.WriteUInt32((uint)(chunkOffsetArray[i] + fixup)); } } else { throw new Exception("ChunkOffsetBox.Write: nothing to write"); } } } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(TrackId); if (EnumUtils.IsBitSet <TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.BaseDataOffsetPresent)) { writer.WriteUInt64(BaseDataOffset); } if (EnumUtils.IsBitSet <TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.SampleDescriptionIndexPresent)) { writer.WriteUInt32(SampleDescriptionIndex); } if (EnumUtils.IsBitSet <TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.DefaultSampleDurationPresent)) { writer.WriteUInt32(DefaultSampleDuration); } if (EnumUtils.IsBitSet <TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.DefaultSampleSizePresent)) { writer.WriteUInt32(DefaultSampleSize); } if (EnumUtils.IsBitSet <TrackFragmentHeaderBoxFlags>((TrackFragmentHeaderBoxFlags)base.Flags, TrackFragmentHeaderBoxFlags.DefaultSampleFlagsPresent)) { writer.WriteUInt32(DefaultSampleFlags); } } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(MfraSize); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(EntryCount); if (ChunkGroupReader != null) { for (int i = 0; i < EntryCount; i++) { writer.WriteUInt32(ChunkGroupReader.ReadUInt32()); writer.WriteUInt32(ChunkGroupReader.ReadUInt32()); writer.WriteUInt32(ChunkGroupReader.ReadUInt32()); } } else if ((ChunkEntries != null) && (ChunkEntries.Length == EntryCount)) { for (int i = 0; i < EntryCount; i++) { writer.WriteUInt32(ChunkEntries[i].firstChunk); writer.WriteUInt32(ChunkEntries[i].samplesPerChunk); writer.WriteUInt32(ChunkEntries[i].sampleDescriptionIndex); } } else { throw new Exception("SampleToChunkBox.Write: Nothing to write"); } } }
public void Write(BoxWriter writer) { if ((SampleDependsOn > 3) || (SampleIsDependedOn > 3) || (SampleHasRedundancy > 3)) throw new Exception("Invalid sdtp box value."); byte data = (byte)((SampleHasRedundancy << 6) | (SampleIsDependedOn << 4) | (SampleDependsOn << 2)); writer.Write(data); }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(EntryCount); if (SttsCountsReader != null) { for (int i = 0; i < EntryCount; i++) { writer.WriteUInt32(SttsCountsReader.ReadUInt32()); writer.WriteUInt32(SttsTimeDeltaReader.ReadUInt32()); } } else if ((SampleCount != null) && (SampleDelta != null) && (SampleCount.Length == EntryCount) && (SampleDelta.Length == EntryCount)) { for (int i = 0; i < EntryCount; i++) { writer.WriteUInt32(SampleCount[i]); writer.WriteUInt32(SampleDelta[i]); } } else { throw new Exception("Nothing to write"); } } }
/// <summary> /// CheckFilePosition /// This should be called just before writing to a fragment mdat. /// It checks whether the base data offset matches the current output file position. /// </summary> /// <param name="writer"></param> public void CheckFilePosition(BoxWriter writer) { if (this.MovieFragmentBox.TrackFragmentBox.TrackFragmentHeaderBox.BaseDataOffset != (ulong)writer.BaseStream.Position) { throw new Exception("Fragment: base data offset does not match file position"); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); if (Version == 1) { writer.WriteUInt64(creationTime); writer.WriteUInt64(modificationTime); writer.WriteUInt32(TrackID); writer.WriteUInt32((uint)0); writer.WriteUInt64(Duration); } else { writer.WriteUInt32((uint)creationTime); writer.WriteUInt32((uint)modificationTime); writer.WriteUInt32(TrackID); writer.WriteUInt32((uint)0); writer.WriteUInt32((uint)Duration); } for (int x = 0; x < 2; x++) { writer.WriteUInt32((uint)0); } writer.Write(Layer); writer.Write(AlternateGroup); writer.Write(_volume); writer.Write((UInt16)0); this.Matrix.Write(writer); writer.Write(_width); writer.Write(_height); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(EntryCount); if (SyncSampleReader != null) { for (int i = 0; i < EntryCount; i++) { writer.WriteUInt32(SyncSampleReader.ReadUInt32()); } } else if ((SampleNumbers != null) && (EntryCount == SampleNumbers.Length)) { for (int i = 0; i < EntryCount; i++) { writer.WriteUInt32(SampleNumbers[i]); } } else { throw new Exception("SyncSampleMapBox.Write: nothing to write"); } } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(SequenceNumber); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); MovieHeaderBox.Write(writer); if (ObjectDescriptorBox != null) { ObjectDescriptorBox.Write(writer); } foreach (TrackBox tbox in TrackBoxes) { tbox.Write(writer); } if (UserDataBox != null) { UserDataBox.Write(writer); } // write out MovieExtendsBox during finalize if (MovieExtendsBox != null) { MovieExtendsBox.Write(writer); } } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); DataReferenceBox.Write(writer); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.Write(_contents, 0, _contents.Length); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.Write(UserType); writer.Write(UserData); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); this.TrackFragmentHeaderBox.Write(writer); this.TrackFragmentRunBox.Write(writer); this.IndependentAndDisposableSamplesBox.Write(writer); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteNullTerminatedString(Name); writer.WriteNullTerminatedString(Location); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.Write((short)Balance); writer.Write((short)0); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); if (EnumUtils.IsBitSet<DataEntryFlags>((DataEntryFlags)base.Flags, DataEntryFlags.MediaDataSameFile) == false) writer.WriteNullTerminatedString(Location); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); if (data != null) writer.Write(data, 0, data.Length); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); foreach (TrackFragmentRandomAccessBox item in TrackFragmentRandomAccessBoxes) { item.Write(writer); } MovieFragmentRandomAccessOffsetBox.Write(writer); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); MediaHeaderBox.Write(writer); HandlerReferenceBox.Write(writer); MediaInformationBox.Write(writer); } }
public void Write(BoxWriter writer) { if ((SampleDependsOn > 3) || (SampleIsDependedOn > 3) || (SampleHasRedundancy > 3)) { throw new Exception("Invalid sdtp box value."); } byte data = (byte)((SampleHasRedundancy << 6) | (SampleIsDependedOn << 4) | (SampleDependsOn << 2)); writer.Write(data); }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt16(GraphicsMode); writer.WriteUInt16(OpColor[0]); writer.WriteUInt16(OpColor[1]); writer.WriteUInt16(OpColor[2]); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); if (EnumUtils.IsBitSet <DataEntryFlags>((DataEntryFlags)base.Flags, DataEntryFlags.MediaDataSameFile) == false) { writer.WriteNullTerminatedString(Location); } } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); for (int i = 0; i < this.m_numSamples; i++) { IndependentAndDisposableSample item = Samples[i]; item.Write(writer); } } }
/// <summary> /// Write - unimplemented for this box. /// CCT: FIXME: we will have to add Write capability when we're dealing with RTSP and RTP protocols. /// </summary> /// <param name="writer"></param> public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); if (elstBox != null) { elstBox.Write(writer); } } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); if (Version == 1) writer.WriteUInt64(FragmentDuration); else writer.WriteUInt32((uint)FragmentDuration); } }
public override void Write(BoxWriter writer) { base.Write(writer); writer.Write(version); byte a = (byte)((flags >> 0x16) & 0xFF); byte b = (byte)((flags >> 0x08) & 0xFF); byte c = (byte)((flags) & 0xFF); writer.Write(a); writer.Write(b); writer.Write(c); }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); if (data != null) { writer.Write(data, 0, data.Length); } } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); for (int i = 0; i < trackID.Length; i++) { writer.Write(trackID[i]); } } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.Write(MaxPDUSize); writer.Write(AvgPDUSize); writer.Write(MaxBitrate); writer.Write(AvgBitrate); writer.Write((short)0); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(TrackID); writer.WriteUInt32(DefaultSampleDescriptionIndex); writer.WriteUInt32(DefaultSampleDuration); writer.WriteUInt32(DefaultSampleSize); writer.WriteUInt32(DefaultSampleFlags); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.Write(major_brand); writer.WriteUInt32(minor_version); foreach (uint brand in compatible_brands) { writer.WriteUInt32(brand); } } }
public virtual void Write(BoxWriter writer) { Common.Logger.Instance.Info("[Box::Write] writing a box of type [" + this.Type + ", " + this.GetType().Name + "], size [" + this.Size + "], offset [" + Offset + "], details: " + this.ToString()); if (this.expectedType == BoxTypes.Any) { return; } writer.WriteUInt32(this.size); writer.WriteBoxType(expectedType); if (this.size == 1) { writer.WriteUInt64(largeSize); } }
/// <summary> /// Write - this write routine for mdat is used only when writing out an MP4 file. /// (See MP4StreamWriter.) /// </summary> /// <param name="writer"></param> public void Write(BoxWriter writer, Stream reader) { if (base.Size == 0UL) { base.Write(writer); reader.CopyTo(writer.BaseStream); } else using (new SizeCalculator(this, writer)) { base.Write(writer); reader.CopyTo(writer.BaseStream); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); // The movie fragment header contains a sequence number MovieFragmentHeaderBox.SequenceNumber, as a safety check. // The sequence number usually starts at 1 and must increase for each movie fragment in the file, on the order in which they occur. // This allows readers to verify integrity of the sequence; it is an error to construct a file where the fragments are out // of sequence.... // See one of the constructors for the Fragment class where this SequenceNumber is managed. this.MovieFragmentHeaderBox.Write(writer); this.TrackFragmentBox.Write(writer); } }
public void Write(BoxWriter writer, uint flags) { if (EnumUtils.IsBitSet<TrackFragmentRunBoxFlags>((TrackFragmentRunBoxFlags) flags, TrackFragmentRunBoxFlags.SampleDurationPresent)) { writer.WriteUInt32(SampleDuration); } if (EnumUtils.IsBitSet<TrackFragmentRunBoxFlags>((TrackFragmentRunBoxFlags) flags, TrackFragmentRunBoxFlags.SampleSizePresent)) { writer.WriteUInt32(SampleSize); } if (!EnumUtils.IsBitSet<TrackFragmentRunBoxFlags>((TrackFragmentRunBoxFlags)flags, TrackFragmentRunBoxFlags.FirstSampleFlagsPresent) && EnumUtils.IsBitSet<TrackFragmentRunBoxFlags>((TrackFragmentRunBoxFlags)flags, TrackFragmentRunBoxFlags.SampleFlagsPresent)) { writer.WriteUInt32(SampleFlags); } if (EnumUtils.IsBitSet<TrackFragmentRunBoxFlags>((TrackFragmentRunBoxFlags) flags, TrackFragmentRunBoxFlags.SampleCompositionTimeOffsetsPresent)) { writer.WriteUInt32(SampleCompositionTimeOffset); } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(EntryCount); if (EntryCount > 0) foreach (DataEntry entry in DataEntry) { if (entry.DataEntryUrlBox != null) { entry.DataEntryUrlBox.Write(writer); } if (entry.DataEntryUrnBox != null) { entry.DataEntryUrnBox.Write(writer); } } } }
/// <summary> /// CheckFilePosition /// This should be called just before writing to a fragment mdat. /// It checks whether the base data offset matches the current output file position. /// </summary> /// <param name="writer"></param> public void CheckFilePosition(BoxWriter writer) { if (this.MovieFragmentBox.TrackFragmentBox.TrackFragmentHeaderBox.BaseDataOffset != (ulong)writer.BaseStream.Position) throw new Exception("Fragment: base data offset does not match file position"); }
public override void Write(BoxWriter writer) { base.Write(writer); // write out just the header }
/// <summary> /// Write /// This does not write to MDAT yet, just to header boxes. /// </summary> /// <param name="writer"></param> public void Write(BoxWriter writer) { this.MovieFragmentBox.Write(writer); this.MediaDataBox.Write(writer); }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.Write((Int32)0); writer.Write(handler_type, 0, 4); for (int i = 0; i < 3; i++) writer.Write((Int32)0); writer.WriteNullTerminatedString(Name); } }
public override void Write(BoxWriter writer) { if (this.EntryCount == 0) { // this means we had no CTTS's which were different and thus this file // doesn't need them and most likely has no b-frames... return; } using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(EntryCount); if (EntryCount > 0) { if (CompToSampleStream != null) { CompToSampleStream.Position = 0L; CompToSampleReader = new BinaryReader(CompToSampleStream); for (int i = 0; i < EntryCount; i++) { writer.WriteUInt32(CompToSampleReader.ReadUInt32()); writer.WriteUInt32(CompToSampleReader.ReadUInt32()); } CompToSampleStream.Close(); CompToSampleStream.Dispose(); } else { for (int i = 0; i < EntryCount; i++) { writer.WriteUInt32(SampleCount[i]); writer.WriteUInt32(SampleOffset[i]); } } } } }
/// <summary> /// Write - write the ChunkOffsetBox to output file. /// For every chunk offset written out, add fixup. /// ChunkOffset data is either stored in a temp file, or in the chunkOffsetArray. /// Data is in the temp file if we are using PrepareSampleWriting, and in the chunkOffsetArray /// if we are simply copying boxes as they are, no recoding. /// </summary> /// <param name="writer"></param> public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); writer.WriteUInt32(entryCount); if (entryCount > 0) { if (ChunkOffsetReader != null) { ChunkOffsetReader.BaseStream.Position = 0L; for (int i = 0; i < entryCount; i++) { uint offs = (uint)(ChunkOffsetReader.ReadUInt32() + fixup); writer.WriteUInt32(offs); } } else if ((chunkOffsetArray != null) && (entryCount == chunkOffsetArray.Length)) { for (int i = 0; i < entryCount; i++) { writer.WriteUInt32((uint)(chunkOffsetArray[i] + fixup)); } } else throw new Exception("ChunkOffsetBox.Write: nothing to write"); } } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); TrackHeaderBox.Write(writer); if (EdtsBox != null) { EdtsBox.Write(writer); //this.Size -= EdtsBox.Size; } MediaBox.Write(writer); if (TrackReferenceBox != null) TrackReferenceBox.Write(writer); } }
public void Write(BoxWriter writer, byte version, uint LengthSizeOfTrafNum, uint LengthSizeOfTrunNum, uint LengthSizeOfSampleNum) { if (version == 1) { ulong tmpTime = Time - BaseTime; writer.WriteUInt64(tmpTime); writer.WriteUInt64(MoofOffset); } else { writer.WriteUInt32((uint)Time); writer.WriteUInt32((uint)MoofOffset); } switch (((LengthSizeOfTrafNum + 1) * 8)) { case 0x18: //this.TrafNumber = reader.ReadUInt24(); writer.WriteUInt24(TrafNumber); break; case 0x20: //this.TrafNumber = reader.ReadUInt32(); writer.WriteUInt32(TrafNumber); break; case 8: //this.TrafNumber = reader.ReadByte(); writer.Write((byte)TrafNumber); break; case 0x10: //this.TrafNumber = reader.ReadUInt16(); writer.WriteUInt16((UInt16)TrafNumber); break; } switch (((LengthSizeOfTrunNum + 1) * 8)) { case 0x18: //this.TrunNumber = reader.ReadUInt24(); writer.WriteUInt24(TrunNumber); break; case 0x20: //this.TrunNumber = reader.ReadUInt32(); writer.WriteUInt32(TrunNumber); break; case 8: //this.TrunNumber = reader.ReadByte(); writer.Write((byte)TrunNumber); break; case 0x10: //this.TrunNumber = reader.ReadUInt16(); writer.WriteUInt16((UInt16)TrunNumber); break; } switch (((LengthSizeOfSampleNum + 1) * 8)) { case 8: //this.SampleNumber = reader.ReadByte(); writer.Write((byte)SampleNumber); return; case 0x10: //this.SampleNumber = reader.ReadUInt16(); writer.WriteUInt16((UInt16)SampleNumber); break; case 0x18: //this.SampleNumber = reader.ReadUInt24(); writer.WriteUInt24(SampleNumber); return; case 0x20: //this.SampleNumber = reader.ReadUInt32(); writer.WriteUInt32(SampleNumber); return; } }
public override void Write(BoxWriter writer) { using (new SizeCalculator(this, writer)) { base.Write(writer); if (Version == 1) { writer.WriteUInt64(creationTime); writer.WriteUInt64(modificationTime); writer.WriteUInt32(TimeScale); writer.WriteUInt64(Duration); } else { writer.WriteUInt32((uint)creationTime); writer.WriteUInt32((uint)modificationTime); writer.WriteUInt32(TimeScale); writer.WriteUInt32((uint)Duration); } writer.Write((Int16)language); writer.Write((Int16)0); } }