vdr and aac support

Message ID 201005182200.28123.jareguero@telefonica.net
State New
Headers

Commit Message

Jose Alberto Reguero May 18, 2010, 8 p.m. UTC
  El Martes, 18 de Mayo de 2010, Luca Olivetti escribió:
> Al 18/05/10 21:43, En/na Luca Olivetti ha escrit:
> > (i.e. it only adds SI::AACDescriptorTag)
> > 
> > I must have missed some patch along the way :-/
> 
> Ok, they were in the "Recording DVB-T HD infrance" (sic).
> It appears that spain is using the same standard.
> 
> Bye

Here is a patch based in Klaus aac pacth that add support for eac3 sound in 
vdr.

Jose Alberto
  

Comments

Eric Valette May 21, 2010, 5:25 a.m. UTC | #1
On 18/05/2010 22:00, Jose Alberto Reguero wrote:

> Here is a patch based in Klaus aac pacth that add support for eac3 sound in
> vdr.

Hi,

I applied manually your patch on my own vdr-1.7.14 source tree. It seems 
to work as far as vdr is concerened but it breaks other plugin such as 
vdr live and vdr streamdev.

Did I miss something (I will double check, as for some reason I had some 
rejecst ad had to apply part of it manually).

--eric
  

Patch

Sólo en vdr-1.7.14.new/: audio.o
diff -ur vdr-1.7.14/channels.c vdr-1.7.14.new/channels.c
--- vdr-1.7.14/channels.c	2010-02-21 14:36:04.000000000 +0100
+++ vdr-1.7.14.new/channels.c	2010-05-18 18:54:57.000000000 +0200
@@ -12,6 +12,7 @@ 
 #include "device.h"
 #include "epg.h"
 #include "timers.h"
+#include "libsi/si.h"
 
 // IMPORTANT NOTE: in the 'sscanf()' calls there is a blank after the '%d'
 // format characters in order to allow any number of blanks after a numeric
@@ -270,14 +271,21 @@ 
   return result;
 }
 
-static int IntArrayToString(char *s, const int *a, int Base = 10, const char n[][MAXLANGCODE2] = NULL)
+static int IntArrayToString(char *s, const int *a, int Base = 10, const char n[][MAXLANGCODE2] = NULL, const int *t = NULL)
 {
   char *q = s;
   int i = 0;
   while (a[i] || i == 0) {
         q += sprintf(q, Base == 16 ? "%s%X" : "%s%d", i ? "," : "", a[i]);
-        if (a[i] && n && *n[i])
-           q += sprintf(q, "=%s", n[i]);
+        const char *Delim = "=";
+        if (a[i]) {
+           if (n && *n[i]) {
+              q += sprintf(q, "%s%s", Delim, n[i]);
+              Delim = "";
+              }
+           if (t && t[i])
+              q += sprintf(q, "%s@%d", Delim, t[i]);
+           }
         if (!a[i])
            break;
         i++;
@@ -286,32 +294,32 @@ 
   return q - s;
 }
 
-void cChannel::SetPids(int Vpid, int Ppid, int Vtype, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid)
+void cChannel::SetPids(int Vpid, int Ppid, int Vtype, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, int *Dtypes, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid)
 {
   int mod = CHANNELMOD_NONE;
   if (vpid != Vpid || ppid != Ppid || vtype != Vtype || tpid != Tpid)
      mod |= CHANNELMOD_PIDS;
-  int m = IntArraysDiffer(apids, Apids, alangs, ALangs) | IntArraysDiffer(dpids, Dpids, dlangs, DLangs) | IntArraysDiffer(spids, Spids, slangs, SLangs);
+  int m = IntArraysDiffer(apids, Apids, alangs, ALangs) | IntArraysDiffer(dpids, Dpids, dlangs, DLangs) | IntArraysDiffer(dtypes, Dtypes) | IntArraysDiffer(spids, Spids, slangs, SLangs);
   if (m & STRDIFF)
      mod |= CHANNELMOD_LANGS;
   if (m & VALDIFF)
      mod |= CHANNELMOD_PIDS;
   if (mod) {
-     const int BufferSize = (MAXAPIDS + MAXDPIDS) * (5 + 1 + MAXLANGCODE2) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod+cod', +10: paranoia
+     const int BufferSize = (MAXAPIDS + MAXDPIDS) * (5 + 1 + MAXLANGCODE2 + 5) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod+cod@type', +10: paranoia
      char OldApidsBuf[BufferSize];
      char NewApidsBuf[BufferSize];
      char *q = OldApidsBuf;
      q += IntArrayToString(q, apids, 10, alangs);
      if (dpids[0]) {
         *q++ = ';';
-        q += IntArrayToString(q, dpids, 10, dlangs);
+        q += IntArrayToString(q, dpids, 10, dlangs, dtypes);
         }
      *q = 0;
      q = NewApidsBuf;
      q += IntArrayToString(q, Apids, 10, ALangs);
      if (Dpids[0]) {
         *q++ = ';';
-        q += IntArrayToString(q, Dpids, 10, DLangs);
+        q += IntArrayToString(q, Dpids, 10, DLangs, Dtypes);
         }
      *q = 0;
      const int SBufferSize = MAXSPIDS * (5 + 1 + MAXLANGCODE2) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod', +10: paranoia
@@ -335,6 +343,7 @@ 
      apids[MAXAPIDS] = 0;
      for (int i = 0; i < MAXDPIDS; i++) {
          dpids[i] = Dpids[i];
+         dtypes[i] = Dtypes[i];
          strn0cpy(dlangs[i], DLangs[i], MAXLANGCODE2);
          }
      dpids[MAXDPIDS] = 0;
@@ -484,13 +493,13 @@ 
      if (Channel->vpid && Channel->vtype)
         q += snprintf(q, sizeof(vpidbuf) - (q - vpidbuf), "=%d", Channel->vtype);
      *q = 0;
-     const int BufferSize = (MAXAPIDS + MAXDPIDS) * (5 + 1 + MAXLANGCODE2) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod+cod', +10: paranoia
+     const int BufferSize = (MAXAPIDS + MAXDPIDS) * (5 + 1 + MAXLANGCODE2 + 5) + 10; // 5 digits plus delimiting ',' or ';' plus optional '=cod+cod@type', +10: paranoia
      char apidbuf[BufferSize];
      q = apidbuf;
      q += IntArrayToString(q, Channel->apids, 10, Channel->alangs);
      if (Channel->dpids[0]) {
         *q++ = ';';
-        q += IntArrayToString(q, Channel->dpids, 10, Channel->dlangs);
+        q += IntArrayToString(q, Channel->dpids, 10, Channel->dlangs, Channel->dtypes);
         }
      *q = 0;
      char caidbuf[MAXCAIDS * 5 + 10]; // 5: 4 digits plus delimiting ',', 10: paranoia
@@ -547,6 +556,7 @@ 
         vtype = 0;
         apids[0] = 0;
         dpids[0] = 0;
+        dtypes[0] = 0;
         ok = false;
         if (parambuf && sourcebuf && vpidbuf && apidbuf) {
            parameters = parambuf;
@@ -600,9 +610,15 @@ 
               char *strtok_next;
               while ((q = strtok_r(p, ",", &strtok_next)) != NULL) {
                     if (NumDpids < MAXDPIDS) {
+                       dtypes[NumDpids] = SI::AC3DescriptorTag; // backwards compatibility
                        char *l = strchr(q, '=');
                        if (l) {
                           *l++ = 0;
+                          char *t = strchr(l, '@');
+                          if (t) {
+                             *t++ = 0;
+                             dtypes[NumDpids] = strtol(t, NULL, 10);
+                             }
                           strn0cpy(dlangs[NumDpids], l, MAXLANGCODE2);
                           }
                        else
@@ -614,6 +630,7 @@ 
                     p = NULL;
                     }
               dpids[NumDpids] = 0;
+              dtypes[NumDpids] = 0;
               }
 
            if (caidbuf) {
diff -ur vdr-1.7.14/channels.h vdr-1.7.14.new/channels.h
--- vdr-1.7.14/channels.h	2010-03-07 14:47:13.000000000 +0100
+++ vdr-1.7.14.new/channels.h	2010-05-18 17:39:09.000000000 +0200
@@ -106,6 +106,7 @@ 
   int apids[MAXAPIDS + 1]; // list is zero-terminated
   char alangs[MAXAPIDS][MAXLANGCODE2];
   int dpids[MAXDPIDS + 1]; // list is zero-terminated
+  int dtypes[MAXAPIDS + 1]; // list is zero-terminated
   char dlangs[MAXDPIDS][MAXLANGCODE2];
   int spids[MAXSPIDS + 1]; // list is zero-terminated
   char slangs[MAXSPIDS][MAXLANGCODE2];
@@ -156,6 +157,7 @@ 
   const char *Alang(int i) const { return (0 <= i && i < MAXAPIDS) ? alangs[i] : ""; }
   const char *Dlang(int i) const { return (0 <= i && i < MAXDPIDS) ? dlangs[i] : ""; }
   const char *Slang(int i) const { return (0 <= i && i < MAXSPIDS) ? slangs[i] : ""; }
+   int Dtype(int i) const { return (0 <= i && i < MAXAPIDS) ? dtypes[i] : 0; }
   uchar SubtitlingType(int i) const { return (0 <= i && i < MAXSPIDS) ? subtitlingTypes[i] : uchar(0); }
   uint16_t CompositionPageId(int i) const { return (0 <= i && i < MAXSPIDS) ? compositionPageIds[i] : uint16_t(0); }
   uint16_t AncillaryPageId(int i) const { return (0 <= i && i < MAXSPIDS) ? ancillaryPageIds[i] : uint16_t(0); }
@@ -185,7 +187,7 @@ 
   void SetId(int Nid, int Tid, int Sid, int Rid = 0);
   void SetName(const char *Name, const char *ShortName, const char *Provider);
   void SetPortalName(const char *PortalName);
-  void SetPids(int Vpid, int Ppid, int Vtype, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
+  void SetPids(int Vpid, int Ppid, int Vtype, int *Apids, char ALangs[][MAXLANGCODE2], int *Dpids, int *Dtypes, char DLangs[][MAXLANGCODE2], int *Spids, char SLangs[][MAXLANGCODE2], int Tpid);
   void SetCaIds(const int *CaIds); // list must be zero-terminated
   void SetCaDescriptors(int Level);
   void SetLinkChannels(cLinkChannels *LinkChannels);
diff -ur vdr-1.7.14/pat.c vdr-1.7.14.new/pat.c
--- vdr-1.7.14/pat.c	2010-03-06 13:00:30.000000000 +0100
+++ vdr-1.7.14.new/pat.c	2010-05-18 17:47:29.000000000 +0200
@@ -333,6 +333,7 @@ 
         int Vtype = 0;
         int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated
         int Dpids[MAXDPIDS + 1] = { 0 };
+        int Dtypes[MAXDPIDS + 1] = { 0 };
         int Spids[MAXSPIDS + 1] = { 0 };
         uchar SubtitlingTypes[MAXSPIDS + 1] = { 0 };
         uint16_t CompositionPageIds[MAXSPIDS + 1] = { 0 };
@@ -395,12 +396,15 @@ 
               //XXX case 8: // STREAMTYPE_13818_DSMCC
                       {
                       int dpid = 0;
+                      int dtype = 0;
                       char lang[MAXLANGCODE1] = { 0 };
                       SI::Descriptor *d;
                       for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext(it)); ) {
                           switch (d->getDescriptorTag()) {
                             case SI::AC3DescriptorTag:
+                            case SI::EnhancedAC3DescriptorTag:
                                  dpid = esPid;
+                                 dtype = d->getDescriptorTag();
                                  ProcessCaDescriptors = true;
                                  break;
                             case SI::SubtitlingDescriptorTag:
@@ -441,6 +445,7 @@ 
                       if (dpid) {
                          if (NumDpids < MAXDPIDS) {
                             Dpids[NumDpids] = dpid;
+                            Dtypes[NumDpids] = dtype;
                             strn0cpy(DLangs[NumDpids], lang, MAXLANGCODE1);
                             NumDpids++;
                             }
@@ -480,7 +485,7 @@ 
                }
             }
         if (Setup.UpdateChannels >= 2) {
-           Channel->SetPids(Vpid, Ppid, Vtype, Apids, ALangs, Dpids, DLangs, Spids, SLangs, Tpid);
+           Channel->SetPids(Vpid, Ppid, Vtype, Apids, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
            Channel->SetCaIds(CaDescriptors->CaIds());
            Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds);
            }
diff -ur vdr-1.7.14/remux.c vdr-1.7.14.new/remux.c
--- vdr-1.7.14/remux.c	2010-02-28 15:42:07.000000000 +0100
+++ vdr-1.7.14.new/remux.c	2010-05-18 17:51:38.000000000 +0200
@@ -188,10 +188,10 @@ 
   return i;
 }
 
-int cPatPmtGenerator::MakeAC3Descriptor(uchar *Target)
+int cPatPmtGenerator::MakeAC3Descriptor(uchar *Target, int dtype)
 {
   int i = 0;
-  Target[i++] = SI::AC3DescriptorTag;
+  Target[i++] = dtype;
   Target[i++] = 0x01; // length
   Target[i++] = 0x00;
   IncEsInfoLength(i);
@@ -323,7 +323,7 @@ 
          }
      for (int n = 0; Channel->Dpid(n); n++) {
          i += MakeStream(buf + i, 0x06, Channel->Dpid(n));
-         i += MakeAC3Descriptor(buf + i);
+         i += MakeAC3Descriptor(buf + i, Channel->Dtype(n));
          i += MakeLanguageDescriptor(buf + i, Channel->Dlang(n));
          }
      for (int n = 0; Channel->Spid(n); n++) {
@@ -546,13 +546,16 @@ 
            case 0x06: // STREAMTYPE_13818_PES_PRIVATE
                       {
                       int dpid = 0;
+                      int dtype = 0;
                       char lang[MAXLANGCODE1] = "";
                       SI::Descriptor *d;
                       for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext(it)); ) {
                           switch (d->getDescriptorTag()) {
                             case SI::AC3DescriptorTag:
+                            case SI::EnhancedAC3DescriptorTag:
                                  dbgpatpmt(" AC3");
                                  dpid = stream.getPid();
+                                 dtype = d->getDescriptorTag();
                                  break;
                             case SI::SubtitlingDescriptorTag:
                                  dbgpatpmt(" subtitling");
@@ -599,7 +602,7 @@ 
                       if (dpid) {
                          if (NumDpids < MAXDPIDS) {
                             dpids[NumDpids] = dpid;
-                            dtypes[NumDpids] = stream.getStreamType();
+                            dtypes[NumDpids] = dtype;
                             strn0cpy(dlangs[NumDpids], lang, sizeof(dlangs[NumDpids]));
                             if (updatePrimaryDevice && Setup.UseDolbyDigital)
                                cDevice::PrimaryDevice()->SetAvailableTrack(ttDolby, NumDpids, dpid, lang);
diff -ur vdr-1.7.14/remux.h vdr-1.7.14.new/remux.h
--- vdr-1.7.14/remux.h	2010-01-29 17:51:26.000000000 +0100
+++ vdr-1.7.14.new/remux.h	2010-05-18 17:48:37.000000000 +0200
@@ -168,7 +168,7 @@ 
   void IncEsInfoLength(int Length);
 protected:
   int MakeStream(uchar *Target, uchar Type, int Pid);
-  int MakeAC3Descriptor(uchar *Target);
+  int MakeAC3Descriptor(uchar *Target, int dtype);
   int MakeSubtitlingDescriptor(uchar *Target, const char *Language, uchar SubtitlingType, uint16_t CompositionPageId, uint16_t AncillaryPageId);
   int MakeLanguageDescriptor(uchar *Target, const char *Language);
   int MakeCRC(uchar *Target, const uchar *Data, int Length);