implement native e2 audio and subtitle track selection interfaces to enable AudioSele...
authorFraxinas <andreas.frisch@multimedia-labs.de>
Thu, 27 Jan 2011 16:02:54 +0000 (17:02 +0100)
committerFraxinas <andreas.frisch@multimedia-labs.de>
Thu, 27 Jan 2011 16:02:54 +0000 (17:02 +0100)
lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.cpp
lib/python/Plugins/Extensions/DVDPlayer/src/servicedvd.h

index 5fbfb0aa3d45f3b69e2bac4949baf2b7212e8f2b..da9c0bb7ff47407feeec230e802491f04e40d1b3 100644 (file)
@@ -397,6 +397,64 @@ RESULT eServiceDVD::subtitle(ePtr<iSubtitleOutput> &ptr)
        return 0;
 }
 
+RESULT eServiceDVD::audioTracks(ePtr<iAudioTrackSelection> &ptr)
+{
+       ptr = this;
+       return 0;
+}
+
+int eServiceDVD::getNumberOfTracks()
+{
+       int i = 0;
+       ddvd_get_audio_count(m_ddvdconfig, &i);
+       eDebug("getNumberOfTracks returns %i", i);
+       return i;
+}
+
+int eServiceDVD::getCurrentTrack()
+{
+       int audio_id,audio_type;
+       uint16_t audio_lang;
+       ddvd_get_last_audio(m_ddvdconfig, &audio_id, &audio_lang, &audio_type);
+       eDebug("getCurrentTrack returns %i", audio_id);
+       return audio_id;
+}
+
+RESULT eServiceDVD::selectTrack(unsigned int i)
+{
+       ddvd_set_audio(m_ddvdconfig, i);
+       eDebug("selectTrack %i", i);
+       return 0;
+}
+
+RESULT eServiceDVD::getTrackInfo(struct iAudioTrackInfo &info, unsigned int audio_id)
+{
+       int audio_type;
+       uint16_t audio_lang;
+       ddvd_get_audio_byid(m_ddvdconfig, audio_id, &audio_lang, &audio_type);
+       char audio_string[3]={audio_lang >> 8, audio_lang, 0};
+       info.m_pid = audio_id+1;
+       info.m_language = audio_string;
+       switch(audio_type)
+       {
+               case DDVD_MPEG:
+                       info.m_description = "MPEG";
+                       break;
+               case DDVD_AC3:
+                       info.m_description = "AC3";
+                       break;
+               case DDVD_DTS:
+                       info.m_description = "DTS";
+                       break;
+               case DDVD_LPCM:
+                       info.m_description = "LPCM";
+                       break;
+               default:
+                       info.m_description = "und";
+       }
+       return 0;
+}
+
 RESULT eServiceDVD::keys(ePtr<iServiceKeys> &ptr)
 {
        ptr=this;
@@ -659,8 +717,28 @@ RESULT eServiceDVD::disableSubtitles(eWidget */*parent*/)
 
 PyObject *eServiceDVD::getSubtitleList()
 {
-       eDebug("eServiceDVD::getSubtitleList nyi");
-       Py_RETURN_NONE;
+       eDebug("eServiceMP3::getSubtitleList");
+
+       ePyObject l = PyList_New(0);
+       unsigned int spu_count = 0;
+       ddvd_get_spu_count(m_ddvdconfig, &spu_count);
+
+       for ( unsigned int spu_id = 0; spu_id < spu_count; spu_id++ )
+       {
+               uint16_t spu_lang;
+               ddvd_get_spu_byid(m_ddvdconfig, spu_id, &spu_lang);
+               char spu_string[3]={spu_lang >> 8, spu_lang, 0};
+
+               ePyObject tuple = PyTuple_New(5);
+               PyTuple_SetItem(tuple, 0, PyInt_FromLong(2));
+               PyTuple_SetItem(tuple, 1, PyInt_FromLong(0));
+               PyTuple_SetItem(tuple, 2, PyInt_FromLong(3));
+               PyTuple_SetItem(tuple, 3, PyInt_FromLong(0));
+               PyTuple_SetItem(tuple, 4, PyString_FromString(spu_string));
+               PyList_Append(l, tuple);
+               Py_DECREF(tuple);
+       }
+       return l;
 }
 
 PyObject *eServiceDVD::getCachedSubtitle()
index c751a39413bdee367c299b4e7c6ba174d66b6f92..80cfcf0c94b954769944cafed7ba6596584c8526 100644 (file)
@@ -26,7 +26,7 @@ public:
        RESULT offlineOperations(const eServiceReference &, ePtr<iServiceOfflineOperations> &ptr);
 };
 
-class eServiceDVD: public iPlayableService, public iPauseableService, public iSeekableService,
+class eServiceDVD: public iPlayableService, public iPauseableService, public iSeekableService, public iAudioTrackSelection,
        public iServiceInformation, public iSubtitleOutput, public iServiceKeys, public iCueSheet, public eThread, public Object
 {
        friend class eServiceFactoryDVD;
@@ -35,7 +35,7 @@ public:
        virtual ~eServiceDVD();
                // not implemented (yet)
        RESULT audioChannel(ePtr<iAudioChannelSelection> &ptr) { ptr = 0; return -1; }
-       RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr) { ptr = 0; return -1; }
+       RESULT audioTracks(ePtr<iAudioTrackSelection> &ptr);
        RESULT frontendInfo(ePtr<iFrontendInformation> &ptr) { ptr = 0; return -1; }
        RESULT subServices(ePtr<iSubserviceList> &ptr) { ptr = 0; return -1; }
        RESULT timeshift(ePtr<iTimeshiftService> &ptr) { ptr = 0; return -1; }
@@ -89,8 +89,15 @@ public:
        void setCutList(SWIG_PYOBJECT(ePyObject));
        void setCutListEnable(int enable);
 
-               // iServiceKeys
+                       // iAudioTrackSelection 
+       int getNumberOfTracks();
+       RESULT selectTrack(unsigned int i);
+       RESULT getTrackInfo(struct iAudioTrackInfo &, unsigned int n);
+       int getCurrentTrack();
+
+       // iServiceKeys
        RESULT keyPressed(int key);
+
 private:
        eServiceDVD(eServiceReference ref);