summaryrefslogtreecommitdiff
path: root/libsi/descriptor.c
diff options
context:
space:
mode:
Diffstat (limited to 'libsi/descriptor.c')
-rw-r--r--libsi/descriptor.c147
1 files changed, 134 insertions, 13 deletions
diff --git a/libsi/descriptor.c b/libsi/descriptor.c
index b552ae7c..d85a6a13 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.7 2004/03/05 15:17:33 kls Exp $
+ * $Id: descriptor.c 1.8 2004/03/07 11:07:57 kls Exp $
* *
***************************************************************************/
@@ -60,13 +60,13 @@ void ExtendedEventDescriptor::Item::Parse() {
item.setData(data+offset, mid->item_length);
}
-int ExtendedEventDescriptors::getTextLength() {
+/*int ExtendedEventDescriptors::getTextLength() {
int ret=0;
for (int i=0;i<length;i++) {
ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
if (!d)
continue;
- ret+=d->text.getLength()+1; //plus a blank
+ ret+=d->text.getLength();
ExtendedEventDescriptor::Item item;
for (Loop::Iterator it; d->itemLoop.hasNext(it); ) {
item=d->itemLoop.getNext(it);
@@ -76,28 +76,82 @@ int ExtendedEventDescriptors::getTextLength() {
}
}
return ret;
-}
+}*/
-//is there a case where this function does not return the same as getTextLength?
int ExtendedEventDescriptors::getMaximumTextLength() {
+ return getMaximumTextPlainLength()+getMaximumTextItemizedLength();
+}
+
+char *ExtendedEventDescriptors::getText(const char *separation1, const char *separation2) {
+ char *text=new char[getMaximumTextLength()];
+ return getText(text, separation1, separation2);
+}
+
+char *ExtendedEventDescriptors::getText(char *buffer, const char *separation1, const char *separation2) {
+ int index=0, len;
+ char tempbuf[256];
+ for (int i=0;i<length;i++) {
+ ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
+ if (!d)
+ continue;
+ d->text.getText(tempbuf);
+ len=strlen(tempbuf);
+ if (len) {
+ memcpy(buffer+index, tempbuf, len);
+ index+=len;
+ }
+ }
+
+ for (int i=0;i<length;i++) {
+ ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
+ if (!d)
+ continue;
+
+ ExtendedEventDescriptor::Item item;
+ for (Loop::Iterator it; d->itemLoop.hasNext(it); ) {
+ item=d->itemLoop.getNext(it);
+
+ item.itemDescription.getText(tempbuf);
+ len=strlen(tempbuf);
+ if (len) {
+ memcpy(buffer+index, tempbuf, len);
+ index+=len;
+ }
+ strcpy(buffer+index, separation1);
+ index += strlen(separation1);
+
+ item.item.getText(tempbuf);
+ len=strlen(tempbuf);
+ if (len) {
+ memcpy(buffer+index, tempbuf, len);
+ index+=len;
+ }
+ strcpy(buffer+index, separation2);
+ index += strlen(separation2);
+ }
+ }
+
+ buffer[index]='\0';
+ return buffer;
+}
+
+int ExtendedEventDescriptors::getMaximumTextPlainLength() {
int ret=0;
for (int i=0;i<length;i++) {
ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
if (!d)
continue;
- ret+=d->text.getLength()+1; //plus a blank
- ret+=d->itemLoop.getLength();
+ ret+=d->text.getLength();
}
return ret;
}
-char *ExtendedEventDescriptors::getText() {
- char *text=new char[getMaximumTextLength()];
+char *ExtendedEventDescriptors::getTextPlain() {
+ char *text=new char[getMaximumTextPlainLength()];
return getText(text);
}
-//appends the Strings of every Descriptor in the group
-char *ExtendedEventDescriptors::getText(char *buffer) {
+char *ExtendedEventDescriptors::getTextPlain(char *buffer) {
int index=0, len;
char tempbuf[256];
for (int i=0;i<length;i++) {
@@ -110,30 +164,97 @@ char *ExtendedEventDescriptors::getText(char *buffer) {
memcpy(buffer+index, tempbuf, len);
index+=len;
}
+ }
+ buffer[index]='\0';
+ return buffer;
+}
+
+int ExtendedEventDescriptors::getMaximumTextItemizedLength() {
+ int ret=0;
+ for (int i=0;i<length;i++) {
+ ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
+ if (!d)
+ continue;
+ //the size for the two separating characters is included ;-)
+ ret+=d->itemLoop.getLength();
+ }
+ return ret;
+}
+
+char *ExtendedEventDescriptors::getTextItemized(const char *separation1, const char *separation2) {
+ char *text=new char[getMaximumTextItemizedLength()];
+ return getText(text, separation1, separation2);
+}
+
+char *ExtendedEventDescriptors::getTextItemized(char *buffer, const char *separation1, const char *separation2) {
+ int index=0, len;
+ char tempbuf[256];
+ for (int i=0;i<length;i++) {
+ ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[i];
+ if (!d)
+ continue;
ExtendedEventDescriptor::Item item;
for (Loop::Iterator it; d->itemLoop.hasNext(it); ) {
item=d->itemLoop.getNext(it);
- item.item.getText(tempbuf);
+ item.itemDescription.getText(tempbuf);
len=strlen(tempbuf);
if (len) {
memcpy(buffer+index, tempbuf, len);
index+=len;
}
+ strcpy(buffer+index, separation1);
+ index += strlen(separation1);
- item.itemDescription.getText(tempbuf);
+ item.item.getText(tempbuf);
len=strlen(tempbuf);
if (len) {
memcpy(buffer+index, tempbuf, len);
index+=len;
}
+ strcpy(buffer+index, separation2);
+ index += strlen(separation2);
}
}
buffer[index]='\0';
return buffer;
}
+//returns the itemized text pair by pair. Maximum length for buffers is 256.
+//Return value is false if and only if the end of the list is reached.
+bool ExtendedEventDescriptors::getTextItemized(Loop::Iterator &it, bool &valid, char *itemDescription, char *itemText) {
+ //The iterator has to store two values: The descriptor index (4bit)
+ //and the item loop index (max overall length 256, min item length 16 => max number 128 => 7bit)
+ valid=false;
+
+ int index=(it.i & 0x780) >> 7; // 0x780 == 1111 000 0000
+ it.i &= 0x7F; //0x7F == 111 1111
+
+ for (;index<length;index++) {
+ ExtendedEventDescriptor *d=(ExtendedEventDescriptor *)array[index];
+ if (!d)
+ continue;
+
+ ExtendedEventDescriptor::Item item;
+ if (d->itemLoop.hasNext(it)) {
+ item=d->itemLoop.getNext(it);
+
+ item.item.getText(itemDescription);
+ item.itemDescription.getText(itemText);
+ valid=true;
+ } else {
+ it.reset();
+ continue;
+ }
+ }
+
+ it.i &= 0x7F;
+ it.i |= (index & 0xF) << 7; //0xF == 1111
+
+ return index<length;
+}
+
int TimeShiftedEventDescriptor::getReferenceServiceId() const {
return HILO(s->reference_service_id);
}