[Redbutton-devel] SF.net SVN: redbutton:[505] redbutton-download/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2008-11-19 13:16:50
|
Revision: 505
http://redbutton.svn.sourceforge.net/redbutton/?rev=505&view=rev
Author: skilvington
Date: 2008-11-19 13:16:45 +0000 (Wed, 19 Nov 2008)
Log Message:
-----------
patch from Andreas Oberritter to cope with SDT's that span more than one section
Modified Paths:
--------------
redbutton-download/trunk/findmheg.c
redbutton-download/trunk/list.c
redbutton-download/trunk/table.c
redbutton-download/trunk/table.h
Modified: redbutton-download/trunk/findmheg.c
===================================================================
--- redbutton-download/trunk/findmheg.c 2008-11-19 13:04:27 UTC (rev 504)
+++ redbutton-download/trunk/findmheg.c 2008-11-19 13:16:45 UTC (rev 505)
@@ -139,7 +139,7 @@
_car.modules = NULL;
/* find the original_network_id from the SDT */
- if(!read_sdt(_car.demux_device, timeout, sdt))
+ if(!read_sdt(_car.demux_device, timeout, sdt, 0))
fatal("Unable to read SDT");
_car.network_id = (sdt[8] << 8) + sdt[9];
vverbose("original_network_id=%u", _car.network_id);
Modified: redbutton-download/trunk/list.c
===================================================================
--- redbutton-download/trunk/list.c 2008-11-19 13:04:27 UTC (rev 504)
+++ redbutton-download/trunk/list.c 2008-11-19 13:16:45 UTC (rev 505)
@@ -41,6 +41,7 @@
uint8_t desc_tag;
uint8_t desc_length;
uint8_t name_len;
+ uint8_t sn, lsn;
snprintf(demux_dev, sizeof(demux_dev), DEMUX_DEVICE, adapter, demux);
@@ -49,50 +50,53 @@
printf("==\t=======\n");
/* grab the Service Description Table */
- if(!read_sdt(demux_dev, timeout, sdt))
- fatal("Unable to read SDT");
-
- /* 12 bit section_length field */
- size = 3 + (((sdt[1] & 0x0f) << 8) + sdt[2]);
-
- /* loop through the services */
- offset = 11;
- /* -4 for the CRC at the end */
- while(offset < (size - 4))
+ for(sn=0, lsn=0; sn<=lsn; sn++)
{
- service_id = (sdt[offset] << 8) + sdt[offset+1];
- printf("%u\t", service_id);
- /* move on to the descriptors */
- offset += 3;
- desc_loop_length = ((sdt[offset] & 0x0f) << 8) + sdt[offset+1];
- offset += 2;
- /* find the service_descriptor tag */
- while(desc_loop_length != 0)
+ if(!read_sdt(demux_dev, timeout, sdt, sn))
+ fatal("Unable to read SDT");
+ /* 12 bit section_length field */
+ size = 3 + (((sdt[1] & 0x0f) << 8) + sdt[2]);
+ /* last_section_number */
+ lsn = sdt[7];
+ /* loop through the services */
+ offset = 11;
+ /* -4 for the CRC at the end */
+ while(offset < (size - 4))
{
- desc_tag = sdt[offset];
- desc_length = sdt[offset+1];
+ service_id = (sdt[offset] << 8) + sdt[offset+1];
+ printf("%u\t", service_id);
+ /* move on to the descriptors */
+ offset += 3;
+ desc_loop_length = ((sdt[offset] & 0x0f) << 8) + sdt[offset+1];
offset += 2;
- desc_loop_length -= 2;
- if(desc_tag == TAG_SERVICE_DESCRIPTOR)
+ /* find the service_descriptor tag */
+ while(desc_loop_length != 0)
{
- /* service_type = sds[offset]; */
- offset += 1;
- /* service_provider_name */
- name_len = sdt[offset];
- offset += 1 + name_len;
- /* service_name */
- name_len = sdt[offset];
- offset += 1;
- printf("%.*s\n", name_len, &sdt[offset]);
- offset += name_len;
+ desc_tag = sdt[offset];
+ desc_length = sdt[offset+1];
+ offset += 2;
+ desc_loop_length -= 2;
+ if(desc_tag == TAG_SERVICE_DESCRIPTOR)
+ {
+ /* service_type = sds[offset]; */
+ offset += 1;
+ /* service_provider_name */
+ name_len = sdt[offset];
+ offset += 1 + name_len;
+ /* service_name */
+ name_len = sdt[offset];
+ offset += 1;
+ printf("%.*s\n", name_len, &sdt[offset]);
+ offset += name_len;
+ }
+ else
+ {
+ vverbose("desc_tag: %u", desc_tag);
+ vhexdump(&sdt[offset], desc_length);
+ offset += desc_length;
+ }
+ desc_loop_length -= desc_length;
}
- else
- {
- vverbose("desc_tag: %u", desc_tag);
- vhexdump(&sdt[offset], desc_length);
- offset += desc_length;
- }
- desc_loop_length -= desc_length;
}
}
Modified: redbutton-download/trunk/table.c
===================================================================
--- redbutton-download/trunk/table.c 2008-11-19 13:04:27 UTC (rev 504)
+++ redbutton-download/trunk/table.c 2008-11-19 13:16:45 UTC (rev 505)
@@ -73,7 +73,7 @@
return true;
/* read it from the DVB card */
- if(!read_table(demux, PID_PAT, TID_PAT, timeout, out))
+ if(!read_table(demux, PID_PAT, TID_PAT, timeout, out, 0))
{
error("Unable to read PAT");
return false;
@@ -135,7 +135,7 @@
vverbose("PMT PID: %u", map_pid);
/* get the PMT */
- rc = read_table(demux, map_pid, TID_PMT, timeout, out);
+ rc = read_table(demux, map_pid, TID_PMT, timeout, out, 0);
/* cache it */
if(rc)
@@ -152,32 +152,38 @@
*/
bool
-read_sdt(char *demux, unsigned int timeout, unsigned char *out)
+read_sdt(char *demux, unsigned int timeout, unsigned char *out, unsigned char sn)
{
+ char cache_item[PATH_MAX];
+
+ snprintf(cache_item, sizeof(cache_item), "sdt-%u", sn);
+
/* is it in the cache */
- if(cache_load("sdt", out))
+ if(cache_load(cache_item, out))
return true;
/* read it from the DVB card */
- if(!read_table(demux, PID_SDT, TID_SDT, timeout, out))
+ if(!read_table(demux, PID_SDT, TID_SDT, timeout, out, sn))
{
error("Unable to read SDT");
return false;
}
/* cache it */
- cache_save("sdt", out);
+ cache_save(cache_item, out);
return true;
}
/*
+ * read the given table (defined by pid and tid) from the given DVB device
+ * sn is the section number
* output buffer must be at least MAX_TABLE_LEN bytes
* returns false if it timesout
*/
bool
-read_table(char *device, uint16_t pid, uint8_t tid, unsigned int secs, unsigned char *out)
+read_table(char *device, uint16_t pid, uint8_t tid, unsigned int secs, unsigned char *out, unsigned char sn)
{
int fd_data;
struct dmx_sct_filter_params sctFilterParams;
@@ -195,8 +201,10 @@
sctFilterParams.pid = pid;
sctFilterParams.timeout = 0;
sctFilterParams.flags = DMX_IMMEDIATE_START;
- sctFilterParams.filter.filter[0] = tid;
- sctFilterParams.filter.mask[0] = 0xff;
+ sctFilterParams.filter.filter[0] = tid;
+ sctFilterParams.filter.mask[0] = 0xff;
+ sctFilterParams.filter.filter[4] = sn;
+ sctFilterParams.filter.mask[4] = 0xff;
if(ioctl(fd_data, DMX_SET_FILTER, &sctFilterParams) < 0)
{
@@ -237,7 +245,7 @@
return false;
}
}
- while(out[0] != tid);
+ while(out[0] != tid || out[6] != sn);
close(fd_data);
Modified: redbutton-download/trunk/table.h
===================================================================
--- redbutton-download/trunk/table.h 2008-11-19 13:04:27 UTC (rev 504)
+++ redbutton-download/trunk/table.h 2008-11-19 13:16:45 UTC (rev 505)
@@ -33,9 +33,9 @@
bool read_pat(char *, unsigned int, unsigned char *);
bool read_pmt(char *, uint16_t, unsigned int, unsigned char *);
-bool read_sdt(char *, unsigned int, unsigned char *);
+bool read_sdt(char *, unsigned int, unsigned char *, unsigned char);
-bool read_table(char *, uint16_t, uint8_t, unsigned int, unsigned char *);
+bool read_table(char *, uint16_t, uint8_t, unsigned int, unsigned char *, unsigned char);
bool read_dsmcc_tables(struct carousel *, unsigned char *);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|