mirror of
https://github.com/tuxbox-neutrino/neutrino.git
synced 2025-08-30 08:51:10 +02:00
add ait scan (hbbtvurls) to /tmp/ait.txt for now
This commit is contained in:
@@ -142,6 +142,7 @@ class CZapitChannel
|
||||
|
||||
unsigned short pcrPid;
|
||||
unsigned short pmtPid;
|
||||
unsigned short aitPid;
|
||||
unsigned short teletextPid;
|
||||
unsigned short videoPid;
|
||||
unsigned short audioPid;
|
||||
@@ -243,6 +244,7 @@ class CZapitChannel
|
||||
unsigned char getAudioChannelCount(void) { return (unsigned char) audioChannels.size(); }
|
||||
unsigned short getPcrPid(void) { return pcrPid; }
|
||||
unsigned short getPmtPid(void) { return pmtPid; }
|
||||
unsigned short getAitPid(void) { return aitPid; }
|
||||
unsigned short getTeletextPid(void) { return teletextPid; }
|
||||
const char * getTeletextLang(void) { return ttx_language_code.c_str(); }
|
||||
unsigned short getVideoPid(void) { return videoPid; }
|
||||
@@ -266,6 +268,7 @@ class CZapitChannel
|
||||
void setAudioChannel(unsigned char pAudioChannel) { if (pAudioChannel < audioChannels.size()) currentAudioChannel = pAudioChannel; }
|
||||
void setPcrPid(unsigned short pPcrPid) { pcrPid = pPcrPid; }
|
||||
void setPmtPid(unsigned short pPmtPid) { pmtPid = pPmtPid; }
|
||||
void setAitPid(unsigned short pAitPid) { aitPid = pAitPid; }
|
||||
void setTeletextPid(unsigned short pTeletextPid) { teletextPid = pTeletextPid; }
|
||||
void setTeletextLang(std::string lang) { ttx_language_code = lang; };
|
||||
void setVideoPid(unsigned short pVideoPid) { videoPid = pVideoPid; }
|
||||
|
61
src/zapit/include/zapit/scanait.h
Normal file
61
src/zapit/include/zapit/scanait.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Neutrino-GUI - DBoxII-Project
|
||||
*
|
||||
* Copyright (C) 2011 CoolStream International Ltd
|
||||
*
|
||||
* License: GPLv2
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __zapit_scan_ait_h__
|
||||
#define __zapit_scan_ait_h__
|
||||
|
||||
#include <OpenThreads/Thread>
|
||||
#include <hardware/dmx.h>
|
||||
|
||||
#include <dvbsi++/application_information_section.h>
|
||||
#include <dvbsi++/application_name_descriptor.h>
|
||||
#include <dvbsi++/application_profile.h>
|
||||
#include <dvbsi++/application_descriptor.h>
|
||||
|
||||
#define AIT_SECTION_SIZE 4096
|
||||
#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; \
|
||||
}
|
||||
|
||||
class CAit : public OpenThreads::Thread
|
||||
{
|
||||
private:
|
||||
int dmxnum;
|
||||
unsigned short pid;
|
||||
std::string name;
|
||||
ApplicationInformationSectionList sections;
|
||||
void run();
|
||||
bool Read();
|
||||
|
||||
public:
|
||||
CAit(int dnum = 0);
|
||||
~CAit();
|
||||
bool Start();
|
||||
bool Stop();
|
||||
bool Parse();
|
||||
bool Parse(CZapitChannel * const channel);
|
||||
};
|
||||
|
||||
#endif
|
@@ -25,6 +25,7 @@ libzapit_a_SOURCES = \
|
||||
frontend.cpp \
|
||||
getservices.cpp \
|
||||
pat.cpp \
|
||||
scanait.cpp \
|
||||
scanbat.cpp \
|
||||
scan.cpp \
|
||||
scannit.cpp \
|
||||
|
@@ -114,6 +114,7 @@ void CZapitChannel::Init()
|
||||
bUseCI = false;
|
||||
altlogo = "";
|
||||
epgmapper = "";
|
||||
aitPid = 0;
|
||||
}
|
||||
|
||||
CZapitChannel::~CZapitChannel(void)
|
||||
|
239
src/zapit/src/scanait.cpp
Normal file
239
src/zapit/src/scanait.cpp
Normal file
@@ -0,0 +1,239 @@
|
||||
/*
|
||||
* Copyright (C) 2011 CoolStream International Ltd
|
||||
*
|
||||
* License: GPLv2
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation;
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <zapit/debug.h>
|
||||
#include <zapit/getservices.h>
|
||||
#include <hardware/dmx.h>
|
||||
#include <zapit/scanait.h>
|
||||
#include <zapit/scan.h>
|
||||
#include <dvbsi++/descriptor_tag.h>
|
||||
#include <dvbsi++/linkage_descriptor.h>
|
||||
#include <dvbsi++/private_data_specifier_descriptor.h>
|
||||
#include <dvbsi++/transport_protocol_descriptor.h>
|
||||
#include <dvbsi++/simple_application_location_descriptor.h>
|
||||
#include <dvbsi++/simple_application_boundary_descriptor.h>
|
||||
#include <math.h>
|
||||
#include <eitd/edvbstring.h>
|
||||
#include <system/set_threadname.h>
|
||||
|
||||
#define DEBUG_AIT
|
||||
#define DEBUG_AIT_UNUSED
|
||||
#define DEBUG_LCN
|
||||
|
||||
CAit::CAit(int dnum)
|
||||
{
|
||||
dmxnum = dnum;
|
||||
pid = 0;
|
||||
}
|
||||
|
||||
bool CAit::Start()
|
||||
{
|
||||
int ret = start();
|
||||
return (ret == 0);
|
||||
}
|
||||
|
||||
bool CAit::Stop()
|
||||
{
|
||||
int ret = join();
|
||||
return (ret == 0);
|
||||
}
|
||||
|
||||
void CAit::run()
|
||||
{
|
||||
set_threadname("zap:ait");
|
||||
if(Parse())
|
||||
printf("[scan] AIT finished.\n");
|
||||
else
|
||||
printf("[scan] AIT failed !\n");
|
||||
}
|
||||
|
||||
CAit::~CAit()
|
||||
{
|
||||
}
|
||||
|
||||
bool CAit::Read()
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
cDemux * dmx = new cDemux(dmxnum);
|
||||
dmx->Open(DMX_PSI_CHANNEL);
|
||||
|
||||
unsigned char buffer[AIT_SECTION_SIZE];
|
||||
|
||||
unsigned char filter[DMX_FILTER_SIZE];
|
||||
unsigned char mask[DMX_FILTER_SIZE];
|
||||
|
||||
memset(filter, 0x00, DMX_FILTER_SIZE);
|
||||
memset(mask, 0x00, DMX_FILTER_SIZE);
|
||||
|
||||
int flen = 1;
|
||||
filter[0] = 0x74;
|
||||
mask[0] = 0xFF;
|
||||
|
||||
if ((!dmx->sectionFilter(pid, filter, mask, flen)) || (dmx->Read(buffer, AIT_SECTION_SIZE) < 0))
|
||||
{
|
||||
printf("CAit::Read: pid %x failed\n", pid);
|
||||
ret = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("CAit::Read: pid %x found\n", pid);
|
||||
ApplicationInformationSection * ait = new ApplicationInformationSection(buffer);
|
||||
sections.push_back(ait);
|
||||
}
|
||||
dmx->Stop();
|
||||
delete dmx;
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool CAit::Parse()
|
||||
{
|
||||
printf("[ait] trying to parse AIT\n");
|
||||
|
||||
if(!Read())
|
||||
return false;
|
||||
|
||||
FILE * pFile = fopen ("/tmp/ait.txt","w");
|
||||
if (pFile)
|
||||
fprintf(pFile, "Channel: %s\n", name.c_str());
|
||||
short int profilecode = 0;
|
||||
int orgid = 0, appid = 0, profileVersion = 0;
|
||||
|
||||
int sectionLength = 0;
|
||||
ApplicationInformationSectionConstIterator sit;
|
||||
for (sit = sections.begin(); sit != sections.end(); ++sit)
|
||||
{
|
||||
|
||||
if (CServiceScan::getInstance()->Aborted())
|
||||
return false;
|
||||
|
||||
std::list<ApplicationInformation *>::const_iterator i = (*sit)->getApplicationInformation()->begin();
|
||||
sectionLength = (*sit)->getSectionLength() + 3;
|
||||
|
||||
for (; i != (*sit)->getApplicationInformation()->end(); ++i)
|
||||
{
|
||||
std::string hbbtvUrl = "", applicationName = "";
|
||||
std::string TPDescPath = "", SALDescPath = "";
|
||||
int controlCode = (*i)->getApplicationControlCode();
|
||||
ApplicationIdentifier * applicationIdentifier = (ApplicationIdentifier *)(*i)->getApplicationIdentifier();
|
||||
profilecode = 0;
|
||||
orgid = applicationIdentifier->getOrganisationId();
|
||||
appid = applicationIdentifier->getApplicationId();
|
||||
//printf("[ait] found applicaions ids (pid : 0x%x) : orgid : %d, appid : %d\n", pid, orgid, appid);
|
||||
if (controlCode == 1 || controlCode == 2) /* 1:AUTOSTART, 2:PRESENT */
|
||||
{
|
||||
for (DescriptorConstIterator desc = (*i)->getDescriptors()->begin();
|
||||
desc != (*i)->getDescriptors()->end(); ++desc)
|
||||
{
|
||||
switch ((*desc)->getTag())
|
||||
{
|
||||
case APPLICATION_DESCRIPTOR:
|
||||
{
|
||||
ApplicationDescriptor* applicationDescriptor = (ApplicationDescriptor*)(*desc);
|
||||
const 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);
|
||||
ApplicationNameConstIterator interactionit = nameDescriptor->getApplicationNames()->begin();
|
||||
for(; interactionit != nameDescriptor->getApplicationNames()->end(); ++interactionit)
|
||||
{
|
||||
applicationName = (*interactionit)->getApplicationName();
|
||||
//if(controlCode == 1) printf("[ait] applicationname: %s\n", applicationName.c_str());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TRANSPORT_PROTOCOL_DESCRIPTOR:
|
||||
{
|
||||
TransportProtocolDescriptor *transport = (TransportProtocolDescriptor*)(*desc);
|
||||
switch (transport->getProtocolId())
|
||||
{
|
||||
case 1: /* object carousel */
|
||||
break;
|
||||
case 2: /* ip */
|
||||
break;
|
||||
case 3: /* interaction */
|
||||
{
|
||||
InterActionTransportConstIterator interactionit = transport->getInteractionTransports()->begin();
|
||||
for(; interactionit != transport->getInteractionTransports()->end(); ++interactionit)
|
||||
{
|
||||
TPDescPath = (*interactionit)->getUrlBase()->getUrl();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case GRAPHICS_CONSTRAINTS_DESCRIPTOR:
|
||||
break;
|
||||
case SIMPLE_APPLICATION_LOCATION_DESCRIPTOR:
|
||||
{
|
||||
SimpleApplicationLocationDescriptor *applicationlocation = (SimpleApplicationLocationDescriptor*)(*desc);
|
||||
SALDescPath = applicationlocation->getInitialPath();
|
||||
break;
|
||||
}
|
||||
case APPLICATION_USAGE_DESCRIPTOR:
|
||||
break;
|
||||
case SIMPLE_APPLICATION_BOUNDARY_DESCRIPTOR:
|
||||
break;
|
||||
}
|
||||
}
|
||||
hbbtvUrl = TPDescPath + SALDescPath;
|
||||
}
|
||||
if(!hbbtvUrl.empty())
|
||||
{
|
||||
printf("[ait] detected AppID: %d, AppName: %s, Url: %s\n", appid, applicationName.c_str(), hbbtvUrl.c_str());
|
||||
if (pFile)
|
||||
{
|
||||
fprintf(pFile, "AppID: %d, AppName: %s, Url: %s\n", appid, applicationName.c_str(), hbbtvUrl.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pFile)
|
||||
fclose(pFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CAit::Parse(CZapitChannel * const channel)
|
||||
{
|
||||
pid = channel->getAitPid();
|
||||
name = channel->getName();
|
||||
unlink("/tmp/ait.txt");
|
||||
if(pid > 0)
|
||||
{
|
||||
Parse();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
@@ -38,6 +38,10 @@
|
||||
#include <dvbsi++/teletext_descriptor.h>
|
||||
#include <dvbsi++/subtitling_descriptor.h>
|
||||
#include <dvbsi++/vbi_teletext_descriptor.h>
|
||||
#include <dvbsi++/application_information_section.h>
|
||||
#include <dvbsi++/application_name_descriptor.h>
|
||||
#include <dvbsi++/application_profile.h>
|
||||
#include <dvbsi++/application_descriptor.h>
|
||||
|
||||
#define DEBUG_PMT
|
||||
//#define DEBUG_PMT_UNUSED
|
||||
@@ -331,6 +335,18 @@ bool CPmt::ParseEsInfo(ElementaryStreamInfo *esinfo, CZapitChannel * const chann
|
||||
audio_type = CZapitAudioChannel::EAC3;
|
||||
audio = true;
|
||||
break;
|
||||
case STREAM_TYPE_PRIVATE_SECTION:
|
||||
for (DescriptorConstIterator desc = esinfo->getDescriptors()->begin(); desc != esinfo->getDescriptors()->end(); ++desc)
|
||||
{
|
||||
switch ((*desc)->getTag())
|
||||
{
|
||||
case APPLICATION_SIGNALLING_DESCRIPTOR:
|
||||
channel->setAitPid(esinfo->getPid());
|
||||
printf("[pmt] found aitpid: 0x%x\n", esinfo->getPid());
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
#ifdef DEBUG_PMT_UNUSED
|
||||
printf("PMT: pid %04x stream_type: %02x\n", esinfo->getPid(), stream_type);
|
||||
|
@@ -45,6 +45,7 @@
|
||||
#include <zapit/getservices.h>
|
||||
#include <zapit/pat.h>
|
||||
#include <zapit/scanpmt.h>
|
||||
#include <zapit/scanait.h>
|
||||
#include <zapit/scan.h>
|
||||
//#include <zapit/fastscan.h>
|
||||
#include <zapit/scansdt.h>
|
||||
@@ -489,6 +490,7 @@ bool CZapit::ParsePatPmt(CZapitChannel * channel)
|
||||
|
||||
CPat pat(channel->getRecordDemux());
|
||||
CPmt pmt(channel->getRecordDemux());
|
||||
CAit ait(channel->getRecordDemux());
|
||||
DBG("looking up pids for channel_id " PRINTF_CHANNEL_ID_TYPE "\n", channel->getChannelID());
|
||||
|
||||
if(!pat.Parse(channel)) {
|
||||
@@ -499,6 +501,10 @@ bool CZapit::ParsePatPmt(CZapitChannel * channel)
|
||||
printf("[zapit] pmt parsing failed\n");
|
||||
return false;
|
||||
}
|
||||
if (channel == current_channel)
|
||||
if(!ait.Parse(channel)) {
|
||||
printf("[zapit] ait parsing failed\n");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
Reference in New Issue
Block a user