2003-12-22 13:29:24 +01:00
|
|
|
/*
|
|
|
|
* pat.c: PAT section filter
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2010-06-05 13:50:56 +02:00
|
|
|
* $Id: pat.c 2.11 2010/06/05 13:26:47 kls Exp $
|
2003-12-22 13:29:24 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "pat.h"
|
|
|
|
#include <malloc.h>
|
2004-01-04 12:30:00 +01:00
|
|
|
#include "channels.h"
|
2003-12-22 13:29:24 +01:00
|
|
|
#include "libsi/section.h"
|
|
|
|
#include "libsi/descriptor.h"
|
2004-01-04 12:30:00 +01:00
|
|
|
#include "thread.h"
|
2003-12-22 13:29:24 +01:00
|
|
|
|
|
|
|
#define PMT_SCAN_TIMEOUT 10 // seconds
|
|
|
|
|
|
|
|
// --- cCaDescriptor ---------------------------------------------------------
|
|
|
|
|
|
|
|
class cCaDescriptor : public cListObject {
|
|
|
|
private:
|
|
|
|
int caSystem;
|
2009-08-15 22:19:42 +02:00
|
|
|
int esPid;
|
2003-12-22 13:29:24 +01:00
|
|
|
int length;
|
|
|
|
uchar *data;
|
|
|
|
public:
|
2009-08-15 22:19:42 +02:00
|
|
|
cCaDescriptor(int CaSystem, int CaPid, int EsPid, int Length, const uchar *Data);
|
2003-12-22 13:29:24 +01:00
|
|
|
virtual ~cCaDescriptor();
|
2004-01-04 12:30:00 +01:00
|
|
|
bool operator== (const cCaDescriptor &arg) const;
|
|
|
|
int CaSystem(void) { return caSystem; }
|
2009-08-15 22:19:42 +02:00
|
|
|
int EsPid(void) { return esPid; }
|
2003-12-22 13:29:24 +01:00
|
|
|
int Length(void) const { return length; }
|
|
|
|
const uchar *Data(void) const { return data; }
|
|
|
|
};
|
|
|
|
|
2009-08-15 22:19:42 +02:00
|
|
|
cCaDescriptor::cCaDescriptor(int CaSystem, int CaPid, int EsPid, int Length, const uchar *Data)
|
2003-12-22 13:29:24 +01:00
|
|
|
{
|
|
|
|
caSystem = CaSystem;
|
2009-08-15 22:19:42 +02:00
|
|
|
esPid = EsPid;
|
2003-12-22 13:29:24 +01:00
|
|
|
length = Length + 6;
|
|
|
|
data = MALLOC(uchar, length);
|
|
|
|
data[0] = SI::CaDescriptorTag;
|
|
|
|
data[1] = length - 2;
|
|
|
|
data[2] = (caSystem >> 8) & 0xFF;
|
|
|
|
data[3] = caSystem & 0xFF;
|
|
|
|
data[4] = ((CaPid >> 8) & 0x1F) | 0xE0;
|
|
|
|
data[5] = CaPid & 0xFF;
|
|
|
|
if (Length)
|
|
|
|
memcpy(&data[6], Data, Length);
|
|
|
|
}
|
|
|
|
|
|
|
|
cCaDescriptor::~cCaDescriptor()
|
|
|
|
{
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
|
2004-01-04 12:30:00 +01:00
|
|
|
bool cCaDescriptor::operator== (const cCaDescriptor &arg) const
|
|
|
|
{
|
2009-08-15 22:19:42 +02:00
|
|
|
return esPid == arg.esPid && length == arg.length && memcmp(data, arg.data, length) == 0;
|
2004-01-04 12:30:00 +01:00
|
|
|
}
|
|
|
|
|
2003-12-22 13:29:24 +01:00
|
|
|
// --- cCaDescriptors --------------------------------------------------------
|
|
|
|
|
2004-01-04 12:30:00 +01:00
|
|
|
class cCaDescriptors : public cListObject {
|
2003-12-22 13:29:24 +01:00
|
|
|
private:
|
2004-01-04 12:30:00 +01:00
|
|
|
int source;
|
|
|
|
int transponder;
|
|
|
|
int serviceId;
|
|
|
|
int numCaIds;
|
|
|
|
int caIds[MAXCAIDS + 1];
|
|
|
|
cList<cCaDescriptor> caDescriptors;
|
|
|
|
void AddCaId(int CaId);
|
2003-12-22 13:29:24 +01:00
|
|
|
public:
|
2004-01-04 12:30:00 +01:00
|
|
|
cCaDescriptors(int Source, int Transponder, int ServiceId);
|
|
|
|
bool operator== (const cCaDescriptors &arg) const;
|
|
|
|
bool Is(int Source, int Transponder, int ServiceId);
|
|
|
|
bool Is(cCaDescriptors * CaDescriptors);
|
|
|
|
bool Empty(void) { return caDescriptors.Count() == 0; }
|
2009-08-15 22:19:42 +02:00
|
|
|
void AddCaDescriptor(SI::CaDescriptor *d, int EsPid);
|
|
|
|
int GetCaDescriptors(const int *CaSystemIds, int BufSize, uchar *Data, int EsPid);
|
2004-01-04 12:30:00 +01:00
|
|
|
const int *CaIds(void) { return caIds; }
|
2003-12-22 13:29:24 +01:00
|
|
|
};
|
|
|
|
|
2004-01-04 12:30:00 +01:00
|
|
|
cCaDescriptors::cCaDescriptors(int Source, int Transponder, int ServiceId)
|
|
|
|
{
|
|
|
|
source = Source;
|
|
|
|
transponder = Transponder;
|
|
|
|
serviceId = ServiceId;
|
|
|
|
numCaIds = 0;
|
|
|
|
caIds[0] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cCaDescriptors::operator== (const cCaDescriptors &arg) const
|
|
|
|
{
|
|
|
|
cCaDescriptor *ca1 = caDescriptors.First();
|
|
|
|
cCaDescriptor *ca2 = arg.caDescriptors.First();
|
|
|
|
while (ca1 && ca2) {
|
|
|
|
if (!(*ca1 == *ca2))
|
|
|
|
return false;
|
|
|
|
ca1 = caDescriptors.Next(ca1);
|
|
|
|
ca2 = arg.caDescriptors.Next(ca2);
|
|
|
|
}
|
|
|
|
return !ca1 && !ca2;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cCaDescriptors::Is(int Source, int Transponder, int ServiceId)
|
|
|
|
{
|
|
|
|
return source == Source && transponder == Transponder && serviceId == ServiceId;
|
|
|
|
}
|
|
|
|
|
2004-01-25 15:32:08 +01:00
|
|
|
bool cCaDescriptors::Is(cCaDescriptors *CaDescriptors)
|
2004-01-04 12:30:00 +01:00
|
|
|
{
|
|
|
|
return Is(CaDescriptors->source, CaDescriptors->transponder, CaDescriptors->serviceId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void cCaDescriptors::AddCaId(int CaId)
|
|
|
|
{
|
|
|
|
if (numCaIds < MAXCAIDS) {
|
|
|
|
for (int i = 0; i < numCaIds; i++) {
|
|
|
|
if (caIds[i] == CaId)
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
caIds[numCaIds++] = CaId;
|
|
|
|
caIds[numCaIds] = 0;
|
2003-12-22 13:29:24 +01:00
|
|
|
}
|
2004-01-04 12:30:00 +01:00
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
|
2009-08-15 22:19:42 +02:00
|
|
|
void cCaDescriptors::AddCaDescriptor(SI::CaDescriptor *d, int EsPid)
|
2004-01-04 12:30:00 +01:00
|
|
|
{
|
2009-08-15 22:19:42 +02:00
|
|
|
cCaDescriptor *nca = new cCaDescriptor(d->getCaType(), d->getCaPid(), EsPid, d->privateData.getLength(), d->privateData.getData());
|
2004-01-04 12:30:00 +01:00
|
|
|
for (cCaDescriptor *ca = caDescriptors.First(); ca; ca = caDescriptors.Next(ca)) {
|
|
|
|
if (*ca == *nca) {
|
|
|
|
delete nca;
|
2003-12-22 13:29:24 +01:00
|
|
|
return;
|
2004-01-04 12:30:00 +01:00
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
}
|
2004-01-04 12:30:00 +01:00
|
|
|
AddCaId(nca->CaSystem());
|
|
|
|
caDescriptors.Add(nca);
|
|
|
|
//#define DEBUG_CA_DESCRIPTORS 1
|
|
|
|
#ifdef DEBUG_CA_DESCRIPTORS
|
|
|
|
char buffer[1024];
|
|
|
|
char *q = buffer;
|
2009-08-15 22:19:42 +02:00
|
|
|
q += sprintf(q, "CAM: %04X %5d %5d %04X %04X -", source, transponder, serviceId, d->getCaType(), EsPid);
|
2004-01-04 12:30:00 +01:00
|
|
|
for (int i = 0; i < nca->Length(); i++)
|
|
|
|
q += sprintf(q, " %02X", nca->Data()[i]);
|
2010-01-01 15:44:52 +01:00
|
|
|
dsyslog("%s", buffer);
|
2004-01-04 12:30:00 +01:00
|
|
|
#endif
|
2003-12-22 13:29:24 +01:00
|
|
|
}
|
|
|
|
|
2009-08-15 22:19:42 +02:00
|
|
|
// EsPid is to select the "type" of CaDescriptor to be returned
|
|
|
|
// >0 - CaDescriptor for the particular esPid
|
|
|
|
// =0 - common CaDescriptor
|
|
|
|
// <0 - all CaDescriptors regardless of type (old default)
|
|
|
|
|
|
|
|
int cCaDescriptors::GetCaDescriptors(const int *CaSystemIds, int BufSize, uchar *Data, int EsPid)
|
2003-12-22 13:29:24 +01:00
|
|
|
{
|
|
|
|
if (!CaSystemIds || !*CaSystemIds)
|
|
|
|
return 0;
|
|
|
|
if (BufSize > 0 && Data) {
|
|
|
|
int length = 0;
|
2004-01-04 12:30:00 +01:00
|
|
|
for (cCaDescriptor *d = caDescriptors.First(); d; d = caDescriptors.Next(d)) {
|
2009-08-15 22:19:42 +02:00
|
|
|
if (EsPid < 0 || d->EsPid() == EsPid) {
|
|
|
|
const int *caids = CaSystemIds;
|
|
|
|
do {
|
|
|
|
if (d->CaSystem() == *caids) {
|
|
|
|
if (length + d->Length() <= BufSize) {
|
|
|
|
memcpy(Data + length, d->Data(), d->Length());
|
|
|
|
length += d->Length();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return -1;
|
2003-12-22 13:29:24 +01:00
|
|
|
}
|
2009-08-15 22:19:42 +02:00
|
|
|
} while (*++caids);
|
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
}
|
|
|
|
return length;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2004-01-04 12:30:00 +01:00
|
|
|
// --- cCaDescriptorHandler --------------------------------------------------
|
|
|
|
|
|
|
|
class cCaDescriptorHandler : public cList<cCaDescriptors> {
|
|
|
|
private:
|
|
|
|
cMutex mutex;
|
|
|
|
public:
|
|
|
|
int AddCaDescriptors(cCaDescriptors *CaDescriptors);
|
|
|
|
// Returns 0 if this is an already known descriptor,
|
|
|
|
// 1 if it is an all new descriptor with actual contents,
|
|
|
|
// and 2 if an existing descriptor was changed.
|
2009-08-15 22:19:42 +02:00
|
|
|
int GetCaDescriptors(int Source, int Transponder, int ServiceId, const int *CaSystemIds, int BufSize, uchar *Data, int EsPid);
|
2004-01-04 12:30:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
int cCaDescriptorHandler::AddCaDescriptors(cCaDescriptors *CaDescriptors)
|
|
|
|
{
|
|
|
|
cMutexLock MutexLock(&mutex);
|
|
|
|
for (cCaDescriptors *ca = First(); ca; ca = Next(ca)) {
|
|
|
|
if (ca->Is(CaDescriptors)) {
|
|
|
|
if (*ca == *CaDescriptors) {
|
|
|
|
delete CaDescriptors;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
Del(ca);
|
|
|
|
Add(CaDescriptors);
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Add(CaDescriptors);
|
|
|
|
return CaDescriptors->Empty() ? 0 : 1;
|
|
|
|
}
|
|
|
|
|
2009-08-15 22:19:42 +02:00
|
|
|
int cCaDescriptorHandler::GetCaDescriptors(int Source, int Transponder, int ServiceId, const int *CaSystemIds, int BufSize, uchar *Data, int EsPid)
|
2004-01-04 12:30:00 +01:00
|
|
|
{
|
|
|
|
cMutexLock MutexLock(&mutex);
|
|
|
|
for (cCaDescriptors *ca = First(); ca; ca = Next(ca)) {
|
|
|
|
if (ca->Is(Source, Transponder, ServiceId))
|
2009-08-15 22:19:42 +02:00
|
|
|
return ca->GetCaDescriptors(CaSystemIds, BufSize, Data, EsPid);
|
2004-01-04 12:30:00 +01:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
cCaDescriptorHandler CaDescriptorHandler;
|
2003-12-22 13:29:24 +01:00
|
|
|
|
2009-08-15 22:19:42 +02:00
|
|
|
int GetCaDescriptors(int Source, int Transponder, int ServiceId, const int *CaSystemIds, int BufSize, uchar *Data, int EsPid)
|
2003-12-22 13:29:24 +01:00
|
|
|
{
|
2009-08-15 22:19:42 +02:00
|
|
|
return CaDescriptorHandler.GetCaDescriptors(Source, Transponder, ServiceId, CaSystemIds, BufSize, Data, EsPid);
|
2003-12-22 13:29:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// --- cPatFilter ------------------------------------------------------------
|
|
|
|
|
|
|
|
cPatFilter::cPatFilter(void)
|
|
|
|
{
|
|
|
|
pmtIndex = 0;
|
|
|
|
pmtPid = 0;
|
2006-03-31 12:41:50 +02:00
|
|
|
pmtSid = 0;
|
2003-12-22 13:29:24 +01:00
|
|
|
lastPmtScan = 0;
|
2004-01-04 12:30:00 +01:00
|
|
|
numPmtEntries = 0;
|
2003-12-22 13:29:24 +01:00
|
|
|
Set(0x00, 0x00); // PAT
|
|
|
|
}
|
|
|
|
|
|
|
|
void cPatFilter::SetStatus(bool On)
|
|
|
|
{
|
|
|
|
cFilter::SetStatus(On);
|
|
|
|
pmtIndex = 0;
|
|
|
|
pmtPid = 0;
|
2006-03-31 12:41:50 +02:00
|
|
|
pmtSid = 0;
|
2003-12-22 13:29:24 +01:00
|
|
|
lastPmtScan = 0;
|
2004-01-04 12:30:00 +01:00
|
|
|
numPmtEntries = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cPatFilter::Trigger(void)
|
|
|
|
{
|
|
|
|
numPmtEntries = 0;
|
|
|
|
}
|
|
|
|
|
2004-03-13 10:35:38 +01:00
|
|
|
bool cPatFilter::PmtVersionChanged(int PmtPid, int Sid, int Version)
|
2004-01-04 12:30:00 +01:00
|
|
|
{
|
2004-03-13 10:35:38 +01:00
|
|
|
uint64_t v = Version;
|
|
|
|
v <<= 32;
|
|
|
|
uint64_t id = (PmtPid | (Sid << 16)) & 0x00000000FFFFFFFFLL;
|
2004-01-04 12:30:00 +01:00
|
|
|
for (int i = 0; i < numPmtEntries; i++) {
|
2004-03-13 10:35:38 +01:00
|
|
|
if ((pmtVersion[i] & 0x00000000FFFFFFFFLL) == id) {
|
|
|
|
bool Changed = (pmtVersion[i] & 0x000000FF00000000LL) != v;
|
2004-01-04 12:30:00 +01:00
|
|
|
if (Changed)
|
2004-03-13 10:35:38 +01:00
|
|
|
pmtVersion[i] = id | v;
|
2004-01-04 12:30:00 +01:00
|
|
|
return Changed;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (numPmtEntries < MAXPMTENTRIES)
|
2004-03-13 10:35:38 +01:00
|
|
|
pmtVersion[numPmtEntries++] = id | v;
|
2004-01-04 12:30:00 +01:00
|
|
|
return true;
|
2003-12-22 13:29:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void cPatFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length)
|
|
|
|
{
|
|
|
|
if (Pid == 0x00) {
|
|
|
|
if (Tid == 0x00) {
|
|
|
|
if (pmtPid && time(NULL) - lastPmtScan > PMT_SCAN_TIMEOUT) {
|
|
|
|
Del(pmtPid, 0x02);
|
|
|
|
pmtPid = 0;
|
|
|
|
pmtIndex++;
|
|
|
|
lastPmtScan = time(NULL);
|
|
|
|
}
|
|
|
|
if (!pmtPid) {
|
|
|
|
SI::PAT pat(Data, false);
|
|
|
|
if (!pat.CheckCRCAndParse())
|
|
|
|
return;
|
|
|
|
SI::PAT::Association assoc;
|
|
|
|
int Index = 0;
|
2004-10-16 10:14:19 +02:00
|
|
|
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
|
2003-12-22 13:29:24 +01:00
|
|
|
if (!assoc.isNITPid()) {
|
2006-01-27 15:53:08 +01:00
|
|
|
if (Index++ >= pmtIndex && Channels.GetByServiceID(Source(), Transponder(), assoc.getServiceId())) {
|
2003-12-22 13:29:24 +01:00
|
|
|
pmtPid = assoc.getPid();
|
2006-03-31 12:41:50 +02:00
|
|
|
pmtSid = assoc.getServiceId();
|
2003-12-22 13:29:24 +01:00
|
|
|
Add(pmtPid, 0x02);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!pmtPid)
|
|
|
|
pmtIndex = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (Pid == pmtPid && Tid == SI::TableIdPMT && Source() && Transponder()) {
|
|
|
|
SI::PMT pmt(Data, false);
|
|
|
|
if (!pmt.CheckCRCAndParse())
|
|
|
|
return;
|
2006-03-31 12:41:50 +02:00
|
|
|
if (pmt.getServiceId() != pmtSid)
|
|
|
|
return; // skip broken PMT records
|
2004-03-13 10:35:38 +01:00
|
|
|
if (!PmtVersionChanged(pmtPid, pmt.getTableIdExtension(), pmt.getVersionNumber())) {
|
2004-01-04 12:30:00 +01:00
|
|
|
lastPmtScan = 0; // this triggers the next scan
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!Channels.Lock(true, 10)) {
|
|
|
|
numPmtEntries = 0; // to make sure we try again
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
cChannel *Channel = Channels.GetByServiceID(Source(), Transponder(), pmt.getServiceId());
|
|
|
|
if (Channel) {
|
|
|
|
SI::CaDescriptor *d;
|
|
|
|
cCaDescriptors *CaDescriptors = new cCaDescriptors(Channel->Source(), Channel->Transponder(), Channel->Sid());
|
|
|
|
// Scan the common loop:
|
|
|
|
for (SI::Loop::Iterator it; (d = (SI::CaDescriptor*)pmt.commonDescriptors.getNext(it, SI::CaDescriptorTag)); ) {
|
2009-08-15 22:19:42 +02:00
|
|
|
CaDescriptors->AddCaDescriptor(d, 0);
|
2004-01-04 12:30:00 +01:00
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
// Scan the stream-specific loop:
|
|
|
|
SI::PMT::Stream stream;
|
|
|
|
int Vpid = 0;
|
2008-08-15 14:49:34 +02:00
|
|
|
int Ppid = 0;
|
|
|
|
int Vtype = 0;
|
2005-08-06 12:29:38 +02:00
|
|
|
int Apids[MAXAPIDS + 1] = { 0 }; // these lists are zero-terminated
|
2010-05-16 13:36:55 +02:00
|
|
|
int Atypes[MAXDPIDS + 1] = { 0 };
|
2005-01-30 12:11:56 +01:00
|
|
|
int Dpids[MAXDPIDS + 1] = { 0 };
|
2010-06-05 13:50:56 +02:00
|
|
|
int Dtypes[MAXDPIDS + 1] = { 0 };
|
2007-10-12 14:52:30 +02:00
|
|
|
int Spids[MAXSPIDS + 1] = { 0 };
|
2009-08-16 15:32:39 +02:00
|
|
|
uchar SubtitlingTypes[MAXSPIDS + 1] = { 0 };
|
|
|
|
uint16_t CompositionPageIds[MAXSPIDS + 1] = { 0 };
|
|
|
|
uint16_t AncillaryPageIds[MAXSPIDS + 1] = { 0 };
|
2005-09-04 14:48:39 +02:00
|
|
|
char ALangs[MAXAPIDS][MAXLANGCODE2] = { "" };
|
|
|
|
char DLangs[MAXDPIDS][MAXLANGCODE2] = { "" };
|
2007-10-12 14:52:30 +02:00
|
|
|
char SLangs[MAXSPIDS][MAXLANGCODE2] = { "" };
|
2004-01-04 12:30:00 +01:00
|
|
|
int Tpid = 0;
|
|
|
|
int NumApids = 0;
|
|
|
|
int NumDpids = 0;
|
2007-10-12 14:52:30 +02:00
|
|
|
int NumSpids = 0;
|
2004-10-16 10:14:19 +02:00
|
|
|
for (SI::Loop::Iterator it; pmt.streamLoop.getNext(stream, it); ) {
|
2009-12-24 13:25:40 +01:00
|
|
|
bool ProcessCaDescriptors = false;
|
2009-08-15 22:19:42 +02:00
|
|
|
int esPid = stream.getPid();
|
2004-01-04 12:30:00 +01:00
|
|
|
switch (stream.getStreamType()) {
|
|
|
|
case 1: // STREAMTYPE_11172_VIDEO
|
|
|
|
case 2: // STREAMTYPE_13818_VIDEO
|
2008-08-15 14:49:34 +02:00
|
|
|
case 0x1B: // MPEG4
|
2009-08-15 22:19:42 +02:00
|
|
|
Vpid = esPid;
|
2008-08-15 14:49:34 +02:00
|
|
|
Ppid = pmt.getPCRPid();
|
|
|
|
Vtype = stream.getStreamType();
|
2009-12-24 13:25:40 +01:00
|
|
|
ProcessCaDescriptors = true;
|
2004-01-04 12:30:00 +01:00
|
|
|
break;
|
|
|
|
case 3: // STREAMTYPE_11172_AUDIO
|
|
|
|
case 4: // STREAMTYPE_13818_AUDIO
|
2010-05-16 13:36:55 +02:00
|
|
|
case 0x0F: // ISO/IEC 13818-7 Audio with ADTS transport sytax
|
|
|
|
case 0x11: // ISO/IEC 14496-3 Audio with LATM transport syntax
|
2004-01-04 12:30:00 +01:00
|
|
|
{
|
2004-01-25 15:32:08 +01:00
|
|
|
if (NumApids < MAXAPIDS) {
|
2009-08-15 22:19:42 +02:00
|
|
|
Apids[NumApids] = esPid;
|
2010-05-16 13:36:55 +02:00
|
|
|
Atypes[NumApids] = stream.getStreamType();
|
2004-01-25 15:32:08 +01:00
|
|
|
SI::Descriptor *d;
|
|
|
|
for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext(it)); ) {
|
|
|
|
switch (d->getDescriptorTag()) {
|
|
|
|
case SI::ISO639LanguageDescriptorTag: {
|
|
|
|
SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d;
|
2005-09-04 14:48:39 +02:00
|
|
|
SI::ISO639LanguageDescriptor::Language l;
|
|
|
|
char *s = ALangs[NumApids];
|
|
|
|
int n = 0;
|
|
|
|
for (SI::Loop::Iterator it; ld->languageLoop.getNext(l, it); ) {
|
|
|
|
if (*ld->languageCode != '-') { // some use "---" to indicate "none"
|
|
|
|
if (n > 0)
|
|
|
|
*s++ = '+';
|
|
|
|
strn0cpy(s, I18nNormalizeLanguageCode(l.languageCode), MAXLANGCODE1);
|
|
|
|
s += strlen(s);
|
|
|
|
if (n++ > 1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-01-25 15:32:08 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
NumApids++;
|
|
|
|
}
|
2009-12-24 13:25:40 +01:00
|
|
|
ProcessCaDescriptors = true;
|
2004-01-04 12:30:00 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5: // STREAMTYPE_13818_PRIVATE
|
|
|
|
case 6: // STREAMTYPE_13818_PES_PRIVATE
|
|
|
|
//XXX case 8: // STREAMTYPE_13818_DSMCC
|
|
|
|
{
|
2004-01-25 15:32:08 +01:00
|
|
|
int dpid = 0;
|
2010-06-05 13:50:56 +02:00
|
|
|
int dtype = 0;
|
2005-09-04 14:48:39 +02:00
|
|
|
char lang[MAXLANGCODE1] = { 0 };
|
2004-01-04 12:30:00 +01:00
|
|
|
SI::Descriptor *d;
|
|
|
|
for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext(it)); ) {
|
|
|
|
switch (d->getDescriptorTag()) {
|
|
|
|
case SI::AC3DescriptorTag:
|
2010-03-27 15:19:06 +01:00
|
|
|
case SI::EnhancedAC3DescriptorTag:
|
2009-08-15 22:19:42 +02:00
|
|
|
dpid = esPid;
|
2010-06-05 13:50:56 +02:00
|
|
|
dtype = d->getDescriptorTag();
|
2009-12-24 13:25:40 +01:00
|
|
|
ProcessCaDescriptors = true;
|
2004-01-04 12:30:00 +01:00
|
|
|
break;
|
2007-10-12 14:52:30 +02:00
|
|
|
case SI::SubtitlingDescriptorTag:
|
|
|
|
if (NumSpids < MAXSPIDS) {
|
2009-08-15 22:19:42 +02:00
|
|
|
Spids[NumSpids] = esPid;
|
2007-10-12 14:52:30 +02:00
|
|
|
SI::SubtitlingDescriptor *sd = (SI::SubtitlingDescriptor *)d;
|
|
|
|
SI::SubtitlingDescriptor::Subtitling sub;
|
|
|
|
char *s = SLangs[NumSpids];
|
|
|
|
int n = 0;
|
|
|
|
for (SI::Loop::Iterator it; sd->subtitlingLoop.getNext(sub, it); ) {
|
|
|
|
if (sub.languageCode[0]) {
|
2009-08-16 15:32:39 +02:00
|
|
|
SubtitlingTypes[NumSpids] = sub.getSubtitlingType();
|
|
|
|
CompositionPageIds[NumSpids] = sub.getCompositionPageId();
|
|
|
|
AncillaryPageIds[NumSpids] = sub.getAncillaryPageId();
|
2007-10-12 14:52:30 +02:00
|
|
|
if (n > 0)
|
|
|
|
*s++ = '+';
|
|
|
|
strn0cpy(s, I18nNormalizeLanguageCode(sub.languageCode), MAXLANGCODE1);
|
|
|
|
s += strlen(s);
|
|
|
|
if (n++ > 1)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
NumSpids++;
|
|
|
|
}
|
|
|
|
break;
|
2004-01-04 12:30:00 +01:00
|
|
|
case SI::TeletextDescriptorTag:
|
2009-08-15 22:19:42 +02:00
|
|
|
Tpid = esPid;
|
2004-01-04 12:30:00 +01:00
|
|
|
break;
|
2004-01-25 15:32:08 +01:00
|
|
|
case SI::ISO639LanguageDescriptorTag: {
|
|
|
|
SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d;
|
2005-09-04 14:48:39 +02:00
|
|
|
strn0cpy(lang, I18nNormalizeLanguageCode(ld->languageCode), MAXLANGCODE1);
|
2004-01-25 15:32:08 +01:00
|
|
|
}
|
|
|
|
break;
|
2004-01-04 12:30:00 +01:00
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
delete d;
|
|
|
|
}
|
2004-01-25 15:32:08 +01:00
|
|
|
if (dpid) {
|
2005-01-16 14:40:47 +01:00
|
|
|
if (NumDpids < MAXDPIDS) {
|
2004-01-25 15:32:08 +01:00
|
|
|
Dpids[NumDpids] = dpid;
|
2010-06-05 13:50:56 +02:00
|
|
|
Dtypes[NumDpids] = dtype;
|
2005-09-04 14:48:39 +02:00
|
|
|
strn0cpy(DLangs[NumDpids], lang, MAXLANGCODE1);
|
2004-01-25 15:32:08 +01:00
|
|
|
NumDpids++;
|
|
|
|
}
|
|
|
|
}
|
2004-01-04 12:30:00 +01:00
|
|
|
}
|
2010-03-06 12:01:17 +01:00
|
|
|
break;
|
|
|
|
case 0x81: // STREAMTYPE_USER_PRIVATE
|
|
|
|
if (Channel->IsAtsc()) { // ATSC AC-3
|
|
|
|
char lang[MAXLANGCODE1] = { 0 };
|
|
|
|
SI::Descriptor *d;
|
|
|
|
for (SI::Loop::Iterator it; (d = stream.streamDescriptors.getNext(it)); ) {
|
|
|
|
switch (d->getDescriptorTag()) {
|
|
|
|
case SI::ISO639LanguageDescriptorTag: {
|
|
|
|
SI::ISO639LanguageDescriptor *ld = (SI::ISO639LanguageDescriptor *)d;
|
|
|
|
strn0cpy(lang, I18nNormalizeLanguageCode(ld->languageCode), MAXLANGCODE1);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default: ;
|
|
|
|
}
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
if (NumDpids < MAXDPIDS) {
|
|
|
|
Dpids[NumDpids] = esPid;
|
|
|
|
strn0cpy(DLangs[NumDpids], lang, MAXLANGCODE1);
|
|
|
|
NumDpids++;
|
|
|
|
}
|
|
|
|
ProcessCaDescriptors = true;
|
|
|
|
}
|
2004-01-04 12:30:00 +01:00
|
|
|
break;
|
2009-12-06 12:57:45 +01:00
|
|
|
default: ;//printf("PID: %5d %5d %2d %3d %3d\n", pmt.getServiceId(), stream.getPid(), stream.getStreamType(), pmt.getVersionNumber(), Channel->Number());
|
2004-01-04 12:30:00 +01:00
|
|
|
}
|
2009-12-24 13:25:40 +01:00
|
|
|
if (ProcessCaDescriptors) {
|
|
|
|
for (SI::Loop::Iterator it; (d = (SI::CaDescriptor*)stream.streamDescriptors.getNext(it, SI::CaDescriptorTag)); ) {
|
|
|
|
CaDescriptors->AddCaDescriptor(d, esPid);
|
|
|
|
delete d;
|
|
|
|
}
|
|
|
|
}
|
2004-01-04 12:30:00 +01:00
|
|
|
}
|
2004-01-05 12:08:09 +01:00
|
|
|
if (Setup.UpdateChannels >= 2) {
|
2010-06-05 13:50:56 +02:00
|
|
|
Channel->SetPids(Vpid, Ppid, Vtype, Apids, Atypes, ALangs, Dpids, Dtypes, DLangs, Spids, SLangs, Tpid);
|
2004-01-05 12:08:09 +01:00
|
|
|
Channel->SetCaIds(CaDescriptors->CaIds());
|
2009-08-16 15:32:39 +02:00
|
|
|
Channel->SetSubtitlingDescriptors(SubtitlingTypes, CompositionPageIds, AncillaryPageIds);
|
2004-01-05 12:08:09 +01:00
|
|
|
}
|
2004-01-25 14:07:24 +01:00
|
|
|
Channel->SetCaDescriptors(CaDescriptorHandler.AddCaDescriptors(CaDescriptors));
|
2004-01-04 12:30:00 +01:00
|
|
|
}
|
2003-12-22 13:29:24 +01:00
|
|
|
lastPmtScan = 0; // this triggers the next scan
|
2004-01-04 12:30:00 +01:00
|
|
|
Channels.Unlock();
|
2003-12-22 13:29:24 +01:00
|
|
|
}
|
|
|
|
}
|