summaryrefslogtreecommitdiff
path: root/ttxtsubsreceiver.c
diff options
context:
space:
mode:
authorTobias Grimm <tobias@e-tobi.loc>2008-12-13 11:01:34 +0100
committerTobias Grimm <tobias@e-tobi.loc>2008-12-13 11:01:34 +0100
commite5d1aacca2020e63dbaf320ba8b1de61746ad410 (patch)
tree0e267f716f34700a439971926fdc79b0172a0f38 /ttxtsubsreceiver.c
parent88012c106b8310507e872c72544f423433bac5d2 (diff)
downloadvdr-plugin-ttxtsubs-0.0.5pre1.tar.gz
vdr-plugin-ttxtsubs-0.0.5pre1.tar.bz2
- New features:v0.0.5pre1
- More than one language can be chosen, they are used in order of preference - Handles languages with two ISO 639-2 identifiers (as ger/deu, fre/fra) - Subtitles can now be turned on or off - Optional main menu alternative for easy access - Selectable vertical position of text for 4:3/Anamorphic or Letterbox - Left, Center or Right horizontal position of text - Remapping option for those French channels that incorrectly sends teletext page numbers in decimal instead of hexadecimal. Very moderate remapping done at the moment, I hope it is enough. - Subtitles are now recorded with their PTS (timestamps). Not that the timestamps are completely wrong on some channels, this may confuse uncareful subtitle extracting software. - Included patch for VDR 1.3.5 - untested! - Bugs fixed: - Fixed a net-to-host-order bug in the si parser that could make it incorrectly think that there are no subtitles on a channel. Thanks to Nicolas "tarass"! - Fixed a bit swapping bug causing incorrect character encoding for some languages. Thanks to Nicolas "tarass"!
Diffstat (limited to 'ttxtsubsreceiver.c')
-rw-r--r--ttxtsubsreceiver.c44
1 files changed, 37 insertions, 7 deletions
diff --git a/ttxtsubsreceiver.c b/ttxtsubsreceiver.c
index b8473e6..b254c88 100644
--- a/ttxtsubsreceiver.c
+++ b/ttxtsubsreceiver.c
@@ -10,6 +10,11 @@
#define MAXINDEXPAGELINES 24
+struct ringBufItem {
+ encodedPTS pts;
+ uint8_t data[46];
+};
+
// ----- cTtxtSubsReceiver -----
cTtxtSubsReceiver::cTtxtSubsReceiver(int Ca, struct ttxtpidinfo *PI)
@@ -17,7 +22,7 @@ cTtxtSubsReceiver::cTtxtSubsReceiver(int Ca, struct ttxtpidinfo *PI)
cReceiver(Ca, -1, 1, PI->pid),
mGetMutex(),
mGetCond(),
- mRingBuf(46 * 500, true),
+ mRingBuf(sizeof(ringBufItem) * 500, true),
mPI(*PI),
mIndexPageLines(0),
mIndexPageCol(0),
@@ -26,6 +31,8 @@ cTtxtSubsReceiver::cTtxtSubsReceiver(int Ca, struct ttxtpidinfo *PI)
int count = 0;
uint16_t *pages = (uint16_t *) malloc(sizeof(uint16_t) * mPI.pagecount);
+ mPTS.valid = 0;
+
// find a free page to put the index page on
mIndexPageNo = 0x100;
int again;
@@ -70,13 +77,18 @@ cTtxtSubsReceiver::~cTtxtSubsReceiver()
// returns pointer buf if there is new data
-uint8_t *cTtxtSubsReceiver::Get(uint8_t *buf)
+uint8_t *cTtxtSubsReceiver::Get(uint8_t *buf, encodedPTS *pts)
{
cFrame *f;
f = mRingBuf.Get();
if(f) {
- memcpy(buf, f->Data(), 46);
+ ringBufItem *i = (ringBufItem*) f->Data();
+ if(pts) {
+ *pts = i->pts;
+ }
+
+ memcpy(buf, i->data, 46);
mRingBuf.Drop(f);
// fprintf(stderr, "cTtxtSubsReceiver::Get: returned data!\n");
return buf;
@@ -117,7 +129,7 @@ void cTtxtSubsReceiver::Activate(bool On)
// XXX We should do some filtering here to avoid unneccessary load!
void cTtxtSubsReceiver::Receive(uchar *Data, int Length)
{
- int i;
+ int i = 0;
if(Length != 188) // should never happen
return;
@@ -125,19 +137,37 @@ void cTtxtSubsReceiver::Receive(uchar *Data, int Length)
if(Data[1] & 0x80) // transport_error_indicator
return;
+ if((Data[3] & 0x30) != 0x10) // only accept TS packets with data and no adaption field
+ return; // (ETSI EN 300 472 $4.1)
+
+ if(Data[1] & 0x40) { // payload_unit_start_indicator
+ if(((Data[11] >> 6) & 0x02) == 0x02) { // PTS_DTS_flags
+ mPTS.data[0] = Data[13];
+ mPTS.data[1] = Data[14];
+ mPTS.data[2] = Data[15];
+ mPTS.data[3] = Data[16];
+ mPTS.data[4] = Data[17];
+ mPTS.valid = 1;
+ } else {
+ mPTS.valid = 0;
+ }
+ }
+
+ ringBufItem it;
+ it.pts = mPTS;
+
// payload_unit_start_indicator
for(i = (Data[1] & 0x40) ? 1 : 0; i < 4; i++) {
- char buf[46];
if(0xff == Data[4 + i*46]) // stuffing data
continue;
- if(mFilter.Filter((char *) Data + 4 + i*46, buf)) {
+ if(mFilter.Filter((char *) Data + 4 + i*46, (char *) it.data)) {
// fprintf(stderr, "Forward Packet:\n");
// print_line((char *) Data + 4 + i*46);
// print_line(buf);
- cFrame *f = new cFrame((uchar *) buf, 46);
+ cFrame *f = new cFrame((uchar *) &it, sizeof(ringBufItem));
mRingBuf.Put(f);
mGetCond.Broadcast();
}