Ticket #10101: eitpf-timing.patch
File eitpf-timing.patch, 10.3 KB (added by , 13 years ago) |
---|
-
mythtv/libs/libmythtv/dtvrecorder.cpp
commit 877b6008fa700713c697eb9043d63119f9398c07 Author: David Matthews <dm@prolingua.co.uk> Date: Fri Oct 14 16:57:26 2011 +0100 Recording timing from EITpf This patch adds code to monitor EITpf. It sets a bookmark when the programme to be recorded changes from "following" to "present" and extends the recording period if a programme is still "present" when the scheduled recording time has been reached. diff --git a/mythtv/libs/libmythtv/dtvrecorder.cpp b/mythtv/libs/libmythtv/dtvrecorder.cpp index e0a5335..1781a55 100644
a b 21 21 #include "atscstreamdata.h" 22 22 #include "mpegstreamdata.h" 23 23 #include "dvbstreamdata.h" 24 #include "dvbtables.h" 24 25 #include "dtvrecorder.h" 25 26 #include "programinfo.h" 26 27 #include "mythlogging.h" … … DTVRecorder::DTVRecorder(TVRec *rec) : 72 73 _input_pat(NULL), 73 74 _input_pmt(NULL), 74 75 _has_no_av(false), 76 // EIT timing 77 _is_running(false), 78 _is_following(false), 75 79 // statistics 76 80 _packet_count(0), 77 81 _continuity_error_count(0), … … bool DTVRecorder::ProcessAVTSPacket(const TSPacket &tspacket) 1182 1186 return true; 1183 1187 } 1184 1188 1189 void DTVRecorder::HandleEIT(const DVBEventInformationTable *eit) 1190 { 1191 DVBStreamData *dsd = dynamic_cast<DVBStreamData*>(_stream_data); 1192 if (dsd && 1193 TableID::PF_EIT == eit->TableID() && 1194 eit->ServiceID() == dsd->DesiredProgram() && 1195 eit->OriginalNetworkID() == dsd->DesiredNetworkID() && 1196 eit->TSID() == dsd->DesiredTransportID()) 1197 { 1198 for (uint i = 0; i < eit->EventCount(); i++) 1199 { 1200 QString programId, recordingProgId, recordingTitle; 1201 desc_list_t list = MPEGDescriptor::Parse( 1202 eit->Descriptors(i), eit->DescriptorsLength(i)); 1203 desc_list_t contentIds = 1204 MPEGDescriptor::FindAll(list, DescriptorID::dvb_content_identifier); 1205 for (uint j = 0; j < contentIds.size(); j++) 1206 { 1207 DVBContentIdentifierDescriptor desc(contentIds[j]); 1208 if (desc.ContentEncoding() == 0 && 1209 (desc.ContentType() == 0x01 || desc.ContentType() == 0x31)) 1210 { 1211 programId = desc.ContentId(); 1212 } 1213 } 1214 1215 if (curRecording) 1216 { 1217 recordingProgId = curRecording->GetProgramID(); 1218 recordingTitle = curRecording->GetTitle(); 1219 } 1220 // The programid in curRecording will have the default authority at the start 1221 // so we have a match if they end the same. 1222 bool isMatch = false; 1223 if (!programId.isEmpty() && !recordingProgId.isEmpty()) 1224 isMatch = recordingProgId.endsWith(programId.toLower()); 1225 else 1226 { 1227 // Fall back to matching on the title. 1228 desc_list_t shortEvents = 1229 MPEGDescriptor::FindAll(list, DescriptorID::short_event); 1230 for (uint j = 0; j < shortEvents.size(); j++) 1231 { 1232 ShortEventDescriptor sed(shortEvents[j]); 1233 // The title may include a subtitle that has been removed 1234 // by a fixup. 1235 if (sed.EventName().startsWith(recordingTitle)) 1236 { 1237 isMatch = true; 1238 break; 1239 } 1240 } 1241 } 1242 1243 if (eit->Section() == 0) 1244 { 1245 LOG(VB_GENERAL, LOG_INFO, LOC + QString("Current is now %1").arg(programId)); 1246 _is_running = isMatch; 1247 } 1248 else if (eit->Section() == 1) 1249 { 1250 LOG(VB_GENERAL, LOG_INFO, LOC + QString("Following is now %1").arg(programId)); 1251 _is_following = isMatch; 1252 } 1253 if (curRecording) 1254 { 1255 LOG(VB_GENERAL, LOG_INFO, 1256 LOC + QString("Recording for %1 (%2) running=%3, following=%4") 1257 .arg(curRecording->GetTitle()).arg(recordingProgId) 1258 .arg(_is_running).arg(_is_following)); 1259 } 1260 } 1261 } 1262 } 1263 1185 1264 /* vim: set expandtab tabstop=4 shiftwidth=4: */ -
mythtv/libs/libmythtv/dtvrecorder.h
diff --git a/mythtv/libs/libmythtv/dtvrecorder.h b/mythtv/libs/libmythtv/dtvrecorder.h index 25b8c7e..f103b17 100644
a b class DTVRecorder : 29 29 public DVBMainStreamListener, 30 30 public ATSCMainStreamListener, 31 31 public TSPacketListener, 32 public TSPacketListenerAV 32 public TSPacketListenerAV, 33 public DVBEITStreamListener 33 34 { 34 35 public: 35 36 DTVRecorder(TVRec *rec); … … class DTVRecorder : 86 87 // Common audio/visual processing 87 88 bool ProcessAVTSPacket(const TSPacket &tspacket); 88 89 90 // EIT timing information 91 bool IsRunning(void) { return _is_running; } 92 bool IsFollowing(void) { return _is_following; } 93 89 94 protected: 90 95 void FinishRecording(void); 91 96 void ResetForNewFile(void); … … class DTVRecorder : 116 121 virtual void SetCAMPMT(const ProgramMapTable*) {} 117 122 virtual void UpdateCAMTimeOffset(void) {} 118 123 124 void HandleEIT(const DVBEventInformationTable*); 125 void HandleEIT(const PremiereContentInformationTable*) {} 126 119 127 // file handle for stream 120 128 int _stream_fd; 121 129 … … class DTVRecorder : 164 172 unsigned char _continuity_counter[0x1fff + 1]; 165 173 vector<TSPacket> _scratch; 166 174 175 // EIT timing 176 bool _is_running, _is_following; 177 167 178 // Statistics 168 179 mutable unsigned long long _packet_count; 169 180 mutable unsigned long long _continuity_error_count; -
mythtv/libs/libmythtv/dvbrecorder.cpp
diff --git a/mythtv/libs/libmythtv/dvbrecorder.cpp b/mythtv/libs/libmythtv/dvbrecorder.cpp index e842e32..d4257f9 100644
a b 24 24 // MythTV includes 25 25 #include "dvbstreamhandler.h" 26 26 #include "mpegstreamdata.h" 27 #include "dvbstreamdata.h" 27 28 #include "dvbrecorder.h" 28 29 #include "dvbchannel.h" 29 30 #include "tv_rec.h" … … void DVBRecorder::run(void) 96 97 if (_channel && (_channel->GetSIStandard() == "dvb")) 97 98 _stream_data->AddListeningPID(DVB_TDT_PID); 98 99 100 DVBStreamData *dsd = dynamic_cast<DVBStreamData*>(_stream_data); 101 if (dsd) 102 dsd->AddDVBEITListener(this); 103 99 104 // Make sure the first things in the file are a PAT & PMT 100 105 bool tmp = _wait_for_keyframe_option; 101 106 _wait_for_keyframe_option = false; … … void DVBRecorder::run(void) 107 112 _stream_data->AddWritingListener(this); 108 113 _stream_handler->AddListener(_stream_data, false, true); 109 114 115 QString recordingProgId = QString("?"), recordingTitle = QString("?"); 116 if (curRecording) 117 { 118 recordingProgId = curRecording->GetProgramID(); 119 recordingTitle = curRecording->GetTitle(); 120 } 121 LOG(VB_GENERAL, LOG_INFO, LOC + QString("Recording %1 (%2) service %3 net %4 transport %5") 122 .arg(recordingTitle).arg(recordingProgId).arg(dsd->DesiredProgram()) 123 .arg(dsd->DesiredNetworkID()).arg(dsd->DesiredTransportID())); 124 110 125 while (IsRecordingRequested() && !IsErrored()) 111 126 { 112 127 if (PauseAndWait()) … … void DVBRecorder::run(void) 139 154 _stream_data->RemoveWritingListener(this); 140 155 _stream_data->RemoveAVListener(this); 141 156 157 if (dsd) 158 dsd->RemoveDVBEITListener(this); 159 142 160 Close(); 143 161 144 162 FinishRecording(); -
mythtv/libs/libmythtv/tv_rec.cpp
diff --git a/mythtv/libs/libmythtv/tv_rec.cpp b/mythtv/libs/libmythtv/tv_rec.cpp index 2eedf68..7011091 100644
a b TVRec::TVRec(int capturecardnum) 109 109 // Current recording info 110 110 curRecording(NULL), autoRunJobs(JOB_NONE), 111 111 overrecordseconds(0), 112 eitIsRunning(false), eitIsFollowing(false), 112 113 // Pseudo LiveTV recording 113 114 pseudoLiveTVRecording(NULL), 114 115 nextLiveTVDir(""), nextLiveTVDirLock(), … … void TVRec::run(void) 1221 1222 // Tell frontends about pending recordings 1222 1223 HandlePendingRecordings(); 1223 1224 1225 bool isRunning = false, isFollowing = false; 1226 if (GetDTVRecorder()) 1227 { 1228 isRunning = GetDTVRecorder()->IsRunning(); 1229 isFollowing = GetDTVRecorder()->IsFollowing(); 1230 } 1231 if (isRunning && eitIsFollowing && ! eitIsRunning) 1232 { 1233 // Set a bookmark at the transition from Following to Present. 1234 if (curRecording) 1235 curRecording->SaveBookmark(GetFramesWritten()); 1236 } 1237 eitIsRunning = isRunning; 1238 eitIsFollowing = isFollowing; 1239 1224 1240 // If we are recording a program, check if the recording is 1225 1241 // over or someone has asked us to finish the recording. 1226 1242 // Add an extra 60 seconds to the recording end time if we … … void TVRec::run(void) 1228 1244 QDateTime recEnd = (!pendingRecordings.empty()) ? 1229 1245 recordEndTime.addSecs(60) : recordEndTime; 1230 1246 if ((GetState() == kState_RecordingOnly) && 1231 ( QDateTime::currentDateTime() > recEnd||1247 ((QDateTime::currentDateTime() > recEnd && !isRunning) || 1232 1248 HasFlags(kFlagFinishRecording))) 1233 1249 { 1250 QDateTime actualTime = QDateTime::currentDateTime(); 1251 QString title; 1252 if (curRecording) 1253 title = curRecording->GetTitle(); 1254 if (actualTime > recordEndTime.addSecs(10)) 1255 LOG(VB_GENERAL, LOG_INFO, 1256 QString("Extended end time of recording of %1 from %2 to %3") 1257 .arg(title) 1258 .arg(recordEndTime.toString("hh:mm:ss")) 1259 .arg(actualTime.toString("hh:mm:ss"))); 1260 1234 1261 ChangeState(kState_None); 1235 1262 ClearFlags(kFlagFinishRecording); 1236 1263 } -
mythtv/libs/libmythtv/tv_rec.h
diff --git a/mythtv/libs/libmythtv/tv_rec.h b/mythtv/libs/libmythtv/tv_rec.h index e867271..59b3d65 100644
a b class MTV_PUBLIC TVRec : public SignalMonitorListener, public QRunnable 369 369 QDateTime recordEndTime; 370 370 int autoRunJobs; 371 371 int overrecordseconds; 372 bool eitIsRunning, eitIsFollowing; 372 373 373 374 // Pending recording info 374 375 PendingMap pendingRecordings;