static void printInFileHeadersOfFileArray(byte[] file1Bytes, int type = 0) { #if DEBUG string fileName = type == 0 ? "log.txt" : "logOriginal.txt"; byte[] chars = Encoding.ASCII.GetBytes("OggS"); List <int> places = FindCharsInArray(file1Bytes, chars, false); List <OggPage> pages = new List <OggPage>(places.Count); for (int i = 0; i < places.Count; i++) { OggPage newOggPage = new OggPage(file1Bytes, places[i]); pages.Add(newOggPage); } using (StreamWriter sw = new StreamWriter(urlFolder + fileName, true)) { for (int i = 0; i < pages.Count; i++) { sw.WriteLine("Page No :" + i.ToString()); sw.WriteLine(" capture_pattern : {0} ", Encoding.ASCII.GetString(pages[i].capture_pattern)); sw.WriteLine(" Version : {0} ", Convert.ToInt32(pages[i].Version[0]).ToString()); sw.WriteLine(" header_type.packet_continued : {0} , header_type.bos : {1}, header_type.eos : {2} ", new BitArray(pages[i].header_type).Get(1), new BitArray(pages[i].header_type).Get(2), new BitArray(pages[i].header_type).Get(4)); sw.WriteLine(" granule_position : {0} ", BitConverter.ToUInt64(pages[i].granule_position, 0)); sw.WriteLine(" bitstream_serial_number : {0}, {1}, {2} ,{3} ", pages[i].bitstream_serial_number[0].ToString(), pages[i].bitstream_serial_number[1].ToString(), pages[i].bitstream_serial_number[2].ToString(), pages[i].bitstream_serial_number[3].ToString()); sw.WriteLine(" page_sequence_number : {0} ", BitConverter.ToUInt32(pages[i].page_sequence_number, 0)); sw.WriteLine(" CRC_checksum : {0} ", BitConverter.ToInt32(pages[i].CRC_checksum, 0)); sw.WriteLine(" page_segments : {0} ", ((uint)pages[i].page_segments[0]).ToString()); for (int j = 0; j < pages[i].segments_number; j++) { sw.WriteLine("segment {0} : {1}", j, pages[i].segments_table[j]); } sw.WriteLine("-------------------"); } } #endif }
static void printHeadersOfFileArray(byte[] file1Bytes) { byte[] chars = Encoding.ASCII.GetBytes("OggS"); List <int> places = FindCharsInArray(file1Bytes, chars, false); List <OggPage> pages = new List <OggPage>(places.Count); for (int i = 0; i < places.Count; i++) { OggPage newOggPage = new OggPage(file1Bytes, places[i]); pages.Add(newOggPage); } for (int i = 0; i < pages.Count; i++) { Console.WriteLine("Page No :" + i.ToString()); Console.WriteLine(" capture_pattern : {0} ", Encoding.ASCII.GetString(pages[i].capture_pattern)); Console.WriteLine(" Version : {0} ", Convert.ToInt32(pages[i].Version[0]).ToString()); Console.WriteLine(" header_type.packet_continued : {0} , header_type.bos : {1}, header_type.eos : {2} ", new BitArray(pages[i].header_type).Get(1), new BitArray(pages[i].header_type).Get(2), new BitArray(pages[i].header_type).Get(4)); Console.WriteLine(" granule_position : {0} ", BitConverter.ToUInt64(pages[i].granule_position, 0)); Console.WriteLine(" bitstream_serial_number : {0}, {1}, {2} ,{3} ", pages[i].bitstream_serial_number[0].ToString(), pages[i].bitstream_serial_number[1].ToString(), pages[i].bitstream_serial_number[2].ToString(), pages[i].bitstream_serial_number[3].ToString()); Console.WriteLine(" page_sequence_number : {0} ", BitConverter.ToUInt32(pages[i].page_sequence_number, 0)); var crcBits = new BitArray(pages[i].CRC_checksum); Console.WriteLine(" CRC_checksum : {0} ", BitConverter.ToInt32(pages[i].CRC_checksum, 0)); Console.WriteLine(" page_segments : {0} ", ((uint)pages[i].page_segments[0]).ToString()); for (int j = 0; j < pages[i].segments_number; j++) { Console.WriteLine("segment {0} : {1}", j, pages[i].segments_table[j]); } Console.WriteLine("-------------------"); } }