aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbatchall <devnull@localhost>2003-02-03 20:26:13 (GMT)
committerbatchall <devnull@localhost>2003-02-03 20:26:13 (GMT)
commitd103e124512df38d0ad2de5b863e3e36d08ec20c (patch)
treef5a55d94d747a238e1b358a009a58188eadbeae9
parent13728f005d0e62275f26028cf78fb61a93c9512c (diff)
New station subsystem, first shot
-rw-r--r--Makefile.am2
-rw-r--r--src/bands.h3
-rw-r--r--src/commands.c330
-rw-r--r--src/freq.c96
-rw-r--r--src/freq.h31
-rw-r--r--src/station.c236
-rw-r--r--src/station.h58
-rw-r--r--src/tvscanner.c10
-rw-r--r--src/tvtime.c5
9 files changed, 475 insertions, 296 deletions
diff --git a/Makefile.am b/Makefile.am
index 3bcfac2..5159fb6 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
-AUTOMAKE_OPTIONS = 1.6
+AUTOMAKE_OPTIONS = 1.5
SUBDIRS = docs data plugins src
EXTRA_DIST = BUGS
diff --git a/src/bands.h b/src/bands.h
index 0ac0a53..baf1e0a 100644
--- a/src/bands.h
+++ b/src/bands.h
@@ -281,4 +281,7 @@ const int numbands = ( sizeof( bands ) / sizeof( band_t ) );
JP Air JP Bcast
*/
+#define NTSC_CABLE_HRC(x) ((x == 77250) ? 78000 : ((x == 83250) ? 84000 : (x - 1250)))
+#define NTSC_CABLE_IRC(x) ((x == 77250) ? 79250 : ((x == 83250) ? 85250 : x))
+
#endif /* BANDS_H_INCLUDED */
diff --git a/src/commands.c b/src/commands.c
index 4ec1bb0..d1908ac 100644
--- a/src/commands.c
+++ b/src/commands.c
@@ -23,7 +23,7 @@
#include "config.h"
#include <ctype.h>
#include "tvtimeconf.h"
-#include "frequencies.h"
+#include "station.h"
#include "mixer.h"
#include "commands.h"
#include "menu.h"
@@ -34,14 +34,7 @@
/* Number of frames to wait for next channel digit. */
#define CHANNEL_DELAY 100
-typedef struct freqinfo_s freqinfo_t;
-struct freqinfo_s {
- int enabled;
-};
-
-freqinfo_t freq_info[ NUM_FREQ_TABLES * CHAN_ENTRIES ];
-static freqinfo_t *get_freq_info( int table, int channel ) { return &(freq_info[ (table * CHAN_ENTRIES) + channel ]); }
struct commands_s {
config_t *cfg;
@@ -73,192 +66,6 @@ struct commands_s {
int capturemode;
};
-/**
- * Tuner settings.
- */
-static int cur_channel = 0;
-static int prev_channel = 0;
-static int cur_freq_table = 1;
-static int ntsc_cable_mode = NTSC_CABLE_MODE_NOMINAL;
-static int finetune_amount = 0;
-static void toggle_ntsc_cable_mode( void ) { ntsc_cable_mode = ( ntsc_cable_mode + 1 ) % 3; }
-
-static int get_current_frequency( void )
-{
- int base = tvtuner[ cur_channel ].freq[ cur_freq_table ];
-
- if( !base ) {
- return 0;
- }
-
- if( cur_freq_table == NTSC_CABLE ) {
- if( ntsc_cable_mode == NTSC_CABLE_MODE_IRC ) {
- base = NTSC_CABLE_IRC( base );
- } else if( ntsc_cable_mode == NTSC_CABLE_MODE_HRC ) {
- base = NTSC_CABLE_HRC( base );
- }
- }
-
- return base + finetune_amount;
-}
-
-static int frequencies_find_current_index( videoinput_t *vidin )
-{
- int tunerfreq = videoinput_get_tuner_freq( vidin );
- int closest = -1;
- int closesti = 0;
- int i;
-
- if( tunerfreq == 0 ) {
- /* Probably no tuner present */
- return 0;
- }
-
- for( i = 0; i < CHAN_ENTRIES; i++ ) {
- int curfreq = tvtuner[ i ].freq[ cur_freq_table ];
-
- if( curfreq && ((closest < 0) || (abs( curfreq - tunerfreq ) < abs( closest - tunerfreq ))) ) {
- closest = curfreq;
- closesti = i;
- }
- }
- cur_channel = closesti;
-
- return 1;
-}
-
-static void frequencies_choose_first_frequency( void )
-{
- int i;
- cur_channel = 0;
-
- for( i = 0; i < CHAN_ENTRIES; i++ ) {
- if( tvtuner[ i ].freq[ cur_freq_table ] ) {
- cur_channel = i;
- break;
- }
- }
-}
-
-static int frequencies_find_named_channel( const char *str )
-{
- int i;
- const char *instr;
-
- if( !str ) return 0;
-
- while( *str == '0' ) {
- str++;
- }
- instr = str;
- if( !(*str) ) {
- instr = "0";
- }
-
- for( i = 0; i < CHAN_ENTRIES; i++ ) {
- const char *curstr = tvtuner[ i ].name;
- while( *curstr == ' ' ) curstr++;
-
- if( !strcasecmp( curstr, instr ) ) {
- cur_channel = i;
- return 1;
- }
- }
-
- return 0;
-}
-
-void frequencies_set_tuner_by_name( const char *tuner_name )
-{
- int i;
- for( i = 0; i < NUM_FREQ_TABLES; i++ ) {
- if( !strcasecmp( freq_table_names[ i ].short_name, tuner_name ) ||
- !strcasecmp( freq_table_names[ i ].long_name, tuner_name ) ) {
- cur_freq_table = i;
- return;
- }
- }
-
- /* Default to NTSC_CABLE. */
- cur_freq_table = NTSC_CABLE;
-}
-
-void frequencies_list_disabled_freqs( void )
-{
- int i;
-
- for( i = 0; i < CHAN_ENTRIES; i++ ) {
- if( tvtuner[ i ].freq[ cur_freq_table ] && !(get_freq_info( cur_freq_table, i )->enabled) ) {
- fprintf( stderr, "channel = %s %s 0\n", freq_table_names[ cur_freq_table ].short_name, tvtuner[ i ].name );
- }
- }
-}
-
-void frequencies_disable_all( void )
-{
- int i;
-
- for( i = 0; i < CHAN_ENTRIES; i++ ) {
- if( tvtuner[ i ].freq[ cur_freq_table ] ) {
- get_freq_info( cur_freq_table, i )->enabled = 0;
- }
- }
-}
-
-void frequencies_disable_freqs( config_t *ct )
-{
- const char *instr;
- const char *tmp;
- char *acopy = NULL, *str;
- parser_file_t *pf = config_get_parsed_file( ct );
- int i=1, j=0, k=0;
- char table_name[255], chan_name[6];
- int enabled, ret, the_freq_table=-1, the_channel=-1;
-
- for(;;) {
- tmp = parser_get( pf, "channel", i++ );
- if( !tmp ) break;
- if( acopy ) free( acopy );
- acopy = strdup( tmp );
-
- ret = sscanf( acopy, " %254s %5s %d ", table_name, chan_name, &enabled );
- if( ret != 3 ) {
- fprintf( stderr, "Ignoring: ret = %d, channel = %s\n", ret, acopy);
- continue;
- }
-
- the_freq_table = -1;
- for( j = 0; j < NUM_FREQ_TABLES; j++ ) {
- if( !strcasecmp( freq_table_names[ j ].short_name, table_name ) ) {
- the_freq_table = j;
- break;
- }
- }
-
- str = chan_name;
-
- while( *str == '0' ) {
- str++;
- }
- instr = str;
- if( !(*str) ) {
- instr = "0";
- }
-
- the_channel = -1;
- for( k = 0; k < CHAN_ENTRIES; k++ ) {
- const char *curstr = tvtuner[ k ].name;
- while( *curstr == ' ' ) curstr++;
-
- if( !strcasecmp( curstr, instr ) ) {
- the_channel = k;
- }
- }
-
- if( the_channel > -1 && the_freq_table > -1 )
- get_freq_info( the_freq_table, the_channel )->enabled = enabled;
- }
-}
static void reinit_tuner( commands_t *in )
{
@@ -268,31 +75,27 @@ static void reinit_tuner( commands_t *in )
* Set to the current channel, or the first channel in our
* frequency list.
*/
- if( !frequencies_find_current_index( in->vidin ) ) {
+ //if( !frequencies_find_current_index( in->vidin ) ) {
/* set to a known frequency */
- frequencies_choose_first_frequency();
- videoinput_set_tuner_freq( in->vidin, get_current_frequency() );
- if( in->vbi ) {
- vbidata_reset( in->vbi );
- vbidata_capture_mode( in->vbi, in->capturemode );
- }
+ //frequencies_choose_first_frequency();
+
+ station_info_t *i= station_getInfo();
+
+
+ videoinput_set_tuner_freq( in->vidin, i->freq );
+ if( in->vbi ) {
+ vbidata_reset( in->vbi );
+ vbidata_capture_mode( in->vbi, in->capturemode );
}
+ //}
if( config_get_verbose( in->cfg ) ) {
- fprintf( stderr, "tvtime: Changing to channel %s.\n",
- tvtuner[ cur_channel ].name );
+ fprintf( stderr, "tvtime: Changing to channel %s.\n", i->name );
}
if( in->osd ) {
- if( cur_freq_table == NTSC_CABLE && ntsc_cable_mode != NTSC_CABLE_MODE_NOMINAL ) {
- char tablename[ 200 ];
- sprintf( tablename, "%s [%s]", freq_table_names[ cur_freq_table ].long_name,
- ntsc_cable_mode == NTSC_CABLE_MODE_IRC ? "IRC" : "HRC" );
- tvtime_osd_set_freq_table( in->osd, tablename );
- } else {
- tvtime_osd_set_freq_table( in->osd, freq_table_names[ cur_freq_table ].long_name );
- }
- tvtime_osd_set_channel_number( in->osd, tvtuner[ cur_channel ].name );
+ tvtime_osd_set_freq_table( in->osd, i->band );
+ tvtime_osd_set_channel_number( in->osd, i->name );
tvtime_osd_show_info( in->osd );
}
} else if( in->osd ) {
@@ -306,7 +109,6 @@ commands_t *commands_new( config_t *cfg, videoinput_t *vidin,
tvtime_osd_t *osd, video_correction_t *vc )
{
commands_t *in = (commands_t *) malloc( sizeof( struct commands_s ) );
- int i;
if( !in ) {
return NULL;
@@ -340,17 +142,9 @@ commands_t *commands_new( config_t *cfg, videoinput_t *vidin,
/**
* Set the current channel list.
*/
- frequencies_set_tuner_by_name( config_get_v4l_freq( in->cfg ) );
- finetune_amount = config_get_finetune( in->cfg );
reinit_tuner( in );
- for( i = 0; i < NUM_FREQ_TABLES * CHAN_ENTRIES; i++ ) {
- freq_info[ i ].enabled = 1;
- }
-
- frequencies_disable_freqs( cfg );
-
return in;
}
@@ -365,7 +159,7 @@ void commands_set_vbidata( commands_t *in, vbidata_t *vbi )
}
-static void commands_channel_change_relative( commands_t *in, int offset )
+static void commands_station_change( commands_t *in )
{
int verbose = config_get_verbose( in->cfg );
@@ -374,16 +168,9 @@ static void commands_channel_change_relative( commands_t *in, int offset )
fprintf( stderr, "tvtime: Can't change channel, "
"no tuner available on this input!\n" );
} else {
- prev_channel = cur_channel;
- for(;;) {
- cur_channel = (cur_channel + offset + CHAN_ENTRIES) % CHAN_ENTRIES;
- if( tvtuner[ cur_channel ].freq[ cur_freq_table ] && get_freq_info( cur_freq_table, cur_channel )->enabled ) {
- break;
- }
- }
-
-
- videoinput_set_tuner_freq( in->vidin, get_current_frequency() );
+ station_info_t *i= station_getInfo();
+
+ videoinput_set_tuner_freq( in->vidin, i->freq );
if( in->vbi ) {
vbidata_reset( in->vbi );
vbidata_capture_mode( in->vbi, in->capturemode );
@@ -391,10 +178,12 @@ static void commands_channel_change_relative( commands_t *in, int offset )
if( verbose ) {
fprintf( stderr, "tvtime: Changing to channel %s\n",
- tvtuner[ cur_channel ].name );
+ i->name );
}
if( in->osd ) {
- tvtime_osd_set_channel_number( in->osd, tvtuner[ cur_channel ].name );
+ //tvtime_osd_set_station_name( in->osd, i->name );
+ tvtime_osd_set_channel_number( in->osd, i->name );
+ tvtime_osd_set_freq_table( in->osd, i->band );
tvtime_osd_show_info( in->osd );
}
}
@@ -454,12 +243,8 @@ void commands_handle( commands_t *in, int tvtime_cmd, int arg )
break;
case TVTIME_SKIP_CHANNEL:
- get_freq_info( cur_freq_table, cur_channel )->enabled = !(get_freq_info( cur_freq_table, cur_channel )->enabled);
- fprintf( stderr, "channel = %s %s %d\n",
- freq_table_names[ cur_freq_table ].short_name,
- tvtuner[ cur_channel ].name,
- get_freq_info( cur_freq_table, cur_channel )->enabled );
- break;
+ // to be removed
+ break;
case TVTIME_ASPECT:
in->toggleaspect = 1;
@@ -540,22 +325,15 @@ void commands_handle( commands_t *in, int tvtime_cmd, int arg )
case TVTIME_FREQLIST_DOWN:
case TVTIME_FREQLIST_UP:
- if( videoinput_has_tuner( in->vidin ) ) {
- cur_freq_table = ( cur_freq_table + ( tvtime_cmd == TVTIME_FREQLIST_UP ? 1 : -1 ) + NUM_FREQ_TABLES ) % NUM_FREQ_TABLES;
- reinit_tuner( in );
- }
- break;
+ break;
case TVTIME_AUTO_ADJUST_PICT:
videoinput_reset_default_settings( in->vidin );
break;
case TVTIME_TOGGLE_NTSC_CABLE_MODE:
- if( videoinput_has_tuner( in->vidin ) ) {
- toggle_ntsc_cable_mode();
- reinit_tuner( in );
- }
- break;
+ //to be removed
+ break;
case TVTIME_FINETUNE_DOWN:
case TVTIME_FINETUNE_UP:
@@ -580,13 +358,17 @@ void commands_handle( commands_t *in, int tvtime_cmd, int arg )
break;
case TVTIME_CHANNEL_UP:
+ station_prev();
+ commands_station_change(in);
+ break;
case TVTIME_CHANNEL_DOWN:
- commands_channel_change_relative( in, (tvtime_cmd == TVTIME_CHANNEL_UP) ? 1 : -1 );
+ station_next();
+ commands_station_change(in);
break;
case TVTIME_CHANNEL_PREV:
- commands_channel_change_relative( in, prev_channel ? (prev_channel - cur_channel) : 0 );
- break;
+ // to be handled otherwise
+ break;
case TVTIME_MIXER_UP:
case TVTIME_MIXER_DOWN:
@@ -655,43 +437,9 @@ void commands_handle( commands_t *in, int tvtime_cmd, int arg )
break;
case TVTIME_ENTER:
- if( in->frame_counter ) {
- if( *in->next_chan_buffer ) {
- prev_channel = cur_channel;
- /* this sets the current channel accordingly */
- if( frequencies_find_named_channel( in->next_chan_buffer ) ) {
- /* go to the next valid channel instead */
- for(;;) {
- if( tvtuner[ cur_channel ].freq[ cur_freq_table ] ) break;
- cur_channel = (cur_channel + 1 + CHAN_ENTRIES) % CHAN_ENTRIES;
- }
- videoinput_set_tuner_freq( in->vidin, get_current_frequency() );
- if( in->vbi ) {
- vbidata_reset( in->vbi );
- vbidata_capture_mode( in->vbi, in->capturemode );
- }
-
-
- if( verbose ) {
- fprintf( stderr, "tvtime: Changing to channel %s\n",
- tvtuner[ cur_channel ].name );
- }
-
- if( in->osd ) {
- tvtime_osd_set_channel_number( in->osd, tvtuner[ cur_channel ].name );
- tvtime_osd_show_info( in->osd );
- }
- in->frame_counter = 0;
- } else {
- /* No valid channel found. */
- if( in->osd ) {
- tvtime_osd_set_channel_number( in->osd, tvtuner[ cur_channel ].name );
- tvtime_osd_show_info( in->osd );
- }
- in->frame_counter = 0;
- }
- }
- }
+ //if ( station_byName( *in->next_chan_buffer ) )
+ // commands_station_change(in);
+ break;
}
}
@@ -749,7 +497,7 @@ void commands_next_frame( commands_t *in )
if( in->frame_counter == 0 ) {
memset( in->next_chan_buffer, 0, 5 );
in->digit_counter = 0;
- tvtime_osd_set_channel_number( in->osd, tvtuner[ cur_channel ].name );
+ tvtime_osd_set_channel_number( in->osd, station_getInfo()->channel );
}
if( in->frame_counter > 0 && !(in->frame_counter % 5)) {
diff --git a/src/freq.c b/src/freq.c
new file mode 100644
index 0000000..135b1a2
--- /dev/null
+++ b/src/freq.c
@@ -0,0 +1,96 @@
+/**
+ * Copyright (c) 2003 Achim Schneider <batchall@mordor.ch>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <string.h>
+#include "freq.h"
+#include "bands.h"
+
+
+
+band_t *getBand( char *band ) {
+ band_t *rp;
+
+ for ( rp= (band_t *)bands; rp < &bands[numbands]; ++rp )
+ if ( !strcasecmp( rp->name, band ) )
+ return rp;
+
+ return NULL;
+}
+
+int freq_byName( char **band, char **channel, int us_cable) {
+ band_t *b;
+ band_entry_t *rp;
+
+ if ( NULL == ( b= getBand(*band) ) )
+ return 0;
+ for ( rp= (band_entry_t *)b->channels; rp < &(b->channels[b->count]); ++rp ) {
+ if ( !strcasecmp( rp->name, *channel ) ) {
+ if ( us_cable != US_CABLE_NOMINAL && !strcmp( b->name, "US Cable") ) {
+ return us_cable == US_CABLE_HRC
+ ? NTSC_CABLE_HRC(rp->freq)
+ : NTSC_CABLE_IRC(rp->freq);
+ }
+ *band= (char *)b->name;
+ *channel= (char *)rp->name;
+ return rp->freq;
+ }
+ }
+
+ return 1;
+}
+
+
+int freq_byPos( char *band, int channel ) {
+ band_t *b;
+
+ if ( NULL == ( b= getBand(band) ) )
+ return 0;
+
+ if ( b->count >= channel || channel < 0 )
+ return 0;
+
+ return b->channels[channel].freq;
+}
+
+
+int freq_for_band(char *band, int us_cable, freq_callback_t f) {
+ band_t *b;
+ band_entry_t *rp;
+ if ( NULL == ( b= getBand(band) ) )
+ return 0;
+
+ for ( rp= (band_entry_t *)b->channels; rp < &b->channels[b->count]; ++rp ) {
+ int freq= rp->freq;
+ if ( us_cable != US_CABLE_NOMINAL && !strcmp( b->name, "US Cable") ) {
+ freq= us_cable == US_CABLE_HRC
+ ? NTSC_CABLE_HRC(rp->freq)
+ : NTSC_CABLE_IRC(rp->freq);
+ }
+
+ (*f) ((char *)b->name, (char *)rp->name, freq);
+ }
+
+ return 1;
+}
+//char *freq_getBands() {
+// return band_names;
+//}
+
+
+
+
diff --git a/src/freq.h b/src/freq.h
new file mode 100644
index 0000000..bf5c435
--- /dev/null
+++ b/src/freq.h
@@ -0,0 +1,31 @@
+/**
+ * Copyright (c) 2003 Achim Schneider <batchall@mordor.ch>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+int freq_byName(char** band, char **channel, int us_cable);
+int freq_byPos(char* band, int channel);
+
+typedef void (*freq_callback_t) (char *band, char *channel, unsigned int freq);
+int freq_for_band(char *band, int us_cable, freq_callback_t f);
+
+
+// tab-seperated
+//char *freq_getBands();
+
+#define US_CABLE_NOMINAL 0
+#define US_CABLE_HRC 1
+#define US_CABLE_IRC 2
diff --git a/src/station.c b/src/station.c
new file mode 100644
index 0000000..e4cf585
--- /dev/null
+++ b/src/station.c
@@ -0,0 +1,236 @@
+/**
+ * Copyright (c) 2003 Achim Schneider <batchall@mordor.ch>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "station.h"
+#include "freq.h"
+
+typedef struct node {
+ struct node *next, *prev;
+ station_info_t *info;
+} node_t;
+
+typedef node_t *node;
+
+
+node first= NULL;
+node current= NULL;
+
+int debug= 0;
+int verbose= 0;
+
+node newNode(node next, node prev, station_info_t *info) {
+ node_t *n;
+ if ( NULL != ( n= malloc(sizeof *n) ) ) {
+ n->next= next;
+ n->prev= prev;
+ n->info= info;
+ return n;
+ }
+ return 0;
+}
+
+station_info_t *newInfo( int pos, char *name, char *band, char *channel, int freq) {
+ station_info_t *i;
+
+ if ( NULL != ( i= malloc(sizeof *i) ) ) {
+ i->pos= pos;
+ i->band= band;
+ i->channel= channel;
+ i->freq= freq;
+ strncpy(i->name, name, 32);
+ i->name[31]= '\0';
+ return i;
+ }
+ return 0;
+}
+
+
+int insert(station_info_t *i) {
+ if ( NULL == first ) {
+ if (( first= newNode(NULL,NULL,i) )) {
+ first->next= first;
+ first->prev= first;
+ return 1;
+ }
+ return 0;
+ } else {
+ node n;
+ node rp= first;
+ do {
+ if ( rp->info->pos == i->pos ) {
+ fprintf(stderr, "station: Position %d already in use\n", i->pos);
+ return 0;
+ }
+
+ if ( rp->info->pos > i->pos ) break;
+
+ } while ( ( rp= rp->next) != first );
+
+ if (( n= newNode( rp, rp->prev, i ) )) {
+ rp->prev->next= n;
+ rp->prev= n;
+
+ if ( rp == first )
+ if ( n->info->pos < first->info->pos )
+ first= n;
+ return 1;
+ }
+ fprintf(stderr, "station: Out of Memory\n");
+ return 0;
+ }
+}
+
+void station_dump() {
+ node rp= first;
+ printf("#\tBand\tChannel\tFreq\tName\n" );
+ do {
+ printf("%d\t%s\t%s\t%d\t%s\n",rp->info->pos, rp->info->band,
+ rp->info->channel, rp->info->freq, rp->info->name);
+ } while ( ( rp= rp->next) != first );
+}
+
+
+
+int station_init(config_t *ct) {
+ debug= config_get_debug(ct);
+ verbose= config_get_verbose(ct);
+
+ // this is a config file parser
+ station_add( 1, "vhf E2-E12", "e4", "ard" );
+ station_add( 2, "VHF E2-E12", "E8", "zdf" );
+ station_add( 3, "VHF E2-E12", "E6", "ndr" );
+
+ station_add_band("US Cable",US_CABLE_HRC);
+
+ if ( NULL == first ) {
+ insert(newInfo( 1, "dummy", "none", "none", 0 ));
+ }
+ current=first;
+ if ( verbose ) {
+ station_dump();
+ }
+ return 1;
+}
+
+
+int station_set(int pos) {
+ node rp= first;
+ do {
+ if ( rp->info->pos == pos ) {
+ current= rp;
+ return 1;
+ }
+ } while ( (rp= rp->next) != first );
+ return 0;
+}
+
+void station_next() {
+ current= current->next;
+}
+
+void station_prev() {
+ current=current->prev;
+}
+
+
+
+
+station_info_t *station_getInfo() {
+ return current->info;
+}
+
+
+
+int station_adds(char *pos, char *band, char *channel, char *name);
+int station_add(int pos, char* band, char *channel, char *name) {
+ int freq;
+ station_info_t *i;
+
+ if ( 0 == ( freq= freq_byName(&band,&channel,US_CABLE_NOMINAL) ) ) {
+ fprintf(stderr, "station: No frequency known for %s %s\n", band, channel);
+ return 0;
+ }
+
+ if ( 0 == ( i= newInfo( pos, name, band, channel, freq ) ) ) {
+ fprintf(stderr, "station: Out of Memory");
+ return 0;
+ }
+
+
+ if ( insert(i) )
+ return 1;
+
+ free(i);
+ return 0;
+}
+
+int isFreePos( int pos ) {
+ node rp= first;
+ do {
+ if ( pos == rp->info->pos ) return 0;
+ } while ( ( rp= rp->next) != first );
+ return 1;
+}
+
+int getNextPos() {
+ return first->prev->info->pos + 1;
+}
+
+
+void freq_callback( char *band, char *channel, unsigned int freq ) {
+ int pos;
+ station_info_t *i;
+
+
+ if ( 1 == sscanf(channel,"%d", &pos) ) {
+ if ( !isFreePos(pos) )
+ pos= getNextPos();
+ } else
+ pos= getNextPos();
+
+ if ( 0 == ( i= newInfo( pos, channel, band, channel, freq ) ) ) {
+ fprintf(stderr, "station: Out of Memory");
+ return;
+ }
+
+
+ if ( insert(i) )
+ return;
+
+ free(i);
+ return;
+
+
+}
+
+
+int station_add_band( char* band, int us_cable ) {
+ freq_for_band( band, us_cable, freq_callback );
+ return 1;
+}
+
+int station_scan(int band) {
+ return 0;
+}
+
+int station_writeConfig(FILE config) {
+ return 0;
+}
diff --git a/src/station.h b/src/station.h
new file mode 100644
index 0000000..95d78db
--- /dev/null
+++ b/src/station.h
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2003 Achim Schneider <batchall@mordor.ch>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef STATION_H_INCLUDED
+#define STATION_H_INCLUDED
+
+
+#include "tvtimeconf.h"
+
+
+typedef struct station_info {
+ int pos;
+ char name[32];
+ char *band;
+ char *channel;
+ int freq;
+} station_info_t;
+
+
+int station_init(config_t *ct);
+
+int station_set(int pos);
+
+
+
+void station_next();
+void station_prev();
+int station_hasChanged();
+
+station_info_t *station_getInfo();
+
+
+
+int station_adds(char *pos, char *band, char *channel, char *name);
+int station_add(int pos, char* band, char *channel, char* name);
+
+int station_add_band( char *band, int us_cable );
+
+int station_scan(int band);
+
+int station_writeConfig(FILE config);
+
+#endif // STATION_H_INCLUDED
diff --git a/src/tvscanner.c b/src/tvscanner.c
index 5bb5e87..7b92707 100644
--- a/src/tvscanner.c
+++ b/src/tvscanner.c
@@ -19,14 +19,14 @@
fprintf(conf,"[%s]\nchannel = %s\n\n",name,chanlist[i].name);
fflush(conf);
}
-*/
+
#include <stdio.h>
#include "bands.h"
#include "videoinput.h"
-
+*/
int main( int argc, char **argv )
-{
+{/*
videoinput_t *vidin = 0;
int i;
@@ -41,7 +41,9 @@ int main( int argc, char **argv )
int tuner_state;
tuner_state = videoinput_check_for_signal( vidin, 1 );
}
-
+*/
return 0;
}
+
+// I'll do that in station.c
diff --git a/src/tvtime.c b/src/tvtime.c
index 1a057de..d0460ac 100644
--- a/src/tvtime.c
+++ b/src/tvtime.c
@@ -50,6 +50,7 @@
#include "vbiscreen.h"
#include "fifo.h"
#include "commands.h"
+#include "station.h"
/**
* This is ridiculous, but apparently I need to give my own
@@ -507,6 +508,7 @@ int main( int argc, char **argv )
double_plugin_init();
linearblend_plugin_init();
scalerbob_plugin_init();
+
ct = config_new( argc, argv );
if( !ct ) {
@@ -515,6 +517,9 @@ int main( int argc, char **argv )
}
verbose = config_get_verbose( ct );
+ station_init(ct);
+
+
if( !strcasecmp( config_get_v4l_norm( ct ), "pal" ) ) {
norm = VIDEOINPUT_PAL;
} else if( !strcasecmp( config_get_v4l_norm( ct ), "secam" ) ) {

Privacy Policy