26 #include <vdr/plugin.h> |
26 #include <vdr/plugin.h> |
27 #include <vdr/filter.h> |
27 #include <vdr/filter.h> |
28 #include <vdr/epg.h> |
28 #include <vdr/epg.h> |
29 #include <vdr/channels.h> |
29 #include <vdr/channels.h> |
30 #include <vdr/dvbdevice.h> |
30 #include <vdr/dvbdevice.h> |
|
31 #include <vdr/i18n.h> |
31 #include <libsi/section.h> |
32 #include <libsi/section.h> |
32 #include <libsi/descriptor.h> |
33 #include <libsi/descriptor.h> |
33 |
34 |
34 //#define DEBUG |
35 //#define DEBUG |
35 //#define DEBUG2 |
36 //#define DEBUG2 |
46 #endif |
47 #endif |
47 |
48 |
48 #define PMT_SCAN_TIMEOUT 10 // seconds |
49 #define PMT_SCAN_TIMEOUT 10 // seconds |
49 #define PMT_SCAN_IDLE 300 // seconds |
50 #define PMT_SCAN_IDLE 300 // seconds |
50 |
51 |
51 static const char *VERSION = "0.0.1"; |
52 static const char *VERSION = "0.0.2"; |
52 static const char *DESCRIPTION = "Parse extended Premiere EPG data"; |
53 static const char *DESCRIPTION = "Parses extended Premiere EPG data"; |
|
54 |
|
55 // --- cSetupPremiereEpg ------------------------------------------------------- |
|
56 |
|
57 const char *optPats[] = { |
|
58 "%s", |
|
59 "%s (Option %d)", |
|
60 "%s (O%d)", |
|
61 "#%2$d %1$s", |
|
62 "[%2$d] %1$s" |
|
63 }; |
|
64 #define NUM_PATS (sizeof(optPats)/sizeof(char *)) |
|
65 |
|
66 class cSetupPremiereEpg { |
|
67 public: |
|
68 int OptPat; |
|
69 public: |
|
70 cSetupPremiereEpg(void); |
|
71 }; |
|
72 |
|
73 cSetupPremiereEpg SetupPE; |
|
74 |
|
75 cSetupPremiereEpg::cSetupPremiereEpg(void) |
|
76 { |
|
77 OptPat=1; |
|
78 } |
|
79 |
|
80 // --- i18n -------------------------------------------------------------------- |
|
81 |
|
82 const tI18nPhrase Phrases[] = { |
|
83 /* |
|
84 */ |
|
85 { "PremiereEPG", |
|
86 "PremiereEPG", |
|
87 "", // TODO |
|
88 "", // TODO |
|
89 "", // TODO |
|
90 "", // TODO |
|
91 "", // TODO |
|
92 "", // TODO |
|
93 "", // TODO |
|
94 "", // TODO |
|
95 "", // TODO |
|
96 "", // TODO |
|
97 "", // TODO |
|
98 "", // TODO |
|
99 "", // TODO |
|
100 "", // TODO |
|
101 }, |
|
102 { "Parses extended Premiere EPG data", |
|
103 "Liest erweiterte Premiere EPG Daten ein", |
|
104 "", // TODO |
|
105 "", // TODO |
|
106 "", // TODO |
|
107 "", // TODO |
|
108 "", // TODO |
|
109 "", // TODO |
|
110 "", // TODO |
|
111 "", // TODO |
|
112 "", // TODO |
|
113 "", // TODO |
|
114 "", // TODO |
|
115 "", // TODO |
|
116 "", // TODO |
|
117 "", // TODO |
|
118 }, |
|
119 { "Tag option events", |
|
120 "Options Events markieren", |
|
121 "", // TODO |
|
122 "", // TODO |
|
123 "", // TODO |
|
124 "", // TODO |
|
125 "", // TODO |
|
126 "", // TODO |
|
127 "", // TODO |
|
128 "", // TODO |
|
129 "", // TODO |
|
130 "", // TODO |
|
131 "", // TODO |
|
132 "", // TODO |
|
133 "", // TODO |
|
134 "", // TODO |
|
135 }, |
|
136 |
|
137 { NULL } |
|
138 }; |
|
139 |
|
140 // --- cMenuSetupPremiereEpg ------------------------------------------------------------ |
|
141 |
|
142 class cMenuSetupPremiereEpg : public cMenuSetupPage { |
|
143 private: |
|
144 cSetupPremiereEpg data; |
|
145 const char *optDisp[NUM_PATS]; |
|
146 char buff[NUM_PATS][32]; |
|
147 protected: |
|
148 virtual void Store(void); |
|
149 public: |
|
150 cMenuSetupPremiereEpg(void); |
|
151 }; |
|
152 |
|
153 cMenuSetupPremiereEpg::cMenuSetupPremiereEpg(void) |
|
154 { |
|
155 data=SetupPE; |
|
156 SetSection(tr("PremiereEPG")); |
|
157 optDisp[0]=tr("off"); |
|
158 for(unsigned int i=1; i<NUM_PATS; i++) { |
|
159 snprintf(buff[i],sizeof(buff[i]),optPats[i],"Event",1); |
|
160 optDisp[i]=buff[i]; |
|
161 } |
|
162 Add(new cMenuEditStraItem(tr("Tag option events"),&data.OptPat,NUM_PATS,optDisp)); |
|
163 } |
|
164 |
|
165 void cMenuSetupPremiereEpg::Store(void) |
|
166 { |
|
167 SetupPE=data; |
|
168 SetupStore("OptionPattern",SetupPE.OptPat); |
|
169 } |
53 |
170 |
54 // --- CIT --------------------------------------------------------------------- |
171 // --- CIT --------------------------------------------------------------------- |
55 |
172 |
56 namespace SI { |
173 namespace SI { |
57 |
174 |
88 u_char content_id_lo_lo :8; |
205 u_char content_id_lo_lo :8; |
89 u_char duration_h :8; |
206 u_char duration_h :8; |
90 u_char duration_m :8; |
207 u_char duration_m :8; |
91 u_char duration_s :8; |
208 u_char duration_s :8; |
92 #if BYTE_ORDER == BIG_ENDIAN |
209 #if BYTE_ORDER == BIG_ENDIAN |
93 u_char reserved :4; |
210 u_char :4; |
94 u_char descriptors_loop_length_hi :4; |
211 u_char descriptors_loop_length_hi :4; |
95 #else |
212 #else |
96 u_char descriptors_loop_length_hi :4; |
213 u_char descriptors_loop_length_hi :4; |
97 u_char reserved :4; |
214 u_char :4; |
98 #endif |
215 #endif |
99 u_char descriptors_loop_length_lo :8; |
216 u_char descriptors_loop_length_lo :8; |
100 }; |
217 }; |
101 |
218 |
102 class CIT : public NumberedSection { |
219 class CIT : public NumberedSection { |
381 if(StartTime+cit.getDuration()+Setup.EPGLinger*60<time(0)) { |
498 if(StartTime+cit.getDuration()+Setup.EPGLinger*60<time(0)) { |
382 d2(printf("(old)\n")) |
499 d2(printf("(old)\n")) |
383 continue; |
500 continue; |
384 } |
501 } |
385 |
502 |
|
503 bool newEvent=false; |
386 cEvent *pEvent=(cEvent *)pSchedule->GetEvent(EventId,StartTime); |
504 cEvent *pEvent=(cEvent *)pSchedule->GetEvent(EventId,StartTime); |
387 if(!pEvent) { |
505 if(!pEvent) { |
388 d2(printf("(new)\n")) |
506 d2(printf("(new)\n")) |
389 pEvent=pSchedule->AddEvent(new cEvent(channelID,EventId)); |
507 #if VDRVERSNUM >= 10325 |
|
508 pEvent=new cEvent(EventId); |
|
509 #else |
|
510 pEvent=new cEvent(channelID,EventId); |
|
511 #endif |
390 if(!pEvent) continue; |
512 if(!pEvent) continue; |
|
513 newEvent=true; |
391 } |
514 } |
392 else { |
515 else { |
393 d2(printf("(upd)\n")) |
516 d2(printf("(upd)\n")) |
394 pEvent->SetSeen(); |
517 pEvent->SetSeen(); |
395 if(pEvent->TableID()==0x00) continue; |
518 if(pEvent->TableID()==0x00) continue; |
400 pEvent->SetVersion(cit.getVersionNumber()); |
523 pEvent->SetVersion(cit.getVersionNumber()); |
401 pEvent->SetStartTime(StartTime); |
524 pEvent->SetStartTime(StartTime); |
402 pEvent->SetDuration(cit.getDuration()); |
525 pEvent->SetDuration(cit.getDuration()); |
403 |
526 |
404 if(ShortEventDescriptor) { |
527 if(ShortEventDescriptor) { |
405 char buffer[256+32]; |
528 char buffer[256]; |
406 ShortEventDescriptor->name.getText(buffer,sizeof(buffer)-32); |
529 ShortEventDescriptor->name.getText(buffer,sizeof(buffer)); |
407 if(isOpt) { |
530 if(isOpt) { |
408 char o[32]; |
531 char buffer2[sizeof(buffer)+32]; |
409 snprintf(o,sizeof(o)," (Option %d)",optCount); |
532 snprintf(buffer2,sizeof(buffer2),optPats[SetupPE.OptPat],buffer,optCount); |
410 strcat(buffer,o); |
533 pEvent->SetTitle(buffer2); |
411 } |
534 } |
412 pEvent->SetTitle(buffer); |
535 else |
|
536 pEvent->SetTitle(buffer); |
413 pEvent->SetShortText(ShortEventDescriptor->text.getText(buffer,sizeof(buffer))); |
537 pEvent->SetShortText(ShortEventDescriptor->text.getText(buffer,sizeof(buffer))); |
414 } |
538 } |
415 if(ExtendedEventDescriptors) { |
539 if(ExtendedEventDescriptors) { |
416 char buffer[ExtendedEventDescriptors->getMaximumTextLength(": ")+1]; |
540 char buffer[ExtendedEventDescriptors->getMaximumTextLength(": ")+1]; |
417 pEvent->SetDescription(ExtendedEventDescriptors->getText(buffer,sizeof(buffer),": ")); |
541 pEvent->SetDescription(ExtendedEventDescriptors->getText(buffer,sizeof(buffer),": ")); |
418 } |
542 } |
419 |
543 |
|
544 if(newEvent) pSchedule->AddEvent(pEvent); |
420 pEvent->SetComponents(NULL); |
545 pEvent->SetComponents(NULL); |
421 pEvent->FixEpgBugs(); |
546 pEvent->FixEpgBugs(); |
422 Modified=true; |
547 Modified=true; |
423 } |
548 } |
424 if(Modified) { |
549 if(Modified) { |
444 cDevice *device; |
569 cDevice *device; |
445 } epg[MAXDVBDEVICES]; |
570 } epg[MAXDVBDEVICES]; |
446 public: |
571 public: |
447 cPluginPremiereEpg(void); |
572 cPluginPremiereEpg(void); |
448 virtual const char *Version(void) { return VERSION; } |
573 virtual const char *Version(void) { return VERSION; } |
449 virtual const char *Description(void) { return DESCRIPTION; } |
574 virtual const char *Description(void) { return tr(DESCRIPTION); } |
450 virtual bool Start(void); |
575 virtual bool Start(void); |
451 virtual void Stop(void); |
576 virtual void Stop(void); |
|
577 virtual cMenuSetupPage *SetupMenu(void); |
|
578 virtual bool SetupParse(const char *Name, const char *Value); |
452 }; |
579 }; |
453 |
580 |
454 cPluginPremiereEpg::cPluginPremiereEpg(void) |
581 cPluginPremiereEpg::cPluginPremiereEpg(void) |
455 { |
582 { |
456 memset(epg,0,sizeof(epg)); |
583 memset(epg,0,sizeof(epg)); |
457 } |
584 } |
458 |
585 |
459 bool cPluginPremiereEpg::Start(void) |
586 bool cPluginPremiereEpg::Start(void) |
460 { |
587 { |
|
588 RegisterI18n(Phrases); |
461 for(int i=0; i<MAXDVBDEVICES; i++) { |
589 for(int i=0; i<MAXDVBDEVICES; i++) { |
462 cDevice *dev=cDevice::GetDevice(i); |
590 cDevice *dev=cDevice::GetDevice(i); |
463 if(dev) { |
591 if(dev) { |
464 epg[i].device=dev; |
592 epg[i].device=dev; |
465 dev->AttachFilter(epg[i].filter=new cFilterPremiereEpg); |
593 dev->AttachFilter(epg[i].filter=new cFilterPremiereEpg); |