]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Fix live TV ac3 playback, probably a very old bug
authorMarten Richter <marten.richter@freenet.de>
Sat, 1 Dec 2012 11:38:46 +0000 (12:38 +0100)
committerMarten Richter <marten.richter@freenet.de>
Sat, 1 Dec 2012 11:38:46 +0000 (12:38 +0100)
demuxer.cc
demuxer.h
demuxerts.cc
demuxerts.h
player.cc
playerliveradio.cc
playerlivetv.cc
vvideolivetv.cc

index c9f27b800084999b2764208e9accfa6c861bf37c..ea1bc8f42f32485953ed46addc777140620801ab 100644 (file)
@@ -426,6 +426,7 @@ Demuxer::Demuxer()
   h264 = false;
   fps = 25.0;
   astreamtype=4;
+  livetv=false;
 }
 
 Demuxer::~Demuxer()
@@ -482,6 +483,7 @@ void Demuxer::reset()
   h264 = false;
   packetnum=0;
   astreamtype=4;
+  livetv=false;
 
   for (int i = 0; i <= (PESTYPE_AUDMAX - PESTYPE_AUD0); i++)
   {
@@ -625,7 +627,7 @@ bool Demuxer::submitPacket(PESPacket& packet)
     avail_ac3audchan[packet.getSubstream() - PESTYPE_SUBSTREAM_AC30] = true;
     if (packet.getSubstream() == audio_current)
     {
-      sent = audiostream.put(&packetdata[0], packet.getSize(), (ispre_1_3_19)? MPTYPE_AC3_PRE13 : MPTYPE_AC3,packetnum);
+      sent = audiostream.put(&packetdata[0], packet.getSize(), (ispre_1_3_19 || livetv)? MPTYPE_AC3_PRE13 : MPTYPE_AC3,packetnum);
          if (sent) packetnum++;
     }
     else
@@ -698,76 +700,78 @@ void Demuxer::parsePacketDetails(PESPacket& packet)
     }
     else if (packet.getPacketType() == PESTYPE_PRIVATE_1) // Private stream
     {
-        //Inspired by vdr's device.c
-        int payload_begin = packet[8]+9;
-        unsigned char substream_id = packet[payload_begin];
-        unsigned char substream_type = substream_id & 0xF0;
-        unsigned char substream_index = substream_id & 0x1F;
-pre_1_3_19_Recording: //This is for old recordings stuff and live TV
-        if (ispre_1_3_19)
-        {
-               int old_substream=packet.getSubstream();
-               if (old_substream){ //someone else already set it, this is live tv
-                       substream_id = old_substream;
-                       substream_type = substream_id & 0xF0;
-                       substream_index = substream_id & 0x1F;
-               } else {
-                substream_id = PESTYPE_PRIVATE_1;
-                substream_type = 0x80;
-                substream_index = 0;
-               }
-
-        }
-        switch (substream_type)
-        {
-        case 0x20://SPU
-        case 0x30://SPU
-            packet.setSubstream(substream_id);
-            break;
-        case 0xA0: //LPCM //not supported yet, is there any LPCM transmissio out there?
-            break;
-        case 0x80: //ac3, currently only one ac3 track per recording supported
-            packet.setSubstream(substream_type+substream_index);
-
-            // Extract audio PTS if it exists
-            if (packet.hasPTS())
-            {
-                audio_pts = packet.getPTS();
-                // We continue to seek on the audio if the video PTS that we
-                // are trying to match is ahead of the audio PTS by at most
-                // SEEK_THRESHOLD. We consider the possibility of PTS wrap.
-                if (aud_seeking && !vid_seeking &&
-                    !( (video_pts_seek > audio_pts &&
-                    video_pts_seek - audio_pts < SEEK_THRESHOLD)
-                    ||
-                    (video_pts_seek < audio_pts &&
-                    video_pts_seek + (1LL<<33) - audio_pts < SEEK_THRESHOLD) ))
-                {
-                    aud_seeking = 0;
-                    Log::getInstance()->log("Demuxer", Log::DEBUG, "Leaving  audio sync: Audio PTS = %llu", audio_pts);
-                }
-            }
-            break;
-        case 0x10: //Teletext Is this correct?
-            packet.setSubstream(substream_id);
-            // Extract teletxt PTS if it exists
-            if (packet.hasPTS())
-            {
-                teletext_pts = packet.getPTS();
-            }
-            break;
-        default:
-            if (!ispre_1_3_19)
-            {
-                ispre_1_3_19=true; //switching to compat mode and live tv mode
-                goto pre_1_3_19_Recording;
-            }
-            else
-            {
-                packet.setSubstream(0);
-            }
-            break;
-        }
+       if (!livetv) {
+               //Inspired by vdr's device.c
+               int payload_begin = packet[8]+9;
+               unsigned char substream_id = packet[payload_begin];
+               unsigned char substream_type = substream_id & 0xF0;
+               unsigned char substream_index = substream_id & 0x1F;
+               pre_1_3_19_Recording: //This is for old recordings stuff and live TV
+               if (ispre_1_3_19)
+               {
+                       int old_substream=packet.getSubstream();
+                       if (old_substream){ //someone else already set it, this is live tv
+                               substream_id = old_substream;
+                               substream_type = substream_id & 0xF0;
+                               substream_index = substream_id & 0x1F;
+                       } else {
+                               substream_id = PESTYPE_PRIVATE_1;
+                               substream_type = 0x80;
+                               substream_index = 0;
+                       }
+
+               }
+               switch (substream_type)
+               {
+               case 0x20://SPU
+               case 0x30://SPU
+                       packet.setSubstream(substream_id);
+                       break;
+               case 0xA0: //LPCM //not supported yet, is there any LPCM transmissio out there?
+                       break;
+               case 0x80: //ac3, currently only one ac3 track per recording supported
+                       packet.setSubstream(substream_type+substream_index);
+
+                       // Extract audio PTS if it exists
+                       if (packet.hasPTS())
+                       {
+                               audio_pts = packet.getPTS();
+                               // We continue to seek on the audio if the video PTS that we
+                               // are trying to match is ahead of the audio PTS by at most
+                               // SEEK_THRESHOLD. We consider the possibility of PTS wrap.
+                               if (aud_seeking && !vid_seeking &&
+                                               !( (video_pts_seek > audio_pts &&
+                                                               video_pts_seek - audio_pts < SEEK_THRESHOLD)
+                                                               ||
+                                                               (video_pts_seek < audio_pts &&
+                                                                               video_pts_seek + (1LL<<33) - audio_pts < SEEK_THRESHOLD) ))
+                               {
+                                       aud_seeking = 0;
+                                       Log::getInstance()->log("Demuxer", Log::DEBUG, "Leaving  audio sync: Audio PTS = %llu", audio_pts);
+                               }
+                       }
+                       break;
+               case 0x10: //Teletext Is this correct?
+                       packet.setSubstream(substream_id);
+                       // Extract teletxt PTS if it exists
+                       if (packet.hasPTS())
+                       {
+                               teletext_pts = packet.getPTS();
+                       }
+                       break;
+               default:
+                       if (!ispre_1_3_19)
+                       {
+                               ispre_1_3_19=true; //switching to compat mode and live tv mode
+                               goto pre_1_3_19_Recording;
+                       }
+                       else
+                       {
+                               packet.setSubstream(0);
+                       }
+                       break;
+               }
+       }
     }
     else if (packet.getPacketType() >= PESTYPE_VID0 &&
         packet.getPacketType() <= PESTYPE_VIDMAX)
index d34612b5346ac14eda572dd503c624979faad1b9..856703ddaa66fccdae48ac2d05cbfb9602b9dbab 100644 (file)
--- a/demuxer.h
+++ b/demuxer.h
@@ -208,6 +208,7 @@ class Demuxer
        bool h264;
     int video_current, audio_current, teletext_current, subtitle_current;
     int astreamtype;
+    bool livetv;
 
     // Video stream information
     void setAspectRatio(enum AspectRatio, int taspectx, int taspecty);
index 70375b4a476bac3db744810f0c56253acfc1cd30..defd4321b7d8b592b01770227961b2d63ae9f9c0 100644 (file)
@@ -106,11 +106,12 @@ void DemuxerTS::setVID(int p_vID)
   vActive = false;
 }
 
-void DemuxerTS::setAID(int p_aID, int type, int streamtype)
+void DemuxerTS::setAID(int p_aID, int type, int streamtype, bool slivetv)
 {
   aID = p_aID;
   atype = type;
   astreamtype = streamtype;
+  livetv=slivetv;
   switch (atype)
   {
   case 1:
@@ -443,7 +444,7 @@ int DemuxerTS::processTS(UCHAR* buf)
                     new_channelinfo.apids.push_back(newapid);
                     new_channelinfo.numAPids++;
                     if (getAID() == 0 && Audio::getInstance()->streamTypeSupported(streamtype)) { //set unset AID to first audio pid that reports itself
-                        setAID(foundpid,0,streamtype);
+                        setAID(foundpid,0,streamtype,false);
                         Log::getInstance()->log("ProcessTS", Log::DEBUG, "Set audio PID to %x", foundpid);
                     }
                         } break;
@@ -532,7 +533,7 @@ int DemuxerTS::processTS(UCHAR* buf)
                while (j<channelinfo.numAPids && !found) {
                        if (Audio::getInstance()->streamTypeSupported(channelinfo.apids[j].type)) {
                                found =true;
-                               setAID(channelinfo.apids[j].pid,0,channelinfo.apids[j].type);
+                               setAID(channelinfo.apids[j].pid,0,channelinfo.apids[j].type,false);
                        }
                        j++;
                }
@@ -543,7 +544,7 @@ int DemuxerTS::processTS(UCHAR* buf)
                while (j<channelinfo.numDPids && !found) {
                        if (Audio::getInstance()->streamTypeSupported(channelinfo.dpids[j].type)) {
                                found =true;
-                               setAID(channelinfo.dpids[j].pid,1,channelinfo.dpids[j].type);
+                               setAID(channelinfo.dpids[j].pid,1,channelinfo.dpids[j].type,false);
                        }
                        i++;
                }
index 90a1d90bc82f285e9528f18bafc7014d6f73d672..5e0cab34273358a273b5ceb2c610700654e08612 100644 (file)
@@ -40,7 +40,7 @@ class DemuxerTS : public Demuxer
     int findPTS(UCHAR* buf, int len, ULLONG* dest);
     void setVID(int p_vID);
     void setTID(int p_tID);
-    void setAID(int p_aID, int type, int streamtype);
+    void setAID(int p_aID, int type, int streamtype,bool slivetv);
     void setSubID(int p_subID);
     int  getVID() { return vID; }
     int  getTID() { return tID; }
@@ -89,6 +89,7 @@ class DemuxerTS : public Demuxer
     PTSMap pts_map;
     Mutex pts_map_mutex;
     void parseTSPacketDetails(PESPacket &packet);
+
    
 
 };
index 790ed9acc365e35daef13305b87ebe903f7c5316..0aeac2fb66df5e80aac3483db31263c72b43792f 100644 (file)
--- a/player.cc
+++ b/player.cc
@@ -231,7 +231,7 @@ void Player::setAudioChannel(int newChannel, int type, int streamtype)
         demuxer->setAudioStream(newChannel);
         return;
     } else {
-        ((DemuxerTS*)demuxer)->setAID(newChannel,type,streamtype);
+        ((DemuxerTS*)demuxer)->setAID(newChannel,type,streamtype,false);
         return;
     }
 }
index 9a4a1bb30dcb2136a330fee06a50a477e3476323..c72ea60115504e56c8f6232303b3cb3727fd4fe5 100644 (file)
@@ -113,7 +113,7 @@ int PlayerLiveRadio::getCurrentSubtitleChannel(){
 
 void PlayerLiveRadio::setAudioChannel(int newChannel, int type,int streamtype)
 {
-  demuxer->setAID(newChannel, type,streamtype);
+  demuxer->setAID(newChannel, type,streamtype,true);
 }
 
 void PlayerLiveRadio::setSubtitleChannel(int newChannel)
@@ -411,7 +411,7 @@ void PlayerLiveRadio::threadMethod()
                  int j=0;
                  while (j<chan->numAPids && !found) {
                          if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type)) {
-                                 demuxer->setAID(chan->apids[j].pid,0,chan->apids[j].type);
+                                 demuxer->setAID(chan->apids[j].pid,0,chan->apids[j].type,true);
                                  audio->setStreamType(Audio::MPEG2_PES);
                                  logger->log("PlayerLiveRadio", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[j].pid,chan->apids[j].type);
                                  found=true;
@@ -427,7 +427,7 @@ void PlayerLiveRadio::threadMethod()
                          int j=0;
                          while (j<chan->numDPids && !found) {
                                  if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type)) {
-                                         demuxer->setAID(chan->dpids[j].pid,1,chan->dpids[j].type);
+                                         demuxer->setAID(chan->dpids[j].pid,1,chan->dpids[j].type,true);
                                          audio->setStreamType(Audio::MPEG2_PES);
                                          logger->log("PlayerLiveRadio", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u", chan->vpid, chan->dpids[j].pid,chan->dpids[j].type);
                                          found=true;
index 16eff3c4de5922f88c8ce89c5858dc936efb1a00..386863871cd2c7998bfd6c737a4033bec7172b72 100644 (file)
@@ -137,7 +137,7 @@ int PlayerLiveTV::getCurrentAudioChannel()
 
 void PlayerLiveTV::setAudioChannel(int newChannel, int type,int streamtype)
 {
-  demuxer->setAID(newChannel,type,streamtype);
+  demuxer->setAID(newChannel,type,streamtype,true);
 }
 
 void PlayerLiveTV::setSubtitleChannel(int newChannel)
@@ -723,7 +723,7 @@ void PlayerLiveTV::threadMethod()
                  int j=0;
                  while (j<chan->numAPids && !found) {
                          if (Audio::getInstance()->streamTypeSupported(chan->apids[j].type)) {
-                                 demuxer->setAID(chan->apids[j].pid,0,chan->apids[j].type);
+                                 demuxer->setAID(chan->apids[j].pid,0,chan->apids[j].type,true);
                                  audio->setStreamType(Audio::MPEG2_PES);
                                  logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer pids: %u %u %u", chan->vpid, chan->apids[j].pid,chan->apids[j].type);
                                  found=true;
@@ -739,7 +739,7 @@ void PlayerLiveTV::threadMethod()
                  int j=0;
                  while (j<chan->numDPids && !found) {
                          if (Audio::getInstance()->streamTypeSupported(chan->dpids[j].type)) {
-                                 demuxer->setAID(chan->dpids[j].pid,1,chan->dpids[j].type);
+                                 demuxer->setAID(chan->dpids[j].pid,1,chan->dpids[j].type,true);
                                  audio->setStreamType(Audio::MPEG2_PES);
                                  logger->log("PlayerLiveTV", Log::DEBUG, "Demuxer pids: %u %u (ac3) %u", chan->vpid, chan->dpids[j].pid,chan->dpids[j].type);
                                  found=true;
index e75adef2fc632d328bc83f6473df2e802797913a..aad1634b0f17f5518ef39eaafa35ee323eb8cc55 100644 (file)
@@ -1005,13 +1005,13 @@ void VVideoLiveTV::processMessage(Message* m)
   }
   else if (m->message == Message::AUDIO_CHANGE_CHANNEL)
   {
-    Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change audio channel to %i", m->parameter);
+    Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change audio channel to %x", m->parameter);
     player->setAudioChannel((m->parameter & 0xFFFF),(m->parameter & 0xFF0000)>>16,(m->parameter & 0xFF000000)>>24);
   } 
   else if (m->message == Message::SUBTITLE_CHANGE_CHANNEL)
   {
     if (streamType !=VDR::VIDEO) return;
-      Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change subtitle channel to %i", m->parameter);
+      Log::getInstance()->log("VVideoLiveTV", Log::DEBUG, "Received change subtitle channel to %x", m->parameter);
       int type=((m->parameter & 0xFF0000)>>16);
       switch (type) {
       case 0x10: { //dvbsubtitle