[mythtv] [PATCH] Enable recording of encrypted channels without decrypting them first.

James Courtier-Dutton james.dutton at gmail.com
Fri Jul 9 00:42:22 UTC 2010


Hi,

Here is a patch that lets one record encrypted channels without
decrypting them first.
It also includes the ECM PID so that the recording can be later
decrypted at playback time.
The main advantage of this is that one can then record as many
encrypted channels as one has tuners, and then later, using the
correct smart card, decrypt them while playing them back.
In this way, you only have to decrypt one channel at a time.

I would be interested to find out if this patch breaks anything.

Kind Regards

James
-------------- next part --------------
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/dtvsignalmonitor.cpp mythtv-0.23.0+fixes24158/libs/libmythtv/dtvsignalmonitor.cpp
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/dtvsignalmonitor.cpp	2010-03-07 03:11:52.000000000 +0000
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/dtvsignalmonitor.cpp	2010-07-09 00:44:18.959896007 +0100
@@ -515,8 +515,9 @@
             return false;
     if ((flags & kDTVSigMon_WaitForSDT) && !matchingSDT.IsGood())
             return false;
-    if ((flags & kDTVSigMon_WaitForCrypt) && !matchingCrypt.IsGood())
-            return false;
+// FIXME: commented out by JCD.
+//    if ((flags & kDTVSigMon_WaitForCrypt) && !matchingCrypt.IsGood())
+//            return false;
 
     return true;
 }
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/dvbrecorder.cpp mythtv-0.23.0+fixes24158/libs/libmythtv/dvbrecorder.cpp
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/dvbrecorder.cpp	2010-04-05 15:44:05.000000000 +0100
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/dvbrecorder.cpp	2010-07-07 20:12:57.659896028 +0100
@@ -517,6 +517,15 @@
     return true;
 }
 
+bool DVBRecorder::ProcessEncTSPacket(const TSPacket &tspacket)
+{
+    const uint pid = tspacket.PID();
+    
+    _buffer_packets = false;
+    BufferedWrite(tspacket);
+    return true;
+}
+
 bool DVBRecorder::ProcessTSPacket(const TSPacket &tspacket)
 {
     const uint pid = tspacket.PID();
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/dvbrecorder.h mythtv-0.23.0+fixes24158/libs/libmythtv/dvbrecorder.h
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/dvbrecorder.h	2010-03-07 03:11:52.000000000 +0000
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/dvbrecorder.h	2010-07-07 20:05:09.959896185 +0100
@@ -85,6 +85,7 @@
 
     // TSPacketListener
     bool ProcessTSPacket(const TSPacket &tspacket);
+    bool ProcessEncTSPacket(const TSPacket &tspacket);
 
     // TSPacketListenerAV
     bool ProcessVideoTSPacket(const TSPacket& tspacket);
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/hdhrrecorder.cpp mythtv-0.23.0+fixes24158/libs/libmythtv/hdhrrecorder.cpp
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/hdhrrecorder.cpp	2010-03-07 03:11:52.000000000 +0000
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/hdhrrecorder.cpp	2010-07-07 20:05:09.959896185 +0100
@@ -452,6 +452,15 @@
     return true;
 }
 
+bool HDHRRecorder::ProcessEncTSPacket(const TSPacket &tspacket)
+{
+    const uint pid = tspacket.PID();
+    VERBOSE(VB_GENERAL, LOC +
+                QString("HDHRRecorder:EncTS").arg(pid,0,16));
+
+    return true;
+}
+
 bool HDHRRecorder::ProcessTSPacket(const TSPacket &tspacket)
 {
     // Only create fake keyframe[s] if there are no audio/video streams
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/hdhrrecorder.h mythtv-0.23.0+fixes24158/libs/libmythtv/hdhrrecorder.h
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/hdhrrecorder.h	2009-08-04 14:48:39.000000000 +0100
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/hdhrrecorder.h	2010-07-07 20:05:09.959896185 +0100
@@ -68,6 +68,7 @@
 
     // TSPacketListener
     bool ProcessTSPacket(const TSPacket &tspacket);
+    bool ProcessEncTSPacket(const TSPacket &tspacket);
 
     // TSPacketListenerAV
     bool ProcessVideoTSPacket(const TSPacket& tspacket);
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/mpeg/mpegstreamdata.cpp mythtv-0.23.0+fixes24158/libs/libmythtv/mpeg/mpegstreamdata.cpp
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/mpeg/mpegstreamdata.cpp	2010-03-07 03:11:52.000000000 +0000
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/mpeg/mpegstreamdata.cpp	2010-07-09 00:47:12.851146204 +0100
@@ -549,10 +549,20 @@
     for (uint i = 0; i < pmt.StreamCount(); i++)
     {
         uint pid = pmt.StreamPID(i);
-
+#if 0
         desc_list_t desc = MPEGDescriptor::ParseAndExclude(
             pmt.StreamInfo(i), pmt.StreamInfoLength(i),
             DescriptorID::conditional_access);
+#endif
+        desc_list_t desc = MPEGDescriptor::Parse(
+            pmt.StreamInfo(i), pmt.StreamInfoLength(i));
+	for (uint i2 = 0; i2 < desc.size(); i2++) {
+		if (DescriptorID::conditional_access == MPEGDescriptor(desc[i2]).DescriptorTag()) {
+			uint ca_pid;
+			ca_pid = ConditionalAccessDescriptor(desc[i2]).PID();
+			dataPIDs.push_back(ca_pid);
+		}
+	}
 
         uint type = StreamID::Normalize(
             pmt.StreamType(i), desc, _sistandard);
@@ -1009,6 +1019,10 @@
         // PCRPID and other streams we're writing may not have payload...
         for (uint j = 0; j < _ts_writing_listeners.size(); j++)
             _ts_writing_listeners[j]->ProcessTSPacket(tspacket);
+    } else if (tspacket.ScramplingControl())
+    {
+        for (uint j = 0; j < _ts_writing_listeners.size(); j++)
+            _ts_writing_listeners[j]->ProcessEncTSPacket(tspacket);
     }
 
     return true;
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/mpeg/streamlisteners.h mythtv-0.23.0+fixes24158/libs/libmythtv/mpeg/streamlisteners.h
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/mpeg/streamlisteners.h	2009-04-19 23:07:22.000000000 +0100
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/mpeg/streamlisteners.h	2010-07-07 20:05:09.959896185 +0100
@@ -51,6 +51,7 @@
 {
   public:
     virtual bool ProcessTSPacket(const TSPacket& tspacket) = 0;
+    virtual bool ProcessEncTSPacket(const TSPacket& tspacket) = 0;
 
   protected:
     virtual ~TSPacketListener() { }
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/mpegrecorder.cpp mythtv-0.23.0+fixes24158/libs/libmythtv/mpegrecorder.cpp
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/mpegrecorder.cpp	2010-04-05 15:44:05.000000000 +0100
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/mpegrecorder.cpp	2010-07-07 20:05:09.959896185 +0100
@@ -1288,6 +1288,14 @@
     recording_wait.wakeAll();
 }
 
+bool MpegRecorder::ProcessEncTSPacket(const TSPacket &tspacket_real)
+{
+    const uint pid = tspacket_real.PID();
+    VERBOSE(VB_GENERAL, LOC +
+                QString("MpegRecorder:EncTS").arg(pid,0,16));
+    return true;
+}
+
 bool MpegRecorder::ProcessTSPacket(const TSPacket &tspacket_real)
 {
     const uint pid = tspacket_real.PID();
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/mpegrecorder.h mythtv-0.23.0+fixes24158/libs/libmythtv/mpegrecorder.h
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/mpegrecorder.h	2010-03-07 03:11:52.000000000 +0000
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/mpegrecorder.h	2010-07-07 20:05:09.959896185 +0100
@@ -50,6 +50,7 @@
 
     // TSPacketListener
     bool ProcessTSPacket(const TSPacket &tspacket);
+    bool ProcessEncTSPacket(const TSPacket &tspacket);
 
     // TSPacketListenerAV
     bool ProcessVideoTSPacket(const TSPacket &tspacket);
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/signalmonitor.h mythtv-0.23.0+fixes24158/libs/libmythtv/signalmonitor.h
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/signalmonitor.h	2010-03-07 03:11:52.000000000 +0000
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/signalmonitor.h	2010-07-08 09:02:21.915713296 +0100
@@ -67,7 +67,10 @@
     bool HasSignalLock(void) const
     {
         QMutexLocker locker(&statusLock);
-        return signalLock.IsGood();
+        bool signal = signalLock.IsGood();
+	VERBOSE(VB_IMPORTANT, 
+                QString("HasSignalLock %1").arg(signal));
+	return signal;
     }
 
     virtual bool IsAllGood(void) const { return HasSignalLock(); }
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/signalmonitorvalue.h mythtv-0.23.0+fixes24158/libs/libmythtv/signalmonitorvalue.h
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/signalmonitorvalue.h	2010-03-07 03:11:52.000000000 +0000
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/signalmonitorvalue.h	2010-07-08 09:01:33.309896174 +0100
@@ -52,6 +52,8 @@
     ///        right side of the threshold (depends on IsHighThreashold()).
     bool IsGood() const
     {
+	VERBOSE(VB_IMPORTANT, "SignalMonitorValue->IsGood " +
+		QString("name %1, value %2, threshold %3, high %4").arg(GetName()).arg(value).arg(threshold).arg(high_threshold));
         return (high_threshold) ? value >= threshold : value <= threshold;
     }
     /// \brief Returns the value normalized to the [newmin, newmax] range.
diff -ur mythtv-0.23.0+fixes24158.org/libs/libmythtv/tv_rec.cpp mythtv-0.23.0+fixes24158/libs/libmythtv/tv_rec.cpp
--- mythtv-0.23.0+fixes24158.org/libs/libmythtv/tv_rec.cpp	2010-03-26 11:25:57.000000000 +0000
+++ mythtv-0.23.0+fixes24158/libs/libmythtv/tv_rec.cpp	2010-07-09 00:48:15.990437632 +0100
@@ -3863,9 +3863,11 @@
 MPEGStreamData *TVRec::TuningSignalCheck(void)
 {
     if (signalMonitor->IsAllGood())
-        VERBOSE(VB_RECORD, LOC + "Got good signal");
-    else if (!signalMonitor->IsErrored())
+        VERBOSE(VB_IMPORTANT, LOC + "Got good signal");
+    else if (!signalMonitor->IsErrored()) {
+        VERBOSE(VB_IMPORTANT, LOC + "Exiting TuningSignalCheck via signalMonior->IsErrored");
         return NULL;
+    }
 
     // grab useful data from DTV signal monitor before we kill it...
     MPEGStreamData *streamData = NULL;


More information about the mythtv-dev mailing list