Example #1
0
        /// <summary>
        /// Entschlüsselt eine einzelne Quelle.
        /// </summary>
        /// <param name="service">Die Informationen zur Quelle.</param>
        /// <param name="graph">Der zu verwendende Graph.</param>
        public void Decrypt(ushort service, DataGraph graph)
        {
            // Check COM interface
            var controlPtr = ComIdentity.QueryInterface(graph.AdditionalFilters[m_filterIndex].Interface, typeof(KsControl.Interface));

            if (controlPtr != IntPtr.Zero)
            {
                using (var control = new KsControl(controlPtr))
                    control.SetServices(service);
            }
        }
Example #2
0
        /// <summary>
        /// Aktiviert die Entschlüsselung einer Quelle.
        /// </summary>
        /// <param name="token">Informationen zur gewählten Quelle.</param>
        public PipelineResult Decrypt(DataGraph.DecryptToken token)
        {
            // Load graph
            if (token != null)
            {
                m_dataGraph = token.Pipeline.Graph;
            }

            // Get unique call identifier
            var callIdentifier = Interlocked.Increment(ref m_changeCounter);

            // See if we can do anything
            if (m_dataGraph == null)
            {
                return(PipelineResult.Continue);
            }
            if (m_filterIndex < 0)
            {
                return(PipelineResult.Continue);
            }
            if (m_filterIndex >= m_dataGraph.AdditionalFilters.Count)
            {
                return(PipelineResult.Continue);
            }

            // Deactivate if CAM reset is forbidden
            var sources   = (token == null) ? null : token.Sources;
            var noSources = (sources == null) || (sources.Length < 1);

            if ((noSources && (m_suppress != SuppressionMode.Complete)) || !m_hasBeenReset)
            {
                lock (m_deviceAccess)
                {
                    // Check COM interface
                    var controlPtr = ComIdentity.QueryInterface(m_dataGraph.AdditionalFilters[m_filterIndex].Interface, typeof(KsControl.Interface));
                    if (controlPtr == IntPtr.Zero)
                    {
                        return(PipelineResult.Continue);
                    }

                    // Process
                    using (var control = new KsControl(controlPtr))
                    {
                        // Report
                        if (BDASettings.BDATraceSwitch.Enabled)
                        {
                            Trace.WriteLine(Properties.Resources.Trace_ResetCAM, BDASettings.BDATraceSwitch.DisplayName);
                        }

                        // Reset the CAM
                        control.Reset();

                        // We did it once
                        m_hasBeenReset = true;
                    }
                }
            }

            // Start processor
            token.WaitForPMTs(
                (pmt, first) =>
            {
                // See if we are still allowed to process and do so
                lock (m_deviceAccess)
                {
                    // No longer current
                    if (Thread.VolatileRead(ref m_changeCounter) != callIdentifier)
                    {
                        return(false);
                    }

                    // Try reset
                    if (!first)
                    {
                        if (m_disableOnChange)
                        {
                            Decrypt(0, m_dataGraph);
                        }
                    }

                    // Wait for it
                    if (m_changeDelay > 0)
                    {
                        Thread.Sleep(m_changeDelay);
                    }

                    // Regular
                    Decrypt(pmt.ProgramNumber, m_dataGraph);
                }

                // Next
                return(true);
            }, sources);

            // Next
            return(PipelineResult.Continue);
        }