diff options
author | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2004-10-17 18:00:00 +0200 |
---|---|---|
committer | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2004-10-17 18:00:00 +0200 |
commit | af483c11aebd8146a978dba3d604bda0951e24ac (patch) | |
tree | 827cb878cb469043ea6e9227037589af88cd7832 /libsi | |
parent | 335a57291373aa25739a7192807fbfe1c8de0efd (diff) | |
download | vdr-patch-lnbsharing-af483c11aebd8146a978dba3d604bda0951e24ac.tar.gz vdr-patch-lnbsharing-af483c11aebd8146a978dba3d604bda0951e24ac.tar.bz2 |
Version 1.3.13vdr-1.3.13
- Fixed checking for the presence of NPTL (thanks to Jouni Karvo).
- Making sure section filters are only set if the device actually has a lock
(thanks to Andreas Share for pointing this out).
- Fixed a possible NULL pointer assignment in cMenuText::SetText() (thanks to
Marco Schlüssler).
- Fixed a crash in case the last line in channels.conf is a group separator and
that group is selected in the channel display (thanks to Dick Streefland).
- Added cRingBufferLinear::Read() to read directly from a file handle into the
ring buffer.
- Using timeouts in ring buffers to avoid 'usleep()'.
- Clearing the 'Transfer Mode' ring buffer after clearing the device to avoid
an "almost full" ring buffer.
- Removed locking from cRingBufferLinear for better performance under high load.
- Using a cRingBufferLinear in cRemux to avoid unnecessary copying of data.
- Using a cRingBufferLinear in cTSBuffer and filling it in a separate thread
to avoid buffer overflows. Plugins using cTSBuffer will need to remove the
call to the now obsolete Read() function (see cDvbDevice::GetTSPacket() for
the new usage of cTSBuffer).
- cRemux::Process() has been split into Put(), Get() and Del() to allow for a
better decoupling of the remuxing and disk writing process. Plugins using
cRemux will need to be modified accordingly.
- The actual disk writing in recordings is now done in a separate thread to
improve the overall throughput.
- Changed cRemux so that it returns the maximum available amount of data with
each call, not just 2048 byte.
- Added a visual display of all cRingBufferLinear buffers for debugging. To
activate it, define DEBUGRINGBUFFERS in ringbuffer.h.
- Instead of cCondVar now using the new cCondWait (which also avoids a possible
"near miss" condition; thanks to Sascha Volkenandt for pointing out this one).
cCondVar is still present for plugins that use it (and VDR itself also still
uses it in cRemote).
- The cRingBuffer now does EnableGet()/EnablePut() only if the buffer is more than
one third full or empty, respectively. This dramatically improves recording
performance and reduces system load (thanks to Marco Schlüßler for doing some
testing regarding buffer performance and giving me some hints that finally led
to finding out that this was the basic problem causing buffer overflows).
- Improved Transfer Mode (thanks to Marco Schlüßler for suggestions and testing).
- Fixed a possible crash with inconsistent SI data (thanks to Marcel Wiesweg).
- Fixed showing the replay mode if the OSD is currently in use (thanks to Kimmo
Tykkala for pointing out this problem).
- cOsdProvider::NewOsd() now always returns a valid pointer, even if the OSD is
currently in use (it will then return a dummy cOsd object and write a message to
the log file).
- Added Estonian language texts (thanks to Arthur Konovalov).
- Fixed 'newplugin' and libsi/Makefile to use the compiler defined in $(CXX) for
generating file dependencies (thanks to Andreas Brachold).
- Moved the initialization of aPid1 and aPid2 to the beginning of cDvbDevice::cDvbDevice()
to have them set in case a patch references them (thanks to Wayne Keer for pointing
this out).
- Completed the Russian OSD texts (thanks to Vyacheslav Dikonov).
- Avoiding unnecessary section filter start/stops (thanks to Marco Schlüßler).
- Made the "Channel not available!" message and mtInfo instead of mtError (suggested
by Wayne Keer).
- Made volume control more linear (thanks to Emil Naepflein and Udo Richter).
- Now skipping code table info in SI data (suggested by Milos Kapoun).
- Added missing Czech characters to fontosd-iso8859-2.c (thanks to Milos Kapoun).
- Fixed a crash in the time search mechanism (reported by Reinhard Nissl).
- If one PID can't be added, the whole cDevice::AttachReceiver() will now fail
and all PIDs added so far will be deleted (thanks to Marco Schlüßler for
pointing out this one).
- Now only saving channels.conf after a modification made by the user (avoids
lots of disk access due to automatic channel updates). Automatic channel
modifications will be saved every 10 minutes if no recording is currently
active.
- Removed the 'Log' parameter from the cChannel::Set... functions. Instead
checking if the channel has a non-zero number.
- Updated 'channels.conf.terr' for Hannover (thanks to Sven Kreiensen).
Diffstat (limited to 'libsi')
-rw-r--r-- | libsi/Makefile | 4 | ||||
-rw-r--r-- | libsi/descriptor.c | 14 | ||||
-rw-r--r-- | libsi/si.c | 26 | ||||
-rw-r--r-- | libsi/si.h | 30 | ||||
-rw-r--r-- | libsi/util.c | 6 | ||||
-rw-r--r-- | libsi/util.h | 9 |
6 files changed, 55 insertions, 34 deletions
diff --git a/libsi/Makefile b/libsi/Makefile index 613fbee..2d8713b 100644 --- a/libsi/Makefile +++ b/libsi/Makefile @@ -1,7 +1,7 @@ # # Makefile for a libsi # -# $Id: Makefile 1.2 2003/12/13 10:41:39 kls Exp $ +# $Id: Makefile 1.3 2004/10/16 13:31:50 kls Exp $ ### The C++ compiler and options: @@ -30,7 +30,7 @@ OBJS = util.o si.o section.o descriptor.o # Dependencies: -MAKEDEP = g++ -MM -MG +MAKEDEP = $(CXX) -MM -MG DEPFILE = .dependencies $(DEPFILE): Makefile @$(MAKEDEP) $(DEFINES) $(INCLUDES) $(OBJS:%.o=%.c) > $@ diff --git a/libsi/descriptor.c b/libsi/descriptor.c index eb921c9..207b7c2 100644 --- a/libsi/descriptor.c +++ b/libsi/descriptor.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: descriptor.c 1.13 2004/06/06 14:47:30 kls Exp $ + * $Id: descriptor.c 1.14 2004/10/16 09:51:05 kls Exp $ * * ***************************************************************************/ @@ -110,9 +110,7 @@ char *ExtendedEventDescriptors::getText(char *buffer, int size, const char *sepa continue; ExtendedEventDescriptor::Item item; - for (Loop::Iterator it; d->itemLoop.hasNext(it); ) { - item=d->itemLoop.getNext(it); - + for (Loop::Iterator it; d->itemLoop.getNext(item, it); ) { if (!separated && size > sepLen2) { strcpy(buffer+index, separation2); // let's have a separator between the long text and the items index += sepLen2; @@ -207,9 +205,7 @@ char *ExtendedEventDescriptors::getTextItemized(char *buffer, int size, const ch continue; ExtendedEventDescriptor::Item item; - for (Loop::Iterator it; d->itemLoop.hasNext(it); ) { - item=d->itemLoop.getNext(it); - + for (Loop::Iterator it; d->itemLoop.getNext(item, it); ) { item.itemDescription.getText(buffer+index, size); len = strlen(buffer+index); index += len; @@ -251,9 +247,7 @@ bool ExtendedEventDescriptors::getTextItemized(Loop::Iterator &it, bool &valid, continue; ExtendedEventDescriptor::Item item; - if (d->itemLoop.hasNext(it)) { - item=d->itemLoop.getNext(it); - + if (d->itemLoop.getNext(item, it)) { item.item.getText(itemDescription, sizeItemDescription); item.itemDescription.getText(itemText, sizeItemText); valid=true; @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: si.c 1.11 2004/06/06 14:43:56 kls Exp $ + * $Id: si.c 1.13 2004/10/16 15:12:57 kls Exp $ * * ***************************************************************************/ @@ -30,6 +30,10 @@ void Object::setData(CharArray &d) { data=d; } +bool Object::checkSize(unsigned int offset) { + return data.checkSize(offset); +} + Section::Section(const unsigned char *data, bool doCopy) { setData(data, getLength(data), doCopy); } @@ -50,15 +54,15 @@ int Section::getLength(const unsigned char *d) { return HILO(((const SectionHeader *)d)->section_length)+sizeof(SectionHeader); } -bool CRCSection::isValid() { +bool CRCSection::isCRCValid() { return CRC32::isValid((const char *)data.getData(), getLength()/*, data.FourBytes(getLength()-4)*/); } bool CRCSection::CheckCRCAndParse() { - if (!isValid()) + if (!isCRCValid()) return false; CheckParse(); - return true; + return isValid(); } int NumberedSection::getTableIdExtension() const { @@ -102,7 +106,7 @@ DescriptorTag Descriptor::getDescriptorTag(const unsigned char *d) { } Descriptor *DescriptorLoop::getNext(Iterator &it) { - if (it.i<getLength()) { + if (isValid() && it.i<getLength()) { return createDescriptor(it.i, true); } return 0; @@ -110,7 +114,7 @@ Descriptor *DescriptorLoop::getNext(Iterator &it) { Descriptor *DescriptorLoop::getNext(Iterator &it, DescriptorTag tag, bool returnUnimplemetedDescriptor) { Descriptor *d=0; - if (it.i<getLength()) { + if (isValid() && it.i<getLength()) { const unsigned char *p=data.getData(it.i); const unsigned char *end=p+getLength()-it.i; while (p < end) { @@ -128,7 +132,7 @@ Descriptor *DescriptorLoop::getNext(Iterator &it, DescriptorTag tag, bool return Descriptor *DescriptorLoop::getNext(Iterator &it, DescriptorTag *tags, int arrayLength, bool returnUnimplementedDescriptor) { Descriptor *d=0; - if (it.i<getLength()) { + if (isValid() && it.i<getLength()) { const unsigned char *p=data.getData(it.i); const unsigned char *end=p+getLength()-it.i; while (p < end) { @@ -147,6 +151,8 @@ Descriptor *DescriptorLoop::getNext(Iterator &it, DescriptorTag *tags, int array } Descriptor *DescriptorLoop::createDescriptor(int &i, bool returnUnimplemetedDescriptor) { + if (!checkSize(Descriptor::getLength(data.getData(i)))) + return 0; Descriptor *d=Descriptor::getDescriptor(data+i, domain, returnUnimplemetedDescriptor); if (!d) return 0; @@ -245,6 +251,9 @@ void String::decodeText(char *buffer, int size) { } */ + if (*from == 0x10) + from += 3; // skips code table info + for (int i = 0; i < getLength(); i++) { if (*from == 0) break; @@ -269,6 +278,9 @@ void String::decodeText(char *buffer, char *shortVersion, int sizeBuffer, int si char *toShort=shortVersion; int IsShortName=0; + if (*from == 0x10) + from += 3; // skips code table info + for (int i = 0; i < getLength(); i++) { if (*from == 0) break; @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: si.h 1.10 2004/06/06 13:35:21 kls Exp $ + * $Id: si.h 1.11 2004/10/16 09:58:10 kls Exp $ * * ***************************************************************************/ @@ -180,12 +180,17 @@ public: //can only be called once since data is immutable void setData(const unsigned char*data, unsigned int size, bool doCopy=true); CharArray getData() { return data; } + //returns the valid flag which indicates if data is all right or errors have been encountered + bool isValid() { return data.isValid(); } virtual int getLength() = 0; protected: CharArray data; //is protected - not used for sections template <class T> friend class StructureLoop; void setData(CharArray &d); + //returns whether the given offset fits within the limits of the actual data + //The valid flag will be set accordingly + bool checkSize(unsigned int offset); }; class Section : public Object { @@ -205,7 +210,7 @@ public: //convenience: sets data and parses if doParse CRCSection(const unsigned char *data, bool doCopy=true) : Section(data, doCopy) {} CRCSection() {} - bool isValid(); + bool isCRCValid(); //convenience: isValid+CheckParse bool CheckCRCAndParse(); }; @@ -229,9 +234,9 @@ public: class VariableLengthPart : public Object { public: //never forget to call this - void setData(CharArray d, int l) { Object::setData(d); length=l; } + void setData(CharArray d, int l) { Object::setData(d); checkSize(l); length=l; } //convenience method - void setDataAndOffset(CharArray d, int l, unsigned int &offset) { Object::setData(d); length=l; offset+=l; } + void setDataAndOffset(CharArray d, int l, unsigned int &offset) { Object::setData(d); checkSize(l); length=l; offset+=l; } virtual int getLength() { return length; } private: int length; @@ -281,29 +286,36 @@ template <class T> class StructureLoop : public Loop { public: //currently you must use a while-loop testing for hasNext() //i must be 0 to get the first descriptor (with the first call) - T getNext(Iterator &it) + bool getNext(T &obj, Iterator &it) { + if (!isValid() || it.i >= getLength()) + return false; CharArray d=data; d.addOffset(it.i); T ret; ret.setData(d); ret.CheckParse(); + if (!checkSize(ret.getLength())) + return false; it.i+=ret.getLength(); - return ret; + obj=ret; + return true; } T* getNextAsPointer(Iterator &it) { - if (getLength() <= it.i) + if (!isValid() || it.i >= getLength()) return 0; CharArray d=data; d.addOffset(it.i); T *ret=new T(); ret->setData(d); ret->CheckParse(); + if (!checkSize(ret->getLength())) + return 0; it.i+=ret->getLength(); return ret; } - bool hasNext(Iterator &it) { return getLength() > it.i; } + //bool hasNext(Iterator &it) { return getLength() > it.i; } }; //contains descriptors of different types @@ -385,7 +397,7 @@ public: it.i+=sizeof(T); return ret; } - bool hasNext(Iterator &it) { return getLength() > it.i; } + bool hasNext(Iterator &it) { return isValid() && (getLength() > it.i); } }; class MHP_DescriptorLoop : public DescriptorLoop { diff --git a/libsi/util.c b/libsi/util.c index a2a6f0d..c6ad234 100644 --- a/libsi/util.c +++ b/libsi/util.c @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: util.c 1.3 2003/12/22 14:03:03 kls Exp $ + * $Id: util.c 1.4 2004/10/16 09:58:41 kls Exp $ * * ***************************************************************************/ @@ -88,9 +88,7 @@ CharArray CharArray::operator+(const unsigned int offset) const { return f; } -CharArray::Data::Data() : count_(1) { - size=0; - data=0; +CharArray::Data::Data() : data(0), size(0), count_(1), valid(true) { /* lockingPid = 0; locked = 0; diff --git a/libsi/util.h b/libsi/util.h index db01923..db2a0a1 100644 --- a/libsi/util.h +++ b/libsi/util.h @@ -6,7 +6,7 @@ * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * - * $Id: util.h 1.3 2003/12/22 14:07:41 kls Exp $ + * $Id: util.h 1.4 2004/10/16 09:59:48 kls Exp $ * * ***************************************************************************/ @@ -58,6 +58,9 @@ public: u_int16_t TwoBytes(const unsigned int index) const { return data_->data ? data_->TwoBytes(off+index) : 0; } u_int32_t FourBytes(const unsigned int index) const { return data_->data ? data_->FourBytes(off+index) : 0; } + bool isValid() const { return data_->valid; } + bool checkSize(unsigned int offset) { return (data_->valid && (data_->valid=(off+offset < data_->size))); } + void addOffset(unsigned int offset) { off+=offset; } private: class Data { @@ -86,10 +89,12 @@ private: const unsigned char*data; unsigned int size; - unsigned count_; // count_ is the number of CharArray objects that point at this // count_ must be initialized to 1 by all constructors // (it starts as 1 since it is pointed to by the CharArray object that created it) + unsigned count_; + + bool valid; /* pthread_mutex_t mutex; |