aboutsummaryrefslogtreecommitdiff
path: root/lib/dvb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/dvb')
-rw-r--r--lib/dvb/decoder.cpp3
-rw-r--r--lib/dvb/decoder.h2
-rw-r--r--lib/dvb/dvb.cpp12
-rw-r--r--lib/dvb/epgcache.cpp4
-rw-r--r--lib/dvb/esection.h25
-rw-r--r--lib/dvb/idvb.h2
-rw-r--r--lib/dvb/pmt.cpp112
-rw-r--r--lib/dvb/pmt.h4
-rw-r--r--lib/dvb/pvrparse.cpp2
-rw-r--r--lib/dvb/scan.cpp4
-rw-r--r--lib/dvb/tstools.cpp27
11 files changed, 149 insertions, 48 deletions
diff --git a/lib/dvb/decoder.cpp b/lib/dvb/decoder.cpp
index 88cd3ee1..8ed9f43f 100644
--- a/lib/dvb/decoder.cpp
+++ b/lib/dvb/decoder.cpp
@@ -203,6 +203,9 @@ int eDVBAudio::startPid(int pid, int type)
case aLPCM:
bypass = 6;
break;
+ case aDTSHD:
+ bypass = 0x10;
+ break;
}
eDebugNoNewLine("AUDIO_SET_BYPASS(%d) - ", bypass);
diff --git a/lib/dvb/decoder.h b/lib/dvb/decoder.h
index 3a0fbac1..7610b654 100644
--- a/lib/dvb/decoder.h
+++ b/lib/dvb/decoder.h
@@ -13,7 +13,7 @@ private:
ePtr<eDVBDemux> m_demux;
int m_fd, m_fd_demux, m_dev, m_is_freezed;
public:
- enum { aMPEG, aAC3, aDTS, aAAC, aAACHE, aLPCM };
+ enum { aMPEG, aAC3, aDTS, aAAC, aAACHE, aLPCM, aDTSHD };
eDVBAudio(eDVBDemux *demux, int dev);
enum { aMonoLeft, aStereo, aMonoRight };
void setChannel(int channel);
diff --git a/lib/dvb/dvb.cpp b/lib/dvb/dvb.cpp
index 414ab8da..cd6c232b 100644
--- a/lib/dvb/dvb.cpp
+++ b/lib/dvb/dvb.cpp
@@ -108,7 +108,7 @@ eDVBResourceManager::eDVBResourceManager()
m_boxtype = DM8000;
}
- eDebug("found %d adapter, %d frontends(%d sim) and %d demux, boxtype %d",
+ eDebug("found %zd adapter, %zd frontends(%zd sim) and %zd demux, boxtype %d",
m_adapter.size(), m_frontend.size(), m_simulate_frontend.size(), m_demux.size(), m_boxtype);
eDVBCAService::registerChannelCallback(this);
@@ -334,7 +334,7 @@ PyObject *eDVBResourceManager::setFrontendSlotInformations(ePyObject list)
}
if (assigned != m_frontend.size()) {
char blasel[256];
- sprintf(blasel, "eDVBResourceManager::setFrontendSlotInformations .. assigned %d socket informations, but %d registered frontends!",
+ sprintf(blasel, "eDVBResourceManager::setFrontendSlotInformations .. assigned %zd socket informations, but %d registered frontends!",
m_frontend.size(), assigned);
PyErr_SetString(PyExc_StandardError, blasel);
return NULL;
@@ -1488,7 +1488,7 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
size = max;
else
size = aligned_end - current_offset;
- eDebug("HIT, %lld < %lld < %lld, size: %d", i->first, current_offset, i->second, size);
+ eDebug("HIT, %lld < %lld < %lld, size: %zd", i->first, current_offset, i->second, size);
return;
}
if (current_offset < aligned_start)
@@ -1529,10 +1529,10 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
len = aligned_end - aligned_start;
start = aligned_end - len;
- eDebug("skipping to %llx, %d", start, len);
+ eDebug("skipping to %llx, %zd", start, len);
}
- eDebug("result: %llx, %x (%llx %llx)", start, size, aligned_start, aligned_end);
+ eDebug("result: %llx, %zx (%llx %llx)", start, size, aligned_start, aligned_end);
return;
}
}
@@ -1548,7 +1548,7 @@ void eDVBChannel::getNextSourceSpan(off_t current_offset, size_t bytes_read, off
{
start = current_offset;
size = max;
- eDebug("NO CUESHEET. (%08llx, %d)", start, size);
+ eDebug("NO CUESHEET. (%08llx, %zd)", start, size);
} else
{
start = current_offset;
diff --git a/lib/dvb/epgcache.cpp b/lib/dvb/epgcache.cpp
index ed31903c..4d324746 100644
--- a/lib/dvb/epgcache.cpp
+++ b/lib/dvb/epgcache.cpp
@@ -366,6 +366,8 @@ void eEPGCache::DVBChannelRunning(iDVBChannel *chan)
messages.send(Message(Message::startChannel, chan));
// -> gotMessage -> changedService
}
+ else
+ data.state=-1;
}
}
}
@@ -1187,7 +1189,7 @@ void eEPGCache::save()
eEPGCache::channel_data::channel_data(eEPGCache *ml)
:cache(ml)
- ,abortTimer(eTimer::create(ml)), zapTimer(eTimer::create(ml)), state(-1)
+ ,abortTimer(eTimer::create(ml)), zapTimer(eTimer::create(ml)), state(-2)
,isRunning(0), haveData(0)
#ifdef ENABLE_PRIVATE_EPG
,startPrivateTimer(eTimer::create(ml))
diff --git a/lib/dvb/esection.h b/lib/dvb/esection.h
index 2bb17a98..3e097ccc 100644
--- a/lib/dvb/esection.h
+++ b/lib/dvb/esection.h
@@ -63,7 +63,7 @@ protected:
else
TABLE_eDebugNoNewLine("-");
- TABLE_eDebug(" %d/%d TID %02x", avail.size(), max, data[0]);
+ TABLE_eDebug(" %zd/%d TID %02x", avail.size(), max, data[0]);
if (avail.size() == max)
{
@@ -100,6 +100,10 @@ class eAUTable: public eAUGTable
int first;
ePtr<iDVBDemux> m_demux;
eMainloop *ml;
+
+ /* needed to detect broken table version handling (seen on some m2ts files) */
+ struct timespec m_prev_table_update;
+ int m_table_cnt;
public:
eAUTable()
@@ -119,6 +123,7 @@ public:
int begin(eMainloop *m, const eDVBTableSpec &spec, ePtr<iDVBDemux> demux)
{
+ m_table_cnt = 0;
ml = m;
m_demux = demux;
first= 1;
@@ -197,6 +202,24 @@ public:
if (current && (!current->getSpec(spec)))
{
+ /* detect broken table version handling (seen on some m2ts files) */
+ if (m_table_cnt)
+ {
+ if (abs(timeout_usec(m_prev_table_update)) > 500000)
+ m_table_cnt = -1;
+ else if (m_table_cnt > 1) // two pmt update within one second
+ {
+ eDebug("Seen two consecutive table version changes within 500ms. "
+ "This seems broken, so auto update for pid %04x, table %02x is now disabled!!",
+ spec.pid, spec.tid);
+ m_table_cnt = 0;
+ return;
+ }
+ }
+
+ ++m_table_cnt;
+ clock_gettime(CLOCK_MONOTONIC, &m_prev_table_update);
+
next = new Table();
CONNECT(next->tableReady, eAUTable::slotTableReady);
spec.flags &= ~(eDVBTableSpec::tfAnyVersion|eDVBTableSpec::tfThisVersion|eDVBTableSpec::tfHaveTimeout);
diff --git a/lib/dvb/idvb.h b/lib/dvb/idvb.h
index f15cd04e..e56a2c7b 100644
--- a/lib/dvb/idvb.h
+++ b/lib/dvb/idvb.h
@@ -650,7 +650,7 @@ public:
/** Set Displayed Video PID and type */
virtual RESULT setVideoPID(int vpid, int type)=0;
- enum { af_MPEG, af_AC3, af_DTS, af_AAC };
+ enum { af_MPEG, af_AC3, af_DTS, af_AAC, af_DTSHD };
/** Set Displayed Audio PID and type */
virtual RESULT setAudioPID(int apid, int type)=0;
diff --git a/lib/dvb/pmt.cpp b/lib/dvb/pmt.cpp
index ca56141b..4ad4e76f 100644
--- a/lib/dvb/pmt.cpp
+++ b/lib/dvb/pmt.cpp
@@ -20,13 +20,14 @@
#include <dvbsi++/registration_descriptor.h>
eDVBServicePMTHandler::eDVBServicePMTHandler()
- :m_ca_servicePtr(0), m_dvb_scan(0), m_decode_demux_num(0xFF)
+ :m_ca_servicePtr(0), m_dvb_scan(0), m_decode_demux_num(0xFF), m_no_pat_entry_delay(eTimer::create())
{
m_use_decode_demux = 0;
m_pmt_pid = -1;
eDVBResourceManager::getInstance(m_resourceManager);
CONNECT(m_PMT.tableReady, eDVBServicePMTHandler::PMTready);
CONNECT(m_PAT.tableReady, eDVBServicePMTHandler::PATready);
+ CONNECT(m_no_pat_entry_delay->timeout, eDVBServicePMTHandler::sendEventNoPatEntry);
}
eDVBServicePMTHandler::~eDVBServicePMTHandler()
@@ -126,25 +127,55 @@ void eDVBServicePMTHandler::PMTready(int error)
}
}
+void eDVBServicePMTHandler::sendEventNoPatEntry()
+{
+ serviceEvent(eventNoPATEntry);
+}
+
void eDVBServicePMTHandler::PATready(int)
{
+ eDebug("PATready");
ePtr<eTable<ProgramAssociationSection> > ptr;
if (!m_PAT.getCurrent(ptr))
{
+ int service_id_single = -1;
+ int pmtpid_single = -1;
int pmtpid = -1;
+ int cnt=0;
std::vector<ProgramAssociationSection*>::const_iterator i;
for (i = ptr->getSections().begin(); pmtpid == -1 && i != ptr->getSections().end(); ++i)
{
const ProgramAssociationSection &pat = **i;
ProgramAssociationConstIterator program;
for (program = pat.getPrograms()->begin(); pmtpid == -1 && program != pat.getPrograms()->end(); ++program)
+ {
+ ++cnt;
if (eServiceID((*program)->getProgramNumber()) == m_reference.getServiceID())
pmtpid = (*program)->getProgramMapPid();
+ if (++cnt == 1 && pmtpid_single == -1 && pmtpid == -1)
+ {
+ pmtpid_single = (*program)->getProgramMapPid();
+ service_id_single = (*program)->getProgramNumber();
+ }
+ else
+ pmtpid_single = service_id_single = -1;
+ }
}
- if (pmtpid == -1)
- serviceEvent(eventNoPATEntry);
- else
+ if (pmtpid_single != -1) // only one PAT entry .. and not valid pmtpid found
+ {
+ eDebug("use single pat entry!");
+ m_reference.setServiceID(eServiceID(service_id_single));
+ pmtpid = pmtpid_single;
+ }
+ if (pmtpid == -1) {
+ eDebug("no PAT entry found.. start delay");
+ m_no_pat_entry_delay->start(1000, true);
+ }
+ else {
+ eDebug("use pmtpid %04x for service_id %04x", pmtpid, m_reference.getServiceID().get());
+ m_no_pat_entry_delay->stop();
m_PMT.begin(eApp, eDVBPMTSpec(pmtpid, m_reference.getServiceID().get()), m_demux);
+ }
} else
serviceEvent(eventNoPAT);
}
@@ -230,8 +261,29 @@ int eDVBServicePMTHandler::getProgramInfo(program &program)
for (i = ptr->getSections().begin(); i != ptr->getSections().end(); ++i)
{
const ProgramMapSection &pmt = **i;
+ int is_hdmv = 0;
+
program.pcrPid = pmt.getPcrPid();
+ for (DescriptorConstIterator desc = pmt.getDescriptors()->begin();
+ desc != pmt.getDescriptors()->end(); ++desc)
+ {
+ if ((*desc)->getTag() == CA_DESCRIPTOR)
+ {
+ CaDescriptor *descr = (CaDescriptor*)(*desc);
+ program::capid_pair pair;
+ pair.caid = descr->getCaSystemId();
+ pair.capid = descr->getCaPid();
+ program.caids.push_back(pair);
+ }
+ else if ((*desc)->getTag() == REGISTRATION_DESCRIPTOR)
+ {
+ RegistrationDescriptor *d = (RegistrationDescriptor*)(*desc);
+ if (d->getFormatIdentifier() == 0x48444d56) // HDMV
+ is_hdmv = 1;
+ }
+ }
+
ElementaryStreamInfoConstIterator es;
for (es = pmt.getEsInfo()->begin(); es != pmt.getEsInfo()->end(); ++es)
{
@@ -287,25 +339,34 @@ int eDVBServicePMTHandler::getProgramInfo(program &program)
audio.type = audioStream::atAACHE;
forced_audio = 1;
}
- case 0x80: // user private ... but blueray LPCM
- if (!isvideo && !isaudio)
+ case 0x80: // user private ... but bluray LPCM
+ case 0xA0: // bluray secondary LPCM
+ if (!isvideo && !isaudio && is_hdmv)
{
isaudio = 1;
audio.type = audioStream::atLPCM;
}
- case 0x81: // user private ... but blueray AC3
- if (!isvideo && !isaudio)
+ case 0x81: // user private ... but bluray AC3
+ case 0xA1: // bluray secondary AC3
+ if (!isvideo && !isaudio && is_hdmv)
{
isaudio = 1;
audio.type = audioStream::atAC3;
}
- case 0x82: // Blueray DTS (dvb user private...)
- case 0xA2: // Blueray secondary DTS
- if (!isvideo && !isaudio)
+ case 0x82: // bluray DTS (dvb user private...)
+ case 0xA2: // bluray secondary DTS
+ if (!isvideo && !isaudio && is_hdmv)
{
isaudio = 1;
audio.type = audioStream::atDTS;
}
+ case 0x86: // bluray DTS-HD (dvb user private...)
+ case 0xA6: // bluray secondary DTS-HD
+ if (!isvideo && !isaudio && is_hdmv)
+ {
+ isaudio = 1;
+ audio.type = audioStream::atDTSHD;
+ }
case 0x06: // PES Private
case 0xEA: // TS_PSI_ST_SMPTE_VC1
{
@@ -497,9 +558,9 @@ int eDVBServicePMTHandler::getProgramInfo(program &program)
default:
break;
}
- if (isteletext && (isaudio || isvideo))
+ if (isteletext && (isaudio || isvideo))
{
- eDebug("ambiguous streamtype for PID %04x detected.. forced as teletext!", (*es)->getPid());
+ eDebug("ambiguous streamtype for PID %04x detected.. forced as teletext!", (*es)->getPid());
continue; // continue with next PID
}
else if (issubtitle && (isaudio || isvideo))
@@ -537,18 +598,6 @@ int eDVBServicePMTHandler::getProgramInfo(program &program)
else
continue;
}
- for (DescriptorConstIterator desc = pmt.getDescriptors()->begin();
- desc != pmt.getDescriptors()->end(); ++desc)
- {
- if ((*desc)->getTag() == CA_DESCRIPTOR)
- {
- CaDescriptor *descr = (CaDescriptor*)(*desc);
- program::capid_pair pair;
- pair.caid = descr->getCaSystemId();
- pair.capid = descr->getCaPid();
- program.caids.push_back(pair);
- }
- }
}
ret = 0;
@@ -710,8 +759,8 @@ int eDVBServicePMTHandler::tuneExt(eServiceReferenceDVB &ref, int use_decode_dem
{
RESULT res=0;
m_reference = ref;
-
m_use_decode_demux = use_decode_demux;
+ m_no_pat_entry_delay->stop();
/* use given service as backup. This is used for timeshift where we want to clone the live stream using the cache, but in fact have a PVR channel */
m_service = service;
@@ -735,13 +784,12 @@ int eDVBServicePMTHandler::tuneExt(eServiceReferenceDVB &ref, int use_decode_dem
{
if (!ref.getServiceID().get() /* incorrect sid in meta file or recordings.epl*/ )
{
- eWarning("no .meta file found, trying to find PMT pid");
eDVBTSTools tstools;
+ bool b = source || !tstools.openFile(ref.path.c_str(), 1);
+ eWarning("no .meta file found, trying to find PMT pid");
if (source)
- tstools.setSource(source, streaminfo_file ? streaminfo_file : ref.path.c_str());
- else if (tstools.openFile(ref.path.c_str()))
- eWarning("failed to open file");
- else
+ tstools.setSource(source, NULL);
+ if (b)
{
int service_id, pmt_pid;
if (!tstools.findPMT(pmt_pid, service_id))
@@ -751,6 +799,8 @@ int eDVBServicePMTHandler::tuneExt(eServiceReferenceDVB &ref, int use_decode_dem
m_pmt_pid = pmt_pid;
}
}
+ else
+ eWarning("no valid source to find PMT pid!");
}
eDebug("alloc PVR");
/* allocate PVR */
diff --git a/lib/dvb/pmt.h b/lib/dvb/pmt.h
index 86b634fc..1888e054 100644
--- a/lib/dvb/pmt.h
+++ b/lib/dvb/pmt.h
@@ -102,6 +102,7 @@ class eDVBServicePMTHandler: public Object
int m_use_decode_demux;
uint8_t m_decode_demux_num;
+ ePtr<eTimer> m_no_pat_entry_delay;
public:
eDVBServicePMTHandler();
~eDVBServicePMTHandler();
@@ -144,7 +145,7 @@ public:
{
int pid,
rdsPid; // hack for some radio services which transmit radiotext on different pid (i.e. harmony fm, HIT RADIO FFH, ...)
- enum { atMPEG, atAC3, atDTS, atAAC, atAACHE, atLPCM };
+ enum { atMPEG, atAC3, atDTS, atAAC, atAACHE, atLPCM, atDTSHD };
int type; // mpeg2, ac3, dts, ...
int component_tag;
@@ -210,6 +211,7 @@ public:
int getPMT(ePtr<eTable<ProgramMapSection> > &ptr) { return m_PMT.getCurrent(ptr); }
int getChannel(eUsePtr<iDVBChannel> &channel);
void resetCachedProgram() { m_have_cached_program = false; }
+ void sendEventNoPatEntry();
/* deprecated interface */
int tune(eServiceReferenceDVB &ref, int use_decode_demux, eCueSheet *sg=0, bool simulate=false, eDVBService *service = 0);
diff --git a/lib/dvb/pvrparse.cpp b/lib/dvb/pvrparse.cpp
index 5cdecbd6..e19dd1e4 100644
--- a/lib/dvb/pvrparse.cpp
+++ b/lib/dvb/pvrparse.cpp
@@ -123,7 +123,7 @@ void eMPEGStreamInformation::fixupDiscontinuties()
pts_t current = i->second - currentDelta;
pts_t diff = current - lastpts_t;
- if (llabs(diff) > (90000*5)) // 5sec diff
+ if (llabs(diff) > (90000*10)) // 10sec diff
{
// eDebug("%llx < %llx, have discont. new timestamp is %llx (diff is %llx)!", current, lastpts_t, i->second, diff);
currentDelta = i->second - lastpts_t; /* FIXME: should be the extrapolated new timestamp, based on the current rate */
diff --git a/lib/dvb/scan.cpp b/lib/dvb/scan.cpp
index d559614c..fb6f2048 100644
--- a/lib/dvb/scan.cpp
+++ b/lib/dvb/scan.cpp
@@ -193,9 +193,9 @@ RESULT eDVBScan::nextChannel()
if (m_ch_toScan.empty())
{
SCAN_eDebug("no channels left to scan.");
- SCAN_eDebug("%d channels scanned, %d were unavailable.",
+ SCAN_eDebug("%zd channels scanned, %zd were unavailable.",
m_ch_scanned.size(), m_ch_unavailable.size());
- SCAN_eDebug("%d channels in database.", m_new_channels.size());
+ SCAN_eDebug("%zd channels in database.", m_new_channels.size());
m_event(evtFinish);
return -ENOENT;
}
diff --git a/lib/dvb/tstools.cpp b/lib/dvb/tstools.cpp
index 1403059f..6cd855cc 100644
--- a/lib/dvb/tstools.cpp
+++ b/lib/dvb/tstools.cpp
@@ -212,6 +212,8 @@ int eDVBTSTools::getPTS(off_t &offset, pts_t &pts, int fixed)
break;
case 0x71: // AC3 / DTS
break;
+ case 0x72: // DTS - HD
+ break;
default:
eDebug("skip unknwn stream_id_extension %02x\n", payload[9+offs]);
continue;
@@ -700,9 +702,26 @@ int eDVBTSTools::findFrame(off_t &_offset, size_t &len, int &direction, int fram
else if (direction == +1)
direction = 0;
}
- /* let's find the next frame after the given offset */
off_t start = offset;
+#if 0
+ /* backtrack to find the previous sequence start, in case of MPEG2 */
+ if ((data & 0xFF) == 0x00) {
+ do {
+ --start;
+ if (m_streaminfo.getStructureEntry(start, data, 0))
+ {
+ eDebug("get previous failed");
+ return -1;
+ }
+ } while (((data & 0xFF) != 9) && ((data & 0xFF) != 0x00) && ((data & 0xFF) != 0xB3)); /* sequence start or previous frame */
+ if ((data & 0xFF) != 0xB3)
+ start = offset; /* Failed to find corresponding sequence start, so never mind */
+ }
+
+#endif
+
+ /* let's find the next frame after the given offset */
do {
if (m_streaminfo.getStructureEntry(offset, data, 1))
{
@@ -717,9 +736,11 @@ int eDVBTSTools::findFrame(off_t &_offset, size_t &len, int &direction, int fram
// eDebug("%08llx@%llx (next)", data, offset);
} while (((data & 0xFF) != 9) && ((data & 0xFF) != 0x00)); /* next frame */
+#if 0
/* align to TS pkt start */
-// start = start - (start % 188);
-// offset = offset - (offset % 188);
+ start = start - (start % 188);
+ offset = offset - (offset % 188);
+#endif
len = offset - start;
_offset = start;