コード例 #1
0
        /// <summary>
        /// Ermittelt alle Sender zu einerm Geräteprofil.
        /// </summary>
        /// <param name="profile">Das gewünschte Geräteprofil.</param>
        /// <returns>Alle Sender, versehen mit eindeutigen Namen.</returns>
        public static SourceItem[] GetSourceItems( Profile profile )
        {
            // The list
            List<SourceItem> items = new List<SourceItem>();

            // All items
            foreach (SourceSelection source in profile.AllSources)
            {
                // Attach to station in it
                Station station = source.Source as Station;

                // Ups
                if (null == station)
                    continue;

                // TV and radio only
                if (station.SourceType != SourceTypes.TV)
                    if (station.SourceType != SourceTypes.Radio)
                        if (!station.IsService)
                            continue;

                // Create the item
                items.Add( new SourceItem { Selection = source, Name = station.FullName } );
            }

            // First duplicate pass - use service identifier
            RemoveDuplicatesAddService( items );

            // Sort
            items.Sort( ( l, r ) => l.Name.CompareTo( r.Name ) );

            // Report
            return items.ToArray();
        }
コード例 #2
0
 /// <summary>
 /// Erzeugt eine neue Verwaltungsinstanz.
 /// </summary>
 /// <param name="profile">Das zugehörige Geräteprofil.</param>
 /// <exception cref="ArgumentNullException">Es wurde kein Geräteprofil angegeben.</exception>
 public ProfileItem( Profile profile )
 {
     // Validate
     if (null == profile)
         throw new ArgumentNullException( "profile" );
     
     // Remember
     Profile = profile;
 }
コード例 #3
0
        /// <summary>
        /// Create a new instance and start EPG parsing on PID <i>0x12</i>.
        /// </summary>
        /// <param name="profile">Related hardware device.</param>
        /// <param name="portal">The currently show station.</param>
        public ServiceParser( Profile profile, SourceIdentifier portal )
        {
            // Remember
            Profile = profile;
            Portal = portal;

            // Register
            HardwareManager.OpenHardware( Profile ).AddProgramGuideConsumer( TableFound );
        }
コード例 #4
0
 /// <summary>
 /// Erstellt eine neue Beschreibung.
 /// </summary>
 /// <param name="profile">Das zugehörige Geräteprpfil.</param>
 /// <param name="active">Gesetzt, wenn das Geräteprofil verwendet wird.</param>
 /// <returns>Die angeforderte Beschreibung.</returns>
 public static ConfigurationProfile Create( Profile profile, bool active )
 {
     // Report
     return
         new ConfigurationProfile
         {
             SourceLimit = ReadSetting( profile, ProfileScheduleResource.ParallelSourceLimitName, ProfileScheduleResource.DefaultParallelSourceLimit ),
             DecryptionLimit = ReadSetting( profile, ProfileScheduleResource.DecryptionLimitName, ProfileScheduleResource.DefaultDecryptionLimit ),
             Priority = ReadSetting( profile, ProfileScheduleResource.SchedulePriorityName, ProfileScheduleResource.DefaultSchedulePriority ),
             UsedForRecording = active,
             Name = profile.Name,
         };
 }
コード例 #5
0
        /// <summary>
        /// Liest eine Einstellung aus.
        /// </summary>
        /// <param name="profile">Ein Geräteprofil.</param>
        /// <param name="settingName">Der Name der Einstellung.</param>
        /// <param name="settingDefault">Die Voreinstellung der Einstellung.</param>
        /// <returns>Der aktuelle Wert, gegebenenfalls die Voreinstellung.</returns>
        private static uint ReadSetting( Profile profile, string settingName, uint settingDefault )
        {
            // Check value
            var settings = profile.GetParameter( settingName );
            if (string.IsNullOrEmpty( settings ))
                return settingDefault;

            // Check value
            uint value;
            if (uint.TryParse( settings, out value ))
                return value;
            else
                return settingDefault;
        }
コード例 #6
0
        /// <summary>
        /// Ermittelt alle Quellen zu einem DVB.NET Geräteprofil.
        /// </summary>
        /// <param name="profile">Das zu verwendende Geräteprofil.</param>
        /// <param name="predicate">Methode, die prüft, ob eine Quelle gemeldet werden soll.</param>
        /// <returns>Alle Quellen zum Profil.</returns>
        public static IEnumerable<SourceSelection> GetSources( Profile profile, Func<SourceSelection, bool> predicate )
        {
            // Resolve
            if (profile == null)
                yield break;

            // Load the map
            Dictionary<SourceIdentifier, SourceSelection> map;
            if (!CurrentState.SourceByIdentifierMap.TryGetValue( profile.Name, out map ))
                yield break;

            // Use state
            foreach (SourceSelection source in map.Values)
                if ((null == predicate) || predicate( source ))
                    yield return source;
        }
コード例 #7
0
 /// <summary>
 /// Ermittelt alle Quellen zu einem DVB.NET Geräteprofil.
 /// </summary>
 /// <param name="profile">Der Name des Geräteprofils.</param>
 /// <returns>Alle Quellen zum Profil.</returns>
 public static IEnumerable<SourceSelection> GetSources( Profile profile ) => GetSources( profile, (Func<SourceSelection, bool>)null );
コード例 #8
0
        /// <summary>
        /// Aktualisiert eine einzelne Eigenschaft.
        /// </summary>
        /// <param name="profile">Ein Geräteprofil.</param>
        /// <param name="propertyName">Der Name der Eigenschaft.</param>
        /// <param name="currentValue">Der aktuelle Wert der Eigenschaft.</param>
        /// <param name="defaultValue">Der bevorzugte Wert der Eigenschaft.</param>
        /// <returns>Gesetzt, wenn die Eigenschaft verändert wurde.</returns>
        private static bool Update( Profile profile, string propertyName, uint currentValue, uint defaultValue )
        {
            // Read the current setting
            var newValue = ReadSetting( profile, propertyName, defaultValue );
            if (newValue == currentValue)
                return false;

            // Reset
            profile.Parameters.RemoveAll( parameter => propertyName.Equals( parameter.Name ) );

            // Add
            if (currentValue != defaultValue)
                profile.Parameters.Add( new ProfileParameter( propertyName, currentValue ) );

            // Did it
            return true;
        }
コード例 #9
0
ファイル: Profile.cs プロジェクト: davinx/DVB.NET---VCR.NET
 /// <summary>
 /// Prüft, ob ein Geräteprofil zu einem anderen kompatibel ist. Kompatibel sind jeweils
 /// nur DVB-S und DVB-S etc.
 /// </summary>
 /// <param name="other">Das andere Geräteprofil.</param>
 /// <returns>Gesetzt, wenn beide Profile kompatibel sind.</returns>
 public abstract bool IsCompatibleTo( Profile other );
コード例 #10
0
        /// <summary>
        /// Führt Änderungen am Geräteprofil aus.
        /// </summary>
        /// <param name="profile">Das Geräteprofil.</param>
        /// <returns>Gesetzt, wenn etwas verändert wurde.</returns>
        public bool WriteBack( Profile profile )
        {
            // Process all
            var newDecryption = Update( profile, ProfileScheduleResource.DecryptionLimitName, DecryptionLimit, ProfileScheduleResource.DefaultDecryptionLimit );
            var newSource = Update( profile, ProfileScheduleResource.ParallelSourceLimitName, SourceLimit, ProfileScheduleResource.DefaultParallelSourceLimit );
            var newPriority = Update( profile, ProfileScheduleResource.SchedulePriorityName, Priority, ProfileScheduleResource.DefaultSchedulePriority );
            var changed = newPriority || newDecryption || newSource;

            // Must persist
            if (changed)
                profile.Save();

            // Done
            return changed;
        }
コード例 #11
0
        /// <summary>
        /// Führt eine Standardumwandlung aus.
        /// </summary>
        /// <param name="profile">Das zu verwendende Geräteprofil.</param>
        /// <param name="hardwareType">Die konkrete Art der DVB.NET 4.0ff Implementierung.</param>
        /// <returns>Die gewünschte Abstraktion.</returns>
        private static Hardware StandardTranslation( Profile profile, Type hardwareType )
        {
            // Result
            Hardware result = null;

            // Create the hardware
            var hardware = (Hardware) Activator.CreateInstance( hardwareType, profile );
            try
            {
                // Report
                if (hardware.Translate())
                {
                    // Reload restrictions - can only use full featured algorithm when fully ported
                    hardware.Restrictions = new HardwareRestriction { ProvidesSignalInformation = true };

                    // Remember
                    result = hardware;
                }
            }
            catch
            {
            }

            // Cleanup
            if (result == null)
                hardware.Dispose();

            // Failed
            return result;
        }
コード例 #12
0
 /// <summary>
 /// Erstellt die Beschreibung eines Gerätes.
 /// </summary>
 /// <param name="profile">Das zugehörige Geräteprofil.</param>
 public StandardDevice( Profile profile )
 {
     m_profile = profile;
 }
コード例 #13
0
 /// <summary>
 /// Erzeugt das Hauptfenster im DVB.NET Modus mit direktem Zugriff auf
 /// eine lokale Hardware.
 /// </summary>
 /// <param name="profile">Die zu verwendene lokale DVB.NET Hardware.</param>
 public ViewerMain( Profile profile )
     : this( profile, StartupModes.LocalDVB )
 {
 }
コード例 #14
0
        /// <summary>
        /// Aktiviert eine bestimmte Geräteabstraktion.
        /// </summary>
        /// <param name="profile">Das zugehörigen Geräteprofils.</param>
        /// <returns>Die gewünschte Hardware oder <i>null</i>, wenn die Geräteverwaltung
        /// nicht aktiv ist.</returns>
        /// <exception cref="ArgumentException">Es wurde kein Geräteprofil angegeben.</exception>
        public static Hardware OpenHardware( Profile profile )
        {
            // Validate
            if (null == profile)
                throw new ArgumentNullException( "profile" );
            if (string.IsNullOrEmpty( profile.Name ))
                throw new ArgumentNullException( "profile.Name" );

            // Be safe
            lock (m_ActiveHardware)
            {
                // Not locked
                if (m_ReferenceCounter < 1)
                    return null;

                // Already active
                Hardware hardware;
                if (m_ActiveHardware.TryGetValue( profile.Name, out hardware ))
                    return hardware;

                // Ask profile
                hardware = profile.CreateHardware();

                // Remember
                m_ActiveHardware[profile.Name] = hardware;

                // Report
                return hardware;
            }
        }
コード例 #15
0
 /// <summary>
 /// Erstellt eine periodische Aufgabe zum Aktualisieren der Quellen.
 /// </summary>
 /// <param name="resource">Die zugehörige Ressource.</param>
 /// <param name="profile">Die vollen Informationen zum Geräteprofil.</param>
 /// <returns>Die Beschreibung der Aufgabe oder <i>null</i>.</returns>
 public PeriodicScheduler CreateSourceScanTask( IScheduleResource resource, Profile profile )
 {
     // Forward
     return new SourceListTask( resource, () => m_lastRunScan[resource.Name] );
 }
コード例 #16
0
 /// <summary>
 /// Erstellt eine periodische Aufgabe zum Aktualisieren der Programmzeitschrift.
 /// </summary>
 /// <param name="resource">Die zugehörige Ressource.</param>
 /// <param name="profile">Die vollen Informationen zum Geräteprofil.</param>
 /// <returns>Die Beschreibung der Aufgabe oder <i>null</i>.</returns>
 public PeriodicScheduler CreateProgramGuideTask( IScheduleResource resource, Profile profile )
 {
     // Forward
     return new ProgramGuideTask( resource, () => m_lastRunGuide[resource.Name] );
 }
コード例 #17
0
        /// <summary>
        /// Erzeugt eine neue Instanz der Abstraktion zu einem Geräteprofil.
        /// </summary>
        /// <param name="profile">Das zu verwendende Geräteprofil.</param>
        /// <param name="migrateOnly">Gesetzt, wenn nur eine Migration der Einstellungen vorgenommen werden soll.</param>
        /// <returns>Die neu erzeugte Instanz, die mit <see cref="IDisposable.Dispose"/>
        /// freigegeben werden muss.</returns>
        /// <exception cref="ArgumentNullException">Es wurde kein Geräteprofil angegeben.</exception>
        /// <exception cref="NotSupportedException">Das Geräteprofil verwendet die nicht mehr unterstützten BDA Abstraktion
        /// vor DVB.NET 4.0.</exception>
        internal static Hardware Create(Profile profile, bool migrateOnly)
        {
            // Validate
            if (profile == null)
            {
                throw new ArgumentNullException("profile");
            }

            // For exception translation
            try
            {
                // Load the primary type
                var primaryType = Type.GetType(profile.HardwareType, true);

                // See we we can translate
                Type translationType;
                if (LegacyAssemblyName.Equals(primaryType.Assembly.GetName().Name))
                {
                    if (s_LegacyMapping.TryGetValue(primaryType.FullName, out translationType))
                    {
                        // Load the provider mapping
                        var provider = profile.GetDeviceAspect(null);
                        if (!string.IsNullOrEmpty(provider))
                        {
                            // Load the translatior
                            Func <Profile, Type, Hardware> translator;
                            if (s_Translators.TryGetValue(provider, out translator))
                            {
                                // Try translate
                                var hardware = translator(profile, translationType);
                                if (hardware == null)
                                {
                                    if (migrateOnly)
                                    {
                                        return(null);
                                    }
                                    else
                                    {
                                        throw new NotSupportedException(string.Format(Properties.Resources.Exception_NoLongerSupported, profile));
                                    }
                                }
                                else
                                {
                                    return(hardware);
                                }
                            }
                        }
                    }
                }

                // Create and report
                if (migrateOnly)
                {
                    return(null);
                }
                else
                {
                    return((Hardware)Activator.CreateInstance(primaryType, profile));
                }
            }
            catch (TargetInvocationException e)
            {
                // Forward
                if (migrateOnly)
                {
                    return(null);
                }
                else
                {
                    throw (null == e.InnerException) ? e : e.InnerException;
                }
            }
        }
コード例 #18
0
        /// <summary>
        /// Führt eine Standardumwandlung für den Satellitenempfang mit DiSEqC aus.
        /// </summary>
        /// <param name="profile">Das zu verwendende Geräteprofil.</param>
        /// <param name="hardwareType">Die konkrete Art der DVB.NET 4.0ff Implementierung.</param>
        /// <returns>Die gewünschte Abstraktion.</returns>
        private static Hardware StandardSatelliteTranslationWithDiSEqC( Profile profile, Type hardwareType )
        {
            // Forward
            var hardware = StandardTranslation( profile, hardwareType );
            if (hardware == null)
                return null;

            // Add item to pipeline
            hardware.EffectivePipeline.Add( new PipelineItem { SupportedOperations = PipelineTypes.DiSEqC, ComponentType = DiSEqCByFrequencyFilter } );

            // Report
            return hardware;
        }
コード例 #19
0
        /// <summary>
        /// Erzeugt as Hauptfenster.
        /// </summary>
        /// <param name="profile">Die zu verwendene lokale DVB.NET Hardware.</param>
        /// <param name="mode">Operationsmodus der Anwendung.</param>
        /// <param name="args">Parameter zum Operationsmodus der Anwendung.</param>
        public ViewerMain( Profile profile, StartupModes mode, params string[] args )
        {
            // Remember
            m_Arguments = args;
            Profile = profile;
            m_Mode = mode;

            // Create components
            InitializeComponent();

            // Attach to viewer
            IViewerSite viewer = (IViewerSite) theViewer;

            // Register additional keys - to be kept we must do this before SetSite fixes the map
            viewer.SetKeyHandler( Keys.J, ProcessFullScreen );
            viewer.SetKeyHandler( Keys.End, Close );

            // Connect viewer control to configuration
            theViewer.SetSite( this );

            // Prepare to show
            SetBounds();
        }
コード例 #20
0
        /// <summary>
        /// Wandelt die Abstraktion für die Hauppauge Nova-S Plus und Nova-SE2 um.
        /// </summary>
        /// <param name="profile">Das zu verwendende Geräteprofil.</param>
        /// <param name="hardwareType">Die konkrete Art der DVB.NET 4.0ff Implementierung.</param>
        /// <returns>Die gewünschte Abstraktion.</returns>
        private static Hardware TranslateNova( Profile profile, Type hardwareType )
        {
            // Forward
            var hardware = StandardTranslation( profile, hardwareType );
            if (hardware == null)
                return null;

            // Default names
            hardware.EffectiveDeviceAspects.Add( new DeviceAspect { Aspekt = Aspect_TunerName, Value = "Hauppauge WinTV 88x DVB-S Tuner/Demod" } );
            hardware.EffectiveDeviceAspects.Add( new DeviceAspect { Aspekt = Aspect_CaptureName, Value = "Hauppauge WinTV 88x TS Capture" } );

            // Add to pipeline
            hardware.EffectivePipeline.Add( new PipelineItem { SupportedOperations = PipelineTypes.DiSEqC, ComponentType = HauppaugeNovaSDiSEqC } );

            // Report
            return hardware;
        }
コード例 #21
0
        /// <summary>
        /// Beginnt die Aufzeichnung in einen <i>Transport Stream</i> - optional als
        /// Datei.
        /// </summary>
        /// <param name="nextPID">Die erste Datenstromkennung (PID), die in der Aufzeichnungsdatei verwendet werden darf.</param>
        /// <param name="recreate">Gesetzt, wenn ein Neustart aufgrund veränderter Nutzdatenströme erforderlich wurde.</param>
        /// <exception cref="ArgumentException">Eine Aufzeichnung der angegebenen Quelle ist nicht möglich.</exception>
        private void CreateStream(short nextPID, bool recreate)
        {
            // Try to get the full name
            var filePath = m_OriginalPath;

            if (filePath != null)
            {
                if (m_FileCount > 0)
                {
                    // Split off the parts
                    var name = Path.GetFileNameWithoutExtension(filePath);
                    var dir  = Path.GetDirectoryName(filePath);
                    var ext  = Path.GetExtension(filePath);

                    // Construct new name
                    filePath = Path.Combine(dir, $"{name} - {m_FileCount}{ext}");
                }
            }

            // Try to decrypt
            if (m_Decrypting = m_OriginalSettings.IsEncrypted)
            {
                try
                {
                    // Process
                    Hardware.Decrypt(Source);
                }
                catch
                {
                    // Ignore any error
                    m_Decrypting = false;
                }
            }

            // Type of the video
            EPG.StreamTypes?videoType;

            // Video first
            if (m_OriginalSettings.VideoStream == 0)
            {
                videoType = null;
            }
            else
            {
                videoType = (m_OriginalSettings.VideoType == VideoTypes.H264) ? EPG.StreamTypes.H264 : EPG.StreamTypes.Video13818;
            }

            // Get the buffer size
            var bufferSize = (FileBufferSizeChooser == null) ? null : FileBufferSizeChooser(videoType);

            // Create the new stream
            m_TransportStream = new Manager(filePath, nextPID, bufferSize.GetValueOrDefault(Manager.DefaultBufferSize));

            // Attach PCR sink
            m_TransportStream.OnWritingPCR = m_WritePCRSink;

            // Report of the actually selected streams
            StreamSelection result = new StreamSelection();

            // Cleanup on any error
            try
            {
                // Video first
                if (videoType.HasValue)
                {
                    AddConsumer(m_OriginalSettings.VideoStream, StreamTypes.Video, m_TransportStream.AddVideo((byte)videoType.Value));
                }

                // Select audio
                ProcessAudioSelection(AudioTypes.MP2, result.MP2Tracks, StreamSelection.MP2Tracks);
                ProcessAudioSelection(AudioTypes.AC3, result.AC3Tracks, StreamSelection.AC3Tracks);

                // Videotext
                if (StreamSelection.Videotext)
                {
                    if (0 != m_OriginalSettings.TextStream)
                    {
                        // Register
                        AddConsumer(m_OriginalSettings.TextStream, StreamTypes.VideoText, m_TransportStream.AddTeleText());

                        // Remember
                        result.Videotext = true;
                    }
                }

                // Subtitle streams
                var subtitles = new Dictionary <ushort, List <EPG.SubtitleInfo> >();

                // Preset mode
                result.SubTitles.LanguageMode = LanguageModes.All;

                // All audio
                // Subtitles
                foreach (var subtitle in m_OriginalSettings.Subtitles)
                {
                    // Check for primary
                    if (StreamSelection.SubTitles.LanguageMode == LanguageModes.Primary)
                    {
                        // Attach to the list
                        AddSubtitleInformation(subtitle, subtitles);

                        // Copy over
                        result.SubTitles.LanguageMode = LanguageModes.Primary;

                        // Remember
                        result.SubTitles.Languages.Add(subtitle.Language);

                        // Done
                        break;
                    }

                    // Standard selection
                    if (StreamSelection.SubTitles.Contains(subtitle.Language))
                    {
                        // Attach to the list
                        AddSubtitleInformation(subtitle, subtitles);

                        // Remember
                        result.SubTitles.Languages.Add(subtitle.Language);
                    }
                    else
                    {
                        // At least one is excluded
                        result.SubTitles.LanguageMode = LanguageModes.Selection;
                    }
                }

                // Clear flag if no audio is used
                if (LanguageModes.All == result.SubTitles.LanguageMode)
                {
                    if (result.SubTitles.Languages.Count < 1)
                    {
                        result.SubTitles.LanguageMode = LanguageModes.Selection;
                    }
                }

                // Process all subtitles
                foreach (var current in subtitles)
                {
                    AddConsumer(current.Key, StreamTypes.SubTitle, m_TransportStream.AddSubtitles(current.Value.ToArray()));
                }

                // See if program guide is requested
                bool epg = StreamSelection.ProgramGuide;

                // May want to disable
                if (epg)
                {
                    if ((Hardware.Profile != null) && Hardware.Profile.DisableProgramGuide)
                    {
                        epg = false;
                    }
                    else if (Profile != null)
                    {
                        if (Profile.GetFilter(Source).DisableProgramGuide)
                        {
                            epg = false;
                        }
                    }
                }

                // EPG
                if (epg)
                {
                    // Activate dispatch
                    m_TransportStream.SetEPGMapping(Source.Network, Source.TransportStream, Source.Service);

                    // Start it
                    Hardware.AddProgramGuideConsumer(DispatchEPG);

                    // Remember
                    result.ProgramGuide = true;
                }

                // Counter
                int started = 0;
                try
                {
                    // Start all
                    foreach (var consumer in m_Consumers)
                    {
                        try
                        {
                            // Forward
                            Hardware.SetConsumerState(consumer, true);

                            // Count it
                            ++started;
                        }
                        catch (OutOfConsumersException)
                        {
                            // Translate
                            throw new OutOfConsumersException(m_Consumers.Count, started)
                                  {
                                      RequestedSelection = result
                                  };
                        }
                    }
                }
                catch
                {
                    // Detach EPG
                    Hardware.RemoveProgramGuideConsumer(DispatchEPG);

                    // Cleanup on all errors
                    foreach (var consumer in m_Consumers)
                    {
                        try
                        {
                            // Remove
                            Hardware.SetConsumerState(consumer, null);
                        }
                        catch
                        {
                            // Ignore any error
                        }
                    }

                    // Forward
                    throw;
                }

                // Remember path
                if (filePath != null)
                {
                    m_AllFiles.Add(new FileStreamInformation {
                        FilePath = filePath, VideoType = m_OriginalSettings.VideoType
                    });
                }

                // Remember the time
                LastActivationTime = DateTime.UtcNow;
            }
            catch
            {
                // Simply forget
                m_TransportStream.Dispose();
                m_TransportStream = null;

                // Forward
                throw;
            }

            // Get the next free PID
            NextStreamIdentifier = m_TransportStream.NextPID;

            // Remember the streams we use
            ActiveSelection = result;

            // Attach to clients
            var createNotify = OnCreatedStream;

            // Report
            if (createNotify != null)
            {
                createNotify(this);
            }
        }
コード例 #22
0
        /// <summary>
        /// Erzeugt eine neue Instanz der Abstraktion zu einem Geräteprofil.
        /// </summary>
        /// <param name="profile">Das zu verwendende Geräteprofil.</param>
        /// <param name="migrateOnly">Gesetzt, wenn nur eine Migration der Einstellungen vorgenommen werden soll.</param>
        /// <returns>Die neu erzeugte Instanz, die mit <see cref="IDisposable.Dispose"/>
        /// freigegeben werden muss.</returns>
        /// <exception cref="ArgumentNullException">Es wurde kein Geräteprofil angegeben.</exception>
        /// <exception cref="NotSupportedException">Das Geräteprofil verwendet die nicht mehr unterstützten BDA Abstraktion
        /// vor DVB.NET 4.0.</exception>
        internal static Hardware Create( Profile profile, bool migrateOnly )
        {
            // Validate
            if (profile == null)
                throw new ArgumentNullException( "profile" );

            // For exception translation
            try
            {
                // Load the primary type
                var primaryType = Type.GetType( profile.HardwareType, true );

                // See we we can translate
                Type translationType;
                if (LegacyAssemblyName.Equals( primaryType.Assembly.GetName().Name ))
                    if (s_LegacyMapping.TryGetValue( primaryType.FullName, out translationType ))
                    {
                        // Load the provider mapping
                        var provider = profile.GetDeviceAspect( null );
                        if (!string.IsNullOrEmpty( provider ))
                        {
                            // Load the translatior
                            Func<Profile, Type, Hardware> translator;
                            if (s_Translators.TryGetValue( provider, out translator ))
                            {
                                // Try translate
                                var hardware = translator( profile, translationType );
                                if (hardware == null)
                                    if (migrateOnly)
                                        return null;
                                    else
                                        throw new NotSupportedException( string.Format( Properties.Resources.Exception_NoLongerSupported, profile ) );
                                else
                                    return hardware;
                            }
                        }
                    }

                // Create and report
                if (migrateOnly)
                    return null;
                else
                    return (Hardware) Activator.CreateInstance( primaryType, profile );
            }
            catch (TargetInvocationException e)
            {
                // Forward
                if (migrateOnly)
                    return null;
                else
                    throw (null == e.InnerException) ? e : e.InnerException;
            }
        }
コード例 #23
0
        /// <summary>
        /// Beginnt mit dem Auslesen der Quelldaten.
        /// </summary>
        /// <param name="source">Die gewünschte Quelle.</param>
        /// <param name="device">Das zu verwendende Gerät.</param>
        /// <param name="profile">Optional das zu berücksichtigende Geräteprofil.</param>
        /// <returns>Die Hintergrundaufgabe zum Auslesen der Quelledaten.</returns>
        public static CancellableTask<SourceInformation> GetSourceInformationAsync( this Hardware device, SourceIdentifier source, Profile profile = null )
        {
            // Validate
            if (device == null)
                throw new ArgumentNullException( "no hardware to use", "device" );
            if (source == null)
                throw new ArgumentException( "no source to get information for", "source" );

            // Attach to tasks
            var patReader = device.AssociationTableReader;
            var groupReader = device.GroupReader;

            // Start 
            return
                CancellableTask<SourceInformation>.Run( cancel =>
                {
                    // Check tasks
                    if (groupReader == null)
                        return null;
                    if (patReader == null)
                        return null;

                    // Wait on tasks
                    if (!groupReader.CancellableWait( cancel ))
                        return null;
                    if (!patReader.CancellableWait( cancel ))
                        return null;

                    // Get the current group information
                    var groupInfo = groupReader.Result;
                    if (groupInfo == null)
                        return null;

                    // See if group exists
                    if (!groupInfo.Sources.Any( source.Equals ))
                        return null;

                    // Find the stream identifier for the service
                    var pmtIdentifier = patReader.Result.FindService( source.Service );
                    if (!pmtIdentifier.HasValue)
                        return null;

                    // Wait for mapping table
                    var pmtReader = device.GetTableAsync<PMT>( pmtIdentifier.Value );
                    if (!pmtReader.CancellableWait( cancel ))
                        return null;

                    // Request table
                    var pmts = pmtReader.Result;
                    if (pmts == null)
                        return null;

                    // Create dummy
                    var currentSettings = new SourceInformation { Source = source, VideoType = VideoTypes.NoVideo };

                    // Process all PMT - actually should be only one
                    foreach (var pmt in pmts)
                    {
                        // Overwrite encryption if CA descriptor is present
                        if (pmt.Table.Descriptors != null)
                            currentSettings.IsEncrypted = pmt.Table.Descriptors.Any( descriptor => EPG.DescriptorTags.CA == descriptor.Tag );

                        // Process the program entries
                        foreach (var program in pmt.Table.ProgramEntries)
                            currentSettings.Update( program );
                    }

                    // Find the related station information
                    var station = groupInfo.Sources.FirstOrDefault( source.Equals ) as Station;
                    if (station != null)
                    {
                        // Take data from there
                        currentSettings.Provider = station.Provider;
                        currentSettings.Name = station.Name;

                        // See if this is a service
                        currentSettings.IsService = station.IsService;

                        // Overwrite encryption if regular service entry exists
                        if (!currentSettings.IsService)
                            currentSettings.IsEncrypted = station.IsEncrypted;
                    }

                    // See if profile is attached
                    if (profile != null)
                    {
                        // Apply the modifier
                        var modifier = profile.GetFilter( currentSettings.Source );
                        if (modifier != null)
                            modifier.ApplyTo( currentSettings );
                    }

                    // Report
                    return currentSettings;
                } );
        }
コード例 #24
0
        /// <summary>
        /// Erzeugt eine neue Verwaltung.
        /// </summary>
        /// <param name="hardware">Das Gerät, auf dem die zugehörige Quellgruppe gerade aktiv ist.</param>
        /// <param name="profile">Optional das Geräteprofil mit der zugehörigen Senderliste.</param>
        /// <param name="source">Die Quelle, die zu betrachten ist.</param>
        /// <param name="selection">Die zu betrachtenden Datenströme.</param>
        /// <exception cref="ArgumentNullException">Ein Parameter wurde nicht angegeben.</exception>
        public SourceStreamsManager( Hardware hardware, Profile profile, SourceIdentifier source, StreamSelection selection )
        {
            // Validate
            if (null == hardware)
                throw new ArgumentNullException( "hardware" );
            if (null == source)
                throw new ArgumentNullException( "source" );
            if (null == selection)
                throw new ArgumentNullException( "selection" );

            // Remember all
            StreamSelection = selection;
            Hardware = hardware;
            Profile = profile;
            Source = source;
        }
コード例 #25
0
 /// <summary>
 /// Ermittelt alle Quellen zu einem DVB.NET Geräteprofil.
 /// </summary>
 /// <param name="profile">Der Name des Geräteprofils.</param>
 /// <returns>Alle Quellen zum Profil.</returns>
 public static IEnumerable<SourceSelection> GetSources( Profile profile )
 {
     // Forward
     return GetSources( profile, (Func<SourceSelection, bool>) null );
 }