internal QT(Atom cAtom) : base(cAtom) { byte[] aBuffer = new byte[sizeof(ulong)]; int nLength, nBytesReaded; #region id nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nID = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion _cStream.Position += sizeof(ushort); //_nReserved1 #region child count nLength = sizeof(ushort); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nChildCount = BitConverter.ToUInt16((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion _cStream.Position += sizeof(uint); //_nReserved2 }
static public Atom Read(Stream cStream) { Atom cAtom = null; try { cAtom = new Atom(cStream); switch (cAtom.eType) { case Type.ftyp: return new FileTypeCompatibility(cAtom); case Type.wide: return new Wide(cAtom); case Type.mdat: return new MovieData(cAtom); case Type.moov: return new Movie(cAtom); case Type.mvhd: return new MovieHeader(cAtom); case Type.trak: return new Track(cAtom); case Type.tkhd: return new TrackHeader(cAtom); case Type.edts: return new Edit(cAtom); case Type.elst: return new Edit.List(cAtom); case Type.mdia: return new MediaHeader(cAtom); case Type.udta: return new UserData(cAtom); } } catch { } return cAtom; }
//Note: A common source of this error is an MPEG-4 file incorrectly named with the .mov file extension or with the MIME type incorrectly set to “video/quicktime”. MPEG-4 files are automatically imported by QuickTime only when they are correctly identified as MPEG-4 files using the Mac OS file type, file extension, or MIME type. internal FileTypeCompatibility(Atom cAtom) : base(cAtom) { byte[] aBuffer = new byte[sizeof(uint)]; int nLength, nBytesReaded; #region major brand nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nMajorBrand = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region minor version nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nMinorVersion = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region compatible brands nLength = sizeof(uint); List<uint> aCompatibleBrands = new List<uint>(); while (_nCapacity < (ulong)_nStreamPositionStart + nSize) { nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); aCompatibleBrands.Add(BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0)); _aCompatibleBrands = aCompatibleBrands.ToArray(); } #endregion }
internal List(Atom cAtom) : base(cAtom) { byte[] aBuffer = new byte[sizeof(uint)]; int nLength, nBytesReaded; #region version nLength = sizeof(byte); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nVersion = aBuffer[0]; #endregion #region flags _cStream.Position += _aFlags.Length; #endregion #region number of entries nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nNumberOfEntries = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region edit list table List<Entry> aEntries = new List<Entry>(); for (int nIndx = 0; _nNumberOfEntries > nIndx; nIndx++) aEntries.Add(new Entry(_cStream)); _aEditListTable = aEntries.ToArray(); #endregion }
public Skip(Atom cAtom) : base(cAtom) { }
internal Atom(Atom cAtom) { _cStream = cAtom._cStream; _nStreamPositionStart = cAtom._nStreamPositionStart; _nSize = cAtom._nSize; _nType = cAtom._nType; _nSizeExtended = cAtom._nSizeExtended; }
internal MovieData(Atom cAtom) : base(cAtom) { }
internal Wide(Atom cAtom) : base(cAtom) { }
public Free(Atom cAtom) : base(cAtom) { }
internal Edit(Atom cAtom) : base(cAtom) { }
internal TrackHeader(Atom cAtom) : base(cAtom) { byte[] aBuffer = new byte[sizeof(uint)]; int nLength, nBytesReaded; #region version nLength = sizeof(byte); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nVersion = aBuffer[0]; #endregion #region flags _cStream.Position += _aFlags.Length; #endregion #region creation time nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nCreationTime = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region modification time nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nModificationTime = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region track id nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nTrackID = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region reserved _cStream.Position += sizeof(uint); #endregion #region duration nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nDuration = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region reserved _cStream.Position += sizeof(byte); #endregion #region layer nLength = sizeof(short); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nLayer = BitConverter.ToInt16((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region alternate group nLength = sizeof(short); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nAlternateGroup = BitConverter.ToInt16((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region volume nLength = sizeof(ushort); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nVolume = BitConverter.ToUInt16((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region reserved _cStream.Position += sizeof(short); #endregion #region matrix structure nLength = _aMatrixStructure.Length; nBytesReaded = _cStream.Read(_aMatrixStructure, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); #endregion #region preview time nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nTrackWidth = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region preview duration nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nTrackHeight = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion }
internal MovieHeader(Atom cAtom) : base(cAtom) { byte[] aBuffer = new byte[sizeof(uint)]; int nLength, nBytesReaded; #region version nLength = sizeof(byte); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nVersion = aBuffer[0]; #endregion #region flags _cStream.Position += _aFlags.Length; #endregion #region creation time nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nCreationTime = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region modification time nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nModificationTime = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region time scale nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nTimeScale = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region duration nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nDuration = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region preferred rate nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nPreferredRate = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region preferred volume nLength = sizeof(ushort); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nPreferredVolume = BitConverter.ToUInt16((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region reserved _cStream.Position += _aReserved.Length; #endregion #region matrix structure nLength = _aMatrixStructure.Length; nBytesReaded = _cStream.Read(_aMatrixStructure, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); #endregion #region preview time nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nPreviewTime = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region preview duration nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nPreviewDuration = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region poster time nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nPosterTime = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region selection time nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nSelectionTime = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region selection duration nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nSelectionDuration = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region current time nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nCurrentTime = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion #region next track ID nLength = sizeof(uint); nBytesReaded = _cStream.Read(aBuffer, 0, nLength); if (nBytesReaded != nLength) throw new Exception("can't read necessary bytes qty"); _nNextTrackID = BitConverter.ToUInt32((BitConverter.IsLittleEndian ? aBuffer.Take(nLength).Reverse().ToArray() : aBuffer), 0); #endregion }
//Modification date //A 32-bit unsigned integer containing a date that indicates when the preview was last updated. The data is in standard Macintosh format. //Version number //A 16-bit integer that must be set to 0. // Atom type //A 32-bit integer that indicates the type of atom that contains the preview data. Typically, this is set to 'PICT' to indicate a QuickDraw picture. // Atom index //A 16-bit integer that identifies which atom of the specified type is to be used as the preview. Typically, this field is set to 1 to indicate that you should use the first atom of the type specified in the atom type field. public Preview(Atom cAtom) : base(cAtom) { }
internal Track(Atom cAtom) : base(cAtom) { }