[Videomode] support HDMI colorspace. (Currently, this option is effective only solo4k)
[vuplus_dvbapp] / lib / dvb / pmt.cpp
index 74f896f..6f0c9ee 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);
@@ -213,6 +214,16 @@ void saveData(int orgid, unsigned char* data, int sectionLength)
        int fd = 0, rc = 0;
        char fileName[255] = {0};
        sprintf(fileName, "/tmp/ait.%d", orgid);
+
+       if (data[6] > 0) {
+               eDebug("section_number %d > 0", data[6]);
+               data[6] = 0;
+       }
+       if (data[7] > data[6]) {
+               eDebug("last_section_number %d > section_number %d", data[7], data[6]);
+               data[7] = data[6];
+       }
+
        if((fd = open(fileName, O_RDWR|O_CREAT|O_TRUNC)) < 0)
        {
                eDebug("Fail to save a AIT Data.");
@@ -225,6 +236,7 @@ void saveData(int orgid, unsigned char* data, int sectionLength)
 
 #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; \
@@ -243,23 +255,26 @@ void eDVBServicePMTHandler::AITready(int error)
 
                eraseHbbTVApplications(&m_HbbTVApplications);
 
-               memcpy(m_AITData, ptr->getBufferData(), 4096);
-
                int sectionLength = 0;
                for (std::vector<ApplicationInformationSection*>::const_iterator it = ptr->getSections().begin(); it != ptr->getSections().end(); ++it)
                {
                        std::list<ApplicationInformation *>::const_iterator i = (*it)->getApplicationInformation()->begin();
-                       sectionLength += (*it)->getSectionLength();
+                       memcpy(m_AITData, ptr->getBufferData(), 4096);
+                       sectionLength = (*it)->getSectionLength() + 3;
                        eDebug("Section Length : %d, Total Section Length : %d", (*it)->getSectionLength(), sectionLength);
                        for (; i != (*it)->getApplicationInformation()->end(); ++i)
                        {
                                std::string hbbtvUrl = "", applicaionName = "";
-
+                               std::string boundaryExtension = "";
+                               
                                int controlCode = (*i)->getApplicationControlCode();
-                               ApplicationIdentifier * applicationIdentifier = (*i)->getApplicationIdentifier();
+                               const 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);
+                               if (controlCode == 1)
+                                       saveData(orgid, m_AITData, sectionLength);
                                if (controlCode == 1 || controlCode == 2) /* 1:AUTOSTART, 2:ETC */
                                {
                                        for (DescriptorConstIterator desc = (*i)->getDescriptors()->begin();
@@ -270,7 +285,7 @@ void eDVBServicePMTHandler::AITready(int error)
                                                case APPLICATION_DESCRIPTOR:
                                                {
                                                        ApplicationDescriptor* applicationDescriptor = (ApplicationDescriptor*)(*desc);
-                                                       ApplicationProfileList* applicationProfiles = applicationDescriptor->getApplicationProfiles();
+                                                       const ApplicationProfileList* applicationProfiles = applicationDescriptor->getApplicationProfiles();
                                                        ApplicationProfileConstIterator interactionit = applicationProfiles->begin();
                                                        for(; interactionit != applicationProfiles->end(); ++interactionit)
                                                        {
@@ -314,7 +329,6 @@ void eDVBServicePMTHandler::AITready(int error)
                                                                        for(; interactionit != transport->getInteractionTransports()->end(); ++interactionit)
                                                                        {
                                                                                hbbtvUrl = (*interactionit)->getUrlBase()->getUrl();
-                                                                               if(controlCode == 1) m_HBBTVUrl = hbbtvUrl;
                                                                                break;
                                                                        }
                                                                        break;
@@ -339,9 +353,10 @@ void eDVBServicePMTHandler::AITready(int error)
                                }
                                if(!hbbtvUrl.empty())
                                {
-                                       char* uu = hbbtvUrl.c_str();
+                                       const 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:
@@ -355,16 +370,40 @@ void eDVBServicePMTHandler::AITready(int error)
                                                        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;
+                                               }
+                                       }
                                }
                        }
                }
 
                if (m_HbbTVApplications.size())
                {
-                       saveData(orgid, m_AITData, sectionLength);//4096);
                        for(HbbTVApplicationInfoListConstIterator infoiter = m_HbbTVApplications.begin() ; infoiter != m_HbbTVApplications.end() ; ++infoiter)
+                       {
+                               char fileName[255] = {0};
+                               sprintf(fileName, "/tmp/ait.%d", (*infoiter)->m_OrgId);
+                               if (access(fileName, 0) < 0)
+                                       saveData((*infoiter)->m_OrgId, m_AITData, sectionLength);
                                eDebug("Found : control[%d], name[%s], url[%s]", 
                                        (*infoiter)->m_ControlCode, (*infoiter)->m_ApplicationName.c_str(), (*infoiter)->m_HbbTVUrl.c_str());
+                       }
                        serviceEvent(eventHBBTVInfo);
                }
                else eDebug("No found anything.");
@@ -381,7 +420,7 @@ void eDVBServicePMTHandler::OCready(int error)
        {
                for (std::vector<OCSection*>::const_iterator it = ptr->getSections().begin(); it != ptr->getSections().end(); ++it)
                {
-                       unsigned char* sectionData = (*it)->getData();
+                       unsigned char* sectionData = (unsigned char*)(*it)->getData();
                }
        }
        /* for now, do not keep listening for table updates */
@@ -532,6 +571,13 @@ int eDVBServicePMTHandler::getProgramInfo(program &program)
                                                video.type = videoStream::vtMPEG4_H264;
                                                isvideo = 1;
                                                //break; fall through !!!
+                                       case 0x24: // H265 HEVC
+                                               if (!isvideo)
+                                               {
+                                                       video.type = videoStream::vtH265_HEVC;
+                                                       isvideo = 1;
+                                               }
+                                               //break; fall through !!!
                                        case 0x10: // MPEG 4 Part 2
                                                if (!isvideo)
                                                {