public Mpeg4AppleDataBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { // Ensure that the data is loaded before the file is closed. // Get the box data based on position and size offsets LoadBoxData(4, -4); }
public Mpeg4AppleDataBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { // Ensure that the data is loaded before the file is closed. // Get the box data based on position and size offsets LoadBoxData(4, -4); }
protected Mpeg4FullBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition); // First 4 buffer contain version and flag data. version = File.ReadBlock(1)[0]; flags = File.ReadBlock(3).ToUInt(); }
public Mpeg4IsoChunkLargeOffsetBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition); offsets = new List<ulong>((int)File.ReadBlock(4).ToUInt()); for (int i = 0; i < offsets.Count; i++) offsets[i] = (ulong)File.ReadBlock(4).ToLong(); }
protected Mpeg4FullBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition); // First 4 buffer contain version and flag data. version = File.ReadBlock(1)[0]; flags = File.ReadBlock(3).ToUInt(); }
public Mpeg4IsoSampleDescriptionBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition); // This box just contains a number saying how many of the first boxes // will be SampleEntries, since they can be named whatever they want to // be. entryCount = File.ReadBlock(4).ToUInt(); }
public Mpeg4IsoSampleDescriptionBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition); // This box just contains a number saying how many of the first boxes // will be SampleEntries, since they can be named whatever they want to // be. entryCount = File.ReadBlock(4).ToUInt(); }
public Mpeg4IsoChunkOffsetBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition); offsets = new List<uint>((int)File.ReadBlock(4).ToUInt()); //new uint[(int)File.ReadBlock(4).ToUInt()]; for (int i = 0; i < offsets.Count; i++) offsets[i] = File.ReadBlock(4).ToUInt(); }
public Mpeg4IsoAudioSampleEntry(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition + 8); channelCount = (ushort)File.ReadBlock(2).ToShort(); sampleSize = (ushort)File.ReadBlock(2).ToShort(); File.Seek(base.DataPosition + 16); sampleRate = (uint)File.ReadBlock(4).ToUInt(); }
public Mpeg4IsoAudioSampleEntry(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition + 8); channelCount = (ushort)File.ReadBlock(2).ToShort(); sampleSize = (ushort)File.ReadBlock(2).ToShort(); File.Seek(base.DataPosition + 16); sampleRate = (uint)File.ReadBlock(4).ToUInt(); }
public Mpeg4IsoChunkLargeOffsetBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition); offsets = new List <ulong>((int)File.ReadBlock(4).ToUInt()); for (int i = 0; i < offsets.Count; i++) { offsets[i] = (ulong)File.ReadBlock(4).ToLong(); } }
public Mpeg4IsoChunkOffsetBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition); offsets = new List <uint>((int)File.ReadBlock(4).ToUInt()); //new uint[(int)File.ReadBlock(4).ToUInt()]; for (int i = 0; i < offsets.Count; i++) { offsets[i] = File.ReadBlock(4).ToUInt(); } }
public Mpeg4IsoHandlerBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { // Reserved File.Seek(base.DataPosition + 4); // Read the handler type. handlerType = File.ReadBlock(4); // Reserved File.Seek(base.DataPosition + 20); // Find the terminating byte and read a string from the data before it. long end = File.Find((byte)0, File.Tell); name = File.ReadBlock((int)(end - File.Tell)).ToString(); }
public Mpeg4Box(Mpeg4BoxHeader header, Mpeg4Box parent) { // Initialize everything. this.header = header; this.parent = parent; //this.data = null; //this.children = new ArrayList(); //this.loadChildrenStarted = false; // This was necessary after refactoring the File, DataPosition and DataSize // properties so that they are no longer virtual if (header != null && file == null) { this.file = header.File; } }
public Mpeg4Box(Mpeg4BoxHeader header, Mpeg4Box parent) { // Initialize everything. this.header = header; this.parent = parent; //this.data = null; //this.children = new ArrayList(); //this.loadChildrenStarted = false; // This was necessary after refactoring the File, DataPosition and DataSize // properties so that they are no longer virtual if (header != null && file == null) { this.file = header.File; } }
public Mpeg4IsoHandlerBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { // Reserved File.Seek(base.DataPosition + 4); // Read the handler type. handlerType = File.ReadBlock(4); // Reserved File.Seek(base.DataPosition + 20); // Find the terminating byte and read a string from the data before it. long end = File.Find((byte)0, File.Tell); name = File.ReadBlock((int)(end - File.Tell)).ToString(); }
public Mpeg4AppleItemListBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4IsoMovieHeaderBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { // Size depends on version. boxSize = Version == 1 ? 108 : 96; // Get everything. File.Seek(base.DataPosition); ByteVector data = File.ReadBlock(boxSize); int pos = 0; // Read version one (large integers). if (Version == 1) { if (data.Count >= pos + 8) creationTime = (ulong)data.Mid(pos, 8).ToLong(); pos += 8; if (data.Count >= pos + 8) modificationTime = (ulong)data.Mid(pos, 8).ToLong(); pos += 8; if (data.Count >= pos + 4) timescale = data.Mid(pos, 4).ToUInt(); pos += 4; if (data.Count >= pos + 8) duration = (ulong)data.Mid(pos, 8).ToLong(); pos += 8; } // Read version zero (normal integers). else { if (data.Count >= pos + 4) creationTime = data.Mid(pos, 4).ToUInt(); pos += 4; if (data.Count >= pos + 4) modificationTime = data.Mid(pos, 4).ToUInt(); pos += 4; if (data.Count >= pos + 4) timescale = data.Mid(pos, 4).ToUInt(); pos += 4; if (data.Count >= pos + 4) duration = (ulong)data.Mid(pos, 4).ToUInt(); pos += 4; } // Get rate if (data.Count >= pos + 4) rate = data.Mid(pos, 4).ToUInt(); pos += 4; // Get volume if (data.Count >= pos + 2) volume = (ushort)data.Mid(pos, 2).ToShort(); pos += 2; // reserved pos += 2; // reserved pos += 8; // video transformation matrix pos += 36; // pre-defined pos += 24; // Get next track ID if (data.Count >= pos + 4) nextTrackId = (ushort)data.Mid(pos, 4).ToUInt(); }
public Mpeg4IsoSampleEntry(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition + 6); dataReferenceIndex = (ushort)File.ReadBlock(2).ToShort(); }
public Mpeg4UnknownBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4AppleAdditionalInfoBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { // The box content is a type string. text = LoadBoxData().ToString(StringType.Latin1); //BoxData.ToString(StringType.Latin1); }
public Mpeg4AppleItemListBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4IsoUserDataBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4IsoMediaInformationBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4AppleAnnotationBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4IsoSampleTableBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4IsoFreeSpaceBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { // set padding equal to the size of the zero space. padding = HeaderDataSize; }
public Mpeg4AppleElementaryStreamDescriptor(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { //WARNING: this was changed from accessing the Data property directy to instead // use LoadBoxData which returns a reference to the underlying data. This change // was required to avoid accessing the virtual methods that the Data property uses // Everything should still work but if it doesn't then this change is the culprit... decoderConfiguration = new ByteVector(); uint length; // This box contains a ton of information. int offset = 0; // This is a safe alternative to the Data property // it will be a reference to the same underlying structure and so should work identically to Data ByteVector boxData = LoadBoxData(); // Elementary Stream Descriptor Tag if (boxData[offset++] == 3) { // We have a descriptor tag. Check that it'field at least 20 long. if ((length = ReadLength(boxData, offset)) < 20) { TagLibDebugger.Debug("TagLib.Mpeg4.AppleElementaryStreamDescriptor () - Could not read data. Too small."); return; } offset += 4; streamId = boxData.Mid(offset, 2).ToShort(); offset += 2; streamPriority = boxData[offset++]; } else { // The tag wasn'type found, so the next two byte are the ID, and // after that, business as usual. streamId = boxData.Mid(offset, 2).ToShort(); offset += 2; } // Verify that the next data is the Decoder Configuration Descriptor // Tag and escape if it won'type work out. if (boxData[offset++] != 4) { TagLibDebugger.Debug("TagLib.Mpeg4.AppleElementaryStreamDescriptor () - Could not identify decoder configuration descriptor."); return; } // Check that it'field at least 15 long. if ((length = ReadLength(boxData, offset)) < 15) { TagLibDebugger.Debug("TagLib.Mpeg4.AppleElementaryStreamDescriptor () - Could not read data. Too small."); return; } offset += 4; // Read a lot of good info. objectTypeId = boxData[offset++]; streamType = boxData[offset++]; bufferSize = boxData.Mid(offset, 3).ToUInt(); offset += 3; maximumBitrate = boxData.Mid(offset, 4).ToUInt(); offset += 4; averageBitrate = boxData.Mid(offset, 4).ToUInt(); offset += 4; // Verify that the next data is the Decoder Specific Descriptor // Tag and escape if it won'type work out. if (boxData[offset++] != 5) { TagLibDebugger.Debug("TagLib.Mpeg4.AppleElementaryStreamDescriptor () - Could not identify decoder specific descriptor."); return; } // The rest of the info is decoder specific. length = ReadLength(boxData, offset); offset += 4; decoderConfiguration = boxData.Mid(offset, (int)length); }
public Mpeg4AppleAnnotationBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4IsoMediaInformationBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4IsoSampleEntry(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { File.Seek(base.DataPosition + 6); dataReferenceIndex = (ushort)File.ReadBlock(2).ToShort(); }
public Mpeg4IsoFreeSpaceBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { // set padding equal to the size of the zero space. padding = HeaderDataSize; }
public Mpeg4IsoTrackBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
// Create a box by reading the file and add it to "parent". public static Mpeg4Box Create(Mpeg4File file, long position, Mpeg4Box parent) { // Read the box header. Mpeg4BoxHeader header = new Mpeg4BoxHeader(file, position); // If we're not even valid, quit. if (!header.IsValid) { return(null); } // IF we're in a SampleDescriptionBox and haven'type loaded all the // entries, try loading an appropriate entry. if (parent.BoxType == "stsd" && parent.Children.Count < ((Mpeg4IsoSampleDescriptionBox)parent).EntryCount) { Mpeg4IsoHandlerBox handler = parent.Handler; if (handler != null && handler.HandlerType == "soun") { return(new Mpeg4IsoAudioSampleEntry(header, parent)); } else { return(new Mpeg4IsoSampleEntry(header, parent)); } } // // A bunch of standard items. // if (header.BoxType == "moov") { return(new Mpeg4IsoMovieBox(header, parent)); } if (header.BoxType == "mvhd") { return(new Mpeg4IsoMovieHeaderBox(header, parent)); } if (header.BoxType == "mdia") { return(new Mpeg4IsoMediaBox(header, parent)); } if (header.BoxType == "minf") { return(new Mpeg4IsoMediaInformationBox(header, parent)); } if (header.BoxType == "stbl") { return(new Mpeg4IsoSampleTableBox(header, parent)); } if (header.BoxType == "stsd") { return(new Mpeg4IsoSampleDescriptionBox(header, parent)); } if (header.BoxType == "stco") { return(new Mpeg4IsoChunkOffsetBox(header, parent)); } if (header.BoxType == "co64") { return(new Mpeg4IsoChunkLargeOffsetBox(header, parent)); } if (header.BoxType == "trak") { return(new Mpeg4IsoTrackBox(header, parent)); } if (header.BoxType == "hdlr") { return(new Mpeg4IsoHandlerBox(header, parent)); } if (header.BoxType == "udta") { return(new Mpeg4IsoUserDataBox(header, parent)); } if (header.BoxType == "meta") { return(new Mpeg4IsoMetaBox(header, parent)); } if (header.BoxType == "ilst") { return(new Mpeg4AppleItemListBox(header, parent)); } if (header.BoxType == "data") { return(new Mpeg4AppleDataBox(header, parent)); } if (header.BoxType == "esds") { return(new Mpeg4AppleElementaryStreamDescriptor(header, parent)); } if (header.BoxType == "free" || header.BoxType == "skip") { return(new Mpeg4IsoFreeSpaceBox(header, parent)); } if (header.BoxType == "mean" || header.BoxType == "name") { return(new Mpeg4AppleAdditionalInfoBox(header, parent)); } // If we still don'type have a tag, and we're inside an ItemLisBox, load // lthe box as an AnnotationBox (Apple tag item). if (parent.GetType() == typeof(Mpeg4AppleItemListBox)) { return(new Mpeg4AppleAnnotationBox(header, parent)); } // Nothing good. Go generic. return(new Mpeg4UnknownBox(header, parent)); }
public Mpeg4IsoMediaBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4IsoMovieHeaderBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { // Size depends on version. boxSize = Version == 1 ? 108 : 96; // Get everything. File.Seek(base.DataPosition); ByteVector data = File.ReadBlock(boxSize); int pos = 0; // Read version one (large integers). if (Version == 1) { if (data.Count >= pos + 8) { creationTime = (ulong)data.Mid(pos, 8).ToLong(); } pos += 8; if (data.Count >= pos + 8) { modificationTime = (ulong)data.Mid(pos, 8).ToLong(); } pos += 8; if (data.Count >= pos + 4) { timescale = data.Mid(pos, 4).ToUInt(); } pos += 4; if (data.Count >= pos + 8) { duration = (ulong)data.Mid(pos, 8).ToLong(); } pos += 8; } // Read version zero (normal integers). else { if (data.Count >= pos + 4) { creationTime = data.Mid(pos, 4).ToUInt(); } pos += 4; if (data.Count >= pos + 4) { modificationTime = data.Mid(pos, 4).ToUInt(); } pos += 4; if (data.Count >= pos + 4) { timescale = data.Mid(pos, 4).ToUInt(); } pos += 4; if (data.Count >= pos + 4) { duration = (ulong)data.Mid(pos, 4).ToUInt(); } pos += 4; } // Get rate if (data.Count >= pos + 4) { rate = data.Mid(pos, 4).ToUInt(); } pos += 4; // Get volume if (data.Count >= pos + 2) { volume = (ushort)data.Mid(pos, 2).ToShort(); } pos += 2; // reserved pos += 2; // reserved pos += 8; // video transformation matrix pos += 36; // pre-defined pos += 24; // Get next track ID if (data.Count >= pos + 4) { nextTrackId = (ushort)data.Mid(pos, 4).ToUInt(); } }
public Mpeg4IsoTrackBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4AppleAdditionalInfoBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { // The box content is a type string. text = LoadBoxData().ToString(StringType.Latin1); //BoxData.ToString(StringType.Latin1); }
public Mpeg4IsoMetaBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4IsoSampleTableBox(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { }
public Mpeg4AppleElementaryStreamDescriptor(Mpeg4BoxHeader header, Mpeg4Box parent) : base(header, parent) { //WARNING: this was changed from accessing the Data property directy to instead // use LoadBoxData which returns a reference to the underlying data. This change // was required to avoid accessing the virtual methods that the Data property uses // Everything should still work but if it doesn't then this change is the culprit... decoderConfiguration = new ByteVector(); uint length; // This box contains a ton of information. int offset = 0; // This is a safe alternative to the Data property // it will be a reference to the same underlying structure and so should work identically to Data ByteVector boxData = LoadBoxData(); // Elementary Stream Descriptor Tag if (boxData[offset++] == 3) { // We have a descriptor tag. Check that it'field at least 20 long. if ((length = ReadLength(boxData, offset)) < 20) { TagLibDebugger.Debug("TagLib.Mpeg4.AppleElementaryStreamDescriptor () - Could not read data. Too small."); return; } offset += 4; streamId = boxData.Mid(offset, 2).ToShort(); offset += 2; streamPriority = boxData[offset++]; } else { // The tag wasn'type found, so the next two byte are the ID, and // after that, business as usual. streamId = boxData.Mid(offset, 2).ToShort(); offset += 2; } // Verify that the next data is the Decoder Configuration Descriptor // Tag and escape if it won'type work out. if (boxData[offset++] != 4) { TagLibDebugger.Debug("TagLib.Mpeg4.AppleElementaryStreamDescriptor () - Could not identify decoder configuration descriptor."); return; } // Check that it'field at least 15 long. if ((length = ReadLength(boxData, offset)) < 15) { TagLibDebugger.Debug("TagLib.Mpeg4.AppleElementaryStreamDescriptor () - Could not read data. Too small."); return; } offset += 4; // Read a lot of good info. objectTypeId = boxData[offset++]; streamType = boxData[offset++]; bufferSize = boxData.Mid(offset, 3).ToUInt(); offset += 3; maximumBitrate = boxData.Mid(offset, 4).ToUInt(); offset += 4; averageBitrate = boxData.Mid(offset, 4).ToUInt(); offset += 4; // Verify that the next data is the Decoder Specific Descriptor // Tag and escape if it won'type work out. if (boxData[offset++] != 5) { TagLibDebugger.Debug("TagLib.Mpeg4.AppleElementaryStreamDescriptor () - Could not identify decoder specific descriptor."); return; } // The rest of the info is decoder specific. length = ReadLength(boxData, offset); offset += 4; decoderConfiguration = boxData.Mid(offset, (int)length); }
// Create a box by reading the file and add it to "parent". public static Mpeg4Box Create(Mpeg4File file, long position, Mpeg4Box parent) { // Read the box header. Mpeg4BoxHeader header = new Mpeg4BoxHeader(file, position); // If we're not even valid, quit. if (!header.IsValid) return null; // IF we're in a SampleDescriptionBox and haven'type loaded all the // entries, try loading an appropriate entry. if (parent.BoxType == "stsd" && parent.Children.Count < ((Mpeg4IsoSampleDescriptionBox)parent).EntryCount) { Mpeg4IsoHandlerBox handler = parent.Handler; if (handler != null && handler.HandlerType == "soun") return new Mpeg4IsoAudioSampleEntry(header, parent); else return new Mpeg4IsoSampleEntry(header, parent); } // // A bunch of standard items. // if (header.BoxType == "moov") return new Mpeg4IsoMovieBox(header, parent); if (header.BoxType == "mvhd") return new Mpeg4IsoMovieHeaderBox(header, parent); if (header.BoxType == "mdia") return new Mpeg4IsoMediaBox(header, parent); if (header.BoxType == "minf") return new Mpeg4IsoMediaInformationBox(header, parent); if (header.BoxType == "stbl") return new Mpeg4IsoSampleTableBox(header, parent); if (header.BoxType == "stsd") return new Mpeg4IsoSampleDescriptionBox(header, parent); if (header.BoxType == "stco") return new Mpeg4IsoChunkOffsetBox(header, parent); if (header.BoxType == "co64") return new Mpeg4IsoChunkLargeOffsetBox(header, parent); if (header.BoxType == "trak") return new Mpeg4IsoTrackBox(header, parent); if (header.BoxType == "hdlr") return new Mpeg4IsoHandlerBox(header, parent); if (header.BoxType == "udta") return new Mpeg4IsoUserDataBox(header, parent); if (header.BoxType == "meta") return new Mpeg4IsoMetaBox(header, parent); if (header.BoxType == "ilst") return new Mpeg4AppleItemListBox(header, parent); if (header.BoxType == "data") return new Mpeg4AppleDataBox(header, parent); if (header.BoxType == "esds") return new Mpeg4AppleElementaryStreamDescriptor(header, parent); if (header.BoxType == "free" || header.BoxType == "skip") return new Mpeg4IsoFreeSpaceBox(header, parent); if (header.BoxType == "mean" || header.BoxType == "name") return new Mpeg4AppleAdditionalInfoBox(header, parent); // If we still don'type have a tag, and we're inside an ItemLisBox, load // lthe box as an AnnotationBox (Apple tag item). if (parent.GetType() == typeof(Mpeg4AppleItemListBox)) return new Mpeg4AppleAnnotationBox(header, parent); // Nothing good. Go generic. return new Mpeg4UnknownBox(header, parent); }