/// <summary> /// Nimmt ein einzelnes Datenpaket entgegen. /// </summary> /// <param name="rawSample">Die COM Schnittstelle des Paketes.</param> public void Receive(IntPtr rawSample) { // Increment reference counter - will be released by wrapper Marshal.AddRef(rawSample); // Wrap it using (var sample = new NoMarshalComObjects.MediaSample(rawSample)) try { // Skip if (!m_Running) { return; } // No parser if (m_Parser == null) { return; } // Attach to the information int size = sample.ActualDataLength; // Skip if (size < 1) { return; } // Attach to data var data = sample.BaseAddress; var buffer = new byte[size]; // Fill Marshal.Copy(data, buffer, 0, buffer.Length); // Process m_Parser.AddPayload(buffer); // Synchronize if (m_Dump != null) { lock (m_DumpLock) if (m_Dump != null) { m_Dump.Write(buffer, 0, buffer.Length); } } } finally { // Forward if (m_TIF != null) { m_TIF.Receive(rawSample); } } }
/// <summary> /// Überträgt den Dateiinhalt zur Analyse. /// </summary> /// <param name="target">Die Analyseinstanz, die befüllt werden soll.</param> private void ReadFile(TSParser target) { // Create buffer to read file var buffer = new byte[100000]; // Open the file using (var file = new FileStream(Text, FileMode.Open, FileAccess.Read, FileShare.Read, buffer.Length)) { // Load the file size SubItems[1].Text = Math.Round(file.Length / 1024.0 / 1024.0).ToString("N0"); // Load for (int n; (n = file.Read(buffer, 0, buffer.Length)) > 0;) { target.AddPayload(buffer, 0, n); } } }
private void starter_Tick(object sender, EventArgs e) { // Disable starter.Enabled = false; // Finsih if (null == File) { // Stop Close(); // Done return; } // Set mode m_Loading = true; // May stop cmdStop.Enabled = true; // Reset GUI m_ListItems.Clear(); m_Entries.Clear(); // Be safe try { // Choose decoding mode Section.ISO6937Encoding = ckStandardSI.Checked; // The mode bool TSMode = (0 == string.Compare(File.Extension, ".ts", true)); // Blocksize byte[] Buffer = new byte[TSMode ? 10000000 : 100000]; // Open the file and create parser using (FileStream read = new FileStream(File.FullName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, Buffer.Length)) using (TSParser parser = new TSParser()) { // Skip junk if (TSMode) { parser.SetFilter(0x12, true, EPGParser.OnData); } // Content for (int n; (n = read.Read(Buffer, 0, Buffer.Length)) > 0;) { // Report progress progress.Value = (int)(read.Position * progress.Maximum / read.Length); // Show up Application.DoEvents(); // Done if (!cmdStop.Enabled) { break; } // Check mode if (TSMode) { // Feed into parser parser.AddPayload(Buffer, 0, n); } else { // SI Table EPGParser.OnData(Buffer, 0, n); } } } } catch (Exception ex) { // Report MessageBox.Show(this, ex.Message); } finally { // Done m_Loading = false; } // Prepare load cmdStop.Text = m_LoadText; cmdStop.Enabled = true; // Load all we found lstEntries.Items.Clear(); lstEntries.Items.AddRange(m_ListItems.ToArray()); // Prepare sorter lstEntries.ListViewItemSorter = new EPGEntry.Comparer(); }
/// <summary> /// Überträgt Daten zur Analyse. /// </summary> /// <param name="buffer">Der Speicher mit den Daten.</param> /// <param name="offset">Die Position des ersten Nutzbytes.</param> /// <param name="length">Die Anzahl der Nutzbytes.</param> public void Feed(byte[] buffer, int offset, int length) { // Forward m_parser.AddPayload(buffer, offset, length); }