Bug in pat.c (VDR 1.7.27) - possible fix attached

Message ID 201204081838.46069.pboettcher@kernellabs.com
State New
Headers

Commit Message

Patrick Boettcher April 8, 2012, 4:38 p.m. UTC
  Hi,

I located a small bug which has been introduced in 1.7.18 (at least I think 
so). Reading the Changes file I could not determine which change caused it, 
but the problem is the following. 

In pat.c: if the PMT of a service has a stream of stream-type  128 (0x80) 
the vpid is overridden with the PID signalled in the Elementary-PID-field of 
this stream. This happens to be the case here in France for some of the DVB-
T services. It breaks 2 channels (France 2 and France 5) when channel-
updates is at least configured to "update PIDs".

The code which is doing that is described as "STREAMTYPE_USER_PRIVATE - 
DigiCipher II VIDEO (ANSI/SCTE 57)" which before was only applied when the 
stream had a certain descriptor and there a certain type. 

The attached patch resets the code to do exactly that for STREAMTYPE 0x80 - 
though can't check whether the digiCipher-stuff is still working. 

Please consider applying soon.

Thanks,
--
Patrick

http://www.kernellabs.com/
  

Comments

Klaus Schmidinger April 9, 2012, 9:40 a.m. UTC | #1
On 08.04.2012 18:38, Patrick Boettcher wrote:
> Hi,
>
> I located a small bug which has been introduced in 1.7.18 (at least I think
> so). Reading the Changes file I could not determine which change caused it,
> but the problem is the following.
>
> In pat.c: if the PMT of a service has a stream of stream-type  128 (0x80)
> the vpid is overridden with the PID signalled in the Elementary-PID-field of
> this stream. This happens to be the case here in France for some of the DVB-
> T services. It breaks 2 channels (France 2 and France 5) when channel-
> updates is at least configured to "update PIDs".
>
> The code which is doing that is described as "STREAMTYPE_USER_PRIVATE -
> DigiCipher II VIDEO (ANSI/SCTE 57)" which before was only applied when the
> stream had a certain descriptor and there a certain type.
>
> The attached patch resets the code to do exactly that for STREAMTYPE 0x80 -
> though can't check whether the digiCipher-stuff is still working.

+                          // http://www.smpte-ra.org/mpegreg/mpegreg.html
+                          ...
+                          case 0x44434949: // STREAMTYPE_USER_PRIVATE - DigiCipher II VIDEO (ANSI/SCTE 57)

There is no entry for 44-43-49-49 on the given page.

Klaus
  
Dominic Evans April 9, 2012, 11:39 a.m. UTC | #2
On 9 April 2012 10:40, Klaus Schmidinger <Klaus.Schmidinger@tvdr.de> wrote:
> +                          // http://www.smpte-ra.org/mpegreg/mpegreg.html
> +                          ...
> +                          case 0x44434949: // STREAMTYPE_USER_PRIVATE -
> DigiCipher II VIDEO (ANSI/SCTE 57)
>
> There is no entry for 44-43-49-49 on the given page.
>
> Klaus

fwiw, Patrick's patch simply re-instates the case statement that was
removed in VDR 1.7.18, although with a slightly different comment
against it

see pat.c diff at
http://git.gekrumbel.de/vdr.git?p=vdr.git;a=commitdiff;h=f3d9ba8bfd6cd51779aa1d2923903949fbb92f3c

I'm guessing this was removed as part of Rolf's patch to add DigiCipher support?
  
Patrick Boettcher April 9, 2012, 3:49 p.m. UTC | #3
On Monday 09 April 2012 13:39:36 Dominic Evans wrote:
> On 9 April 2012 10:40, Klaus Schmidinger <Klaus.Schmidinger@tvdr.de> 
wrote:
> > +                          //
> > http://www.smpte-ra.org/mpegreg/mpegreg.html +                        
> >  ...
> > +                          case 0x44434949: // STREAMTYPE_USER_PRIVATE
> > - DigiCipher II VIDEO (ANSI/SCTE 57)
> > 
> > There is no entry for 44-43-49-49 on the given page.

It wasn't me who added this stream-type check, I just re-applied the checks 
how they were done before.

> see pat.c diff at
> http://git.gekrumbel.de/vdr.git?p=vdr.git;a=commitdiff;h=f3d9ba8bfd6cd517
> 79aa1d2923903949fbb92f3c

I used exactly this repository to find out that the regression was introduced 
in 1.7.18.
 
> I'm guessing this was removed as part of Rolf's patch to add DigiCipher
> support?

Rolf contacted me off-list and confirmed your assumption. 

I sent the PMT (attached here as well) of the channel to him to see whether 
he has an idea how it can be avoided.

In general I think just brutally replace the VPID with the PID signalled in 
the stream which is "user-defined" can't be the right way.

--
Patrick 
http://www.kernellabs.com/
dvbsnoop V1.4.50 -- http://dvbsnoop.sourceforge.net/

------------------------------------------------------------
SECT-Packet: 00000001   PID: 110 (0x006e), Length: 98 (0x0062)
Time received: Mon 2012-04-09  09:51:42.797
------------------------------------------------------------
  0000:  02 b0 5f 01 01 ff 00 00  e0 78 f0 00 02 e0 78 f0   .._......x....x.
  0010:  03 11 01 ff 03 e0 82 f0  06 0a 04 66 72 61 00 03   ...........fra..
  0020:  e0 83 f0 0d 0a 04 71 61  64 00 7f 05 06 85 66 72   ......qad.....fr
  0030:  61 06 e0 8c f0 0a 59 08  66 72 61 20 00 01 00 01   a.....Y.fra ....
  0040:  05 e0 aa f0 05 6f 03 80  10 e0 80 e0 ab f0 00 80   .....o..........
  0050:  e0 ac f0 00 80 e0 ad f0  00 80 e0 ae f0 00 eb 4a   ...............J
  0060:  d3 d2                                              ..

PID:  110 (0x006e)

Guess table from table id...
PMT-decoding....
Table_ID: 2 (0x02)  [= Program Map Table (PMT)]
section_syntax_indicator: 1 (0x01)
(fixed '0'): 0 (0x00)
reserved_1: 3 (0x03)
Section_length: 95 (0x005f)
Program_number: 257 (0x0101)
reserved_2: 3 (0x03)
Version_number: 31 (0x1f)
current_next_indicator: 1 (0x01)  [= valid now]
Section_number: 0 (0x00)
Last_Section_number: 0 (0x00)
reserved_3: 7 (0x07)
PCR PID: 120 (0x0078)
reserved_4: 15 (0x0f)
Program_info_length: 0 (0x0000)

Stream_type loop:

    Stream_type: 2 (0x02)  [= ITU-T Rec. H.262 | ISO/IEC 13818-2 Video | ISO/IEC 11172-2 constr. parameter video stream]
    reserved_1: 7 (0x07)
    Elementary_PID: 120 (0x0078)
    reserved_2: 15 (0x0f)
    ES_info_length: 3 (0x0003)

            MPEG-DescriptorTag: 17 (0x11)  [= STD_descriptor]
            descriptor_length: 1 (0x01)
            reserved_1: 127 (0x7f)
            leak_valid_flag: 1 (0x01)


    Stream_type: 3 (0x03)  [= ISO/IEC 11172 Audio]
    reserved_1: 7 (0x07)
    Elementary_PID: 130 (0x0082)
    reserved_2: 15 (0x0f)
    ES_info_length: 6 (0x0006)

            MPEG-DescriptorTag: 10 (0x0a)  [= ISO_639_language_descriptor]
            descriptor_length: 4 (0x04)
               ISO639_language_code:  fra
               Audio_type: 0 (0x00)  [= undefined]



    Stream_type: 3 (0x03)  [= ISO/IEC 11172 Audio]
    reserved_1: 7 (0x07)
    Elementary_PID: 131 (0x0083)
    reserved_2: 15 (0x0f)
    ES_info_length: 13 (0x000d)

            MPEG-DescriptorTag: 10 (0x0a)  [= ISO_639_language_descriptor]
            descriptor_length: 4 (0x04)
               ISO639_language_code:  qad
               Audio_type: 0 (0x00)  [= undefined]


            DVB-DescriptorTag: 127 (0x7f)  [= extension_descriptor]
            descriptor_length: 5 (0x05)
            descriptor_tag_extension: 6 (0x06)
            selector_bytes:
                 0000:  85 66 72 61                                        .fra


    Stream_type: 6 (0x06)  [= ITU-T Rec. H.222.0 | ISO/IEC 13818-1 PES packets containing private data]
    reserved_1: 7 (0x07)
    Elementary_PID: 140 (0x008c)
    reserved_2: 15 (0x0f)
    ES_info_length: 10 (0x000a)

            DVB-DescriptorTag: 89 (0x59)  [= subtitling_descriptor]
            descriptor_length: 8 (0x08)
                 ISO639_language_code:  fra
               Subtitling_type: 32 (0x20)  [= DVB subtitles (for the hard hearing) with no monitor aspect ratio critical]
               Composition_page_id: 1 (0x0001)
               Ancillary_page_id: 1 (0x0001)



    Stream_type: 5 (0x05)  [= ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private sections]
    reserved_1: 7 (0x07)
    Elementary_PID: 170 (0x00aa)
    reserved_2: 15 (0x0f)
    ES_info_length: 5 (0x0005)

            DVB-DescriptorTag: 111 (0x6f)  [= application_signalling_descriptor]
            descriptor_length: 3 (0x03)
            Application type: 32784 (0x8010)
            reserved: 7 (0x07)
            AIT version nr.: 0 (0x00)


    Stream_type: 128 (0x80)  [= User private]
    reserved_1: 7 (0x07)
    Elementary_PID: 171 (0x00ab)
    reserved_2: 15 (0x0f)
    ES_info_length: 0 (0x0000)


    Stream_type: 128 (0x80)  [= User private]
    reserved_1: 7 (0x07)
    Elementary_PID: 172 (0x00ac)
    reserved_2: 15 (0x0f)
    ES_info_length: 0 (0x0000)


    Stream_type: 128 (0x80)  [= User private]
    reserved_1: 7 (0x07)
    Elementary_PID: 173 (0x00ad)
    reserved_2: 15 (0x0f)
    ES_info_length: 0 (0x0000)


    Stream_type: 128 (0x80)  [= User private]
    reserved_1: 7 (0x07)
    Elementary_PID: 174 (0x00ae)
    reserved_2: 15 (0x0f)
    ES_info_length: 0 (0x0000)

CRC: 3947549650 (0xeb4ad3d2)
  

Patch

diff --git a/pat.c b/pat.c
index d9b93f6..f0d0024 100644
--- a/pat.c
+++ b/pat.c
@@ -456,12 +456,30 @@  void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length
                          }
                       }
                       break;
-              case 0x80: // STREAMTYPE_USER_PRIVATE - DigiCipher II VIDEO (ANSI/SCTE 57)
-                      Vpid = esPid;
-                      Ppid = pmt.getPCRPid();
-                      Vtype = 0x02; // compression based upon MPEG-2
-                      ProcessCaDescriptors = true;
-                      break;
+              case 0x80: {
+                  SI::Descriptor *d;
+                  for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext(it)); ) {
+                      switch (d->getDescriptorTag()) {
+                      case SI::RegistrationDescriptorTag: {
+                          SI::RegistrationDescriptor *rd = (SI::RegistrationDescriptor *)d;
+                          // http://www.smpte-ra.org/mpegreg/mpegreg.html
+                          switch (rd->getFormatIdentifier()) {
+                          case 0x44434949: // STREAMTYPE_USER_PRIVATE - DigiCipher II VIDEO (ANSI/SCTE 57)
+                              Vpid = esPid;
+                              Ppid = pmt.getPCRPid();
+                              Vtype = 0x02; // compression based upon MPEG-2
+                              ProcessCaDescriptors = true;
+                              break;
+                          default:
+                              break;
+                          }
+                      } break;
+                      default:
+                          break;
+                      }
+                  }
+              } break;
+
               case 0x81: // STREAMTYPE_USER_PRIVATE - ATSC A/53 AUDIO (ANSI/SCTE 57)
                       {
                       char lang[MAXLANGCODE1] = { 0 };