use eit component tags to get language info of audio streams (premiere)
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 5 Dec 2005 11:17:11 +0000 (11:17 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Mon, 5 Dec 2005 11:17:11 +0000 (11:17 +0000)
lib/dvb/pmt.cpp
lib/python/Screens/AudioSelection.py
lib/service/event.cpp
lib/service/event.h
lib/service/servicedvb.cpp

index 19e6cf9cf510ca9c93e8d5637e860212a7960b83..fdee5b40cb1c0274bd743b1c545b6c3bd31b363d 100644 (file)
@@ -7,7 +7,7 @@
 #include <dvbsi++/ca_program_map_section.h>
 #include <dvbsi++/descriptor_tag.h>
 #include <dvbsi++/iso639_language_descriptor.h>
-#include <dvbsi++/component_descriptor.h>
+#include <dvbsi++/stream_identifier_descriptor.h>
 
 eDVBServicePMTHandler::eDVBServicePMTHandler(int record)
        :m_ca_servicePtr(0)
@@ -143,6 +143,7 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
                                int isaudio = 0, isvideo = 0;
                                videoStream video;
                                audioStream audio;
+                               audio.component_tag=-1;
                                
                                video.pid = (*es)->getPid();
                                audio.pid = (*es)->getPid();
@@ -191,8 +192,8 @@ int eDVBServicePMTHandler::getProgramInfo(struct program &program)
 
                                                        break;
                                                }
-                                               case COMPONENT_DESCRIPTOR:
-                                                       audio.component_tag = ((ComponentDescriptor*)*desc)->getComponentTag();
+                                               case STREAM_IDENTIFIER_DESCRIPTOR:
+                                                       audio.component_tag = ((StreamIdentifierDescriptor*)*desc)->getComponentTag();
                                                        break;
                                                }
                                        }
index a38417475e62feaee4b6b106280812d499dcdf21..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1,42 +0,0 @@
-from Screen import Screen
-from Components.ActionMap import ActionMap
-from Components.MenuList import MenuList
-from Components.Label import Label
-from Tools.ISO639 import LanguageCodes
-
-class AudioSelection(Screen):
-       def KeyOk(self):
-               selection = self["tracks"].getCurrent()
-               print "select track " + str(selection[1])
-               
-               self.audio.selectTrack(selection[1])
-               self.close()
-       def __init__(self, session, audio):
-               Screen.__init__(self, session)
-
-               self["actions"] = ActionMap(["OkCancelActions"], 
-                       {
-                               "cancel": self.close,
-                               "ok": self.KeyOk,
-                       })
-
-               self.audio = audio
-
-               tlist = []
-               n = audio.getNumberOfTracks()
-               for x in range(n):
-                       i = audio.getTrackInfo(x)
-                       langCode = i.getLanguage()
-                       
-                       description = i.getDescription();
-                       
-                       if langCode in LanguageCodes:
-                               language = LanguageCodes[langCode][0]
-                               if len(description):
-                                       description += " (" + language + ")"
-                               else:
-                                       description = language
-
-                       tlist.append((description, x))
-
-               self["tracks"] = MenuList(tlist)
index e76ea315968b3adbfa997f3837f8cb7eaa15d6c5..81a8d4bb1de2f6e195e4409617e74dcb62ea8146 100644 (file)
@@ -6,9 +6,11 @@
 #include <dvbsi++/short_event_descriptor.h>
 #include <dvbsi++/extended_event_descriptor.h>
 #include <dvbsi++/linkage_descriptor.h>
+#include <dvbsi++/component_descriptor.h>
 #include <dvbsi++/descriptor_tag.h>
 
 DEFINE_REF(eServiceEvent);
+DEFINE_REF(eComponentData);
 
 const char MAX_LANG = 37;
 /* OSD language (see /share/locales/locales) to iso639 conversion table */
@@ -109,18 +111,30 @@ bool eServiceEvent::loadLanguage(Event *evt, std::string lang, int tsidonid)
                {
                        switch ((*desc)->getTag())
                        {
+                               case COMPONENT_DESCRIPTOR:
+                               {
+                                       const ComponentDescriptor *cp = (ComponentDescriptor*)*desc;
+                                       eComponentData data;
+                                       data.m_streamContent = cp->getStreamContent();
+                                       data.m_componentType = cp->getComponentType();
+                                       data.m_componentTag = cp->getComponentTag();
+                                       data.m_iso639LanguageCode = cp->getIso639LanguageCode();
+                                       data.m_text = convertDVBUTF8(cp->getText());
+                                       m_component_data.push_back(data);
+                                       break;
+                               }
                                case LINKAGE_DESCRIPTOR:
                                {
                                        const LinkageDescriptor  *ld = (LinkageDescriptor*)*desc;
                                        if ( ld->getLinkageType() == 0xB0 )
                                        {
                                                linkage_service s;
-                                               s.onid = ld->getOriginalNetworkId();
-                                               s.tsid = ld->getTransportStreamId();
-                                               s.sid = ld->getServiceId();
+                                               s.m_onid = ld->getOriginalNetworkId();
+                                               s.m_tsid = ld->getTransportStreamId();
+                                               s.m_sid = ld->getServiceId();
                                                const PrivateDataByteVector *privateData =
                                                        ld->getPrivateDataBytes();
-                                               s.description.assign((const char*)&((*privateData)[0]), privateData->size());
+                                               s.m_description.assign((const char*)&((*privateData)[0]), privateData->size());
                                                m_linkage_services.push_back(s);
                                        }
                                        break;
@@ -158,7 +172,7 @@ RESULT eServiceEvent::parseFrom(Event *evt, int tsidonid)
        return 0;
 }
 
-std::string eServiceEvent::getBeginTimeString()
+std::string eServiceEvent::getBeginTimeString() const
 {
        tm t;
        localtime_r(&m_begin, &t);
@@ -169,4 +183,20 @@ std::string eServiceEvent::getBeginTimeString()
        return std::string(tmp, 12);
 }
 
+RESULT eServiceEvent::getComponentData(ePtr<eComponentData> &dest, int tagnum) const
+{
+       std::list<eComponentData>::const_iterator it =
+               m_component_data.begin();
+       for(;it != m_component_data.end(); ++it)
+       {
+               if ( it->m_componentTag == tagnum )
+               {
+                       dest=new eComponentData(*it);
+                       return 0;
+               }
+       }
+       dest=0;
+       return -1;
+}
+
 DEFINE_REF(eDebugClass);
index 3bbb322efd127ffe4e82a991395b8922e2fbafde..d224c183de311f9f42119657afec2e4e5c5d3f4a 100644 (file)
@@ -9,21 +9,42 @@
 class Event;
 #endif
 
+struct eComponentData
+{
+DECLARE_REF(eComponentData);
+#ifndef SWIG
+       uint8_t m_streamContent;
+       uint8_t m_componentType;
+       uint8_t m_componentTag;
+       std::string m_iso639LanguageCode;
+       std::string m_text;
+#endif
+       int getStreamContent(void) const { return m_streamContent; }
+       int getComponentType(void) const { return m_componentType; }
+       int getComponentTag(void) const { return m_componentTag; }
+       std::string getIso639LanguageCode(void) const { return m_iso639LanguageCode; }
+       std::string getText(void) const { return m_text; }
+};
+
+TEMPLATE_TYPEDEF(ePtr<eComponentData>, eComponentDataPtr);
+
+struct linkage_service
+{
+       uint16_t m_sid;
+       uint16_t m_onid;
+       uint16_t m_tsid;
+       std::string m_description;
+};
+
 class eServiceEvent: public iObject
 {
 DECLARE_REF(eServiceEvent);
 #ifndef SWIG
        bool loadLanguage(Event *event, std::string lang, int tsidonid);
+       std::list<eComponentData> m_component_data;
 #endif
 public:
 #ifndef SWIG
-       struct linkage_service
-       {
-               uint16_t sid;
-               uint16_t onid;
-               uint16_t tsid;
-               std::string description;
-       };
        std::list<linkage_service> m_linkage_services;
        time_t m_begin;
        int m_duration;
@@ -31,12 +52,13 @@ public:
        // .. additional info
        RESULT parseFrom(Event *evt, int tsidonid=0);
 #endif
-       time_t getBeginTime() { return m_begin; }
-       int getDuration() { return m_duration; }
-       std::string getEventName() { return m_event_name; }
-       std::string getShortDescription() { return m_short_description; }
-       std::string getExtendedDescription() { return m_extended_description; }
-       std::string getBeginTimeString();
+       time_t getBeginTime() const { return m_begin; }
+       int getDuration() const { return m_duration; }
+       std::string getEventName() const { return m_event_name; }
+       std::string getShortDescription() const { return m_short_description; }
+       std::string getExtendedDescription() const { return m_extended_description; }
+       std::string getBeginTimeString() const;
+       SWIG_VOID(RESULT) getComponentData(ePtr<eComponentData> &SWIG_OUTPUT, int tagnum) const;
 };
 
 TEMPLATE_TYPEDEF(ePtr<eServiceEvent>, eServiceEventPtr);
index 271b94f075e4a38922f812d430d15369b6eea590..3cb5387abdadf54a36b463b15f5027e074ea8715 100644 (file)
@@ -789,9 +789,20 @@ RESULT eDVBServicePlay::getTrackInfo(struct iAudioTrackInfo &info, unsigned int
                info.m_description = "DTS";
        else
                info.m_description = "???";
-       
-               /* CHECK here for component tag override. */
-       info.m_language = program.audioStreams[i].language_code;
+
+       if (program.audioStreams[i].component_tag != -1)
+       {
+               ePtr<eServiceEvent> evt;
+               if (!m_event_handler.getEvent(evt, 0))
+               {
+                       ePtr<eComponentData> data;
+                       if (!evt->getComponentData(data, program.audioStreams[i].component_tag))
+                               info.m_language = data->getText();
+               }
+       }
+
+       if (info.m_language.empty())
+               info.m_language = program.audioStreams[i].language_code;
        
        return 0;
 }
@@ -803,7 +814,7 @@ int eDVBServicePlay::selectAudioStream(int i)
        if (m_service_handler.getProgramInfo(program))
                return -1;
        
-       if (i >= program.audioStreams.size())
+       if ((unsigned int)i >= program.audioStreams.size())
                return -2;
        
        if (!m_decoder)