Exemple #1
0
            /// <summary>
            /// Erzeugt eine neue Analyseinstanz für einen Nutzdatenstrom.
            /// </summary>
            /// <param name="parser">Die zugehörige Instanz zum Gesamtdatenstrom.</param>
            /// <param name="pid">Die betroffenen Datenstromkennung.</param>
            /// <param name="callback">Der Empfänger der eigentlichen Nutzdaten.</param>
            public PESInfo( TSParser parser, ushort pid, Action<byte[]> callback )
            {
                // Remember
                PID = pid;

                // Create
                m_Builder = new PESBuilder( parser, callback );
            }
Exemple #2
0
            /// <summary>
            /// Erzeugt eine neue Analyseinstanz für einen Nutzdatenstrom.
            /// </summary>
            /// <param name="parser">Die zugehörige Instanz zum Gesamtdatenstrom.</param>
            /// <param name="pid">Die betroffenen Datenstromkennung.</param>
            /// <param name="callback">Der Empfänger der eigentlichen Nutzdaten.</param>
            public PESInfo(TSParser parser, ushort pid, Action <byte[]> callback)
            {
                // Remember
                PID = pid;

                // Create
                m_Builder = new PESBuilder(parser, callback);
            }
        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();
        }
Exemple #4
0
        /// <summary>
        /// Analysiert die aktuelle Datei.
        /// </summary>
        public void Analyse()
        {
            // Reset
            Streams.Clear();

            // Be safe
            try
            {
                // First run to get the stream analysis
                using (var parser = new TSParser { FillStatistics = true })
                {
                    // Fill it
                    ReadFile( parser );

                    // Load statistics
                    foreach (var info in parser.PacketStatistics.OrderBy( p => p.Key ))
                        Streams.Add( new StreamItem( info.Key, info.Value ) );

                    // Add statistics
                    SubItems[2].Text = parser.BytesReceived.ToString( "N0" );
                    SubItems[3].Text = parser.BytesSkipped.ToString( "N0" );
                    SubItems[4].Text = parser.Callbacks.ToString();
                    SubItems[5].Text = parser.Resynchronized.ToString();
                    SubItems[6].Text = parser.Scrambled.ToString( "N0" );
                    SubItems[7].Text = parser.TransmissionErrors.ToString();
                    SubItems[8].Text = parser.ValidPATCount.ToString();
                    SubItems[9].Text = parser.PacketsReceived.ToString( "N0" );

                    // Check mode
                    if (parser.ValidPATCount > 0)
                        SubItems[10].Text = Math.Round( parser.BytesReceived * 1.0 / parser.ValidPATCount ).ToString( "N0" );
                }

                // First run to do detail analysis
                using (var parser = new TSParser())
                {
                    // Connect
                    foreach (var stream in Streams)
                        stream.RegisterPhase1( parser );

                    // Fill it
                    ReadFile( parser );
                }

                // Second run to do get SI Tables
                using (var parser = new TSParser())
                {
                    // Connect
                    foreach (var stream in Streams)
                        stream.RegisterPhase2( parser );

                    // Fill it
                    ReadFile( parser );
                }

                // See if PAT is available
                StreamItem pat = Streams.FirstOrDefault( s => s.PID == 0 );
                if (pat != null)
                    SubItems[11].Text = string.Join( ", ", pat.TransportIdentifiers.Select( t => t.ToString() ).ToArray() );

            }
            catch (Exception e)
            {
                // Remember
                SubItems[12].Text = e.Message;
            }

            // Finish
            foreach (var stream in Streams)
                stream.RefreshUI();
        }
Exemple #5
0
        /// <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 );
            }
        }
 /// <summary>
 /// Erzeugt einen neuen Vermittler.
 /// </summary>
 /// <param name="analyser">Die eigentliche Analyseeinheit.</param>
 /// <param name="item">Die zugehörige Beschreibung.</param>
 public _Builder( TSParser analyser, StreamItem item )
     : base( analyser, null )
 {
     // Remember
     m_Item = item;
 }
        /// <summary>
        /// Meldet sich als Verbraucher an eine Analyse an.
        /// </summary>
        /// <param name="analyser">Die Analyseeinheit.</param>
        public void RegisterPhase2( TSParser analyser )
        {
            // See if there is a well known table 
            foreach (var tableType in typeof( WellKnownTable ).Assembly.GetExportedTypes())
                if (typeof( WellKnownTable ).IsAssignableFrom( tableType ))
                    if (!tableType.IsAbstract)
                        if (WellKnownTable.GetWellKnownStream( tableType ) == PID)
                        {
                            // Remember
                            SubItems[6].Text = tableType.Name;

                            // Create consumer
                            var parser = TableParser.Create( CountTable, tableType );

                            // Connect
                            analyser.SetFilter( PID, true, parser.AddPayload );

                            // Done
                            break;
                        }
        }
 /// <summary>
 /// Meldet sich als Verbraucher an eine Analyse an.
 /// </summary>
 /// <param name="analyser">Die Analyseeinheit.</param>
 public void RegisterPhase1( TSParser analyser )
 {
     // Add as a custom builder
     analyser.RegisterCustomFilter( PID, new _Builder( analyser, this ) );
 }