[Redbutton-devel] SF.net SVN: redbutton: [17] redbutton-download/trunk
Brought to you by:
skilvington
|
From: <ski...@us...> - 2006-03-15 12:39:26
|
Revision: 17 Author: skilvington Date: 2006-03-15 04:39:15 -0800 (Wed, 15 Mar 2006) ViewCVS: http://svn.sourceforge.net/redbutton/?rev=17&view=rev Log Message: ----------- replace -d option with -a Modified Paths: -------------- redbutton-download/trunk/findmheg.c redbutton-download/trunk/findmheg.h redbutton-download/trunk/list.c redbutton-download/trunk/list.h redbutton-download/trunk/module.h redbutton-download/trunk/rb-download.c redbutton-download/trunk/table.c redbutton-download/trunk/utils.h Modified: redbutton-download/trunk/findmheg.c =================================================================== --- redbutton-download/trunk/findmheg.c 2006-03-04 14:42:35 UTC (rev 16) +++ redbutton-download/trunk/findmheg.c 2006-03-15 12:39:15 UTC (rev 17) @@ -72,7 +72,7 @@ static struct carousel _car; struct carousel * -find_mheg(char *device, unsigned int timeout, uint16_t service_id, int carousel_id) +find_mheg(unsigned int adapter, unsigned int timeout, uint16_t service_id, int carousel_id) { unsigned char *pat; uint16_t section_length; @@ -88,7 +88,8 @@ uint16_t component_tag; /* carousel data we know so far */ - _car.device = device; + snprintf(_car.demux_device, sizeof(_car.demux_device), DEMUX_DEVICE, adapter); + snprintf(_car.dvr_device, sizeof(_car.dvr_device), DVR_DEVICE, adapter); _car.timeout = timeout; _car.service_id = service_id; @@ -108,7 +109,7 @@ _car.modules = NULL; /* get the PAT */ - if((pat = read_table(device, PID_PAT, TID_PAT, timeout)) == NULL) + if((pat = read_table(_car.demux_device, PID_PAT, TID_PAT, timeout)) == NULL) fatal("Unable to read PAT"); section_length = 3 + (((pat[1] & 0x0f) << 8) + pat[2]); @@ -136,7 +137,7 @@ // printf("programme_map_PID: 0x%x\n", map_pid); /* get the PMT */ - if((pmt = read_table(device, map_pid, TID_PMT, timeout)) == NULL) + if((pmt = read_table(_car.demux_device, map_pid, TID_PMT, timeout)) == NULL) fatal("Unable to read PMT"); section_length = 3 + (((pmt[1] & 0x0f) << 8) + pmt[2]); Modified: redbutton-download/trunk/findmheg.h =================================================================== --- redbutton-download/trunk/findmheg.h 2006-03-04 14:42:35 UTC (rev 16) +++ redbutton-download/trunk/findmheg.h 2006-03-15 12:39:15 UTC (rev 17) @@ -25,7 +25,7 @@ #include <stdint.h> -struct carousel *find_mheg(char *, unsigned int, uint16_t, int); +struct carousel *find_mheg(unsigned int, unsigned int, uint16_t, int); #endif /* __FINDMHEG_H__ */ Modified: redbutton-download/trunk/list.c =================================================================== --- redbutton-download/trunk/list.c 2006-03-04 14:42:35 UTC (rev 16) +++ redbutton-download/trunk/list.c 2006-03-15 12:39:15 UTC (rev 17) @@ -21,20 +21,22 @@ */ #include <stdio.h> +#include <limits.h> #include "table.h" #include "utils.h" /* PID and TID we want */ -#define PID_SDT 0x0011 +#define PID_SDT 0x0011 #define TID_SDS 0x42 /* service_descriptor tag */ #define TAG_SERVICE_DESCRIPTOR 0x48 void -list_channels(char *device, unsigned int timeout) +list_channels(unsigned int adapter, unsigned int timeout) { + char demux_dev[PATH_MAX]; unsigned char *sds; uint16_t size; uint16_t offset; @@ -44,12 +46,14 @@ uint8_t desc_length; uint8_t name_len; + snprintf(demux_dev, sizeof(demux_dev), DEMUX_DEVICE, adapter); + printf("Channels on this mutiplex:\n\n"); printf("ID\tChannel\n"); printf("==\t=======\n"); /* grab the Service Description Section table */ - if((sds = read_table(device, PID_SDT, TID_SDS, timeout)) == NULL) + if((sds = read_table(demux_dev, PID_SDT, TID_SDS, timeout)) == NULL) fatal("Unable to read SDT"); /* 12 bit section_length field */ Modified: redbutton-download/trunk/list.h =================================================================== --- redbutton-download/trunk/list.h 2006-03-04 14:42:35 UTC (rev 16) +++ redbutton-download/trunk/list.h 2006-03-15 12:39:15 UTC (rev 17) @@ -23,7 +23,7 @@ #ifndef __LIST_H__ #define __LIST_H__ -void list_channels(char *, unsigned int); +void list_channels(unsigned int, unsigned int); #endif /* __LIST_H__ */ Modified: redbutton-download/trunk/module.h =================================================================== --- redbutton-download/trunk/module.h 2006-03-04 14:42:35 UTC (rev 16) +++ redbutton-download/trunk/module.h 2006-03-15 12:39:15 UTC (rev 17) @@ -25,6 +25,7 @@ #include <stdint.h> #include <stdbool.h> +#include <limits.h> #include "dsmcc.h" #include "assoc.h" @@ -54,8 +55,9 @@ /* the whole carousel */ struct carousel { - char *device; /* demux device */ - unsigned int timeout; /* timeout for the demux device */ + char demux_device[PATH_MAX]; /* demux device path */ + char dvr_device[PATH_MAX]; /* dvr device path */ + unsigned int timeout; /* timeout for the DVB devices */ uint16_t service_id; uint32_t carousel_id; uint16_t audio_pid; /* PID of default audio stream for this service_id */ Modified: redbutton-download/trunk/rb-download.c =================================================================== --- redbutton-download/trunk/rb-download.c 2006-03-04 14:42:35 UTC (rev 16) +++ redbutton-download/trunk/rb-download.c 2006-03-15 12:39:15 UTC (rev 17) @@ -1,5 +1,5 @@ /* - * rb-download [-d <demux_device>] [-b <base_dir>] [-t <timeout>] [-l[<listen-addr>]] [-c <carousel_id>] [<service_id>] + * rb-download [-a <adapter>] [-b <base_dir>] [-t <timeout>] [-l[<listen-addr>]] [-c <carousel_id>] [<service_id>] * * Download the DVB Object Carousel for the given channel onto the local hard disc * files will be stored under the current dir if no -b option is given @@ -10,6 +10,11 @@ * the default timeout is 10 seconds * if no DSMCC data is read after this time, it is assumed none is being broadcast * + * the DVB devices used will be: + * /dev/dvb/adapter0/demux0 + * /dev/dvb/adapter0/dvr0 + * use the -a option to change the adapter number (eg "-a 1" will use /dev/dvb/adapter1/demux0 etc) + * * if -l is given, rb-download listens on the network for commands from a remote rb-browser * the default IP to listen on is 0.0.0.0 (ie all interfaces), the default TCP port is 10101 * listen-addr should be given in the form "host:port", where host defaults to 0.0.0.0 and port defaults to 10101 @@ -60,9 +65,6 @@ #include "listen.h" #include "utils.h" -/* DVB demux device */ -#define DEFAULT_DEVICE "/dev/dvb/adapter0/demux0" - /* seconds before we assume no DSMCC data is available on this PID */ #define DEFAULT_TIMEOUT 10 @@ -76,7 +78,7 @@ main(int argc, char *argv[]) { char *prog_name = argv[0]; - char *device = DEFAULT_DEVICE; + unsigned int adapter = 0; unsigned int timeout = DEFAULT_TIMEOUT; bool listen = false; struct listen_data listen_data; @@ -85,12 +87,12 @@ struct carousel *car; int arg; - while((arg = getopt(argc, argv, "d:b:t:l::c:")) != EOF) + while((arg = getopt(argc, argv, "a:b:t:l::c:")) != EOF) { switch(arg) { - case 'd': - device = optarg; + case 'a': + adapter = strtoul(optarg, NULL, 0); break; case 'b': @@ -124,12 +126,12 @@ if(argc == optind) { - list_channels(device, timeout); + list_channels(adapter, timeout); } else if(argc - optind == 1) { service_id = strtoul(argv[optind], NULL, 0); - car = find_mheg(device, timeout, service_id, carousel_id); + car = find_mheg(adapter, timeout, service_id, carousel_id); printf("Carousel ID=%u\n", car->carousel_id); printf("Video PID=%u\n", car->video_pid); printf("Audio PID=%u\n", car->audio_pid); @@ -151,7 +153,7 @@ void usage(char *prog_name) { - fatal("Usage: %s [-d <demux_device>] " + fatal("Usage: %s [-a <adapter>] " "[-b <base_dir>] " "[-t <timeout>] " "[-l[<listen-addr>]] " Modified: redbutton-download/trunk/table.c =================================================================== --- redbutton-download/trunk/table.c 2006-03-04 14:42:35 UTC (rev 16) +++ redbutton-download/trunk/table.c 2006-03-15 12:39:15 UTC (rev 17) @@ -163,7 +163,7 @@ } if(fd == -1) { - error("Timeout reading %s", car->device); + error("Timeout reading %s", car->demux_device); return NULL; } /* read the table */ @@ -205,8 +205,8 @@ fds->pid = pid; /* open an fd to read the DSMCC control tables (DSI and DII) */ - if((fds->fd_ctrl = open(car->device, O_RDWR)) < 0) - fatal("open '%s': %s", car->device, strerror(errno)); + if((fds->fd_ctrl = open(car->demux_device, O_RDWR)) < 0) + fatal("open '%s': %s", car->demux_device, strerror(errno)); /* set the table filter */ memset(&sctFilterParams, 0, sizeof(sctFilterParams)); @@ -219,8 +219,8 @@ fatal("ioctl DMX_SET_FILTER: %s", strerror(errno)); /* open an fd to read the DSMCC data table (DDB) */ - if((fds->fd_data = open(car->device, O_RDWR)) < 0) - fatal("open '%s': %s", car->device, strerror(errno)); + if((fds->fd_data = open(car->demux_device, O_RDWR)) < 0) + fatal("open '%s': %s", car->demux_device, strerror(errno)); /* set the table filter */ memset(&sctFilterParams, 0, sizeof(sctFilterParams)); Modified: redbutton-download/trunk/utils.h =================================================================== --- redbutton-download/trunk/utils.h 2006-03-04 14:42:35 UTC (rev 16) +++ redbutton-download/trunk/utils.h 2006-03-15 12:39:15 UTC (rev 17) @@ -31,6 +31,12 @@ #define MAX(a, b) ((a) > (b) ? (a) : (b)) #endif +/* DVB demux device - %u is card number */ +#define DEMUX_DEVICE "/dev/dvb/adapter%u/demux0" + +/* DVB dvr device - %u is card number */ +#define DVR_DEVICE "/dev/dvb/adapter%u/dvr0" + void write_string(int, const char *); void write_all(int, const void *, size_t); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |