Пример #1
0
        protected override void OnStart(byte[] filterData, byte[] filterMask)
        {
            // Reset
            m_Bytes = 0;

            // Start in memory filter
            DVBException.ThrowOnError(_SetFilter(m_Class.ClassPointer, BudgetFilterType.Section, FilterPID, filterData, filterMask, (byte)filterData.Length), "Unable to filter PID (section)");
        }
Пример #2
0
        protected override void OnStart()
        {
            // Reset
            m_Bytes = 0;

            // Set up filter
            DVBException.ThrowOnError(_SetFilter(m_Class.ClassPointer, BudgetFilterType.Piping, FilterPID, null, null, (byte)PipeSize.Eight), "Unable to filter PID (piping)");
        }
Пример #3
0
        public void Initialize()
        {
            // Reset
            DVBException.ThrowOnError(_ResetInit(m_Class.ClassPointer), "Unable to initialize board");

            // Relax a bit
            Thread.Sleep(100);
        }
Пример #4
0
        public void Open()
        {
            // Close first
            Close();

            // Process
            DVBException.ThrowOnError(_Open(m_Class.ClassPointer), "Unable to open CI");

            // Remember
            m_Open = true;
        }
Пример #5
0
        internal Channel_C SetChannel(Frontend frontend)
        {
            // Process
            DVBException.ThrowOnError(_SetChannel(frontend.ClassPointer, this, false), "Unable to tune");

            // Get channel once
            GetChannel(frontend);

            // Report second
            return(GetChannel(frontend));
        }
Пример #6
0
        internal static Channel_C GetChannel(Frontend frontend)
        {
            // Create
            Channel_C channel;

            // Process
            DVBException.ThrowOnError(_GetChannel(frontend.ClassPointer, out channel), "Unable to request tune status");

            // Report
            return(channel);
        }
Пример #7
0
        public void Close()
        {
            // Not necessary
            if (!m_Open)
            {
                return;
            }

            // Process
            DVBException.ThrowOnError(_Close(m_Class.ClassPointer), "Unable to close CI");

            // Remember
            m_Open = false;
        }
        /// <summary>
        /// Start decrypting a program.
        /// </summary>
        /// <param name="serviceIdentifier">The service identifier for the program.</param>
        public void Decrypt(ushort serviceIdentifier)
        {
            // Synchronize
            lock (this)
            {
                // Test
                if (!m_Open)
                {
                    throw new DVBException("CI is closed");
                }

                // Forward
                DVBException.ThrowOnError(CDVBComnIF_ReadPSIFast(m_Class.ClassPointer, serviceIdentifier), "unable to start decryption");
            }
        }
        /// <summary>
        /// Close the CI device.
        /// </summary>
        /// <exception cref="DVBException">CI is not open or shutting down
        /// failed.</exception>
        public void Close()
        {
            // Synchronize
            lock (this)
            {
                // Test
                if (!m_Open)
                {
                    throw new DVBException("CI is already closed");
                }

                // Forward
                DVBException.ThrowOnError(CDVBComnIF_Close(m_Class.ClassPointer), "CI could not be closed");

                // Mark
                m_Open = false;
            }
        }
        /// <summary>
        /// Open the CI device.
        /// </summary>
        /// <exception cref="DVBException">CI is already open or opening
        /// failed.</exception>
        public void Open()
        {
            // Synchronize
            lock (this)
            {
                // Test
                if (m_Open)
                {
                    throw new DVBException("CI is already in use");
                }

                // Forward
                DVBException.ThrowOnError(CDVBComnIF_Open(m_Class.ClassPointer), "CI could not be opened");

                // Mark
                m_Open = true;
            }
        }
Пример #11
0
        public void Decrypt(ushort serviceIdentifier)
        {
            // Not active
            if (!m_Open)
            {
                // Nothing to decrypt
                if (0 == serviceIdentifier)
                {
                    return;
                }

                // Open access
                Open();
            }

            // Process
            DVBException.ThrowOnError(_ReadPSIFast(m_Class.ClassPointer, serviceIdentifier), "Unable to activate or deactivate decryption");
        }
Пример #12
0
        /// <summary>
        /// Load the board ARM firmware from the indicated path.
        /// </summary>
        /// <param name="firmwarePath">If the path does not end with a backslash
        /// a backslash is automatically added.</param>
        /// <exception cref="DVBException">
        /// Thrown when the C++ method invocation reports some <see cref="DVBError"/>.
        /// </exception>
        public void BootARM(string firmwarePath)
        {
            // Expand
            if (!firmwarePath.EndsWith(@"\"))
            {
                firmwarePath += @"\";
            }

            // Create string
            using (MFCString pathString = new MFCString(firmwarePath))
                for (int retry = 2; ;)
                {
                    // Try reset first
                    DVBException.ThrowOnError(CDVBBoardControl_ResetInit(m_Class.ClassPointer), "Initialisation failed");

                    try
                    {
                        // Process
                        DVBException.ThrowOnError(CDVBBoardControl_BootARM(m_Class.ClassPointer, pathString.ClassPointer), "Unable to Boot " + firmwarePath);

                        // Done
                        break;
                    }
                    catch (DVBException e)
                    {
                        // Not a hardware error
                        if (DVBError.Hardware != e.ErrorCode)
                        {
                            throw e;
                        }

                        // Retry through
                        if (--retry < 1)
                        {
                            throw e;
                        }

                        // Delay before retry
                        System.Threading.Thread.Sleep(1000);
                    }
                }
        }
Пример #13
0
        /// <summary>
        /// Aktiviert den Empfang.
        /// </summary>
        /// <param name="pattern">Das Vergleichsmuster für den Empfang.</param>
        /// <param name="mask">Die Auswahl der Vergleichbits.</param>
        public void Start(byte[] pattern, byte[] mask)
        {
            // Check size
            if ((pattern == null) != (mask == null))
            {
                throw new ArgumentException("Filter Data and Mask do not match");
            }
            if (pattern != null)
            {
                // Validate
                if (pattern.Length != mask.Length)
                {
                    throw new ArgumentException("Filter Data and Mask are not of same Size");
                }
                if (pattern.Length > 255)
                {
                    throw new ArgumentException("Filter Data and Mask are too large - a Maximum of 255 Bytes is allowed");
                }
            }

            // Length to send
            var bLenParam = (byte)((pattern == null) ? 0 : pattern.Length);

            // Piping
            if (FilterType == FilterType.Piping)
            {
                // Validate
                if (pattern != null)
                {
                    throw new ArgumentException("Piping does not allow Filter Data and Mask");
                }

                // Set buffer parameter
                bLenParam = (byte)((UseExplicitBuffer != PipeSize.None) ? UseExplicitBuffer : PipeSize.ThirtyTwo);
            }

            // Try to start the current filter
            DVBException.ThrowOnError(CDVBTSFilter_SetFilter(m_Class.ClassPointer, FilterType, m_streamIdentifier, pattern, mask, bLenParam), "Could not filter");
        }
Пример #14
0
 private void CheckChannel(DVBError errorCode)
 {
     // Validate
     DVBException.ThrowOnError(errorCode, "Unable to set channel");
 }
Пример #15
0
 /// <summary>
 /// Beendet den Empfang kurzzeitig.
 /// </summary>
 private void Suspend()
 {
     // Check operation
     DVBException.ThrowOnError(CDVBTSFilter_ResetFilter(m_Class.ClassPointer), "Could not stop the Filter");
 }
Пример #16
0
 /// <summary>
 /// Legt die Nutzdatenströme fest.
 /// </summary>
 /// <param name="audio">Der Datenstrom für die Stereo-Tonspur.</param>
 /// <param name="video">Das Datenstrom des Bildsignals.</param>
 /// <param name="clock">Der Datenstrom, der den Zeitgeber mit sich führt.</param>
 public void SetPIDs(ushort audio, ushort video, ushort clock)
 {
     // Execute
     DVBException.ThrowOnError(CDVBAVControl_SetPIDs(m_Class.ClassPointer, audio, video, clock), "Unable to set all PIDs at once");
 }
Пример #17
0
 /// <summary>
 /// Initialize the A/V control.
 /// </summary>
 /// <exception cref="DVBException">
 /// Thrown when the C++ method invocation reports some <see cref="DVBError"/>.
 /// </exception>
 public void Initialize()
 {
     // Execute
     DVBException.ThrowOnError(CDVBAVControl_Init(m_Class.ClassPointer, false), "Can not initialize Audio/Video Control");
 }
Пример #18
0
        /// <summary>
        /// Wählt eine Quellgruppe aus.
        /// </summary>
        /// <param name="group">Díe Daten der Quellgruppe.</param>
        /// <param name="location">Die Wahl des Ursprungs, über den die Quellgruppe empfangen werden kann.</param>
        /// <returns>Gesetzt, wenn es sich um eine DVB-S Quellgruppe handelt.</returns>
        private bool SendChannel(SatelliteGroup group, SatelliteLocation location)
        {
            // Not us
            if (location == null)
            {
                return(false);
            }
            if (group == null)
            {
                return(false);
            }

            // Validate
            if (FrontendType != FrontendType.Satellite)
            {
                throw new DVBException("Expected " + FrontendType.ToString() + " Channel");
            }

            // Create channel
            var channel =
                new Channel_S
            {
                Inversion  = SpectrumInversion.Auto,
                SymbolRate = group.SymbolRate,
                Frequency  = group.Frequency,
            };

            // Attach to the DiSEqC setting
            var selector = StandardDiSEqC.FromSourceGroup(group, location);

            // See if the message is different from the last one
            if (!selector.Equals(m_lastMessage))
            {
                // Remember
                m_lastMessage = selector.Clone();

                // As long as necessary
                for (int nCount = selector.Repeat; nCount-- > 0; Thread.Sleep(120))
                {
                    // Send it
                    DVBException.ThrowOnError(CDVBFrontend_SendDiSEqCMsg(m_Class.ClassPointer, selector.Request, (byte)selector.Request.Length, selector.Burst), "Could not send DiSEqC Message");

                    // Set repeat flag
                    if (selector.Request.Length > 0)
                    {
                        selector.Request[0] |= 1;
                    }
                }
            }

            // Calculated items
            channel.b22kHz = (group.Frequency >= location.SwitchFrequency) ? 1 : 0;
            channel.LOF    = (0 == channel.b22kHz) ? location.Frequency1 : location.Frequency2;

            // Power modes
            switch (group.Polarization)
            {
            case Polarizations.Horizontal: channel.LNBPower = PowerMode.Horizontal; break;

            case Polarizations.Vertical: channel.LNBPower = PowerMode.Vertical; break;

            case Polarizations.NotDefined: channel.LNBPower = PowerMode.Off; break;

            default: throw new ArgumentException(group.Polarization.ToString(), "Polarization");
            }

            // Process
            CheckChannel(CDVBFrontend_SetChannel(m_Class.ClassPointer, channel, false));

            // Check up for synchronisation
            Channel_S val1, val2;

            // Get channel twice
            CheckChannel(CDVBFrontend_GetChannel(m_Class.ClassPointer, out val1));
            CheckChannel(CDVBFrontend_GetChannel(m_Class.ClassPointer, out val2));

            // Did it
            return(true);
        }
Пример #19
0
        /// <summary>
        /// Wählt eine Quellgruppe aus.
        /// </summary>
        /// <param name="group">Díe Daten der Quellgruppe.</param>
        /// <param name="location">Die Wahl des Ursprungs, über den die Quellgruppe empfangen werden kann.</param>
        /// <returns>Gesetzt, wenn es sich um eine DVB-S Quellgruppe handelt.</returns>
        private Channel_S?Tune(SatelliteGroup group, SatelliteLocation location)
        {
            // Not us
            if (location == null)
            {
                return(null);
            }
            if (group == null)
            {
                return(null);
            }

            // Validate
            if (FrontendType != FrontendType.Satellite)
            {
                throw new DVBException("Expected " + FrontendType.ToString() + " Channel");
            }

            // Create channel
            var data =
                new Channel_S
            {
                Mode       = group.UsesS2Modulation ? DVBSMode.DVB_S2 : DVBSMode.DVB_S,
                Inversion  = SpectrumInversion.Auto,
                SymbolRate = group.SymbolRate,
                Frequency  = group.Frequency,
            };


            // Attach to the DiSEqC setting
            var selector = StandardDiSEqC.FromSourceGroup(group, location);

            // See if the message is different from the last one
            if (!selector.Equals(m_lastMessage))
            {
                // Remember
                m_lastMessage = selector.Clone();

                // As long as necessary
                for (int nCount = selector.Repeat; nCount-- > 0; Thread.Sleep(120))
                {
                    // Send it
                    DVBException.ThrowOnError(_SendDiSEqCMsg(m_Class.ClassPointer, selector.Request, (byte)selector.Request.Length, selector.Burst), "Could not send DiSEqC message");

                    // Set repeat flag
                    if (selector.Request.Length > 0)
                    {
                        selector.Request[0] |= 1;
                    }
                }
            }

            // Calculated items
            data.b22kHz = (group.Frequency >= location.SwitchFrequency) ? 1 : 0;
            data.LOF    = (0 == data.b22kHz) ? location.Frequency1 : location.Frequency2;

            // Power modes
            switch (group.Polarization)
            {
            case Polarizations.Horizontal: data.LNBPower = PowerMode.Horizontal; break;

            case Polarizations.Vertical: data.LNBPower = PowerMode.Vertical; break;

            case Polarizations.NotDefined: data.LNBPower = PowerMode.Off; break;

            default: throw new ArgumentException(group.Polarization.ToString(), "Polarization");
            }

            // Process
            return(data.SetChannel(this, false));
        }
Пример #20
0
 public void EnableDMA()
 {
     // Enable DMA
     DVBException.ThrowOnError(_EnableDataDMA(m_Class.ClassPointer, true), "Unable to activate DMA");
 }