/// <summary> /// Erzeugt eine neue Verwaltung. /// </summary> /// <param name="hardware">Das zu verwendende DVB.NET Gerät.</param> /// <param name="pid">Die gewünschte Datenstromkennung.</param> /// <param name="type">Die Art des Datenstroms.</param> /// <param name="name">Der Name dieses Eintrags.</param> /// <param name="videoType">Gesetzt, wenn es sich um ein HDTV Bildsignal handelt. Ist der /// Datenstrom kein Bildsignal, so wird <i>null</i> verwendet.</param> public StreamItem(Hardware hardware, ushort pid, StreamTypes type, string name, bool?videoType) : base(string.Format("{0} ({1})", name, pid)) { // Create rate indicator SubItems.Add("?"); SubItems.Add(string.Empty); // Reset m_Total = (long)0; // Remember m_Hardware = hardware; // Register m_ConsumerId = m_Hardware.AddConsumer(pid, type, OnData); // Create decoder if (videoType.HasValue) { if (videoType.Value) { m_StreamDecoder = new HDTVStream(this, 512, true); } else { m_StreamDecoder = new VideoStream(this, 512, true); } } // Start it m_Hardware.SetConsumerState(m_ConsumerId, true); }
/// <summary> /// Erzeugt eine neue Verwaltung. /// </summary> /// <param name="hardware">Das zu verwendende DVB.NET Gerät.</param> /// <param name="pid">Die gewünschte Datenstromkennung.</param> /// <param name="type">Die Art des Datenstroms.</param> /// <param name="name">Der Name dieses Eintrags.</param> /// <param name="videoType">Gesetzt, wenn es sich um ein HDTV Bildsignal handelt. Ist der /// Datenstrom kein Bildsignal, so wird <i>null</i> verwendet.</param> public StreamItem( Hardware hardware, ushort pid, StreamTypes type, string name, bool? videoType ) : base( string.Format( "{0} ({1})", name, pid ) ) { // Create rate indicator SubItems.Add( "?" ); SubItems.Add( string.Empty ); // Reset m_Total = (long) 0; // Remember m_Hardware = hardware; // Register m_ConsumerId = m_Hardware.AddConsumer( pid, type, OnData ); // Create decoder if (videoType.HasValue) if (videoType.Value) m_StreamDecoder = new HDTVStream( this, 512, true ); else m_StreamDecoder = new VideoStream( this, 512, true ); // Start it m_Hardware.SetConsumerState( m_ConsumerId, true ); }
/// <summary> /// Führt den eigentliche Zugriff aus. /// </summary> private void Worker() { // Be fully safe try { // With hardware using (HardwareManager.Open()) { // Attach to group PlugIn.LastSource.SelectGroup(); // Attach to device Hardware device = PlugIn.LastSource.GetHardware(); // Create parser m_Parser = TableParser.Create <GenericTable>(OnTable); // Register raw stream Guid consumerId = device.AddConsumer(m_Stream, m_Extended ? StreamTypes.ExtendedTable : StreamTypes.StandardTable, OnData); // Start it device.SetConsumerState(consumerId, true); // Process while (null != m_Worker) { Thread.Sleep(100); } // Stop all device.SetConsumerState(consumerId, null); } } catch { } // Close the file using (BinaryWriter writer = m_TargetFile) m_TargetFile = null; // Did it Invoke(new Action(AdminSite.OperationDone)); }
/// <summary> /// Steuerung der Aktivierung der Programmzeitschrift. /// </summary> /// <param name="device">Das aktuell verwendete DVB.NET Gerät.</param> private void CollectProgramGuide(Hardware device) { // Not necessary if (!EPGProgress.HasValue) { return; } // Be safe try { // Load interval once if (!EPGItemCountCheckInterval.HasValue) { try { // Load setting string interval = ConfigurationManager.AppSettings["CardServerProgramGuideCountCheckInterval"]; // Load data uint value; if (!string.IsNullOrEmpty(interval)) { if (uint.TryParse(interval, out value)) { if ((value > 0) && (value < int.MaxValue)) { EPGItemCountCheckInterval = (int)value; } } } } finally { // Load default if (!EPGItemCountCheckInterval.HasValue) { EPGItemCountCheckInterval = 10; } } } // Time since we last checked the item count TimeSpan countDelta = DateTime.UtcNow - m_EPGLastItemCheck; // Must recheck if (countDelta.TotalSeconds >= EPGItemCountCheckInterval.Value) { if (m_EPGLastItemCount == m_EPGItemCount) { // Early stop m_EPGLastTune = DateTime.MinValue; } else { // Remember item count m_EPGLastItemCheck = DateTime.UtcNow; m_EPGLastItemCount = m_EPGItemCount; } } // Read the interval since the last tune TimeSpan delta = DateTime.UtcNow - m_EPGLastTune; // Check for change interval if (delta.TotalSeconds < 60) { return; } // Always shut down receivers device.SelectGroup(null, null); // Get the current state int total = m_EPGGroups.Count, left = m_EPGPending.Count; // Set the progress value if (total < 1) { EPGProgress = 1; } else { EPGProgress = 1.0 * (total - left) / total; } // See if we are fully done if (left < 1) { return; } // Load next GroupKey next = m_EPGPending[0]; // Remove from list m_EPGPending.RemoveAt(0); // Tune to transponder device.SelectGroup(next.Location, next.Group); // See if there is something on this group if (null == device.GetGroupInformation(5000)) { // Push back m_EPGPending.Add(next); // Next after a short delay return; } // Add standard EPG device.AddProgramGuideConsumer(OnStandardEPGEvent); // Check PREMIERE Direct if (0 != (m_EPGExtensions & EPGExtensions.PREMIEREDirect)) { foreach (SourceSelection selection in Profile.FindSource(DirectCIT.TriggerSource)) { if (Equals(selection.Location, device.CurrentLocation)) { if (Equals(selection.Group, device.CurrentGroup)) { // Register device.SetConsumerState(device.AddConsumer <DirectCIT>(OnPremiereEPGEvent), true); // Did it break; } } } } // Check PREMIERE Sport if (0 != (m_EPGExtensions & EPGExtensions.PREMIERESport)) { foreach (SourceSelection selection in Profile.FindSource(SportCIT.TriggerSource)) { if (Equals(selection.Location, device.CurrentLocation)) { if (Equals(selection.Group, device.CurrentGroup)) { // Register device.SetConsumerState(device.AddConsumer <SportCIT>(OnPremiereEPGEvent), true); // Did it break; } } } } // Check FreeSat UK if (0 != (m_EPGExtensions & EPGExtensions.FreeSatUK)) { foreach (SourceSelection selection in Profile.FindSource(EIT.FreeSatEPGTriggerSource)) { if (Equals(selection.Location, device.CurrentLocation)) { if (Equals(selection.Group, device.CurrentGroup)) { // Register Guid consumerId = device.AddConsumer <EIT>(EIT.FreeSatEPGPID, OnStandardEPGEvent); device.SetConsumerState(consumerId, true); // Did it break; } } } } // Reset time m_EPGLastTune = DateTime.UtcNow; // Remember item count m_EPGLastItemCheck = DateTime.UtcNow; m_EPGLastItemCount = m_EPGItemCount; } catch { // Just go on } }
/// <summary> /// Steuerung der Aktivierung der Programmzeitschrift. /// </summary> /// <param name="device">Das aktuell verwendete DVB.NET Gerät.</param> private void CollectProgramGuide( Hardware device ) { // Not necessary if (!EPGProgress.HasValue) return; // Be safe try { // Load interval once if (!EPGItemCountCheckInterval.HasValue) try { // Load setting string interval = ConfigurationManager.AppSettings["CardServerProgramGuideCountCheckInterval"]; // Load data uint value; if (!string.IsNullOrEmpty( interval )) if (uint.TryParse( interval, out value )) if ((value > 0) && (value < int.MaxValue)) EPGItemCountCheckInterval = (int) value; } finally { // Load default if (!EPGItemCountCheckInterval.HasValue) EPGItemCountCheckInterval = 10; } // Time since we last checked the item count TimeSpan countDelta = DateTime.UtcNow - m_EPGLastItemCheck; // Must recheck if (countDelta.TotalSeconds >= EPGItemCountCheckInterval.Value) if (m_EPGLastItemCount == m_EPGItemCount) { // Early stop m_EPGLastTune = DateTime.MinValue; } else { // Remember item count m_EPGLastItemCheck = DateTime.UtcNow; m_EPGLastItemCount = m_EPGItemCount; } // Read the interval since the last tune TimeSpan delta = DateTime.UtcNow - m_EPGLastTune; // Check for change interval if (delta.TotalSeconds < 60) return; // Always shut down receivers device.SelectGroup( null, null ); // Get the current state int total = m_EPGGroups.Count, left = m_EPGPending.Count; // Set the progress value if (total < 1) EPGProgress = 1; else EPGProgress = 1.0 * (total - left) / total; // See if we are fully done if (left < 1) return; // Load next GroupKey next = m_EPGPending[0]; // Remove from list m_EPGPending.RemoveAt( 0 ); // Tune to transponder device.SelectGroup( next.Location, next.Group ); // See if there is something on this group if (null == device.GetGroupInformation( 5000 )) { // Push back m_EPGPending.Add( next ); // Next after a short delay return; } // Add standard EPG device.AddProgramGuideConsumer( OnStandardEPGEvent ); // Check PREMIERE Direct if (0 != (m_EPGExtensions & EPGExtensions.PREMIEREDirect)) foreach (SourceSelection selection in Profile.FindSource( DirectCIT.TriggerSource )) if (Equals( selection.Location, device.CurrentLocation )) if (Equals( selection.Group, device.CurrentGroup )) { // Register device.SetConsumerState( device.AddConsumer<DirectCIT>( OnPremiereEPGEvent ), true ); // Did it break; } // Check PREMIERE Sport if (0 != (m_EPGExtensions & EPGExtensions.PREMIERESport)) foreach (SourceSelection selection in Profile.FindSource( SportCIT.TriggerSource )) if (Equals( selection.Location, device.CurrentLocation )) if (Equals( selection.Group, device.CurrentGroup )) { // Register device.SetConsumerState( device.AddConsumer<SportCIT>( OnPremiereEPGEvent ), true ); // Did it break; } // Check FreeSat UK if (0 != (m_EPGExtensions & EPGExtensions.FreeSatUK)) foreach (SourceSelection selection in Profile.FindSource( EIT.FreeSatEPGTriggerSource )) if (Equals( selection.Location, device.CurrentLocation )) if (Equals( selection.Group, device.CurrentGroup )) { // Register Guid consumerId = device.AddConsumer<EIT>( EIT.FreeSatEPGPID, OnStandardEPGEvent ); device.SetConsumerState( consumerId, true ); // Did it break; } // Reset time m_EPGLastTune = DateTime.UtcNow; // Remember item count m_EPGLastItemCheck = DateTime.UtcNow; m_EPGLastItemCount = m_EPGItemCount; } catch { // Just go on } }
/// <summary> /// Zeigt Bild, Ton und Videotext an. /// </summary> /// <param name="audio">Die zu verwendende Tonspur.</param> private void Activate(AudioInformation audio) { // Stop current StopReceivers(true); // Reset anything in queue Accessor.ClearBuffers(); // Mode of operation bool mpeg4 = ((0 != CurrentSourceConfiguration.VideoStream) && (VideoTypes.H264 == CurrentSourceConfiguration.VideoType)), ac3 = false; // Configure video if (0 != CurrentSourceConfiguration.VideoStream) { VideoId = Device.AddConsumer(CurrentSourceConfiguration.VideoStream, StreamTypes.Video, Accessor.AddVideo); } // Use default audio if (null == audio) { if (CurrentSourceConfiguration.AudioTracks.Count > 0) { audio = CurrentSourceConfiguration.AudioTracks[0]; } } // Configure audio if (null != audio) { // Remember the type ac3 = (AudioTypes.AC3 == audio.AudioType); // Create the filter AudioId = Device.AddConsumer(audio.AudioStream, StreamTypes.Audio, Accessor.AddAudio); } // Remember for update CurrentAudio = audio; // Start streaming Device.SetConsumerState(VideoId, true); Device.SetConsumerState(AudioId, true); // Check for video text if (0 != CurrentSourceConfiguration.TextStream) { // Create the PES analyser TTXStream stream = new TTXStream(m_TTXConnector, (short)CurrentSourceConfiguration.TextStream, false); // Create the filter TextId = Device.AddConsumer(CurrentSourceConfiguration.TextStream, StreamTypes.VideoText, stream.AddPayload); // Start the filter Device.SetConsumerState(TextId, true); } // Now restart data transmission Accessor.StartGraph(mpeg4, ac3); // Enable service parser if we are allowed to to so if (!Profile.DisableProgramGuide) { if (!Profile.GetFilter(CurrentSelection.Source).DisableProgramGuide) { Device.AddProgramGuideConsumer(ReceiveEPG); } } }