Пример #1
0
        /// <summary>
        /// Parse the VDX to locate individual chunks
        /// </summary>
        private void parseROQ()
        {
            long stop = 0;
            // Final stream position
            /*if (rlData.HasValue)
            {
                stop = rlData.Value.offset + rlData.Value.length;
            }
            else
            {
                stop = file.BaseStream.Length;
            }*/
            //ROQHeader header = new VDXHeader();
            ROQChunkHeader chunk = new ROQChunkHeader();

            // Initialise queue's
            audioOffsets = new Queue<long>();
            //videoOffsets = new Queue<long>();

            // Read VDX header
            //header.ID = file.ReadUInt16();
            //if (header.ID != 0x9267)
            //    throw new Exception("Invalid VDX header");

            //header.Unknown1 = file.ReadByte();
            //header.Unknown2 = file.ReadByte();
            //header.Unknown3 = file.ReadByte();
            //header.Unknown4 = file.ReadByte();
            //header.FPS = file.ReadUInt16();

            //fps = (byte)header.FPS;
            try
            {
                chunk = readChunkHeader();
                if (chunk.BlockType != ROQBlockType.FileStart)
                    throw new Exception("Bad file type");

                while (file.BaseStream.Position < file.BaseStream.Length)
                {
                    // Read VDX chunk header
                    chunk = readChunkHeader();

                    // Add offsets where appropriate
                    switch (chunk.BlockType)
                    {
                        case ROQBlockType.Mono:
                        case ROQBlockType.Stereo:
                            audioOffsets.Enqueue(file.BaseStream.Position - VDXChunkHeader.size);
                            break;

                        case ROQBlockType.AudioContainer:
                            break;

                        //case VDXBlockType.Video:
                        //    videoFrames++;
                        //    goto case VDXBlockType.Zero;
                        //case VDXBlockType.Zero:
                        //    videoMaster.Enqueue(file.BaseStream.Position - VDXChunkHeader.size);
                        //    break;
                        //case VDXBlockType.Sound:
                        //    audioOffsets.Enqueue(file.BaseStream.Position - VDXChunkHeader.size);
                        //    break;
                        case ROQBlockType.Image:
                            //if (imageOffset == 0)
                                imageOffset.Add(file.BaseStream.Position - ROQChunkHeader.size);

                            break;
                        case ROQBlockType.ImageInfo:
                            //System.Diagnostics.Debug.WriteLine("Img Info - size: " + file.ReadUInt16() + "x" + file.ReadUInt16());
                            break;
                    }

                    // Seek to next chunk
                    if (chunk.BlockType != ROQBlockType.AudioContainer)
                        file.BaseStream.Seek(chunk.DataSize, System.IO.SeekOrigin.Current);
                }
            } catch {
                audio = null;
                //videoFrames = 1;

            }
        }
Пример #2
0
        /// <summary>
        /// Read in the header for the current chunk
        /// </summary>
        /// <returns>Chunk header structure</returns>
        private ROQChunkHeader readChunkHeader()
        {
            ROQChunkHeader chunk = new ROQChunkHeader();

            chunk.BlockType = (ROQBlockType)file.ReadByte();
            chunk.Identifier = file.ReadByte();
            chunk.DataSize = file.ReadUInt32();
            chunk.BlockParameter = file.ReadUInt16();

            return chunk;
        }