public void ReportPCR()
        {
            // Prepare receiption
            var station = GetDefaultStation();

            // Prepare selection
            var selection = new StreamSelection { Videotext = false, ProgramGuide = false };

            // Add all
            selection.AC3Tracks.LanguageMode = LanguageModes.Selection;
            selection.SubTitles.LanguageMode = LanguageModes.Selection;
            selection.MP2Tracks.LanguageMode = LanguageModes.Primary;

            // Get a file name
            var tempFile = GetUniqueFile();

            // Collected PCR data
            var pcrData = new Dictionary<long, TimeSpan>();

            // Minium
            TimeSpan? minPCR = null;

            // Open it
            using (var streamManager = new SourceStreamsManager( Device, Profile, station.Source, selection ))
            {
                // Attach PCR handler
                streamManager.OnWritingPCR += ( path, position, packet ) =>
                    {
                        // Test
                        Assert.AreEqual( tempFile.FullName, path );

                        // Get the PCR
                        TimeSpan pcr = Manager.GetPCR( packet );

                        // Remember minimum
                        if (!minPCR.HasValue)
                            minPCR = pcr;

                        // Remember
                        pcrData.Add( position, pcr );
                    };

                // Send to file
                streamManager.CreateStream( tempFile.FullName, station );

                // Process
                Thread.Sleep( 10000 );

                // Done
                streamManager.CloseStream();
            }

            // Must have some
            Assert.IsTrue( minPCR.HasValue );

            // Report
            foreach (var pair in pcrData.OrderBy( p => p.Key ))
                Console.WriteLine( "{0:000000000}\t{1}\t{2}", pair.Key, pair.Value, pair.Value - minPCR.Value );
        }
Example #2
0
        /// <summary>
        /// Erzeugt eine neue Beschreibung.
        /// </summary>
        /// <param name="uniqueIdentifier">Die eindeutige Kennung dieses Datenstroms.</param>
        /// <param name="manager">Die Verwaltung des Empfangs.</param>
        /// <param name="targetPath">Ein optionaler Dateiname zur Ablage der empfangenen Daten.</param>
        /// <param name="originalSelection">Die ursprünglich angeforderte Konfiguration der Aufzeichnung.</param>
        /// <exception cref="ArgumentNullException">Es wurde keine Verwaltung angegeben</exception>
        public ActiveStream( Guid uniqueIdentifier, SourceStreamsManager manager, StreamSelection originalSelection, string targetPath )
        {
            // Validate
            if (manager == null)
                throw new ArgumentNullException( "manager" );

            // Remember
            SourceKey = new SourceIdenfierWithKey( uniqueIdentifier, manager.Source );
            RequestedStreams = originalSelection.Clone();
            TargetPath = targetPath;
            Manager = manager;
        }
        public void SplitFiles()
        {
            // Prepare receiption
            var station = GetDefaultStation();

            // Prepare selection
            var selection = new StreamSelection { Videotext = true, ProgramGuide = false };

            // Add all
            selection.AC3Tracks.LanguageMode = LanguageModes.All;
            selection.MP2Tracks.LanguageMode = LanguageModes.All;
            selection.SubTitles.LanguageMode = LanguageModes.All;

            // Get a file name
            var tempFile = GetUniqueFile();

            // Get the file name pattern
            var filePattern = Path.Combine( tempFile.DirectoryName, Path.GetFileNameWithoutExtension( tempFile.Name ) );

            // Open it
            using (var streamManager = new SourceStreamsManager( Device, Profile, station.Source, selection ))
            {
                // Send to file
                streamManager.CreateStream( string.Format( FileNamePattern, filePattern, 0 ), station );

                // Process
                for (int i = 0; i++ < 3; Thread.Sleep( 10000 ))
                {
                    // Delay - first and last will have only half the size
                    Thread.Sleep( 10000 );

                    // New file
                    Assert.IsTrue( streamManager.SplitFile( string.Format( FileNamePattern, filePattern, i ) ) );
                }

                // Done
                streamManager.CloseStream();

                // Report
                foreach (var file in streamManager.AllFiles)
                    Console.WriteLine( file );
            }
        }
        /// <summary>
        /// Fügt eine Quelle zur Aufzeichnung hinzu.
        /// </summary>
        /// <param name="source">Die gewünschte Quelle.</param>
        /// <param name="streams">Die Informationen zu den einzuschliessenden
        /// Teildatenströmen (PID).</param>
        /// <exception cref="ArgumentNullException">Ein Parameter wurde nicht angegeben.</exception>
        public void Add( SourceSelection source, StreamSelection streams )
        {
            // Validate
            if (null == source)
                throw new ArgumentNullException( "source" );
            if (null == streams)
                throw new ArgumentNullException( "streams" );

            // Remember
            m_Sources.Add( new SelectionInfo { Source = source, OriginalStreams = streams.Clone() } );
        }
        /// <summary>
        /// Ermittelt eine möglicherweise eingeschränkte Datenstromauswahl.
        /// </summary>
        /// <param name="manager">Die Quelle, um die es geht.</param>
        /// <returns>Eine geeignete Auswahl.</returns>
        private StreamSelection GetOptimizedStreams( SourceStreamsManager manager )
        {
            // Not possible
            if (null == CurrentSelection)
                return null;

            // What we want to record
            StreamSelection selection = new StreamSelection();

            // Put it on
            selection.AC3Tracks.LanguageMode = LanguageModes.All;
            selection.MP2Tracks.LanguageMode = LanguageModes.All;
            selection.SubTitles.LanguageMode = LanguageModes.All;
            selection.ProgramGuide = true;
            selection.Videotext = true;

            // See if we are working on a limited device
            if (!Device.HasConsumerRestriction)
                return selection;

            // Stop picture for a moment
            Device.SetConsumerState( VideoId, false );
            Device.SetConsumerState( AudioId, false );
            Device.SetConsumerState( TextId, false );

            // Require restart
            m_NeedRestart = true;

            // Create a brand new optimizer
            StreamSelectionOptimizer localOpt = new StreamSelectionOptimizer();

            // Add the one stream
            localOpt.Add( CurrentSelection, selection );

            // Run the optimization
            localOpt.Optimize();

            // Report result
            return localOpt.GetStreams( 0 );
        }