Mercurial > mplayer.hg
comparison libmpdemux/tv.c @ 3284:702e399a4b3e
update (audio support is coming:)
author | alex |
---|---|
date | Mon, 03 Dec 2001 16:38:40 +0000 |
parents | 49a0d462dffe |
children | bd7bff4cb453 |
comparison
equal
deleted
inserted
replaced
3283:73de2c85844d | 3284:702e399a4b3e |
---|---|
1 /* | 1 /* |
2 TV subsystem for libMPDemux by Alex | 2 TV Interface for MPlayer |
3 | 3 |
4 API idea based on libvo2's | 4 (C) Alex Beregszaszi <alex@naxine.org> |
5 | |
6 API idea based on libvo2 | |
5 | 7 |
6 UNDER HEAVY DEVELOPEMENT, NO FEATURE REQUESTS PLEASE! :) | 8 UNDER HEAVY DEVELOPEMENT, NO FEATURE REQUESTS PLEASE! :) |
7 */ | 9 */ |
8 | 10 |
9 #include <stdio.h> | 11 #include <stdio.h> |
31 | 33 |
32 #include "frequencies.h" | 34 #include "frequencies.h" |
33 | 35 |
34 /* some default values */ | 36 /* some default values */ |
35 char *tv_param_freq = NULL; | 37 char *tv_param_freq = NULL; |
36 char *tv_param_channel = "26"; /* hungarian national tv channel 1 */ | 38 char *tv_param_channel = NULL; |
37 char *tv_param_norm = "pal"; | 39 char *tv_param_norm = "pal"; |
38 char *tv_param_chanlist = "europe-east"; | 40 char *tv_param_chanlist = "europe-east"; |
39 char *tv_param_device = NULL; | 41 char *tv_param_device = NULL; |
40 char *tv_param_driver = "dummy"; | 42 char *tv_param_driver = "dummy"; |
41 int tv_param_width = -1; | 43 int tv_param_width = -1; |
150 } | 152 } |
151 | 153 |
152 /* set some params got from cmdline */ | 154 /* set some params got from cmdline */ |
153 funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input); | 155 funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input); |
154 | 156 |
155 /* we need to set frequency */ | |
156 if (tv_param_freq && (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE)) | |
157 { | |
158 unsigned long freq = atof(tv_param_freq)*16; | |
159 | |
160 /* set freq in MHz */ | |
161 funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq); | |
162 | |
163 funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq); | |
164 mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n", | |
165 freq, (float)freq/16); | |
166 } | |
167 | |
168 /* select video norm */ | 157 /* select video norm */ |
169 if (!strcasecmp(tv_param_norm, "pal")) | 158 if (!strcasecmp(tv_param_norm, "pal")) |
170 tvh->norm = TV_NORM_PAL; | 159 tvh->norm = TV_NORM_PAL; |
171 else if (!strcasecmp(tv_param_norm, "ntsc")) | 160 else if (!strcasecmp(tv_param_norm, "ntsc")) |
172 tvh->norm = TV_NORM_NTSC; | 161 tvh->norm = TV_NORM_NTSC; |
173 else if (!strcasecmp(tv_param_norm, "secam")) | 162 else if (!strcasecmp(tv_param_norm, "secam")) |
174 tvh->norm = TV_NORM_SECAM; | 163 tvh->norm = TV_NORM_SECAM; |
175 | 164 |
176 mp_msg(MSGT_TV, MSGL_INFO, "Selected norm: %s\n", tv_param_norm); | 165 mp_msg(MSGT_TV, MSGL_INFO, "Selected norm: %s\n", tv_param_norm); |
177 | 166 |
167 if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE) | |
168 { | |
169 mp_msg(MSGT_TV, MSGL_WARN, "Selected input hasn't got a tuner!\n"); | |
170 goto start_device; | |
171 } | |
172 | |
178 /* select channel list */ | 173 /* select channel list */ |
179 for (i = 0; chanlists[i].name != NULL; i++) | 174 for (i = 0; chanlists[i].name != NULL; i++) |
180 { | 175 { |
181 if (!strcasecmp(chanlists[i].name, tv_param_chanlist)) | 176 if (!strcasecmp(chanlists[i].name, tv_param_chanlist)) |
182 { | 177 { |
187 } | 182 } |
188 | 183 |
189 if (tvh->chanlist == -1) | 184 if (tvh->chanlist == -1) |
190 mp_msg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n", | 185 mp_msg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n", |
191 tv_param_chanlist); | 186 tv_param_chanlist); |
192 | 187 else |
193 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel list: %s (including %d channels)\n", | 188 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel list: %s (including %d channels)\n", |
194 chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count); | 189 chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count); |
195 | 190 |
196 if (tv_param_freq && tv_param_channel) | 191 if (tv_param_freq && tv_param_channel) |
197 mp_msg(MSGT_TV, MSGL_HINT, "You can't set frequency and channel simultanly!\n"); | 192 { |
198 | 193 mp_msg(MSGT_TV, MSGL_WARN, "You can't set frequency and channel simultanly!\n"); |
199 if (!tv_param_freq && tv_param_channel) | 194 goto start_device; |
195 } | |
196 | |
197 /* we need to set frequency */ | |
198 if (tv_param_freq) | |
199 { | |
200 unsigned long freq = atof(tv_param_freq)*16; | |
201 | |
202 /* set freq in MHz */ | |
203 funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq); | |
204 | |
205 funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq); | |
206 mp_msg(MSGT_TV, MSGL_INFO, "Selected frequency: %lu (%.3f)\n", | |
207 freq, (float)freq/16); | |
208 } | |
209 | |
210 if (tv_param_channel) | |
200 { | 211 { |
201 struct CHANLIST cl; | 212 struct CHANLIST cl; |
213 | |
214 mp_msg(MSGT_TV, MSGL_V, "Requested channel: %s\n", tv_param_channel); | |
202 for (i = 0; i < chanlists[tvh->chanlist].count; i++) | 215 for (i = 0; i < chanlists[tvh->chanlist].count; i++) |
203 { | 216 { |
204 cl = tvh->chanlist_s[i]; | 217 cl = tvh->chanlist_s[i]; |
205 // printf("count%d: name: %s, freq: %d\n", | 218 // printf("count%d: name: %s, freq: %d\n", |
206 // i, cl.name, cl.freq); | 219 // i, cl.name, cl.freq); |
212 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); | 225 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); |
213 break; | 226 break; |
214 } | 227 } |
215 } | 228 } |
216 } | 229 } |
217 | 230 |
231 start_device: | |
218 /* also start device! */ | 232 /* also start device! */ |
219 return(funcs->start(tvh->priv)); | 233 return(funcs->start(tvh->priv)); |
220 } | 234 } |
221 | 235 |
222 int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh) | 236 int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh) |