aboutsummaryrefslogtreecommitdiff
path: root/lib/dvb/tstools.cpp
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2006-03-06 12:13:05 +0000
committerFelix Domke <tmbinc@elitedvb.net>2006-03-06 12:13:05 +0000
commit89d110df542204a384916db773acd2d19cb0542a (patch)
tree993992167745e5f7573e5ab807bc1ead22f80cc2 /lib/dvb/tstools.cpp
parentc4f2b9b542581bf518bc36476e11ec15074f99b4 (diff)
downloadenigma2-89d110df542204a384916db773acd2d19cb0542a.tar.gz
enigma2-89d110df542204a384916db773acd2d19cb0542a.zip
moved PID search to proper please, simplified a bit (using the first found PMT should be ok)
Diffstat (limited to 'lib/dvb/tstools.cpp')
-rw-r--r--lib/dvb/tstools.cpp72
1 files changed, 71 insertions, 1 deletions
diff --git a/lib/dvb/tstools.cpp b/lib/dvb/tstools.cpp
index 34edbc9e..4dab5294 100644
--- a/lib/dvb/tstools.cpp
+++ b/lib/dvb/tstools.cpp
@@ -64,7 +64,7 @@ int eDVBTSTools::getPTS(off_t &offset, pts_t &pts, int fixed)
if (m_use_streaminfo)
return m_streaminfo.getPTS(offset, pts);
- if (!m_file.valid() < 0)
+ if (!m_file.valid())
return -1;
offset -= offset % 188;
@@ -344,3 +344,73 @@ void eDVBTSTools::takeSamples()
m_samples[m_pts_end] = m_offset_end;
// eDebug("begin, end: %llx %llx", m_offset_begin, m_offset_end);
}
+
+int eDVBTSTools::findPMT(int &pmt_pid, int &service_id)
+{
+ /* FIXME: this will be factored out soon! */
+ if (!m_file.valid())
+ {
+ eDebug(" file not valid");
+ return -1;
+ }
+
+ if (m_file.lseek(0, SEEK_SET) < 0)
+ {
+ eDebug("seek failed");
+ return -1;
+ }
+
+ int left = 5*1024*1024;
+
+ while (left >= 188)
+ {
+ unsigned char block[188];
+ if (m_file.read(block, 188) != 188)
+ {
+ eDebug("read error");
+ break;
+ }
+ left -= 188;
+
+ if (block[0] != 0x47)
+ {
+ int i = 0;
+ while (i < 188)
+ {
+ if (block[i] == 0x47)
+ break;
+ ++i;
+ }
+ m_file.lseek(i - 188, SEEK_CUR);
+ continue;
+ }
+
+ int pid = ((block[1] << 8) | block[2]) & 0x1FFF;
+
+ int pusi = !!(block[1] & 0x40);
+
+ if (!pusi)
+ continue;
+
+ /* ok, now we have a PES header or section header*/
+ unsigned char *sec;
+
+ /* check for adaption field */
+ if (block[3] & 0x20)
+ sec = block + block[4] + 4 + 1;
+ else
+ sec = block + 4;
+
+ if (sec[0]) /* table pointer, assumed to be 0 */
+ continue;
+
+ if (sec[1] == 0x02) /* program map section */
+ {
+ pmt_pid = pid;
+ service_id = (sec[4] << 8) | sec[5];
+ return 0;
+ }
+ }
+
+ return -1;
+}