add a tuxbox plugins plugin to prepare loading of tuxbox plugins when the c++ part...
[enigma2.git] / lib / service / servicedvb.cpp
index 778892f6c6917492f85119f37c89680aaed199e5..15deff62901599a5e54ab6dae751480e570346a9 100644 (file)
@@ -8,6 +8,7 @@
 
 #include <lib/dvb/dvb.h>
 #include <lib/dvb/db.h>
+#include <lib/dvb/decoder.h>
 
 #include <lib/service/servicedvbrecord.h>
 #include <lib/dvb/metaparser.h>
@@ -613,12 +614,22 @@ void eDVBServicePlay::serviceEvent(int event)
                                /* don't worry about non-existing services, nor pvr services */
                        if (m_dvb_service && !m_is_pvr)
                        {
+                               if (apidtype == eDVBAudio::aMPEG)
+                               {
+                                       m_dvb_service->setCachePID(eDVBService::cAPID, apid);
+                                       m_dvb_service->setCachePID(eDVBService::cAC3PID, -1);
+                               }
+                               else
+                               {
+                                       m_dvb_service->setCachePID(eDVBService::cAPID, -1);
+                                       m_dvb_service->setCachePID(eDVBService::cAC3PID, apid);
+                               }
                                m_dvb_service->setCachePID(eDVBService::cVPID, vpid);
-                               m_dvb_service->setCachePID(eDVBService::cAPID, apid);
                                m_dvb_service->setCachePID(eDVBService::cPCRPID, pcrpid);
                        }
                }
-               
+
+               m_event((iPlayableService*)this, evUpdatedInfo);
                break;
        }
        }
@@ -767,7 +778,7 @@ RESULT eDVBServicePlay::getPlayPosition(pts_t &pos)
        if (!demux)
                return -1;
        
-       return pvr_channel->getCurrentPosition(demux, pos);
+       return pvr_channel->getCurrentPosition(demux, pos, 1);
 }
 
 RESULT eDVBServicePlay::setTrickmode(int trick)
@@ -841,12 +852,51 @@ int eDVBServicePlay::getInfo(int w)
        
        switch (w)
        {
+       case sAspect:
+               if (!program.videoStreams.empty() && program.videoStreams[0].component_tag != -1)
+               {
+                       ePtr<eServiceEvent> evt;
+                       if (!m_event_handler.getEvent(evt, 0))
+                       {
+                               ePtr<eComponentData> data;
+                               if (!evt->getComponentData(data, program.videoStreams[0].component_tag))
+                               {
+                                       if ( data->getStreamContent() == 1 )
+                                       {
+                                               switch(data->getComponentType())
+                                               {
+                                                       // SD
+                                                       case 1: // 4:3 SD PAL
+                                                       case 2:
+                                                       case 3: // 16:9 SD PAL
+                                                       case 4: // > 16:9 PAL
+                                                       case 5: // 4:3 SD NTSC
+                                                       case 6: 
+                                                       case 7: // 16:9 SD NTSC
+                                                       case 8: // > 16:9 NTSC
+
+                                                       // HD
+                                                       case 9: // 4:3 HD PAL
+                                                       case 0xA:
+                                                       case 0xB: // 16:9 HD PAL
+                                                       case 0xC: // > 16:9 HD PAL
+                                                       case 0xD: // 4:3 HD NTSC
+                                                       case 0xE:
+                                                       case 0xF: // 16:9 HD NTSC
+                                                       case 0x10: // > 16:9 HD PAL
+                                                               return data->getComponentType();
+                                               }
+                                       }
+                               }
+                       }
+               }
+               return -1;
+       case sIsCrypted: return program.isCrypted;
        case sVideoPID: if (program.videoStreams.empty()) return -1; return program.videoStreams[0].pid;
        case sAudioPID: if (program.audioStreams.empty()) return -1; return program.audioStreams[m_current_audio_stream].pid;
        case sPCRPID: return program.pcrPid;
        case sPMTPID: return program.pmtPid;
        case sTXTPID: return -1;
-               
        case sSID: return ((const eServiceReferenceDVB&)m_reference).getServiceID().get();
        case sONID: return ((const eServiceReferenceDVB&)m_reference).getOriginalNetworkID().get();
        case sTSID: return ((const eServiceReferenceDVB&)m_reference).getTransportStreamID().get();
@@ -939,6 +989,23 @@ int eDVBServicePlay::selectAudioStream(int i)
        if (m_decoder->setAudioPID(program.audioStreams[i].pid, program.audioStreams[i].type))
                return -4;
 
+       if (m_dvb_service && !m_is_pvr)
+       {
+               if (m_dvb_service && !m_is_pvr)
+               {
+                       if (program.audioStreams[i].type == eDVBAudio::aMPEG)
+                       {
+                               m_dvb_service->setCachePID(eDVBService::cAPID, program.audioStreams[i].pid);
+                               m_dvb_service->setCachePID(eDVBService::cAC3PID, -1);
+                       }
+                       else
+                       {
+                               m_dvb_service->setCachePID(eDVBService::cAPID, -1);
+                               m_dvb_service->setCachePID(eDVBService::cAC3PID, program.audioStreams[i].pid);
+                       }
+               }
+       }
+
        m_current_audio_stream = i;
 
        return 0;
@@ -970,29 +1037,8 @@ RESULT eDVBServicePlay::getSubservice(eServiceReference &sub, unsigned int n)
        ePtr<eServiceEvent> evt;
        if (!m_event_handler.getEvent(evt, 0))
        {
-               if (!evt->getLinkageService(sub, n))
-               {
-                       eServiceReferenceDVB &subservice = (eServiceReferenceDVB&) sub;
-                       eServiceReferenceDVB &current = (eServiceReferenceDVB&) m_reference;
-                       subservice.setDVBNamespace(current.getDVBNamespace());
-                       if ( current.getParentTransportStreamID().get() )
-                       {
-                               subservice.setParentTransportStreamID( current.getParentTransportStreamID() );
-                               subservice.setParentServiceID( current.getParentServiceID() );
-                       }
-                       else
-                       {
-                               subservice.setParentTransportStreamID( current.getTransportStreamID() );
-                               subservice.setParentServiceID( current.getServiceID() );
-                       }
-                       if ( subservice.getParentTransportStreamID() == subservice.getTransportStreamID() &&
-                               subservice.getParentServiceID() == subservice.getServiceID() )
-                       {
-                               subservice.setParentTransportStreamID( eTransportStreamID(0) );
-                               subservice.setParentServiceID( eServiceID(0) );
-                       }
+               if (!evt->getLinkageService(sub, m_reference, n))
                        return 0;
-               }
        }
        sub.type=eServiceReference::idInvalid;
        return -1;