[hbbtv] changed ait handle
[vuplus_dvbapp] / lib / dvb / pmt.cpp
index 5b19ebd..5b89e8a 100644 (file)
@@ -117,6 +117,7 @@ void eDVBServicePMTHandler::PMTready(int error)
        {
                m_have_cached_program = false;
                serviceEvent(eventNewProgramInfo);
+               mDemuxId = m_decode_demux_num;
                if (!m_pvr_channel) // don't send campmt to camd.socket for playbacked services
                {
                        eEPGCache::getInstance()->PMTready(this);
@@ -223,13 +224,23 @@ void saveData(int orgid, unsigned char* data, int sectionLength)
        close(fd);
 }
 
+#include <dvbsi++/application_profile.h>
+#include <dvbsi++/application_descriptor.h>
+#include <dvbsi++/simple_application_boundary_descriptor.h>
+#define PACK_VERSION(major,minor,micro) (((major) << 16) + ((minor) << 8) + (micro))
+#define UNPACK_VERSION(version,major,minor,micro) { \
+       major = (version)&0xff; \
+       minor = (version>>8)&0xff; \
+       micro = (version>>16)&0xff; \
+}
 void eDVBServicePMTHandler::AITready(int error)
 {
        eDebug("AITready");
        ePtr<eTable<ApplicationInformationSection> > ptr;
        if (!m_AIT.getCurrent(ptr))
        {
-               int orgid = 0, appid = 0;
+               short profilecode = 0;
+               int orgid = 0, appid = 0, profileVersion = 0;
                m_ApplicationName = m_HBBTVUrl = "";
 
                eraseHbbTVApplications(&m_HbbTVApplications);
@@ -245,9 +256,11 @@ void eDVBServicePMTHandler::AITready(int error)
                        for (; i != (*it)->getApplicationInformation()->end(); ++i)
                        {
                                std::string hbbtvUrl = "", applicaionName = "";
-
+                               std::string boundaryExtension = "";
+                               
                                int controlCode = (*i)->getApplicationControlCode();
                                ApplicationIdentifier * applicationIdentifier = (*i)->getApplicationIdentifier();
+                               profilecode = 0;
                                orgid = applicationIdentifier->getOrganisationId();
                                appid = applicationIdentifier->getApplicationId();
                                eDebug("found applicaions ids >> pid : %x, orgid : %d, appid : %d", m_ait_pid, orgid, appid);
@@ -259,7 +272,21 @@ void eDVBServicePMTHandler::AITready(int error)
                                                switch ((*desc)->getTag())
                                                {
                                                case APPLICATION_DESCRIPTOR:
+                                               {
+                                                       ApplicationDescriptor* applicationDescriptor = (ApplicationDescriptor*)(*desc);
+                                                       ApplicationProfileList* applicationProfiles = applicationDescriptor->getApplicationProfiles();
+                                                       ApplicationProfileConstIterator interactionit = applicationProfiles->begin();
+                                                       for(; interactionit != applicationProfiles->end(); ++interactionit)
+                                                       {
+                                                               profilecode = (*interactionit)->getApplicationProfile();
+                                                               profileVersion = PACK_VERSION(
+                                                                       (*interactionit)->getVersionMajor(),
+                                                                       (*interactionit)->getVersionMinor(),
+                                                                       (*interactionit)->getVersionMicro()
+                                                               );
+                                                       }
                                                        break;
+                                               }
                                                case APPLICATION_NAME_DESCRIPTOR:
                                                {
                                                        ApplicationNameDescriptor *nameDescriptor  = (ApplicationNameDescriptor*)(*desc);
@@ -291,7 +318,6 @@ void eDVBServicePMTHandler::AITready(int error)
                                                                        for(; interactionit != transport->getInteractionTransports()->end(); ++interactionit)
                                                                        {
                                                                                hbbtvUrl = (*interactionit)->getUrlBase()->getUrl();
-                                                                               if(controlCode == 1) m_HBBTVUrl = hbbtvUrl;
                                                                                break;
                                                                        }
                                                                        break;
@@ -314,7 +340,45 @@ void eDVBServicePMTHandler::AITready(int error)
                                                }
                                        }
                                }
-                               m_HbbTVApplications.push_back(new HbbTVApplicationInfo(controlCode, orgid, appid, hbbtvUrl, applicaionName));
+                               if(!hbbtvUrl.empty())
+                               {
+                                       char* uu = hbbtvUrl.c_str();
+                                       if(!strncmp(uu, "http://", 7) || !strncmp(uu, "dvb://", 6) || !strncmp(uu, "https://", 8))
+                                       {
+                                               if(controlCode == 1) m_HBBTVUrl = hbbtvUrl;
+                                               switch(profileVersion)
+                                               {
+                                               case 65793:
+                                               case 66049:
+                                                       m_HbbTVApplications.push_back(new HbbTVApplicationInfo(controlCode, orgid, appid, hbbtvUrl, applicaionName, profilecode));
+                                                       break;
+                                               case 1280:
+                                               case 65538:
+                                               default:
+                                                       m_HbbTVApplications.push_back(new HbbTVApplicationInfo((-1)*controlCode, orgid, appid, hbbtvUrl, applicaionName, profilecode));
+                                                       break;
+                                               }
+                                       }
+                                       else if (!boundaryExtension.empty()) {
+                                               if(boundaryExtension.at(boundaryExtension.length()-1) != '/') {
+                                                       boundaryExtension += "/";
+                                               }
+                                               boundaryExtension += hbbtvUrl;
+                                               if(controlCode == 1) m_HBBTVUrl = boundaryExtension;
+                                               switch(profileVersion)
+                                               {
+                                               case 65793:
+                                               case 66049:
+                                                       m_HbbTVApplications.push_back(new HbbTVApplicationInfo(controlCode, orgid, appid, boundaryExtension, applicaionName, profilecode));
+                                                       break;
+                                               case 1280:
+                                               case 65538:
+                                               default:
+                                                       m_HbbTVApplications.push_back(new HbbTVApplicationInfo((-1)*controlCode, orgid, appid, boundaryExtension, applicaionName, profilecode));
+                                                       break;
+                                               }
+                                       }
+                               }
                        }
                }
 
@@ -392,12 +456,13 @@ PyObject *eDVBServicePMTHandler::getHbbTVApplications(void)
        {
                for(HbbTVApplicationInfoListConstIterator infoiter = m_HbbTVApplications.begin() ; infoiter != m_HbbTVApplications.end() ; ++infoiter)
                {
-                       ePyObject tuple = PyTuple_New(5);
+                       ePyObject tuple = PyTuple_New(6);
                        PyTuple_SET_ITEM(tuple, 0, PyInt_FromLong((*infoiter)->m_ControlCode));
                        PyTuple_SET_ITEM(tuple, 1, PyString_FromString((*infoiter)->m_ApplicationName.c_str()));
                        PyTuple_SET_ITEM(tuple, 2, PyString_FromString((*infoiter)->m_HbbTVUrl.c_str()));
                        PyTuple_SET_ITEM(tuple, 3, PyInt_FromLong((*infoiter)->m_OrgId));
                        PyTuple_SET_ITEM(tuple, 4, PyInt_FromLong((*infoiter)->m_AppId));
+                       PyTuple_SET_ITEM(tuple, 5, PyInt_FromLong((*infoiter)->m_ProfileCode));
                        PyList_Append(ret, tuple);
                        Py_DECREF(tuple);
                }