コード例 #1
0
 /// <summary>
 /// Erzeugt eine Kopie der angegebenen Ursprungs.
 /// </summary>
 /// <param name="location">Der ursprüngliche Ursprung, wobei <i>null</i> erlaubt ist.</param>
 /// <returns>Eine Kopie des Ursprungs oder <i>null</i>.</returns>
 public static T CloneLocation <T>(this T location) where T : GroupLocation
 {
     // Create it
     if (location == null)
     {
         return(null);
     }
     else
     {
         return(GroupLocation.FromString <T>(location.ToString()));
     }
 }
コード例 #2
0
        /// <summary>
        /// Stellt den Empfang auf eine bestimmte Quellgruppe eines Ursprungs ein.
        /// </summary>
        /// <remarks>Der Aufruf dieser Methode darf niemals auf mehreren Threads
        /// gleichzeitig erfolgen.</remarks>
        /// <param name="location">Der gewünschte Ursprung.</param>
        /// <param name="group">Die gewünschte Quellgruppe.</param>
        public void SelectGroup(GroupLocation location, SourceGroup group)
        {
            // Report
            if (TunerTraceSwitch.Enabled)
            {
                Trace.WriteLine(string.Format(Properties.Resources.Trace_Tuner_Request, location, group), TunerTraceSwitch.DisplayName);
            }

            // Always use clones
            location = location.CloneLocation();
            group    = group.CloneGroup();

            // Stop all current
            if ((CurrentLocation != null) || (CurrentGroup != null))
            {
                // Report
                if (ConsumerTraceSwitch.Enabled)
                {
                    Trace.WriteLine(Properties.Resources.Trace_Consumer_StoppingAll, ConsumerTraceSwitch.DisplayName);
                }

                // See if provide has a fast way to stop all streams
                bool allStopped = OnStopAll();

                // Stop all table readers
                ResetReader(ref m_networkInformationReader);
                ResetReader(ref m_associationReader);
                ResetReader(ref m_serviceReader);
                m_groupReader = null;

                // Erase list of EPG receivers
                m_programGuideConsumers = null;

                // List of active consumers
                StreamInformation[] consumers;

                // Be safe
                lock (InstanceSynchronizer)
                {
                    // Remember
                    consumers = m_streamsByPID.Values.ToArray();

                    // Wipe out
                    m_streamsByPID.Clear();
                    m_streamsById.Clear();
                }

                // Forward to all streams
                if (!allStopped)
                {
                    foreach (var consumer in consumers)
                    {
                        if (consumer.ActiveConsumerCount > 0)
                        {
                            OnStop(consumer);
                        }
                    }
                }
            }

            // See if something changed
            if (!Equals(location, CurrentLocation) || !Equals(group, CurrentGroup))
            {
                // Report
                if (TunerTraceSwitch.Enabled)
                {
                    Trace.WriteLine(Properties.Resources.Trace_Tuner_Hardware, TunerTraceSwitch.DisplayName);
                }

                // Activate hardware
                OnSelectGroup(location, group);

                // Remember
                CurrentLocation = location;
                CurrentGroup    = group;

                // Mark time
                m_lastTuneTime = DateTime.UtcNow;
            }

            // Restart all readers
            ResetInformationReaders(true);
        }
コード例 #3
0
 /// <summary>
 /// Stellt den Empfang auf eine bestimmte Quellgruppe eines Ursprungs ein.
 /// </summary>
 /// <param name="location">Der gewünschte Ursprung.</param>
 /// <param name="group">Die gewünschte Quellgruppe.</param>
 protected abstract void OnSelectGroup(GroupLocation location, SourceGroup group);
コード例 #4
0
        /// <summary>
        /// Erzeugt eine Informationsinstanz zu einem Ursprung aus eine zusammengehörigen Gruppe von
        /// SI NIT Tabellen eines DVB.NET Gerätes.
        /// </summary>
        /// <typeparam name="G">Die konkrete Art der Quellgruppen.</typeparam>
        /// <typeparam name="L">Die konkrete Art der Information.</typeparam>
        /// <param name="location">Der Usprung, zu dem die Tabellen ermittelt wurden.</param>
        /// <param name="tables">Die SI NIT Tabellengruppe zum noch angewählten Ursprung.</param>
        /// <returns>Eine Informationsisntanz passend zur SI NIT Tabellengruppe oder <i>null</i>.</returns>
        private static L CreateLocationInformation <G, L>(GroupLocation <G> location, NIT[] tables)
            where G : SourceGroup, new()
            where L : LocationInformation <G>, new()
        {
            // None
            if (null == tables)
            {
                return(null);
            }

            // Create the new instance
            L info = new L {
                Location = location
            };

            // Process all groups in all tables
            foreach (var table in tables)
            {
                foreach (var entry in table.Table.NetworkEntries)
                {
                    foreach (var descriptor in entry.Descriptors)
                    {
                        // Start with DVB-S(2)
                        var sat = descriptor as EPG.Descriptors.SatelliteDelivery;
                        if (null != sat)
                        {
                            // Process
                            G group = sat.ToGroup() as G;

                            // Add if possible
                            if (null != group)
                            {
                                info.SourceGroups.Add(group);
                            }

                            // Process next group
                            break;
                        }

                        // Then DVB-C
                        var cab = descriptor as EPG.Descriptors.CableDelivery;
                        if (null != cab)
                        {
                            // Process
                            G group = cab.ToGroup() as G;

                            // Add if possible
                            if (null != group)
                            {
                                info.SourceGroups.Add(group);
                            }

                            // Process next group
                            break;
                        }

                        // Finally DVB-T
                        var ter = descriptor as EPG.Descriptors.TerrestrialDelivery;
                        if (null != ter)
                        {
                            // Process
                            G group = ter.ToGroup() as G;

                            // Add if possible
                            if (null != group)
                            {
                                info.SourceGroups.Add(group);
                            }

                            // Process next group
                            break;
                        }
                    }
                }
            }

            // Report
            return(info);
        }