2007-09-29 01:23:12 +02:00
|
|
|
/*
|
2007-10-01 20:14:57 +02:00
|
|
|
* sidscanner.c: IPTV plugin for the Video Disk Recorder
|
2007-09-29 01:23:12 +02:00
|
|
|
*
|
|
|
|
* See the README file for copyright information and how to reach the author.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <libsi/section.h>
|
|
|
|
|
|
|
|
#include "common.h"
|
2007-10-01 20:14:57 +02:00
|
|
|
#include "sidscanner.h"
|
2007-09-29 01:23:12 +02:00
|
|
|
|
2007-10-01 20:14:57 +02:00
|
|
|
cSidScanner::cSidScanner(void)
|
2007-09-29 01:23:12 +02:00
|
|
|
{
|
2007-10-01 20:14:57 +02:00
|
|
|
debug("cSidScanner::cSidScanner()\n");
|
2007-09-29 01:23:12 +02:00
|
|
|
channel = cChannel();
|
|
|
|
Set(0x00, 0x00); // PAT
|
|
|
|
}
|
|
|
|
|
2007-10-01 20:14:57 +02:00
|
|
|
void cSidScanner::SetStatus(bool On)
|
2007-09-29 01:23:12 +02:00
|
|
|
{
|
2007-10-01 20:14:57 +02:00
|
|
|
debug("cSidScanner::SetStatus(): %d\n", On);
|
2007-09-29 01:23:12 +02:00
|
|
|
cFilter::SetStatus(On);
|
|
|
|
}
|
|
|
|
|
2007-10-01 20:14:57 +02:00
|
|
|
void cSidScanner::SetChannel(const cChannel *Channel)
|
2007-09-29 01:23:12 +02:00
|
|
|
{
|
|
|
|
if (Channel) {
|
2010-03-04 16:34:21 +01:00
|
|
|
debug("cSidScanner::SetChannel(): %s\n", Channel->Parameters());
|
2007-09-29 01:23:12 +02:00
|
|
|
channel = *Channel;
|
|
|
|
}
|
|
|
|
else {
|
2007-10-01 20:14:57 +02:00
|
|
|
debug("cSidScanner::SetChannel()\n");
|
2007-09-29 01:23:12 +02:00
|
|
|
channel = cChannel();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-01 20:14:57 +02:00
|
|
|
void cSidScanner::Process(u_short Pid, u_char Tid, const u_char *Data, int Length)
|
2007-09-29 01:23:12 +02:00
|
|
|
{
|
2007-10-01 20:14:57 +02:00
|
|
|
//debug("cSidScanner::Process()\n");
|
2007-09-30 19:33:02 +02:00
|
|
|
if ((Pid == 0x00) && (Tid == 0x00) && channel.GetChannelID().Valid()) {
|
2007-10-01 20:14:57 +02:00
|
|
|
debug("cSidScanner::Process(): Pid=%d Tid=%02X\n", Pid, Tid);
|
2007-09-29 01:23:12 +02:00
|
|
|
SI::PAT pat(Data, false);
|
|
|
|
if (!pat.CheckCRCAndParse())
|
|
|
|
return;
|
|
|
|
SI::PAT::Association assoc;
|
|
|
|
for (SI::Loop::Iterator it; pat.associationLoop.getNext(assoc, it); ) {
|
|
|
|
if (!assoc.isNITPid()) {
|
|
|
|
if (assoc.getServiceId() != channel.Sid()) {
|
2007-10-01 20:14:57 +02:00
|
|
|
debug("cSidScanner::Process(): Sid=%d\n", assoc.getServiceId());
|
2007-09-30 00:44:23 +02:00
|
|
|
if (!Channels.Lock(true, 10))
|
2007-09-29 01:23:12 +02:00
|
|
|
return;
|
2007-09-30 00:44:23 +02:00
|
|
|
cChannel *IptvChannel = Channels.GetByChannelID(channel.GetChannelID());
|
2009-02-25 13:34:19 +01:00
|
|
|
if (IptvChannel)
|
|
|
|
IptvChannel->SetId(IptvChannel->Nid(), IptvChannel->Tid(),
|
|
|
|
assoc.getServiceId(), IptvChannel->Rid());
|
2007-09-29 01:23:12 +02:00
|
|
|
Channels.Unlock();
|
|
|
|
}
|
|
|
|
SetChannel(NULL);
|
|
|
|
SetStatus(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|