diff options
author | Lars Hanisch <dvb@flensrocker.de> | 2010-03-24 20:38:33 +0100 |
---|---|---|
committer | Lars Hanisch <dvb@flensrocker.de> | 2010-03-24 20:38:33 +0100 |
commit | 5055546e40d4171a7f67689a3ea0b103d60b762b (patch) | |
tree | a4e5b7f115ebc40179b84f1b908c2d5a9a66b851 | |
parent | 7173683e4cd89bd981421aa59e29d54705b295a2 (diff) | |
download | vdr-plugin-pvrinput-5055546e40d4171a7f67689a3ea0b103d60b762b.tar.gz vdr-plugin-pvrinput-5055546e40d4171a7f67689a3ea0b103d60b762b.tar.bz2 |
Rework of teletext PMT handling
Due to retuning of the vdr on a pid-change the intended behaviour of pvrinput could not be achieved.
Now a PMT with teletext descriptor is sent if there's at least one device present, which is capable of sliced vbi.
-rw-r--r-- | device.c | 5 | ||||
-rw-r--r-- | device.h | 1 | ||||
-rw-r--r-- | reader.c | 59 | ||||
-rw-r--r-- | reader.h | 1 |
4 files changed, 22 insertions, 44 deletions
@@ -18,6 +18,7 @@ char CARDNAME[][9] = { cPvrDevice *PvrDevices[kMaxPvrDevices]; cString cPvrDevice::externChannelSwitchScript; +int cPvrDevice::VBIDeviceCount = 0; cPvrDevice::cPvrDevice(int DeviceNumber) : number(DeviceNumber), @@ -88,7 +89,8 @@ cPvrDevice::cPvrDevice(int DeviceNumber) /*The pvrusb2 driver advertises vbi capability, although it isn't there. This was fixed in v4l-dvb hg in 01/2009 and will hopefully be in Kernel 2.6.30*/ SupportsSlicedVBI = true; - log(pvrDEBUG1, "%s supports sliced VBI Capture", *devName); + VBIDeviceCount++; + log(pvrDEBUG1, "%s supports sliced VBI Capture, total number of VBI capable devices is now &d", *devName, VBIDeviceCount); } if (video_vcap.capabilities & V4L2_CAP_VIDEO_OUTPUT_OVERLAY) hasDecoder = true; //can only be a PVR350 @@ -252,6 +254,7 @@ bool cPvrDevice::Probe(int DeviceNumber) bool cPvrDevice::Initialize(void) { int found = 0; + VBIDeviceCount = 0; #ifdef PVR_SOURCEPARAMS new cPvrSourceParam(); #endif @@ -55,6 +55,7 @@ class cPvrDevice : public cDevice { private: static bool Probe(int DeviceNumber); static cString externChannelSwitchScript; + static int VBIDeviceCount; public: static bool Initialize(void); @@ -153,34 +153,6 @@ const unsigned char kInvTab[256] = { 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff, }; -static bool GetPMT(unsigned char *PMT, int Sid, bool WithTeletext, bool IncreaseVersion) -{ - uint8_t cont_counter = 0; - uint8_t next_version = 0; - if (IncreaseVersion) { - cont_counter = PMT[3] & 0x0f; - next_version = (PMT[10] + 2) | 0xc1; - } - int crc_offset = 0; - if (WithTeletext) { - memcpy(PMT, kPMTwithTeletext, TS_SIZE); - crc_offset = 40; - } - else { - memcpy(PMT, kPMTwithoutTeletext, TS_SIZE); - crc_offset = 33; - } - PMT[3] = (PMT[3] & 0xf0) | cont_counter; - PMT[8] = (Sid >> 8) & 0xFF; - PMT[9] = Sid & 0xFF; - PMT[10] = next_version; - int crc = SI::CRC32::crc32((const char*)(PMT + 5), crc_offset - 5, 0xFFFFFFFF); - PMT[crc_offset] = crc >> 24; - PMT[crc_offset + 1] = crc >> 16; - PMT[crc_offset + 2] = crc >> 8; - PMT[crc_offset + 3] = crc; - return WithTeletext; -} cPvrReadThread::cPvrReadThread(cRingBufferLinear *TsBuffer, cPvrDevice *_parent) : tsBuffer(TsBuffer), @@ -244,11 +216,6 @@ void cPvrReadThread::PesToTs(uint8_t *Data, uint32_t Length) uint32_t Payload_Rest = Length % PayloadSize; stream_id = Data[3]; - if ((stream_id == 0xBD) && !pmt_has_teletext && (parent->CurrentInputType != eRadio)) { - pmt_has_teletext = GetPMT(pmt_buffer, parent->CurrentChannel.Sid(), true, true); - packet_counter = 0; - } - if (packet_counter <= 0) { // time to send PAT and PMT // increase continuity counter pat_buffer[ 3] = (pat_buffer[ 3] & 0xF0) | (((pat_buffer[ 3] & 0x0F) + 1) & 0x0F); @@ -545,18 +512,26 @@ void cPvrReadThread::Action(void) pat_buffer[19] = crc >> 8; pat_buffer[20] = crc; + int crc_offset = 0; if (parent->CurrentInputType == eRadio) { memcpy(pmt_buffer, kPMTRadio, TS_SIZE); - pmt_buffer[8] = (sid >> 8) & 0xFF; - pmt_buffer[9] = sid & 0xFF; - crc = SI::CRC32::crc32((const char*)(pmt_buffer + 5), 23, 0xFFFFFFFF); - pmt_buffer[28] = crc >> 24; - pmt_buffer[29] = crc >> 16; - pmt_buffer[30] = crc >> 8; - pmt_buffer[31] = crc; + crc_offset = 28; + } + else if (cPvrDevice::VBIDeviceCount > 0) { + memcpy(pmt_buffer, kPMTwithTeletext, TS_SIZE); + crc_offset = 40; + } + else { + memcpy(pmt_buffer, kPMTwithoutTeletext, TS_SIZE); + crc_offset = 33; } - else - pmt_has_teletext = GetPMT(pmt_buffer, sid, false, false); + pmt_buffer[8] = (sid >> 8) & 0xFF; + pmt_buffer[9] = sid & 0xFF; + crc = SI::CRC32::crc32((const char*)(pmt_buffer + 5), crc_offset - 5, 0xFFFFFFFF); + pmt_buffer[crc_offset] = crc >> 24; + pmt_buffer[crc_offset + 1] = crc >> 16; + pmt_buffer[crc_offset + 2] = crc >> 8; + pmt_buffer[crc_offset + 3] = crc; } retry: while (Running() && parent->readThreadRunning) { @@ -9,7 +9,6 @@ private: cRingBufferLinear *tsBuffer; uint8_t pat_buffer[TS_SIZE]; uint8_t pmt_buffer[TS_SIZE]; - bool pmt_has_teletext; uint8_t ts_buffer[TS_SIZE]; uint8_t video_counter; uint8_t audio_counter; |