// Process a RIFF chunk element (skip the data) public void ProcessChunk(RiffParser rp, int FourCC, int length, int paddedLength) { string type = RiffParser.FromFourCC(FourCC); Debug.WriteLine("Found chunk element of type \"" + type + "\" and length " + length.ToString()); if (type.Trim() == "fmt") { BinaryReader br = new BinaryReader(rp.m_stream); var format = br.ReadUInt16(); var channels = br.ReadUInt16(); var sampleRate = br.ReadUInt32(); var bytePerSec = br.ReadUInt32(); var blockSize = br.ReadUInt16(); var bit = br.ReadUInt16(); Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { this.Info.Text = $"{channels} channels / {sampleRate} hz / {bit} bit / {bytePerSec} bytes/sec"; }); rp.SkipData(paddedLength - 16); } else { // Skip data and update bytesleft rp.SkipData(paddedLength); } }
/// <summary> /// Handle chunk elements found in the AVI file. Ignores unknown chunks and /// </summary> /// <param name="rp"></param> /// <param name="FourCC"></param> /// <param name="unpaddedLength"></param> /// <param name="paddedLength"></param> private void ProcessAVIChunk(RiffParser rp, int FourCC, int unpaddedLength, int paddedLength) { if (AviRiffData.ckidMainAVIHeader == FourCC) { // Main AVI header DecodeAVIHeader(rp, unpaddedLength, paddedLength); } else if (AviRiffData.ckidAVIStreamHeader == FourCC) { // Stream header DecodeAVIStream(rp, unpaddedLength, paddedLength); } else if (AviRiffData.ckidAVIISFT == FourCC) { Byte[] ba = new byte[paddedLength]; rp.ReadData(ba, 0, paddedLength); StringBuilder sb = new StringBuilder(unpaddedLength); for (int i = 0; i < unpaddedLength; ++i) { if (0 != ba[i]) { sb.Append((char)ba[i]); } } m_isft = sb.ToString(); } else { // Unknon chunk - skip rp.SkipData(paddedLength); } }
private void ProcessWaveChunk(RiffParser rp, int FourCC, int unpaddedLength, int length) { // Is this a 'fmt' chunk? if (AviRiffData.ckidWaveFMT == FourCC) { DecodeWave(rp, length); } else { rp.SkipData(length); } }
/// <summary> /// Handle List elements found in the AVI file. Ignores unknown lists and recursively looks /// at the content of known lists. /// </summary> /// <param name="rp"></param> /// <param name="FourCC"></param> /// <param name="length"></param> private void ProcessAVIList(RiffParser rp, int FourCC, int length) { RiffParser.ProcessChunkElement pac = new RiffParser.ProcessChunkElement(ProcessAVIChunk); RiffParser.ProcessListElement pal = new RiffParser.ProcessListElement(ProcessAVIList); // Is this the header? if ((AviRiffData.ckidAVIHeaderList == FourCC) || (AviRiffData.ckidAVIStreamList == FourCC) || (AviRiffData.ckidINFOList == FourCC)) { while (length > 0) { if (false == rp.ReadElement(ref length, pac, pal)) { break; } } } else { // Unknown lists - ignore rp.SkipData(length); } }
private void ProcessCDRList(RiffParser rp, int FourCC, int length) { Console.WriteLine(String.Format("LIST:{0:s}", RiffParser.FromFourCC(FourCC))); rp.SkipData(length); }
private void ProcessCDRChunk(RiffParser rp, int FourCC, int unpaddedLength, int length) { Console.WriteLine(String.Format("Chunk:{0:s}", RiffParser.FromFourCC(FourCC))); rp.SkipData(length); }
/// <summary> /// Default list element handler - skip the entire list /// </summary> /// <param name="rp"></param> /// <param name="FourCC"></param> /// <param name="length"></param> private void ProcessList(RiffParser rp, int FourCC, int length) { rp.SkipData(length); }
/// <summary> /// Defaulkt chunk handler - skip chunk data /// </summary> /// <param name="rp"></param> /// <param name="FourCC"></param> /// <param name="unpaddedLength"></param> /// <param name="paddedLength"></param> private void ProcessChunk(RiffParser rp, int FourCC, int unpaddedLength, int paddedLength) { rp.SkipData(paddedLength); }