| 1 | From 5638a2a40bba939604200aa0c330b819313f89ac Mon Sep 17 00:00:00 2001
|
|---|
| 2 | From: root <SHinck@web.de>
|
|---|
| 3 | Date: Sun, 9 Jun 2013 22:06:24 +0200
|
|---|
| 4 | Subject: [PATCH] Fix for decrypting 2 channels in parallel.
|
|---|
| 5 |
|
|---|
| 6 | If CAM-Module decrypts one channel it's now possible to add a second
|
|---|
| 7 | recording which needs also decryption without destroying the first or
|
|---|
| 8 | both recordings. During LiveTV it speeds up decryption at channel
|
|---|
| 9 | changes.
|
|---|
| 10 | ---
|
|---|
| 11 | mythtv/libs/libmythtv/dtvrecorder.cpp | 1 +
|
|---|
| 12 | mythtv/libs/libmythtv/dtvsignalmonitor.cpp | 11 ----
|
|---|
| 13 | mythtv/libs/libmythtv/dtvsignalmonitor.h | 2 -
|
|---|
| 14 | mythtv/libs/libmythtv/dvbcam.cpp | 86 +++++++++++++++++++++----
|
|---|
| 15 | mythtv/libs/libmythtv/dvbcam.h | 1 +
|
|---|
| 16 | mythtv/libs/libmythtv/dvbchannel.cpp | 4 ++
|
|---|
| 17 | mythtv/libs/libmythtv/dvbrecorder.cpp | 3 +
|
|---|
| 18 | mythtv/libs/libmythtv/dvbsignalmonitor.cpp | 15 +++--
|
|---|
| 19 | mythtv/libs/libmythtv/mpeg/mpegstreamdata.cpp | 2 +-
|
|---|
| 20 | 9 files changed, 94 insertions(+), 31 deletions(-)
|
|---|
| 21 |
|
|---|
| 22 | diff --git a/mythtv/libs/libmythtv/dtvrecorder.cpp b/mythtv/libs/libmythtv/dtvrecorder.cpp
|
|---|
| 23 | index c87ed36..489d73b 100644
|
|---|
| 24 | --- a/mythtv/libs/libmythtv/dtvrecorder.cpp
|
|---|
| 25 | +++ b/mythtv/libs/libmythtv/dtvrecorder.cpp
|
|---|
| 26 | @@ -1222,6 +1222,7 @@ void DTVRecorder::HandlePMT(uint progNum, const ProgramMapTable *_pmt)
|
|---|
| 27 | }
|
|---|
| 28 | _has_no_av = has_no_av;
|
|---|
| 29 |
|
|---|
| 30 | + _stream_data->TestDecryption(_input_pmt);
|
|---|
| 31 | SetCAMPMT(_input_pmt);
|
|---|
| 32 | delete oldpmt;
|
|---|
| 33 | }
|
|---|
| 34 | diff --git a/mythtv/libs/libmythtv/dtvsignalmonitor.cpp b/mythtv/libs/libmythtv/dtvsignalmonitor.cpp
|
|---|
| 35 | index 06cdd42..e80596f 100644
|
|---|
| 36 | --- a/mythtv/libs/libmythtv/dtvsignalmonitor.cpp
|
|---|
| 37 | +++ b/mythtv/libs/libmythtv/dtvsignalmonitor.cpp
|
|---|
| 38 | @@ -4,7 +4,6 @@
|
|---|
| 39 | using namespace std;
|
|---|
| 40 |
|
|---|
| 41 | #include "dtvchannel.h"
|
|---|
| 42 | -#include "dvbchannel.h"
|
|---|
| 43 | #include "dtvsignalmonitor.h"
|
|---|
| 44 | #include "scanstreamdata.h"
|
|---|
| 45 | #include "mpegtables.h"
|
|---|
| 46 | @@ -370,12 +369,7 @@ void DTVSignalMonitor::HandlePMT(uint, const ProgramMapTable *pmt)
|
|---|
| 47 | {
|
|---|
| 48 | if (pmt->IsEncrypted(GetDTVChannel()->GetSIStandard()) &&
|
|---|
| 49 | !ignore_encrypted)
|
|---|
| 50 | - {
|
|---|
| 51 | - DVBChannel *dvbchannel = GetDVBChannel();
|
|---|
| 52 | - if (dvbchannel)
|
|---|
| 53 | - dvbchannel->SetPMT(pmt);
|
|---|
| 54 | AddFlags(kDTVSigMon_WaitForCrypt);
|
|---|
| 55 | - }
|
|---|
| 56 |
|
|---|
| 57 | AddFlags(kDTVSigMon_PMTMatch);
|
|---|
| 58 | }
|
|---|
| 59 | @@ -539,11 +533,6 @@ const ScanStreamData *DTVSignalMonitor::GetScanStreamData() const
|
|---|
| 60 | return dynamic_cast<const ScanStreamData*>(stream_data);
|
|---|
| 61 | }
|
|---|
| 62 |
|
|---|
| 63 | -DVBChannel *DTVSignalMonitor::GetDVBChannel(void)
|
|---|
| 64 | -{
|
|---|
| 65 | - return dynamic_cast<DVBChannel*>(channel);
|
|---|
| 66 | -}
|
|---|
| 67 | -
|
|---|
| 68 | bool DTVSignalMonitor::IsAllGood(void) const
|
|---|
| 69 | {
|
|---|
| 70 | QMutexLocker locker(&statusLock);
|
|---|
| 71 | diff --git a/mythtv/libs/libmythtv/dtvsignalmonitor.h b/mythtv/libs/libmythtv/dtvsignalmonitor.h
|
|---|
| 72 | index 2be4302..0d14b7f 100644
|
|---|
| 73 | --- a/mythtv/libs/libmythtv/dtvsignalmonitor.h
|
|---|
| 74 | +++ b/mythtv/libs/libmythtv/dtvsignalmonitor.h
|
|---|
| 75 | @@ -11,7 +11,6 @@ using namespace std;
|
|---|
| 76 | #include "streamlisteners.h"
|
|---|
| 77 |
|
|---|
| 78 | class DTVChannel;
|
|---|
| 79 | -class DVBChannel;
|
|---|
| 80 |
|
|---|
| 81 | class DTVSignalMonitor : public SignalMonitor,
|
|---|
| 82 | public MPEGStreamListener,
|
|---|
| 83 | @@ -104,7 +103,6 @@ class DTVSignalMonitor : public SignalMonitor,
|
|---|
| 84 |
|
|---|
| 85 | protected:
|
|---|
| 86 | DTVChannel *GetDTVChannel(void);
|
|---|
| 87 | - DVBChannel *GetDVBChannel(void);
|
|---|
| 88 | void UpdateMonitorValues(void);
|
|---|
| 89 | void UpdateListeningForEIT(void);
|
|---|
| 90 |
|
|---|
| 91 | diff --git a/mythtv/libs/libmythtv/dvbcam.cpp b/mythtv/libs/libmythtv/dvbcam.cpp
|
|---|
| 92 | index 74a2e96..36dfe86 100644
|
|---|
| 93 | --- a/mythtv/libs/libmythtv/dvbcam.cpp
|
|---|
| 94 | +++ b/mythtv/libs/libmythtv/dvbcam.cpp
|
|---|
| 95 | @@ -146,6 +146,7 @@ bool DVBCam::Stop(void)
|
|---|
| 96 | for (it = PMTAddList.begin(); it != PMTAddList.end(); ++it)
|
|---|
| 97 | delete *it;
|
|---|
| 98 | PMTAddList.clear();
|
|---|
| 99 | + progNumAdded.clear();
|
|---|
| 100 |
|
|---|
| 101 | return true;
|
|---|
| 102 | }
|
|---|
| 103 | @@ -156,7 +157,7 @@ void DVBCam::HandleUserIO(void)
|
|---|
| 104 | if (enq != NULL)
|
|---|
| 105 | {
|
|---|
| 106 | if (enq->Text() != NULL)
|
|---|
| 107 | - LOG(VB_DVBCAM, LOG_INFO, LOC + QString("CAM: Received message: %1")
|
|---|
| 108 | + LOG(VB_GENERAL, LOG_INFO, LOC + QString("CAM: Received message: %1")
|
|---|
| 109 | .arg(enq->Text()));
|
|---|
| 110 | delete enq;
|
|---|
| 111 | }
|
|---|
| 112 | @@ -165,18 +166,18 @@ void DVBCam::HandleUserIO(void)
|
|---|
| 113 | if (menu != NULL)
|
|---|
| 114 | {
|
|---|
| 115 | if (menu->TitleText() != NULL)
|
|---|
| 116 | - LOG(VB_DVBCAM, LOG_INFO, LOC + QString("CAM: Menu Title: %1")
|
|---|
| 117 | + LOG(VB_GENERAL, LOG_INFO, LOC + QString("CAM: Menu Title: %1")
|
|---|
| 118 | .arg(menu->TitleText()));
|
|---|
| 119 | if (menu->SubTitleText() != NULL)
|
|---|
| 120 | - LOG(VB_DVBCAM, LOG_INFO, LOC + QString("CAM: Menu SubTitle: %1")
|
|---|
| 121 | + LOG(VB_GENERAL, LOG_INFO, LOC + QString("CAM: Menu SubTitle: %1")
|
|---|
| 122 | .arg(menu->SubTitleText()));
|
|---|
| 123 | if (menu->BottomText() != NULL)
|
|---|
| 124 | - LOG(VB_DVBCAM, LOG_INFO, LOC + QString("CAM: Menu BottomText: %1")
|
|---|
| 125 | + LOG(VB_GENERAL, LOG_INFO, LOC + QString("CAM: Menu BottomText: %1")
|
|---|
| 126 | .arg(menu->BottomText()));
|
|---|
| 127 |
|
|---|
| 128 | for (int i=0; i<menu->NumEntries(); i++)
|
|---|
| 129 | if (menu->Entry(i) != NULL)
|
|---|
| 130 | - LOG(VB_DVBCAM, LOG_INFO, LOC + QString("CAM: Menu Entry: %1")
|
|---|
| 131 | + LOG(VB_GENERAL, LOG_INFO, LOC + QString("CAM: Menu Entry: %1")
|
|---|
| 132 | .arg(menu->Entry(i)));
|
|---|
| 133 |
|
|---|
| 134 | if (menu->Selectable())
|
|---|
| 135 | @@ -203,7 +204,7 @@ void DVBCam::HandlePMT(void)
|
|---|
| 136 | LOG(VB_DVBCAM, LOG_INFO, LOC + "CiHandler needs CA_PMT");
|
|---|
| 137 | QMutexLocker locker(&pmt_lock);
|
|---|
| 138 |
|
|---|
| 139 | - if (pmt_sent && pmt_added && !pmt_updated)
|
|---|
| 140 | + if (pmt_sent && pmt_added && pmt_updated)
|
|---|
| 141 | {
|
|---|
| 142 | // Send added PMT
|
|---|
| 143 | while (PMTAddList.size() > 0)
|
|---|
| 144 | @@ -286,30 +287,91 @@ void DVBCam::SetPMT(const ChannelBase *chan, const ProgramMapTable *pmt)
|
|---|
| 145 |
|
|---|
| 146 | pmt_list_t::iterator it = PMTList.find(chan);
|
|---|
| 147 | pmt_list_t::iterator it2 = PMTAddList.find(chan);
|
|---|
| 148 | + int currentProgramNumber;
|
|---|
| 149 | + if (pmt)
|
|---|
| 150 | + currentProgramNumber = pmt->ProgramNumber();
|
|---|
| 151 | if (!pmt && (it != PMTList.end()))
|
|---|
| 152 | {
|
|---|
| 153 | + LOG(VB_DVBCAM, LOG_INFO, LOC +
|
|---|
| 154 | + QString("Program %1 not used any more")
|
|---|
| 155 | + .arg(chan->GetCurrentName()));
|
|---|
| 156 | delete *it;
|
|---|
| 157 | PMTList.erase(it);
|
|---|
| 158 | - pmt_updated = true;
|
|---|
| 159 | + if (PMTList.size() == 1)
|
|---|
| 160 | + {
|
|---|
| 161 | + progNumAdded.clear();
|
|---|
| 162 | + progNumAdded.append((*PMTList.begin())->ProgramNumber());
|
|---|
| 163 | + LOG(VB_DVBCAM, LOG_INFO, LOC +
|
|---|
| 164 | + QString("Decrypted PID List cleared"));
|
|---|
| 165 | + }
|
|---|
| 166 | +// pmt_updated = true;
|
|---|
| 167 | }
|
|---|
| 168 | else if (!pmt && (it2 != PMTAddList.end()))
|
|---|
| 169 | {
|
|---|
| 170 | + LOG(VB_DVBCAM, LOG_INFO, LOC +
|
|---|
| 171 | + QString("Take Program %1 from AddList")
|
|---|
| 172 | + .arg(chan->GetCurrentName()));
|
|---|
| 173 | delete *it2;
|
|---|
| 174 | PMTAddList.erase(it2);
|
|---|
| 175 | pmt_added = !PMTAddList.empty();
|
|---|
| 176 | }
|
|---|
| 177 | - else if (pmt && (PMTList.empty() || (it != PMTList.end())))
|
|---|
| 178 | + else if (pmt && (PMTList.empty()))
|
|---|
| 179 | {
|
|---|
| 180 | - if (it != PMTList.end())
|
|---|
| 181 | - delete *it;
|
|---|
| 182 | + LOG(VB_DVBCAM, LOG_INFO, LOC +
|
|---|
| 183 | + QString("Sending Program %1 to CAM")
|
|---|
| 184 | + .arg(currentProgramNumber));
|
|---|
| 185 | PMTList[chan] = new ProgramMapTable(*pmt);
|
|---|
| 186 | + progNumAdded.append(currentProgramNumber);
|
|---|
| 187 | have_pmt = true;
|
|---|
| 188 | pmt_updated = true;
|
|---|
| 189 | }
|
|---|
| 190 | + else if (pmt && (it != PMTList.end()))
|
|---|
| 191 | + {
|
|---|
| 192 | + int oldProgramNumber = (*it)->ProgramNumber();
|
|---|
| 193 | + if (currentProgramNumber != oldProgramNumber)
|
|---|
| 194 | + {
|
|---|
| 195 | + LOG(VB_DVBCAM, LOG_INFO, LOC +
|
|---|
| 196 | + QString("Updating Program %1 to Program %2")
|
|---|
| 197 | + .arg(oldProgramNumber)
|
|---|
| 198 | + .arg(currentProgramNumber));
|
|---|
| 199 | + progNumAdded.removeAll(oldProgramNumber);
|
|---|
| 200 | + delete *it;
|
|---|
| 201 | + PMTList.erase(it);
|
|---|
| 202 | + if (PMTList.empty())
|
|---|
| 203 | + {
|
|---|
| 204 | + LOG(VB_DVBCAM, LOG_INFO, LOC +
|
|---|
| 205 | + QString("Sending Program %1 to CAM")
|
|---|
| 206 | + .arg(currentProgramNumber));
|
|---|
| 207 | + PMTList[chan] = new ProgramMapTable(*pmt);
|
|---|
| 208 | + progNumAdded.append(currentProgramNumber);
|
|---|
| 209 | + pmt_updated = true;
|
|---|
| 210 | + }
|
|---|
| 211 | + else if (!progNumAdded.contains(currentProgramNumber))
|
|---|
| 212 | + {
|
|---|
| 213 | + LOG(VB_DVBCAM, LOG_INFO, LOC +
|
|---|
| 214 | + QString("Add Program %1 to AddList")
|
|---|
| 215 | + .arg(currentProgramNumber));
|
|---|
| 216 | + PMTAddList[chan] = new ProgramMapTable(*pmt);
|
|---|
| 217 | + progNumAdded.append(oldProgramNumber);
|
|---|
| 218 | + progNumAdded.append(currentProgramNumber);
|
|---|
| 219 | + pmt_added = true;
|
|---|
| 220 | + pmt_updated = true;
|
|---|
| 221 | + }
|
|---|
| 222 | + else
|
|---|
| 223 | + progNumAdded.append(oldProgramNumber);
|
|---|
| 224 | + }
|
|---|
| 225 | + }
|
|---|
| 226 | else if (pmt && (it == PMTList.end()))
|
|---|
| 227 | {
|
|---|
| 228 | - PMTAddList[chan] = new ProgramMapTable(*pmt);
|
|---|
| 229 | - pmt_added = true;
|
|---|
| 230 | + if (!progNumAdded.contains(currentProgramNumber))
|
|---|
| 231 | + {
|
|---|
| 232 | + LOG(VB_DVBCAM, LOG_INFO, LOC +
|
|---|
| 233 | + QString("Add Program %1 to AddList")
|
|---|
| 234 | + .arg(currentProgramNumber));
|
|---|
| 235 | + PMTAddList[chan] = new ProgramMapTable(*pmt);
|
|---|
| 236 | + progNumAdded.append(currentProgramNumber);
|
|---|
| 237 | + pmt_added = true;
|
|---|
| 238 | + }
|
|---|
| 239 | }
|
|---|
| 240 | }
|
|---|
| 241 |
|
|---|
| 242 | diff --git a/mythtv/libs/libmythtv/dvbcam.h b/mythtv/libs/libmythtv/dvbcam.h
|
|---|
| 243 | index 03a5a5e..317a172 100644
|
|---|
| 244 | --- a/mythtv/libs/libmythtv/dvbcam.h
|
|---|
| 245 | +++ b/mythtv/libs/libmythtv/dvbcam.h
|
|---|
| 246 | @@ -61,6 +61,7 @@ class DVBCam : public QRunnable
|
|---|
| 247 | bool pmt_sent;
|
|---|
| 248 | bool pmt_updated;
|
|---|
| 249 | bool pmt_added;
|
|---|
| 250 | + QList<int> progNumAdded;
|
|---|
| 251 | };
|
|---|
| 252 |
|
|---|
| 253 | #endif // DVBCAM_H
|
|---|
| 254 | diff --git a/mythtv/libs/libmythtv/dvbchannel.cpp b/mythtv/libs/libmythtv/dvbchannel.cpp
|
|---|
| 255 | index 0d6f6bd..5a129e2 100644
|
|---|
| 256 | --- a/mythtv/libs/libmythtv/dvbchannel.cpp
|
|---|
| 257 | +++ b/mythtv/libs/libmythtv/dvbchannel.cpp
|
|---|
| 258 | @@ -124,7 +124,11 @@ DVBChannel::~DVBChannel()
|
|---|
| 259 | master_map_lock.lockForRead();
|
|---|
| 260 | MasterMap::iterator mit = master_map.find(devname);
|
|---|
| 261 | if ((*mit).empty())
|
|---|
| 262 | + {
|
|---|
| 263 | + if (dvbcam->IsRunning())
|
|---|
| 264 | + dvbcam->Stop();
|
|---|
| 265 | delete dvbcam;
|
|---|
| 266 | + }
|
|---|
| 267 | dvbcam = NULL;
|
|---|
| 268 | master_map_lock.unlock();
|
|---|
| 269 |
|
|---|
| 270 | diff --git a/mythtv/libs/libmythtv/dvbrecorder.cpp b/mythtv/libs/libmythtv/dvbrecorder.cpp
|
|---|
| 271 | index 92f3413..7a66648 100644
|
|---|
| 272 | --- a/mythtv/libs/libmythtv/dvbrecorder.cpp
|
|---|
| 273 | +++ b/mythtv/libs/libmythtv/dvbrecorder.cpp
|
|---|
| 274 | @@ -182,7 +182,10 @@ QString DVBRecorder::GetSIStandard(void) const
|
|---|
| 275 | void DVBRecorder::SetCAMPMT(const ProgramMapTable *pmt)
|
|---|
| 276 | {
|
|---|
| 277 | if (pmt->IsEncrypted(_channel->GetSIStandard()))
|
|---|
| 278 | + {
|
|---|
| 279 | + LOG(VB_DVBCAM, LOG_INFO, LOC + "DVBRecorder SetPMT and decrypt channel");
|
|---|
| 280 | _channel->SetPMT(pmt);
|
|---|
| 281 | + }
|
|---|
| 282 | }
|
|---|
| 283 |
|
|---|
| 284 | void DVBRecorder::UpdateCAMTimeOffset(void)
|
|---|
| 285 | diff --git a/mythtv/libs/libmythtv/dvbsignalmonitor.cpp b/mythtv/libs/libmythtv/dvbsignalmonitor.cpp
|
|---|
| 286 | index 33bcf26..bdabd6c 100644
|
|---|
| 287 | --- a/mythtv/libs/libmythtv/dvbsignalmonitor.cpp
|
|---|
| 288 | +++ b/mythtv/libs/libmythtv/dvbsignalmonitor.cpp
|
|---|
| 289 | @@ -17,6 +17,7 @@
|
|---|
| 290 | #include "cardutil.h"
|
|---|
| 291 |
|
|---|
| 292 | #include "dvbtypes.h"
|
|---|
| 293 | +#include "dvbchannel.h"
|
|---|
| 294 | #include "dvbrecorder.h"
|
|---|
| 295 | #include "dvbstreamhandler.h"
|
|---|
| 296 |
|
|---|
| 297 | @@ -171,13 +172,17 @@ void DVBSignalMonitor::HandlePMT(uint program_num, const ProgramMapTable *pmt)
|
|---|
| 298 | {
|
|---|
| 299 | DTVSignalMonitor::HandlePMT(program_num, pmt);
|
|---|
| 300 |
|
|---|
| 301 | -/* if (pmt->ProgramNumber() == (uint)programNumber)
|
|---|
| 302 | + if (pmt->ProgramNumber() == (uint)programNumber)
|
|---|
| 303 | {
|
|---|
| 304 | - DVBChannel *dvbchannel = GetDVBChannel();
|
|---|
| 305 | - if (dvbchannel)
|
|---|
| 306 | - dvbchannel->SetPMT(pmt);
|
|---|
| 307 | + if (pmt->IsEncrypted(GetDVBChannel()->GetSIStandard()) &&
|
|---|
| 308 | + !ignore_encrypted)
|
|---|
| 309 | + {
|
|---|
| 310 | + LOG(VB_DVBCAM, LOG_INFO, LOC + "DVBSignalmonitor SetPMT and decrypt channel");
|
|---|
| 311 | + DVBChannel *dvbchannel = GetDVBChannel();
|
|---|
| 312 | + if (dvbchannel)
|
|---|
| 313 | + dvbchannel->SetPMT(pmt);
|
|---|
| 314 | + }
|
|---|
| 315 | }
|
|---|
| 316 | -*/
|
|---|
| 317 | }
|
|---|
| 318 |
|
|---|
| 319 | void DVBSignalMonitor::HandleSTT(const SystemTimeTable *stt)
|
|---|
| 320 | diff --git a/mythtv/libs/libmythtv/mpeg/mpegstreamdata.cpp b/mythtv/libs/libmythtv/mpeg/mpegstreamdata.cpp
|
|---|
| 321 | index 0191064..448b8c0 100644
|
|---|
| 322 | --- a/mythtv/libs/libmythtv/mpeg/mpegstreamdata.cpp
|
|---|
| 323 | +++ b/mythtv/libs/libmythtv/mpeg/mpegstreamdata.cpp
|
|---|
| 324 | @@ -1821,7 +1821,7 @@ void MPEGStreamData::AddEncryptionTestPID(uint pnum, uint pid, bool isvideo)
|
|---|
| 325 |
|
|---|
| 326 | AddListeningPID(pid);
|
|---|
| 327 |
|
|---|
| 328 | - _encryption_pid_to_info[pid] = CryptInfo((isvideo) ? 10000 : 500, 8);
|
|---|
| 329 | + _encryption_pid_to_info[pid] = CryptInfo((isvideo) ? 1000 : 50, (isvideo) ? 1000 : 50);
|
|---|
| 330 |
|
|---|
| 331 | _encryption_pid_to_pnums[pid].push_back(pnum);
|
|---|
| 332 | _encryption_pnum_to_pids[pnum].push_back(pid);
|
|---|