libsi Premiere content descriptor erroneous

Message ID e4sgqb$5uh$1@video.local.muempf.de
State New
Headers

Commit Message

Stefan Huelswitt May 22, 2006, 2:11 p.m. UTC
  Hi,
the implementation of the Premiere content descriptor in libsi is
erroneous.
The list of starttimes is a nested structure. The outer structure
gives the day and the inner structure give the times for this day.

The attached patch fixes the code.

Regards.
  

Comments

Klaus Schmidinger May 23, 2006, 4:02 p.m. UTC | #1
Stefan Huelswitt wrote:
> Hi,
> the implementation of the Premiere content descriptor in libsi is
> erroneous.
> The list of starttimes is a nested structure. The outer structure
> gives the day and the inner structure give the times for this day.
> 
> The attached patch fixes the code.

I'll postpone adopting this until an API change is actually
unavoidable. Since VDR itself doesn't use these things yet,
I prefer to keep the API version constant for now.

Thanks for the fix, though.

Klaus
  
Stefan Huelswitt May 23, 2006, 6:03 p.m. UTC | #2
On 23 May 2006 Klaus Schmidinger <Klaus.Schmidinger@cadsoft.de> wrote:

> Stefan Huelswitt wrote:
>
>> The attached patch fixes the code.
> 
> I'll postpone adopting this until an API change is actually
> unavoidable. Since VDR itself doesn't use these things yet,
> I prefer to keep the API version constant for now.

I plan to release an updated premiereepg plugin soon, which uses
this libsi code and thus depends on the fix.

But I can include the patch with the plugin as well.

Regards.
  
Klaus Schmidinger May 23, 2006, 8:24 p.m. UTC | #3
Stefan Huelswitt wrote:
> On 23 May 2006 Klaus Schmidinger <Klaus.Schmidinger@cadsoft.de> wrote:
> 
>> Stefan Huelswitt wrote:
>>
>>> The attached patch fixes the code.
>> I'll postpone adopting this until an API change is actually
>> unavoidable. Since VDR itself doesn't use these things yet,
>> I prefer to keep the API version constant for now.
> 
> I plan to release an updated premiereepg plugin soon, which uses
> this libsi code and thus depends on the fix.
> 
> But I can include the patch with the plugin as well.

Well, I don't _have_ to keep the API version constant.
Just thought I'd save people from having to recompile
all their plugins. If the general vote is to bump the
API version and rather have this fix included, that's
fine with me.

Let's hear it!

Klaus
  

Patch

diff -ur vdr-1.4.0-orig/libsi/descriptor.c vdr-1.4.0/libsi/descriptor.c
--- vdr-1.4.0-orig/libsi/descriptor.c	2006-04-17 14:19:15.000000000 +0200
+++ vdr-1.4.0/libsi/descriptor.c	2006-05-22 15:32:12.000000000 +0200
@@ -806,21 +806,34 @@ 
    return HILO(s->service_id);
 }
 
-int PremiereContentTransmissionDescriptor::getMJD() const {
+void PremiereContentTransmissionDescriptor::Parse() {
+   s=data.getData<const descr_premiere_content_transmission>();
+   startDayLoop.setData(data+sizeof(descr_premiere_content_transmission), getLength()-sizeof(descr_premiere_content_transmission));
+}
+
+int PremiereContentTransmissionDescriptor::StartDayEntry::getMJD() const {
    return HILO(s->mjd);
 }
 
-void PremiereContentTransmissionDescriptor::Parse() {
-   s=data.getData<const descr_premiere_content_transmission>();
-   startTimeLoop.setData(data+sizeof(descr_premiere_content_transmission), getLength()-sizeof(descr_premiere_content_transmission));
+int PremiereContentTransmissionDescriptor::StartDayEntry::getLoopLength() const {
+   return s->start_time_loop;
+}
+
+int PremiereContentTransmissionDescriptor::StartDayEntry::getLength() {
+   return sizeof(item_premiere_content_transmission_day)+getLoopLength();
+}
+
+void PremiereContentTransmissionDescriptor::StartDayEntry::Parse() {
+   s=data.getData<const item_premiere_content_transmission_day>();
+   startTimeLoop.setData(data+sizeof(item_premiere_content_transmission_day), getLoopLength());
 }
 
-time_t PremiereContentTransmissionDescriptor::StartTimeEntry::getStartTime(int mjd) const {
+time_t PremiereContentTransmissionDescriptor::StartDayEntry::StartTimeEntry::getStartTime(int mjd) const {
    return DVBTime::getTime(mjd >> 8, mjd & 0xff, s->start_time_h, s->start_time_m, s->start_time_s);
 }
 
-void PremiereContentTransmissionDescriptor::StartTimeEntry::Parse() {
-   s=data.getData<const item_premiere_content_transmission_reference>();
+void PremiereContentTransmissionDescriptor::StartDayEntry::StartTimeEntry::Parse() {
+   s=data.getData<const item_premiere_content_transmission_time>();
 }
 
 void ApplicationSignallingDescriptor::Parse() {
diff -ur vdr-1.4.0-orig/libsi/descriptor.h vdr-1.4.0/libsi/descriptor.h
--- vdr-1.4.0-orig/libsi/descriptor.h	2006-04-14 12:53:44.000000000 +0200
+++ vdr-1.4.0/libsi/descriptor.h	2006-05-22 15:30:41.000000000 +0200
@@ -490,20 +490,30 @@ 
 
 class PremiereContentTransmissionDescriptor : public Descriptor {
 public:
-   class StartTimeEntry : public LoopElement {
+   class StartDayEntry : public LoopElement {
    public:
-      virtual int getLength() { return sizeof(item_premiere_content_transmission_reference); }
-      time_t getStartTime(int mjd) const; //UTC
+      class StartTimeEntry : public LoopElement {
+      public:
+         virtual int getLength() { return sizeof(item_premiere_content_transmission_time); }
+         time_t getStartTime(int mjd) const; //UTC
+      protected:
+         virtual void Parse();
+      private:
+         const item_premiere_content_transmission_time *s;
+      };
+      StructureLoop<StartTimeEntry> startTimeLoop;
+      virtual int getLength();
+      int getMJD() const;
+      int getLoopLength() const;
    protected:
       virtual void Parse();
    private:
-      const item_premiere_content_transmission_reference *s;
+      const item_premiere_content_transmission_day *s;
    };
-   StructureLoop<StartTimeEntry> startTimeLoop;
+   StructureLoop<StartDayEntry> startDayLoop;
    int getOriginalNetworkId() const;
    int getTransportStreamId() const;
    int getServiceId() const;
-   int getMJD() const;
 protected:
    virtual void Parse();
 private:
diff -ur vdr-1.4.0-orig/libsi/headers.h vdr-1.4.0/libsi/headers.h
--- vdr-1.4.0-orig/libsi/headers.h	2006-04-14 12:53:44.000000000 +0200
+++ vdr-1.4.0/libsi/headers.h	2006-05-22 14:51:20.000000000 +0200
@@ -1790,7 +1790,7 @@ 
 // 0xF2  Content Transmission Descriptor
 // http://dvbsnoop.sourceforge.net/examples/example-private-section.html
 
-#define DESCR_PREMIERE_CONTENT_TRANSMISSION_LEN 11
+#define DESCR_PREMIERE_CONTENT_TRANSMISSION_LEN 8
 
 struct descr_premiere_content_transmission {
    u_char descriptor_tag                         :8;
@@ -1801,14 +1801,19 @@ 
    u_char original_network_id_lo                 :8;
    u_char service_id_hi                          :8;
    u_char service_id_lo                          :8;
+};
+
+#define ITEM_PREMIERE_CONTENT_TRANSMISSION_DAY_LEN 3
+
+struct item_premiere_content_transmission_day {
    u_char mjd_hi                                 :8;
    u_char mjd_lo                                 :8;
    u_char start_time_loop                        :8;
 };
 
-#define ITEM_PREMIERE_CONTENT_TRANSMISSION_LEN 3
+#define ITEM_PREMIERE_CONTENT_TRANSMISSION_TIME_LEN 3
 
-struct item_premiere_content_transmission_reference {
+struct item_premiere_content_transmission_time {
    u_char start_time_h                           :8;
    u_char start_time_m                           :8;
    u_char start_time_s                           :8;