Mercurial > mplayer.hg
annotate libmpdemux/tv.c @ 5360:40f87aaaa2f3
ported back hack for interlaced mpeg2, without it mplayer draws whole frame for every field -100% slowdown
author | iive |
---|---|
date | Tue, 26 Mar 2002 17:05:09 +0000 |
parents | 1d54c3a27093 |
children | 8cd761968f35 |
rev | line source |
---|---|
2790 | 1 /* |
3284 | 2 TV Interface for MPlayer |
2790 | 3 |
3284 | 4 (C) Alex Beregszaszi <alex@naxine.org> |
5 | |
6 API idea based on libvo2 | |
2790 | 7 |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
8 Feb 19, 2002: Significant rewrites by Charles R. Henrich (henrich@msu.edu) |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
9 try to fix audio support, and bktr *BSD support. |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
10 |
2790 | 11 */ |
12 | |
13 #include <stdio.h> | |
14 #include <stdlib.h> | |
15 #include <unistd.h> | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
16 #include <string.h> |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
17 #include <sys/time.h> |
2790 | 18 |
19 #include "config.h" | |
20 | |
2819
2e58962dc9fe
cleaned up some warnings, and tv_param_on moved out from #ifdef USE_TV
alex
parents:
2818
diff
changeset
|
21 int tv_param_on = 0; |
2e58962dc9fe
cleaned up some warnings, and tv_param_on moved out from #ifdef USE_TV
alex
parents:
2818
diff
changeset
|
22 |
2790 | 23 #ifdef USE_TV |
24 #include "mp_msg.h" | |
25 #include "help_mp.h" | |
26 | |
27 #include "stream.h" | |
28 #include "demuxer.h" | |
29 #include "stheader.h" | |
2830 | 30 |
31 #include "../libao2/afmt.h" | |
32 #include "../libvo/img_format.h" | |
33 #include "../libvo/fastmemcpy.h" | |
34 | |
2802 | 35 #include "tv.h" |
2790 | 36 |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
37 #include "frequencies.h" |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
38 |
2790 | 39 /* some default values */ |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
40 int tv_param_noaudio = 0; |
2837 | 41 char *tv_param_freq = NULL; |
3284 | 42 char *tv_param_channel = NULL; |
2790 | 43 char *tv_param_norm = "pal"; |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
44 char *tv_param_chanlist = "europe-east"; |
2790 | 45 char *tv_param_device = NULL; |
46 char *tv_param_driver = "dummy"; | |
47 int tv_param_width = -1; | |
48 int tv_param_height = -1; | |
2802 | 49 int tv_param_input = 0; /* used in v4l and bttv */ |
2817 | 50 char *tv_param_outfmt = "yv12"; |
3285 | 51 float tv_param_fps = -1.0; |
2790 | 52 |
53 /* ================== DEMUX_TV ===================== */ | |
54 /* | |
55 Return value: | |
56 0 = EOF(?) or no stream | |
57 1 = successfully read a packet | |
58 */ | |
59 /* fill demux->video and demux->audio */ | |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
60 |
2802 | 61 int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh) |
2790 | 62 { |
2813 | 63 demux_packet_t* dp; |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
64 |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
65 sh_video_t *sh_video = demux->video->sh; |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
66 u_int len; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
67 u_int cframe; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
68 int aframeswaiting; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
69 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
70 len = cframe = -1; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
71 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
72 /* ================== ADD AUDIO PACKET =================== */ |
2790 | 73 |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
74 if (tv_param_noaudio == 0 && |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
75 tvh->functions->control(tvh->priv, |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
76 TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE) |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
77 { |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
78 len = tvh->functions->get_audio_framesize(tvh->priv); |
2802 | 79 |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
80 do { |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
81 dp=new_demux_packet(len); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
82 aframeswaiting=tvh->functions->grab_audio_frame(tvh->priv, |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
83 dp->buffer,len); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
84 dp->pts=tvh->seq/sh_video->fps; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
85 dp->pos=tvh->seq*len; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
86 ds_add_packet(demux->audio,dp); |
2790 | 87 |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
88 tvh->seq++; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
89 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
90 } while (aframeswaiting > 0); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
91 } |
2802 | 92 |
2790 | 93 /* ================== ADD VIDEO PACKET =================== */ |
94 | |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
95 if (tvh->functions->control(tvh->priv, |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
96 TVI_CONTROL_IS_VIDEO, 0) == TVI_CONTROL_TRUE) |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
97 { |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
98 len = tvh->functions->get_video_framesize(tvh->priv); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
99 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
100 dp=new_demux_packet(len); |
2790 | 101 |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
102 cframe=tvh->functions->grab_video_frame(tvh->priv, dp->buffer, |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
103 len); |
2802 | 104 |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
105 if(tv_param_noaudio == 1) tvh->seq = cframe; |
2813 | 106 |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
107 dp->pos=tvh->seq*len; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
108 dp->pts=tvh->seq/sh_video->fps; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
109 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
110 ds_add_packet(demux->video,dp); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
111 } |
2790 | 112 |
113 return 1; | |
114 } | |
115 | |
2931 | 116 int stream_open_tv(stream_t *stream, tvi_handle_t *tvh) |
117 { | |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
118 int i; |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
119 tvi_functions_t *funcs = tvh->functions; |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
120 int picture_format = 0; |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
121 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
122 if (funcs->control(tvh->priv, TVI_CONTROL_IS_VIDEO, 0) != TVI_CONTROL_TRUE) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
123 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
124 mp_msg(MSGT_TV, MSGL_ERR, "Error: no video input present!\n"); |
3728 | 125 return 0; |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
126 } |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
127 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
128 if (!strcasecmp(tv_param_outfmt, "yv12")) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
129 picture_format = IMGFMT_YV12; |
3703 | 130 else if (!strcasecmp(tv_param_outfmt, "i420")) |
131 picture_format = IMGFMT_I420; | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
132 else if (!strcasecmp(tv_param_outfmt, "uyvy")) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
133 picture_format = IMGFMT_UYVY; |
4350 | 134 else if (!strcasecmp(tv_param_outfmt, "yuy2")) |
135 picture_format = IMGFMT_YUY2; | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
136 else if (!strcasecmp(tv_param_outfmt, "rgb32")) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
137 picture_format = IMGFMT_RGB32; |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
138 else if (!strcasecmp(tv_param_outfmt, "rgb24")) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
139 picture_format = IMGFMT_RGB24; |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
140 else if (!strcasecmp(tv_param_outfmt, "rgb16")) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
141 picture_format = IMGFMT_RGB16; |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
142 else if (!strcasecmp(tv_param_outfmt, "rgb15")) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
143 picture_format = IMGFMT_RGB15; |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
144 else |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
145 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
146 mp_msg(MSGT_TV, MSGL_ERR, "Unknown format given: %s\n", tv_param_outfmt); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
147 mp_msg(MSGT_TV, MSGL_INFO, "Using default: Planar YV12\n"); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
148 picture_format = IMGFMT_YV12; |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
149 } |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
150 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_FORMAT, &picture_format); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
151 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
152 /* set width */ |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
153 if (tv_param_width != -1) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
154 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
155 if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_WIDTH, &tv_param_width) == TVI_CONTROL_TRUE) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
156 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_WIDTH, &tv_param_width); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
157 else |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
158 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
159 mp_msg(MSGT_TV, MSGL_ERR, "Unable set requested width: %d\n", tv_param_width); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
160 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &tv_param_width); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
161 } |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
162 } |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
163 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
164 /* set height */ |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
165 if (tv_param_height != -1) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
166 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
167 if (funcs->control(tvh->priv, TVI_CONTROL_VID_CHK_HEIGHT, &tv_param_height) == TVI_CONTROL_TRUE) |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
168 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HEIGHT, &tv_param_height); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
169 else |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
170 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
171 mp_msg(MSGT_TV, MSGL_ERR, "Unable set requested height: %d\n", tv_param_height); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
172 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &tv_param_height); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
173 } |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
174 } |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
175 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
176 /* set some params got from cmdline */ |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
177 funcs->control(tvh->priv, TVI_CONTROL_SPC_SET_INPUT, &tv_param_input); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
178 |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
179 /* select video norm */ |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
180 if (!strcasecmp(tv_param_norm, "pal")) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
181 tvh->norm = TV_NORM_PAL; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
182 else if (!strcasecmp(tv_param_norm, "ntsc")) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
183 tvh->norm = TV_NORM_NTSC; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
184 else if (!strcasecmp(tv_param_norm, "secam")) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
185 tvh->norm = TV_NORM_SECAM; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
186 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
187 mp_msg(MSGT_TV, MSGL_INFO, "Selected norm: %s\n", tv_param_norm); |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
188 funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_NORM, &tvh->norm); |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
189 |
3284 | 190 if (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) != TVI_CONTROL_TRUE) |
191 { | |
192 mp_msg(MSGT_TV, MSGL_WARN, "Selected input hasn't got a tuner!\n"); | |
193 goto start_device; | |
194 } | |
195 | |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
196 /* select channel list */ |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
197 for (i = 0; chanlists[i].name != NULL; i++) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
198 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
199 if (!strcasecmp(chanlists[i].name, tv_param_chanlist)) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
200 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
201 tvh->chanlist = i; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
202 tvh->chanlist_s = chanlists[i].list; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
203 break; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
204 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
205 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
206 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
207 if (tvh->chanlist == -1) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
208 mp_msg(MSGT_TV, MSGL_WARN, "Unable to find selected channel list! (%s)\n", |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
209 tv_param_chanlist); |
3284 | 210 else |
211 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel list: %s (including %d channels)\n", | |
212 chanlists[tvh->chanlist].name, chanlists[tvh->chanlist].count); | |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
213 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
214 if (tv_param_freq && tv_param_channel) |
3284 | 215 { |
216 mp_msg(MSGT_TV, MSGL_WARN, "You can't set frequency and channel simultanly!\n"); | |
217 goto start_device; | |
218 } | |
219 | |
220 /* we need to set frequency */ | |
221 if (tv_param_freq) | |
222 { | |
223 unsigned long freq = atof(tv_param_freq)*16; | |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
224 |
3284 | 225 /* set freq in MHz */ |
226 funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq); | |
227 | |
228 funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq); | |
229 mp_msg(MSGT_TV, MSGL_INFO, "Selected frequency: %lu (%.3f)\n", | |
230 freq, (float)freq/16); | |
231 } | |
232 | |
233 if (tv_param_channel) | |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
234 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
235 struct CHANLIST cl; |
3284 | 236 |
237 mp_msg(MSGT_TV, MSGL_V, "Requested channel: %s\n", tv_param_channel); | |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
238 for (i = 0; i < chanlists[tvh->chanlist].count; i++) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
239 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
240 cl = tvh->chanlist_s[i]; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
241 // printf("count%d: name: %s, freq: %d\n", |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
242 // i, cl.name, cl.freq); |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
243 if (!strcasecmp(cl.name, tv_param_channel)) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
244 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
245 tvh->channel = i; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
246 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
247 cl.name, (float)cl.freq/1000); |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
248 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
249 break; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
250 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
251 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
252 } |
3284 | 253 |
254 start_device: | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
255 /* also start device! */ |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
256 return(funcs->start(tvh->priv)); |
2931 | 257 } |
258 | |
2802 | 259 int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh) |
2790 | 260 { |
2802 | 261 sh_video_t *sh_video = NULL; |
262 sh_audio_t *sh_audio = NULL; | |
2790 | 263 tvi_functions_t *funcs = tvh->functions; |
264 | |
2802 | 265 sh_video = new_sh_video(demuxer, 0); |
2790 | 266 |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
267 /* get IMAGE FORMAT */ |
2802 | 268 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &sh_video->format); |
2810 | 269 // if (IMGFMT_IS_RGB(sh_video->format) || IMGFMT_IS_BGR(sh_video->format)) |
3398 | 270 // sh_video->format = 0x0; |
2802 | 271 |
272 /* set FPS and FRAMETIME */ | |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
273 |
2790 | 274 if(!sh_video->fps) |
275 { | |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
276 int tmp; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
277 if (funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FPS, &tmp) != TVI_CONTROL_TRUE) |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
278 sh_video->fps = 25.0f; /* on PAL */ |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
279 else sh_video->fps = tmp; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
280 } |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
281 |
3285 | 282 if (tv_param_fps != -1.0f) |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
283 sh_video->fps = tv_param_fps; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
284 |
2790 | 285 sh_video->frametime = 1.0f/sh_video->fps; |
286 | |
3815 | 287 printf("fps: %f, frametime: %f\n", sh_video->fps, sh_video->frametime); |
288 | |
2790 | 289 /* set width */ |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
290 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w); |
2790 | 291 |
292 /* set height */ | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
293 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h); |
2802 | 294 |
2818 | 295 mp_msg(MSGT_TV, MSGL_INFO, "Output size: %dx%d\n", sh_video->disp_w, sh_video->disp_h); |
2790 | 296 |
297 demuxer->video->sh = sh_video; | |
298 sh_video->ds = demuxer->video; | |
299 demuxer->video->id = 0; | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
300 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
301 // demuxer->seekable = 0; |
2790 | 302 |
303 /* here comes audio init */ | |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
304 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
305 if (tv_param_noaudio == 0 && funcs->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE) |
2802 | 306 { |
307 int audio_format; | |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
308 int sh_audio_format; |
2802 | 309 |
310 /* yeah, audio is present */ | |
311 if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE) | |
312 goto no_audio; | |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
313 |
2802 | 314 switch(audio_format) |
315 { | |
316 case AFMT_U8: | |
317 case AFMT_S8: | |
318 case AFMT_U16_LE: | |
319 case AFMT_U16_BE: | |
320 case AFMT_S16_LE: | |
321 case AFMT_S16_BE: | |
322 case AFMT_S32_LE: | |
323 case AFMT_S32_BE: | |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
324 sh_audio_format = 0x1; /* PCM */ |
2802 | 325 break; |
326 case AFMT_IMA_ADPCM: | |
327 case AFMT_MU_LAW: | |
328 case AFMT_A_LAW: | |
329 case AFMT_MPEG: | |
330 case AFMT_AC3: | |
331 default: | |
2818 | 332 mp_msg(MSGT_TV, MSGL_ERR, "Audio type '%s' unsupported!\n", audio_out_format_name(audio_format)); |
2802 | 333 goto no_audio; |
334 } | |
335 | |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
336 sh_audio = new_sh_audio(demuxer, 0); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
337 sh_audio->wf = (WAVEFORMATEX *)malloc(sizeof(WAVEFORMATEX)); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
338 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
339 funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE, |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
340 &sh_audio->samplerate); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
341 funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLESIZE, |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
342 &sh_audio->samplesize); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
343 funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS, |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
344 &sh_audio->channels); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
345 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
346 sh_audio->format = sh_audio_format; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
347 sh_audio->sample_format = audio_format; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
348 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
349 sh_audio->i_bps = sh_audio->o_bps = |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
350 sh_audio->samplerate * sh_audio->samplesize/8 * |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
351 sh_audio->channels; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
352 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
353 sh_audio->wf->wFormatTag = sh_audio->format; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
354 sh_audio->wf->nChannels = sh_audio->channels; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
355 switch(audio_format) |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
356 { |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
357 case AFMT_U8: |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
358 case AFMT_S8: |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
359 sh_audio->wf->wBitsPerSample = 8; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
360 break; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
361 case AFMT_U16_LE: |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
362 case AFMT_U16_BE: |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
363 case AFMT_S16_LE: |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
364 case AFMT_S16_BE: |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
365 sh_audio->wf->wBitsPerSample = 16; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
366 break; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
367 case AFMT_S32_LE: |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
368 case AFMT_S32_BE: |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
369 sh_audio->wf->wBitsPerSample = 32; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
370 break; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
371 } |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
372 sh_audio->wf->nSamplesPerSec = sh_audio->samplerate; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
373 sh_audio->wf->nBlockAlign = sh_audio->wf->nAvgBytesPerSec; |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
374 sh_audio->wf->nAvgBytesPerSec = sh_audio->wf->nChannels * |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
375 sh_audio->samplesize/8 * |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
376 sh_audio->samplerate; |
2802 | 377 |
378 demuxer->audio->sh = sh_audio; | |
379 sh_audio->ds = demuxer->audio; | |
380 demuxer->audio->id = 0; | |
381 } | |
382 no_audio: | |
383 | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
384 return(1); |
2790 | 385 } |
386 | |
387 /* ================== STREAM_TV ===================== */ | |
2802 | 388 tvi_handle_t *tv_begin(void) |
2790 | 389 { |
390 if (!strcmp(tv_param_driver, "dummy")) | |
2802 | 391 return (tvi_handle_t *)tvi_init_dummy(tv_param_device); |
3249 | 392 #ifdef HAVE_TV_V4L |
2790 | 393 if (!strcmp(tv_param_driver, "v4l")) |
2802 | 394 return (tvi_handle_t *)tvi_init_v4l(tv_param_device); |
3249 | 395 #endif |
5087
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
396 #ifdef HAVE_TV_BSDBT848 |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
397 if (!strcmp(tv_param_driver, "bsdbt848")) |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
398 return (tvi_handle_t *)tvi_init_bsdbt848(tv_param_device); |
1d54c3a27093
audio support and pts based packet handling by Charles Henrich
alex
parents:
4350
diff
changeset
|
399 #endif |
2790 | 400 |
401 mp_msg(MSGT_TV, MSGL_ERR, "No such driver: %s\n", tv_param_driver); | |
402 return(NULL); | |
403 } | |
404 | |
2802 | 405 int tv_init(tvi_handle_t *tvh) |
2790 | 406 { |
2818 | 407 mp_msg(MSGT_TV, MSGL_INFO, "Selected driver: %s\n", tvh->info->short_name); |
408 mp_msg(MSGT_TV, MSGL_INFO, " name: %s\n", tvh->info->name); | |
409 mp_msg(MSGT_TV, MSGL_INFO, " author: %s\n", tvh->info->author); | |
2802 | 410 if (tvh->info->comment) |
2818 | 411 mp_msg(MSGT_TV, MSGL_INFO, " comment: %s\n", tvh->info->comment); |
2790 | 412 |
3815 | 413 return(tvh->functions->init(tvh->priv)); |
2837 | 414 } |
415 | |
416 int tv_uninit(tvi_handle_t *tvh) | |
417 { | |
418 return(tvh->functions->uninit(tvh->priv)); | |
2790 | 419 } |
2937 | 420 |
421 /* utilities for mplayer (not mencoder!!) */ | |
422 int tv_set_color_options(tvi_handle_t *tvh, int opt, int value) | |
423 { | |
424 tvi_functions_t *funcs = tvh->functions; | |
425 | |
426 switch(opt) | |
427 { | |
428 case TV_COLOR_BRIGHTNESS: | |
429 if (value == 50) | |
430 value = 32768; | |
431 if (value > 50) | |
432 { | |
433 value *= 100; | |
434 value += 32768; | |
435 } | |
436 if (value < 50) | |
437 { | |
438 int i; | |
439 value *= 100; | |
440 i = value; | |
441 value = 32768 - i; | |
442 } | |
443 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value); | |
444 break; | |
445 case TV_COLOR_HUE: | |
446 if (value == 50) | |
447 value = 32768; | |
448 if (value > 50) | |
449 { | |
450 value *= 100; | |
451 value += 32768; | |
452 } | |
453 if (value < 50) | |
454 { | |
455 int i; | |
456 value *= 100; | |
457 i = value; | |
458 value = 32768 - i; | |
459 } | |
460 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value); | |
461 break; | |
462 case TV_COLOR_SATURATION: | |
463 if (value == 50) | |
464 value = 32512; | |
465 if (value > 50) | |
466 { | |
467 value *= 100; | |
468 value += 32512; | |
469 } | |
470 if (value < 50) | |
471 { | |
472 int i; | |
473 value *= 100; | |
474 i = value; | |
475 value = 32512 - i; | |
476 } | |
477 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value); | |
478 break; | |
479 case TV_COLOR_CONTRAST: | |
480 if (value == 50) | |
481 value = 27648; | |
482 if (value > 50) | |
483 { | |
484 value *= 100; | |
485 value += 27648; | |
486 } | |
487 if (value < 50) | |
488 { | |
489 int i; | |
490 value *= 100; | |
491 i = value; | |
492 value = 27648 - i; | |
493 } | |
494 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value); | |
495 break; | |
496 default: | |
497 mp_msg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt); | |
498 } | |
499 | |
500 return(1); | |
501 } | |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
502 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
503 int tv_set_freq(tvi_handle_t *tvh, unsigned long freq) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
504 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
505 if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_TUNER, 0) == TVI_CONTROL_TRUE) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
506 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
507 // unsigned long freq = atof(tv_param_freq)*16; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
508 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
509 /* set freq in MHz */ |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
510 tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq); |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
511 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
512 tvh->functions->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq); |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
513 mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n", |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
514 freq, (float)freq/16); |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
515 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
516 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
517 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
518 int tv_step_channel(tvi_handle_t *tvh, int direction) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
519 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
520 struct CHANLIST cl; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
521 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
522 if (direction == TV_CHANNEL_LOWER) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
523 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
524 if (tvh->channel-1 >= 0) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
525 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
526 cl = tvh->chanlist_s[tvh->channel--]; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
527 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
528 cl.name, (float)cl.freq/1000); |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
529 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
530 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
531 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
532 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
533 if (direction == TV_CHANNEL_HIGHER) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
534 { |
4242 | 535 if (tvh->channel+1 < chanlists[tvh->chanlist].count) |
2941
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
536 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
537 cl = tvh->chanlist_s[tvh->channel++]; |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
538 mp_msg(MSGT_TV, MSGL_INFO, "Selected channel: %s (freq: %.3f)\n", |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
539 cl.name, (float)cl.freq/1000); |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
540 tv_set_freq(tvh, (unsigned long)(((float)cl.freq/1000)*16)); |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
541 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
542 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
543 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
544 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
545 int tv_step_norm(tvi_handle_t *tvh) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
546 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
547 } |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
548 |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
549 int tv_step_chanlist(tvi_handle_t *tvh) |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
550 { |
60c1b7c0ea21
added support for norm=,chanlist=,channel= and also on-the-fly channel chaning with keys
alex
parents:
2937
diff
changeset
|
551 } |
2790 | 552 #endif /* USE_TV */ |