comparison libmpdemux/tv.c @ 2941:60c1b7c0ea21

added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
author alex
date Sat, 17 Nov 2001 00:23:48 +0000
parents 4307478ad922
children 49a0d462dffe
comparison
equal deleted inserted replaced
2940:1902b7ff9cdc 2941:60c1b7c0ea21
27 #include "../libvo/img_format.h" 27 #include "../libvo/img_format.h"
28 #include "../libvo/fastmemcpy.h" 28 #include "../libvo/fastmemcpy.h"
29 29
30 #include "tv.h" 30 #include "tv.h"
31 31
32 #include "frequencies.h"
33
32 /* some default values */ 34 /* some default values */
33 char *tv_param_freq = NULL; 35 char *tv_param_freq = NULL;
34 char *tv_param_channel = "26"; /* hungarian national tv channel 1 */ 36 char *tv_param_channel = "26"; /* hungarian national tv channel 1 */
35 char *tv_param_norm = "pal"; 37 char *tv_param_norm = "pal";
38 char *tv_param_chanlist = "europe-east";
36 char *tv_param_device = NULL; 39 char *tv_param_device = NULL;
37 char *tv_param_driver = "dummy"; 40 char *tv_param_driver = "dummy";
38 int tv_param_width = -1; 41 int tv_param_width = -1;
39 int tv_param_height = -1; 42 int tv_param_height = -1;
40 int tv_param_input = 0; /* used in v4l and bttv */ 43 int tv_param_input = 0; /* used in v4l and bttv */
90 return 1; 93 return 1;
91 } 94 }
92 95
93 int stream_open_tv(stream_t *stream, tvi_handle_t *tvh) 96 int stream_open_tv(stream_t *stream, tvi_handle_t *tvh)
94 { 97 {
98 int i;
95 tvi_functions_t *funcs = tvh->functions; 99 tvi_functions_t *funcs = tvh->functions;
96 int picture_format = 0; 100 int picture_format = 0;
97 101
98 if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE) 102 if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE)
99 { 103 {
157 funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq); 161 funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
158 162
159 funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq); 163 funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
160 mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n", 164 mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n",
161 freq, (float)freq/16); 165 freq, (float)freq/16);
166 }
167
168 /* select video norm */
169 if (!strcasecmp(tv_param_norm, "pal"))
170 tvh->norm = TV_NORM_PAL;
171 else if (!strcasecmp(tv_param_norm, "ntsc"))
172 tvh->norm = TV_NORM_NTSC;
173 else if (!strcasecmp(tv_param_norm, "secam"))
174 tvh->norm = TV_NORM_SECAM;
175
176 mp_msg(MSGT_TV, MSGL_INFO, "Selected norm: %s\n", tv_param_norm);
177
178 /* select channel list */
179 for (i = 0; chanlists[i].name != NULL; i++)
180 {
181 if (!strcasecmp(chanlists[i].name, tv_param_chanlist))
182 {
183 tvh->chanlist = i;
184 tvh->chanlist_s = chanlists[i].list;
185 break;
186 }
187 }
188
189 if (tvh->chanlist == -1)
190 mp_msg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n",
191 tv_param_chanlist);
192
193 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel list: %s (including %d channels)\n",
194 chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count);
195
196 if (tv_param_freq && tv_param_channel)
197 mp_msg(MSGT_TV, MSGL_HINT, "You can't set frequency and channel simultanly!\n");
198
199 if (!tv_param_freq && tv_param_channel)
200 {
201 struct CHANLIST cl;
202 for (i = 0; i < chanlists[tvh->chanlist].count; i++)
203 {
204 cl = tvh->chanlist_s[i];
205 // printf("count%d: name: %s, freq: %d\n",
206 // i, cl.name, cl.freq);
207 if (!strcasecmp(cl.name, tv_param_channel))
208 {
209 tvh->channel = i;
210 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
211 cl.name, (float)cl.freq/1000);
212 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
213 break;
214 }
215 }
162 } 216 }
163 217
164 /* also start device! */ 218 /* also start device! */
165 return(funcs->start(tvh->priv)); 219 return(funcs->start(tvh->priv));
166 } 220 }
364 mp_msg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt); 418 mp_msg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt);
365 } 419 }
366 420
367 return(1); 421 return(1);
368 } 422 }
423
424 int tv_set_freq(tvi_handle_t *tvh, unsigned long freq)
425 {
426 if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)
427 {
428 // unsigned long freq = atof(tv_param_freq)*16;
429
430 /* set freq in MHz */
431 tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq);
432
433 tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq);
434 mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n",
435 freq, (float)freq/16);
436 }
437 }
438
439 int tv_step_channel(tvi_handle_t *tvh, int direction)
440 {
441 struct CHANLIST cl;
442
443 if (direction == TV_CHANNEL_LOWER)
444 {
445 if (tvh->channel-1 >= 0)
446 {
447 cl = tvh->chanlist_s[tvh->channel--];
448 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
449 cl.name, (float)cl.freq/1000);
450 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
451 }
452 }
453
454 if (direction == TV_CHANNEL_HIGHER)
455 {
456 if (tvh->channel+1 <= chanlists[tvh->chanlist].count)
457 {
458 cl = tvh->chanlist_s[tvh->channel++];
459 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n",
460 cl.name, (float)cl.freq/1000);
461 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16));
462 }
463 }
464 }
465
466 int tv_step_norm(tvi_handle_t *tvh)
467 {
468 }
469
470 int tv_step_chanlist(tvi_handle_t *tvh)
471 {
472 }
369 #endif /* USE_TV */ 473 #endif /* USE_TV */