Mercurial > mplayer.hg
annotate libmpdemux/tv.c @ 2937:4307478ad922
added support for setting color values
author | alex |
---|---|
date | Fri, 16 Nov 2001 22:59:07 +0000 |
parents | fa3224774679 |
children | 60c1b7c0ea21 |
rev | line source |
---|---|
2790 | 1 /* |
2 TV subsystem for libMPDemux by Alex | |
3 | |
4 API idea based on libvo2's | |
5 | |
2931 | 6 UNDER HEAVY DEVELOPEMENT, NO FEATURE REQUESTS PLEASE! :) |
2790 | 7 */ |
8 | |
9 #include <stdio.h> | |
10 #include <stdlib.h> | |
11 #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
|
12 #include <string.h> |
2790 | 13 |
14 #include "config.h" | |
15 | |
2819
2e58962dc9fe
cleaned up some warnings, and tv_param_on moved out from #ifdef USE_TV
alex
parents:
2818
diff
changeset
|
16 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
|
17 |
2790 | 18 #ifdef USE_TV |
19 #include "mp_msg.h" | |
20 #include "help_mp.h" | |
21 | |
22 #include "stream.h" | |
23 #include "demuxer.h" | |
24 #include "stheader.h" | |
2830 | 25 |
26 #include "../libao2/afmt.h" | |
27 #include "../libvo/img_format.h" | |
28 #include "../libvo/fastmemcpy.h" | |
29 | |
2802 | 30 #include "tv.h" |
2790 | 31 |
32 /* some default values */ | |
2837 | 33 char *tv_param_freq = NULL; |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
34 char *tv_param_channel = "26"; /* hungarian national tv channel 1 */ |
2790 | 35 char *tv_param_norm = "pal"; |
36 char *tv_param_device = NULL; | |
37 char *tv_param_driver = "dummy"; | |
38 int tv_param_width = -1; | |
39 int tv_param_height = -1; | |
2802 | 40 int tv_param_input = 0; /* used in v4l and bttv */ |
2817 | 41 char *tv_param_outfmt = "yv12"; |
2790 | 42 |
43 | |
44 /* ================== DEMUX_TV ===================== */ | |
45 /* | |
46 Return value: | |
47 0 = EOF(?) or no stream | |
48 1 = successfully read a packet | |
49 */ | |
50 /* fill demux->video and demux->audio */ | |
2802 | 51 int demux_tv_fill_buffer(demuxer_t *demux, tvi_handle_t *tvh) |
2790 | 52 { |
2810 | 53 int seq = tvh->seq++; |
2813 | 54 demux_packet_t* dp; |
55 int len; | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
56 sh_video_t *sh_video = demux->video->sh; |
2790 | 57 |
2931 | 58 mp_dbg(MSGT_DEMUX, MSGL_DBG2, "demux_tv_fill_buffer(sequence:%d) called!\n", seq); |
2802 | 59 |
2813 | 60 // demux->filepos = -1; |
2790 | 61 |
2810 | 62 // seq++; |
63 // tvh->seq++; | |
2802 | 64 |
2790 | 65 /* ================== ADD VIDEO PACKET =================== */ |
2813 | 66 len = tvh->functions->get_video_framesize(tvh->priv); |
2790 | 67 |
2813 | 68 dp=new_demux_packet(len); |
69 tvh->functions->grab_video_frame(tvh->priv, dp->buffer, len); | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
70 dp->pts=seq/sh_video->fps; //(float)pts/90000.0f; |
2813 | 71 //dp->pos=pos; |
72 //dp->flags=flags; | |
73 // append packet to DS stream: | |
74 ds_add_packet(demux->video,dp); | |
2790 | 75 |
76 /* ================== ADD AUDIO PACKET =================== */ | |
2802 | 77 if (tvh->functions->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) != TVI_CONTROL_TRUE) |
78 return 1; /* no audio, only video */ | |
79 | |
2813 | 80 len = tvh->functions->get_audio_framesize(tvh->priv); |
81 | |
82 dp=new_demux_packet(len); | |
83 tvh->functions->grab_audio_frame(tvh->priv, dp->buffer, len); | |
84 //dp->pts=pts; //(float)pts/90000.0f; | |
85 //dp->pos=pos; | |
86 //dp->flags=flags; | |
87 // append packet to DS stream: | |
88 ds_add_packet(demux->audio,dp); | |
2790 | 89 |
90 return 1; | |
91 } | |
92 | |
2931 | 93 int stream_open_tv(stream_t *stream, tvi_handle_t *tvh) |
94 { | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
95 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
|
96 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
|
97 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
98 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
|
99 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
100 mp_msg(MSGT_TV, MSGL_ERR, "Error: no video input present!\n"); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
101 return; |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
102 } |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
103 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
104 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
|
105 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
|
106 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
|
107 picture_format = IMGFMT_UYVY; |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
108 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
|
109 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
|
110 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
|
111 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
|
112 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
|
113 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
|
114 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
|
115 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
|
116 else |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
117 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
118 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
|
119 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
|
120 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
|
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 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
|
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 /* 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
|
125 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
|
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 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
|
128 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
|
129 else |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
130 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
131 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
|
132 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
|
133 } |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
134 } |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
135 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
136 /* 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
|
137 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
|
138 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
139 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
|
140 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
|
141 else |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
142 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
143 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
|
144 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
|
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 } |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
147 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
148 /* 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
|
149 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
|
150 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
151 /* we need to set frequency */ |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
152 if (tv_param_freq && (funcs->control(tvh->priv, TVI_CONTROL_IS_TUNER, 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
|
153 { |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
154 unsigned long freq = atof(tv_param_freq)*16; |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
155 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
156 /* set freq in MHz */ |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
157 funcs->control(tvh->priv, TVI_CONTROL_TUN_SET_FREQ, &freq); |
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 funcs->control(tvh->priv, TVI_CONTROL_TUN_GET_FREQ, &freq); |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
160 mp_msg(MSGT_TV, MSGL_INFO, "Current frequency: %lu (%.3f)\n", |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
161 freq, (float)freq/16); |
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 /* 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
|
165 return(funcs->start(tvh->priv)); |
2931 | 166 } |
167 | |
2802 | 168 int demux_open_tv(demuxer_t *demuxer, tvi_handle_t *tvh) |
2790 | 169 { |
2802 | 170 sh_video_t *sh_video = NULL; |
171 sh_audio_t *sh_audio = NULL; | |
2790 | 172 tvi_functions_t *funcs = tvh->functions; |
173 | |
2802 | 174 sh_video = new_sh_video(demuxer, 0); |
2790 | 175 |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
176 /* get IMAGE FORMAT */ |
2802 | 177 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FORMAT, &sh_video->format); |
2810 | 178 // if (IMGFMT_IS_RGB(sh_video->format) || IMGFMT_IS_BGR(sh_video->format)) |
2802 | 179 sh_video->format = 0x0; |
180 | |
181 /* set FPS and FRAMETIME */ | |
2790 | 182 if(!sh_video->fps) |
183 { | |
184 if (funcs->control(tvh->priv, TVI_CONTROL_VID_GET_FPS, &sh_video->fps) != TVI_CONTROL_TRUE) | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
185 sh_video->fps = 25.0f; /* on PAL */ |
2790 | 186 } |
187 sh_video->frametime = 1.0f/sh_video->fps; | |
188 | |
189 /* 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
|
190 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_WIDTH, &sh_video->disp_w); |
2790 | 191 |
192 /* 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
|
193 funcs->control(tvh->priv, TVI_CONTROL_VID_GET_HEIGHT, &sh_video->disp_h); |
2802 | 194 |
2818 | 195 mp_msg(MSGT_TV, MSGL_INFO, "Output size: %dx%d\n", sh_video->disp_w, sh_video->disp_h); |
2790 | 196 |
197 demuxer->video->sh = sh_video; | |
198 sh_video->ds = demuxer->video; | |
199 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
|
200 |
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
201 // demuxer->seekable = 0; |
2790 | 202 |
203 /* here comes audio init */ | |
2802 | 204 if (funcs->control(tvh->priv, TVI_CONTROL_IS_AUDIO, 0) == TVI_CONTROL_TRUE) |
205 { | |
206 int audio_format; | |
207 | |
208 sh_audio = new_sh_audio(demuxer, 0); | |
209 | |
210 sh_audio->wf = malloc(sizeof(WAVEFORMATEX)); | |
211 memset(sh_audio->wf, 0, sizeof(WAVEFORMATEX)); | |
212 | |
213 /* yeah, audio is present */ | |
214 if (funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_FORMAT, &audio_format) != TVI_CONTROL_TRUE) | |
215 goto no_audio; | |
216 switch(audio_format) | |
217 { | |
218 case AFMT_U8: | |
219 case AFMT_S8: | |
220 case AFMT_U16_LE: | |
221 case AFMT_U16_BE: | |
222 case AFMT_S16_LE: | |
223 case AFMT_S16_BE: | |
224 case AFMT_S32_LE: | |
225 case AFMT_S32_BE: | |
226 sh_audio->format = 0x1; /* PCM */ | |
227 break; | |
228 case AFMT_IMA_ADPCM: | |
229 case AFMT_MU_LAW: | |
230 case AFMT_A_LAW: | |
231 case AFMT_MPEG: | |
232 case AFMT_AC3: | |
233 default: | |
2818 | 234 mp_msg(MSGT_TV, MSGL_ERR, "Audio type '%s' unsupported!\n", audio_out_format_name(audio_format)); |
2802 | 235 goto no_audio; |
236 } | |
237 | |
238 funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_CHANNELS, &sh_audio->wf->nChannels); | |
239 funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLERATE, &sh_audio->wf->nSamplesPerSec); | |
240 funcs->control(tvh->priv, TVI_CONTROL_AUD_GET_SAMPLESIZE, &sh_audio->wf->nAvgBytesPerSec); | |
241 | |
242 demuxer->audio->sh = sh_audio; | |
243 sh_audio->ds = demuxer->audio; | |
244 demuxer->audio->id = 0; | |
245 } | |
246 no_audio: | |
247 | |
2932
fa3224774679
splitted demux_open_tv into two parts: stream_open_tv and demux_open_tv to support caching
alex
parents:
2931
diff
changeset
|
248 return(1); |
2790 | 249 } |
250 | |
251 /* ================== STREAM_TV ===================== */ | |
2802 | 252 tvi_handle_t *tv_begin(void) |
2790 | 253 { |
254 if (!strcmp(tv_param_driver, "dummy")) | |
2802 | 255 return (tvi_handle_t *)tvi_init_dummy(tv_param_device); |
2790 | 256 if (!strcmp(tv_param_driver, "v4l")) |
2802 | 257 return (tvi_handle_t *)tvi_init_v4l(tv_param_device); |
2790 | 258 |
259 mp_msg(MSGT_TV, MSGL_ERR, "No such driver: %s\n", tv_param_driver); | |
260 return(NULL); | |
261 } | |
262 | |
2802 | 263 int tv_init(tvi_handle_t *tvh) |
2790 | 264 { |
2802 | 265 tvi_param_t *params; |
266 | |
2818 | 267 mp_msg(MSGT_TV, MSGL_INFO, "Selected driver: %s\n", tvh->info->short_name); |
268 mp_msg(MSGT_TV, MSGL_INFO, " name: %s\n", tvh->info->name); | |
269 mp_msg(MSGT_TV, MSGL_INFO, " author: %s\n", tvh->info->author); | |
2802 | 270 if (tvh->info->comment) |
2818 | 271 mp_msg(MSGT_TV, MSGL_INFO, " comment: %s\n", tvh->info->comment); |
2790 | 272 |
2802 | 273 params = malloc(sizeof(tvi_param_t)*2); |
274 params[0].opt = malloc(strlen("input")); | |
275 sprintf((char *)params[0].opt, "input"); | |
276 params[0].value = malloc(sizeof(int)); | |
277 (int)*(void **)params[0].value = tv_param_input; | |
278 params[1].opt = params[1].value = NULL; | |
279 | |
2837 | 280 return(tvh->functions->init(tvh->priv, params)); |
281 } | |
282 | |
283 int tv_uninit(tvi_handle_t *tvh) | |
284 { | |
285 return(tvh->functions->uninit(tvh->priv)); | |
2790 | 286 } |
2937 | 287 |
288 /* utilities for mplayer (not mencoder!!) */ | |
289 int tv_set_color_options(tvi_handle_t *tvh, int opt, int value) | |
290 { | |
291 tvi_functions_t *funcs = tvh->functions; | |
292 | |
293 switch(opt) | |
294 { | |
295 case TV_COLOR_BRIGHTNESS: | |
296 if (value == 50) | |
297 value = 32768; | |
298 if (value > 50) | |
299 { | |
300 value *= 100; | |
301 value += 32768; | |
302 } | |
303 if (value < 50) | |
304 { | |
305 int i; | |
306 value *= 100; | |
307 i = value; | |
308 value = 32768 - i; | |
309 } | |
310 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_BRIGHTNESS, &value); | |
311 break; | |
312 case TV_COLOR_HUE: | |
313 if (value == 50) | |
314 value = 32768; | |
315 if (value > 50) | |
316 { | |
317 value *= 100; | |
318 value += 32768; | |
319 } | |
320 if (value < 50) | |
321 { | |
322 int i; | |
323 value *= 100; | |
324 i = value; | |
325 value = 32768 - i; | |
326 } | |
327 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_HUE, &value); | |
328 break; | |
329 case TV_COLOR_SATURATION: | |
330 if (value == 50) | |
331 value = 32512; | |
332 if (value > 50) | |
333 { | |
334 value *= 100; | |
335 value += 32512; | |
336 } | |
337 if (value < 50) | |
338 { | |
339 int i; | |
340 value *= 100; | |
341 i = value; | |
342 value = 32512 - i; | |
343 } | |
344 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_SATURATION, &value); | |
345 break; | |
346 case TV_COLOR_CONTRAST: | |
347 if (value == 50) | |
348 value = 27648; | |
349 if (value > 50) | |
350 { | |
351 value *= 100; | |
352 value += 27648; | |
353 } | |
354 if (value < 50) | |
355 { | |
356 int i; | |
357 value *= 100; | |
358 i = value; | |
359 value = 27648 - i; | |
360 } | |
361 funcs->control(tvh->priv, TVI_CONTROL_VID_SET_CONTRAST, &value); | |
362 break; | |
363 default: | |
364 mp_msg(MSGT_TV, MSGL_WARN, "Unknown color option (%d) specified!\n", opt); | |
365 } | |
366 | |
367 return(1); | |
368 } | |
2790 | 369 #endif /* USE_TV */ |