Mercurial > mplayer.hg
annotate stream/tvi_dshow.c @ 33944:78ba6c8c46a5
Cosmetic: Move guiInfo member VideoWindow.
Put it on top of the other Video members.
author | ib |
---|---|
date | Thu, 01 Sep 2011 17:01:10 +0000 |
parents | 277ec491a8a7 |
children | 3d7ee643b110 |
rev | line source |
---|---|
24744 | 1 /* |
26737
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
2 * TV support under Win32 |
24744 | 3 * |
26737
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
4 * (C) 2007 Vladimir Voroshilov <voroshil@gmail.com> |
24744 | 5 * |
26737
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
6 * Based on tvi_dummy.c with help of tv.c, tvi_v4l2.c code. |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
7 * |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
8 * This file is part of MPlayer. |
24744 | 9 * |
26737
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
10 * MPlayer is free software; you can redistribute it and/or modify |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
11 * it under the terms of the GNU General Public License as published by |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
12 * the Free Software Foundation; either version 2 of the License, or |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
13 * (at your option) any later version. |
24744 | 14 * |
26737
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
15 * MPlayer is distributed in the hope that it will be useful, |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
18 * GNU General Public License for more details. |
24744 | 19 * |
26737
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
20 * You should have received a copy of the GNU General Public License along |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
21 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
23 */ |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
24 |
a26e50cae389
Use standard license headers with standard formatting.
diego
parents:
25689
diff
changeset
|
25 /* |
24744 | 26 * WARNING: This is alpha code! |
27 * | |
28 * Abilities: | |
29 * * Watching TV under Win32 using WDM Capture driver and DirectShow | |
30 * * Grabbing synchronized audio/video with mencoder (synchronization is beeing done by DirectShow) | |
31 * * If device driver provides IAMStreamConfig interface, user can choose width/height with "-tv height=<h>:width=<w>" | |
32 * * Adjusting BRIGHTNESS,HUE,SATURATION,CONTRAST if supported by device | |
33 * * Selecting Tuner,S-Video,... as media source | |
34 * * User can select used video capture device, passing -tv device=<dev#> | |
35 * * User can select used audio input, passing -tv audioid=<input#> | |
36 * | |
37 * options which will not be implemented (probably sometime in future, if possible): | |
38 * * alsa | |
39 * * mjpeg | |
40 * * decimation=<1|2|4> | |
41 * * quality=<0\-100> | |
42 * * forceaudio | |
43 * * forcechan=<1\-2> | |
44 * * [volume|bass|treble|balance] | |
45 * | |
46 * Works with: | |
47 * - LifeView FlyTV Prime 34FM (SAA7134 based) with driver from Ivan Uskov | |
48 * Partially works with: | |
49 * - ATI 9200 VIVO based card | |
50 * - ATI AIW 7500 | |
51 * - nVidia Ti-4400 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
52 * |
24744 | 53 * Known bugs: |
54 * * stream goes with 24.93 FPS (NTSC), while reporting 25 FPS (PAL) ?! | |
55 * * direct set frequency call does not work ('Insufficient Buffer' error) | |
56 * * audio stream goes with about 1 sample/sec rate when capturing sound from audio card | |
57 * | |
58 * TODO: | |
59 * * check audio with small buffer on vivo !!! | |
60 * * norm for IAMVideoDecoder and for IAMTVtuner - differs !! | |
61 * * check how to change TVFormat on VIVO card without tuner | |
62 * * Flip image upside-down for RGB formats. | |
63 * * | |
64 * * remove debug sleep() | |
65 * * Add some notes to methods' parameters | |
66 * * refactor console messages | |
67 * * check using header files and keep only needed | |
68 * * add additional comments to methods' bodies | |
69 * | |
70 */ | |
71 | |
72 | |
73 /// \ingroup tvi_dshow | |
74 | |
75 #include "config.h" | |
76 | |
77 #include <stdio.h> | |
78 #include "libmpcodecs/img_format.h" | |
29759
d287e2785570
Move teletext specific code from stream into libmpcodecs.
cehoyos
parents:
29263
diff
changeset
|
79 #include "libmpcodecs/dec_teletext.h" |
24744 | 80 #include "libaf/af_format.h" |
81 #include "help_mp.h" | |
82 #include "osdep/timer.h" | |
83 | |
84 | |
85 #include "tv.h" | |
86 #include "mp_msg.h" | |
87 #include "frequencies.h" | |
88 | |
89 | |
90 #include "tvi_dshow.h" | |
91 | |
30127
774aa6f7399e
Several hacks to fix compilation of tvi_dshow on MinGW64.
reimar
parents:
29809
diff
changeset
|
92 #ifndef STDCALL |
774aa6f7399e
Several hacks to fix compilation of tvi_dshow on MinGW64.
reimar
parents:
29809
diff
changeset
|
93 // mingw64 needs this |
774aa6f7399e
Several hacks to fix compilation of tvi_dshow on MinGW64.
reimar
parents:
29809
diff
changeset
|
94 #define STDCALL __stdcall |
774aa6f7399e
Several hacks to fix compilation of tvi_dshow on MinGW64.
reimar
parents:
29809
diff
changeset
|
95 #endif |
774aa6f7399e
Several hacks to fix compilation of tvi_dshow on MinGW64.
reimar
parents:
29809
diff
changeset
|
96 |
24744 | 97 static tvi_handle_t *tvi_init_dshow(tv_param_t* tv_param); |
98 | |
99 /* | |
100 *--------------------------------------------------------------------------------------- | |
101 * | |
102 * Data structures | |
103 * | |
104 *--------------------------------------------------------------------------------------- | |
105 */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
106 /** |
24744 | 107 information about this file |
108 */ | |
25689 | 109 const tvi_info_t tvi_info_dshow = { |
24744 | 110 tvi_init_dshow, |
111 "DirectShow TV", | |
112 "dshow", | |
113 "Vladimir Voroshilov", | |
114 "Very experimental!! Use with caution" | |
115 }; | |
116 | |
117 | |
118 /** | |
119 ringbuffer related info | |
120 */ | |
121 typedef struct { | |
122 CRITICAL_SECTION *pMutex; ///< pointer to critical section (mutex) | |
123 char **ringbuffer; ///< ringbuffer array | |
124 double*dpts; ///< samples' timestamps | |
125 | |
126 int buffersize; ///< size of buffer in blocks | |
127 int blocksize; ///< size of individual block | |
128 int head; ///< index of first valid sample | |
129 int tail; ///< index of last valid sample | |
130 int count; ///< count of valid samples in ringbuffer | |
131 double tStart; ///< pts of first sample (first sample should have pts 0) | |
132 } grabber_ringbuffer_t; | |
133 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
134 typedef enum { unknown, video, audio, vbi } stream_type; |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
135 |
24744 | 136 /** |
137 CSampleGrabberCD definition | |
138 */ | |
139 typedef struct CSampleGrabberCB { | |
140 ISampleGrabberCBVtbl *lpVtbl; | |
141 int refcount; | |
142 GUID interfaces[2]; | |
143 grabber_ringbuffer_t *pbuf; | |
144 } CSampleGrabberCB; | |
145 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
146 /** |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
147 Chain related structure |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
148 */ |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
149 typedef struct { |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
150 stream_type type; ///< stream type |
25080 | 151 const GUID* majortype; ///< GUID of major mediatype (video/audio/vbi) |
25094
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
152 const GUID* pin_category; ///< pin category (pointer to one of PIN_CATEGORY_*) |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
153 |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
154 IBaseFilter *pCaptureFilter; ///< capture device filter |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
155 IAMStreamConfig *pStreamConfig; ///< for configuring stream |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
156 ISampleGrabber *pSG; ///< ISampleGrabber interface of SampleGrabber filter |
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
157 IBaseFilter *pSGF; ///< IBaseFilter interface of SampleGrabber filter |
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
158 IPin *pCapturePin; ///< output capture pin |
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
159 IPin *pSGIn; ///< input pin of SampleGrabber filter |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
160 |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
161 grabber_ringbuffer_t *rbuf; ///< sample frabber data |
25086
e91503fbf524
Move pointer to SampleGrabber filter into chain structure.
voroshil
parents:
25085
diff
changeset
|
162 CSampleGrabberCB* pCSGCB; ///< callback object |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
163 |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
164 AM_MEDIA_TYPE *pmt; ///< stream properties. |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
165 int nFormatUsed; ///< index of used format |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
166 AM_MEDIA_TYPE **arpmt; ///< available formats |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
167 void** arStreamCaps; ///< VIDEO_STREAM_CONFIG_CAPS or AUDIO_STREAM_CONFIG_CAPS |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
168 } chain_t; |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
169 |
31322
016194f71de3
Fix function pointer types in tvi_functions struct
reimar
parents:
30702
diff
changeset
|
170 typedef struct priv { |
24744 | 171 int dev_index; ///< capture device index in device list (defaul: 0, first available device) |
172 int adev_index; ///< audio capture device index in device list (default: -1, not used) | |
173 int immediate_mode; ///< immediate mode (no sound capture) | |
174 int state; ///< state: 1-filter graph running, 0-filter graph stopped | |
175 int direct_setfreq_call; ///< 0-find nearest channels from system channel list(workaround),1-direct call to set frequency | |
176 int direct_getfreq_call; ///< 0-find frequncy from frequency table (workaround),1-direct call to get frequency | |
177 | |
178 int fcc; ///< used video format code (FourCC) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
179 int width; ///< picture width (default: auto) |
24744 | 180 int height; ///< picture height (default: auto) |
181 | |
182 int channels; ///< number of audio channels (default: auto) | |
183 int samplerate; ///< audio samplerate (default: auto) | |
184 | |
185 long *freq_table; ///< frequency table (in Hz) | |
186 int freq_table_len; ///< length of freq table | |
187 int first_channel; ///< channel number of first entry in freq table | |
188 int input; ///< used input | |
189 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
190 chain_t* chains[3]; ///< chains' data (0-video, 1-audio, 2-vbi) |
24744 | 191 |
192 IAMTVTuner *pTVTuner; ///< interface for tuner device | |
193 IGraphBuilder *pGraph; ///< filter graph | |
194 ICaptureGraphBuilder2 *pBuilder; ///< graph builder | |
195 IMediaControl *pMediaControl; ///< interface for controlling graph (start, stop,...) | |
196 IAMVideoProcAmp *pVideoProcAmp; ///< for adjusting hue,saturation,etc | |
197 IAMCrossbar *pCrossbar; ///< for selecting input (Tuner,Composite,S-Video,...) | |
198 DWORD dwRegister; ///< allow graphedit to connect to our graph | |
199 void *priv_vbi; ///< private VBI data structure | |
200 tt_stream_props tsp; ///< data for VBI initialization | |
201 | |
202 tv_param_t* tv_param; ///< TV parameters | |
203 } priv_t; | |
204 | |
205 #include "tvi_def.h" | |
206 | |
207 /** | |
208 country table entry structure (for loading freq table stored in kstvtuner.ax | |
209 | |
210 \note | |
211 structure have to be 2-byte aligned and have 10-byte length!! | |
212 */ | |
213 typedef struct __attribute__((__packed__)) { | |
214 WORD CountryCode; ///< Country code | |
215 WORD CableFreqTable; ///< index of resource with frequencies for cable channels | |
216 WORD BroadcastFreqTable; ///< index of resource with frequencies for broadcast channels | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
217 DWORD VideoStandard; ///< used video standard |
24744 | 218 } TRCCountryList; |
219 /** | |
220 information about image formats | |
221 */ | |
222 typedef struct { | |
223 uint32_t fmt; ///< FourCC | |
224 const GUID *subtype; ///< DirectShow's subtype | |
225 int nBits; ///< number of bits | |
226 int nCompression; ///< complression | |
227 int tail; ///< number of additional bytes followed VIDEOINFOHEADER structure | |
228 } img_fmt; | |
229 | |
230 /* | |
231 *--------------------------------------------------------------------------------------- | |
232 * | |
233 * Methods forward declaration | |
234 * | |
235 *--------------------------------------------------------------------------------------- | |
236 */ | |
237 static HRESULT init_ringbuffer(grabber_ringbuffer_t * rb, int buffersize, | |
238 int blocksize); | |
239 static HRESULT show_filter_info(IBaseFilter * pFilter); | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
240 #if 0 |
24744 | 241 //defined in current MinGW release |
242 HRESULT STDCALL GetRunningObjectTable(DWORD, IRunningObjectTable **); | |
243 HRESULT STDCALL CreateItemMoniker(LPCOLESTR, LPCOLESTR, IMoniker **); | |
244 #endif | |
245 static CSampleGrabberCB *CSampleGrabberCB_Create(grabber_ringbuffer_t * | |
246 pbuf); | |
247 static int set_crossbar_input(priv_t * priv, int input); | |
248 static int subtype2imgfmt(const GUID * subtype); | |
249 | |
250 /* | |
251 *--------------------------------------------------------------------------------------- | |
252 * | |
253 * Global constants and variables | |
254 * | |
255 *--------------------------------------------------------------------------------------- | |
256 */ | |
257 /** | |
258 lookup tables for physical connector types | |
259 */ | |
260 static const struct { | |
261 long type; | |
262 char *name; | |
263 } tv_physcon_types[]={ | |
264 {PhysConn_Video_Tuner, "Tuner" }, | |
265 {PhysConn_Video_Composite, "Composite" }, | |
266 {PhysConn_Video_SVideo, "S-Video" }, | |
267 {PhysConn_Video_RGB, "RGB" }, | |
268 {PhysConn_Video_YRYBY, "YRYBY" }, | |
269 {PhysConn_Video_SerialDigital, "SerialDigital" }, | |
270 {PhysConn_Video_ParallelDigital, "ParallelDigital"}, | |
271 {PhysConn_Video_VideoDecoder, "VideoDecoder" }, | |
272 {PhysConn_Video_VideoEncoder, "VideoEncoder" }, | |
273 {PhysConn_Video_SCART, "SCART" }, | |
274 {PhysConn_Video_Black, "Blaack" }, | |
275 {PhysConn_Audio_Tuner, "Tuner" }, | |
276 {PhysConn_Audio_Line, "Line" }, | |
277 {PhysConn_Audio_Mic, "Mic" }, | |
278 {PhysConn_Audio_AESDigital, "AESDiital" }, | |
279 {PhysConn_Audio_SPDIFDigital, "SPDIFDigital" }, | |
280 {PhysConn_Audio_AudioDecoder, "AudioDecoder" }, | |
281 {PhysConn_Audio_SCSI, "SCSI" }, | |
282 {PhysConn_Video_SCSI, "SCSI" }, | |
283 {PhysConn_Audio_AUX, "AUX" }, | |
284 {PhysConn_Video_AUX, "AUX" }, | |
285 {PhysConn_Audio_1394, "1394" }, | |
286 {PhysConn_Video_1394, "1394" }, | |
287 {PhysConn_Audio_USB, "USB" }, | |
288 {PhysConn_Video_USB, "USB" }, | |
289 {-1, NULL } | |
290 }; | |
291 | |
292 static const struct { | |
293 char *chanlist_name; | |
294 int country_code; | |
295 } tv_chanlist2country[]={ | |
296 {"us-bcast", 1}, | |
297 {"russia", 7}, | |
298 {"argentina", 54}, | |
299 {"japan-bcast", 81}, | |
300 {"china-bcast", 86}, | |
301 {"southafrica", 27}, | |
302 {"australia", 61}, | |
303 {"ireland", 353}, | |
304 {"france", 33}, | |
305 {"italy", 39}, | |
306 {"newzealand", 64}, | |
307 //directshow table uses eastern europe freq table for russia | |
308 {"europe-east", 7}, | |
309 //directshow table uses western europe freq table for germany | |
310 {"europe-west", 49}, | |
311 /* cable channels */ | |
312 {"us-cable", 1}, | |
313 {"us-cable-hrc", 1}, | |
314 {"japan-cable", 81}, | |
315 //default is USA | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
316 {NULL, 1} |
24744 | 317 }; |
318 | |
319 /** | |
320 array, contains information about various supported (i hope) image formats | |
321 */ | |
322 static const img_fmt img_fmt_list[] = { | |
25054 | 323 {IMGFMT_YUY2, &MEDIASUBTYPE_YUY2, 16, IMGFMT_YUY2, 0}, |
324 {IMGFMT_YV12, &MEDIASUBTYPE_YV12, 12, IMGFMT_YV12, 0}, | |
325 {IMGFMT_IYUV, &MEDIASUBTYPE_IYUV, 12, IMGFMT_IYUV, 0}, | |
326 {IMGFMT_I420, &MEDIASUBTYPE_I420, 12, IMGFMT_I420, 0}, | |
327 {IMGFMT_UYVY, &MEDIASUBTYPE_UYVY, 16, IMGFMT_UYVY, 0}, | |
328 {IMGFMT_YVYU, &MEDIASUBTYPE_YVYU, 16, IMGFMT_YVYU, 0}, | |
329 {IMGFMT_YVU9, &MEDIASUBTYPE_YVU9, 9, IMGFMT_YVU9, 0}, | |
330 {IMGFMT_BGR32, &MEDIASUBTYPE_RGB32, 32, 0, 0}, | |
331 {IMGFMT_BGR24, &MEDIASUBTYPE_RGB24, 24, 0, 0}, | |
332 {IMGFMT_BGR16, &MEDIASUBTYPE_RGB565, 16, 3, 12}, | |
333 {IMGFMT_BGR15, &MEDIASUBTYPE_RGB555, 16, 3, 12}, | |
334 {0, &GUID_NULL, 0, 0, 0} | |
24744 | 335 }; |
336 | |
337 #define TV_NORMS_COUNT 19 | |
338 static const struct { | |
339 long index; | |
340 char *name; | |
341 } tv_norms[TV_NORMS_COUNT] = { | |
342 { | |
343 AnalogVideo_NTSC_M, "ntsc-m"}, { | |
344 AnalogVideo_NTSC_M_J, "ntsc-mj"}, { | |
345 AnalogVideo_NTSC_433, "ntsc-433"}, { | |
346 AnalogVideo_PAL_B, "pal-b"}, { | |
347 AnalogVideo_PAL_D, "pal-d"}, { | |
348 AnalogVideo_PAL_G, "pal-g"}, { | |
349 AnalogVideo_PAL_H, "pal-h"}, { | |
350 AnalogVideo_PAL_I, "pal-i"}, { | |
351 AnalogVideo_PAL_M, "pal-m"}, { | |
352 AnalogVideo_PAL_N, "pal-n"}, { | |
353 AnalogVideo_PAL_60, "pal-60"}, { | |
354 AnalogVideo_SECAM_B, "secam-b"}, { | |
355 AnalogVideo_SECAM_D, "secam-d"}, { | |
356 AnalogVideo_SECAM_G, "secam-g"}, { | |
357 AnalogVideo_SECAM_H, "secam-h"}, { | |
358 AnalogVideo_SECAM_K, "secam-k"}, { | |
359 AnalogVideo_SECAM_K1, "secam-k1"}, { | |
360 AnalogVideo_SECAM_L, "secam-l"}, { | |
361 AnalogVideo_SECAM_L1, "secam-l1"} | |
362 }; | |
363 static long tv_available_norms[TV_NORMS_COUNT]; | |
364 static int tv_available_norms_count = 0; | |
365 | |
366 | |
367 static long *tv_available_inputs; | |
368 static int tv_available_inputs_count = 0; | |
369 | |
370 /* | |
371 *--------------------------------------------------------------------------------------- | |
372 * | |
373 * Various GUID definitions | |
374 * | |
375 *--------------------------------------------------------------------------------------- | |
376 */ | |
30305
fd0de0336717
Add hack to fix tvi_dshow compilation with 64-bit MinGW
reimar
parents:
30300
diff
changeset
|
377 // selectany can not be used with "static", fixes compilation with mingw-w64 |
fd0de0336717
Add hack to fix tvi_dshow compilation with 64-bit MinGW
reimar
parents:
30300
diff
changeset
|
378 #undef DECLSPEC_SELECTANY |
fd0de0336717
Add hack to fix tvi_dshow compilation with 64-bit MinGW
reimar
parents:
30300
diff
changeset
|
379 #define DECLSPEC_SELECTANY |
24744 | 380 /// CLSID definitions (used for CoCreateInstance call) |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
381 #define CLSID_SampleGrabber MP_CLSID_SampleGrabber |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
382 static DEFINE_GUID(CLSID_SampleGrabber, 0xC1F400A0, 0x3F08, 0x11d3, 0x9F, 0x0B, |
24744 | 383 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
384 #define CLSID_NullRenderer MP_CLSID_NullRenderer |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
385 static DEFINE_GUID(CLSID_NullRenderer, 0xC1F400A4, 0x3F08, 0x11d3, 0x9F, 0x0B, |
24744 | 386 0x00, 0x60, 0x08, 0x03, 0x9E, 0x37); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
387 #define CLSID_SystemDeviceEnum MP_CLSID_SystemDeviceEnum |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
388 static DEFINE_GUID(CLSID_SystemDeviceEnum, 0x62BE5D10, 0x60EB, 0x11d0, 0xBD, 0x3B, |
24744 | 389 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
390 #define CLSID_CaptureGraphBuilder2 MP_CLSID_CaptureGraphBuilder2 |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
391 static DEFINE_GUID(CLSID_CaptureGraphBuilder2, 0xBF87B6E1, 0x8C27, 0x11d0, 0xB3, |
24744 | 392 0xF0, 0x00, 0xAA, 0x00, 0x37, 0x61, 0xC5); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
393 #define CLSID_VideoInputDeviceCategory MP_CLSID_VideoInputDeviceCategory |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
394 static DEFINE_GUID(CLSID_VideoInputDeviceCategory, 0x860BB310, 0x5D01, 0x11d0, |
24744 | 395 0xBD, 0x3B, 0x00, 0xA0, 0xC9, 0x11, 0xCE, 0x86); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
396 #define CLSID_AudioInputDeviceCategory MP_CLSID_AudioInputDeviceCategory |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
397 static DEFINE_GUID(CLSID_AudioInputDeviceCategory, 0x33d9a762, 0x90c8, 0x11d0, |
24744 | 398 0xbd, 0x43, 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
399 #define CLSID_FilterGraph MP_CLSID_FilterGraph |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
400 static DEFINE_GUID(CLSID_FilterGraph, 0xe436ebb3, 0x524f, 0x11ce, 0x9f, 0x53, |
24744 | 401 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
402 #define CLSID_SystemClock MP_CLSID_SystemClock |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
403 static DEFINE_GUID(CLSID_SystemClock, 0xe436ebb1, 0x524f, 0x11ce, 0x9f, 0x53, |
24744 | 404 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); |
405 #ifdef NOT_USED | |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
406 #define CLSID_CaptureGraphBuilder MP_CLSID_CaptureGraphBuilder |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
407 static DEFINE_GUID(CLSID_CaptureGraphBuilder, 0xBF87B6E0, 0x8C27, 0x11d0, 0xB3, |
24744 | 408 0xF0, 0x00, 0xAA, 0x00, 0x37, 0x61, 0xC5); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
409 #define CLSID_VideoPortManager MP_CLSID_VideoPortManager |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
410 static DEFINE_GUID(CLSID_VideoPortManager, 0x6f26a6cd, 0x967b, 0x47fd, 0x87, 0x4a, |
24744 | 411 0x7a, 0xed, 0x2c, 0x9d, 0x25, 0xa2); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
412 #define IID_IPin MP_IID_IPin |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
413 static DEFINE_GUID(IID_IPin, 0x56a86891, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, 0x20, |
24744 | 414 0xaf, 0x0b, 0xa7, 0x70); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
415 #define IID_ICaptureGraphBuilder MP_IID_ICaptureGraphBuilder |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
416 static DEFINE_GUID(IID_ICaptureGraphBuilder, 0xbf87b6e0, 0x8c27, 0x11d0, 0xb3, |
24744 | 417 0xf0, 0x00, 0xaa, 0x00, 0x37, 0x61, 0xc5); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
418 #define IID_IFilterGraph MP_IID_IFilterGraph |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
419 static DEFINE_GUID(IID_IFilterGraph, 0x56a8689f, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, |
24744 | 420 0x20, 0xaf, 0x0b, 0xa7, 0x70); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
421 #define PIN_CATEGORY_PREVIEW MP_PIN_CATEGORY_PREVIEW |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
422 static DEFINE_GUID(PIN_CATEGORY_PREVIEW, 0xfb6c4282, 0x0353, 0x11d1, 0x90, 0x5f, |
24744 | 423 0x00, 0x00, 0xc0, 0xcc, 0x16, 0xba); |
424 #endif | |
425 | |
426 /// IID definitions (used for QueryInterface call) | |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
427 #define IID_IReferenceClock MP_IID_IReferenceClock |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
428 static DEFINE_GUID(IID_IReferenceClock, 0x56a86897, 0x0ad4, 0x11ce, 0xb0, 0x3a, |
24744 | 429 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
430 #define IID_IAMBufferNegotiation MP_IID_IAMBufferNegotiation |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
431 static DEFINE_GUID(IID_IAMBufferNegotiation, 0x56ED71A0, 0xAF5F, 0x11D0, 0xB3, 0xF0, |
24744 | 432 0x00, 0xAA, 0x00, 0x37, 0x61, 0xC5); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
433 #define IID_IKsPropertySet MP_IID_IKsPropertySet |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
434 static DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, |
24744 | 435 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
436 #define IID_ISampleGrabber MP_IID_ISampleGrabber |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
437 static DEFINE_GUID(IID_ISampleGrabber, 0x6B652FFF, 0x11FE, 0x4fce, 0x92, 0xAD, |
24744 | 438 0x02, 0x66, 0xB5, 0xD7, 0xC7, 0x8F); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
439 #define IID_ISampleGrabberCB MP_IID_ISampleGrabberCB |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
440 static DEFINE_GUID(IID_ISampleGrabberCB, 0x0579154A, 0x2B53, 0x4994, 0xB0, 0xD0, |
24744 | 441 0xE7, 0x73, 0x14, 0x8E, 0xFF, 0x85); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
442 #define IID_ICaptureGraphBuilder2 MP_IID_ICaptureGraphBuilder2 |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
443 static DEFINE_GUID(IID_ICaptureGraphBuilder2, 0x93e5a4e0, 0x2d50, 0x11d2, 0xab, |
24744 | 444 0xfa, 0x00, 0xa0, 0xc9, 0xc6, 0xe3, 0x8d); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
445 #define IID_ICreateDevEnum MP_IID_ICreateDevEnum |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
446 static DEFINE_GUID(IID_ICreateDevEnum, 0x29840822, 0x5b84, 0x11d0, 0xbd, 0x3b, |
24744 | 447 0x00, 0xa0, 0xc9, 0x11, 0xce, 0x86); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
448 #define IID_IGraphBuilder MP_IID_IGraphBuilder |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
449 static DEFINE_GUID(IID_IGraphBuilder, 0x56a868a9, 0x0ad4, 0x11ce, 0xb0, 0x3a, |
24744 | 450 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
451 #define IID_IAMVideoProcAmp MP_IID_IAMVideoProcAmp |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
452 static DEFINE_GUID(IID_IAMVideoProcAmp, 0xC6E13360, 0x30AC, 0x11d0, 0xA1, 0x8C, |
24744 | 453 0x00, 0xA0, 0xC9, 0x11, 0x89, 0x56); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
454 #define IID_IVideoWindow MP_IID_IVideoWindow |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
455 static DEFINE_GUID(IID_IVideoWindow, 0x56a868b4, 0x0ad4, 0x11ce, 0xb0, 0x3a, 0x00, |
24744 | 456 0x20, 0xaf, 0x0b, 0xa7, 0x70); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
457 #define IID_IMediaControl MP_IID_IMediaControl |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
458 static DEFINE_GUID(IID_IMediaControl, 0x56a868b1, 0x0ad4, 0x11ce, 0xb0, 0x3a, |
24744 | 459 0x00, 0x20, 0xaf, 0x0b, 0xa7, 0x70); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
460 #define IID_IAMTVTuner MP_IID_IAMTVTuner |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
461 static DEFINE_GUID(IID_IAMTVTuner, 0x211A8766, 0x03AC, 0x11d1, 0x8D, 0x13, 0x00, |
24744 | 462 0xAA, 0x00, 0xBD, 0x83, 0x39); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
463 #define IID_IAMCrossbar MP_IID_IAMCrossbar |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
464 static DEFINE_GUID(IID_IAMCrossbar, 0xc6e13380, 0x30ac, 0x11d0, 0xa1, 0x8c, 0x00, |
24744 | 465 0xa0, 0xc9, 0x11, 0x89, 0x56); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
466 #define IID_IAMStreamConfig MP_IID_IAMStreamConfig |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
467 static DEFINE_GUID(IID_IAMStreamConfig, 0xc6e13340, 0x30ac, 0x11d0, 0xa1, 0x8c, |
24744 | 468 0x00, 0xa0, 0xc9, 0x11, 0x89, 0x56); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
469 #define IID_IAMAudioInputMixer MP_IID_IAMAudioInputMixer |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
470 static DEFINE_GUID(IID_IAMAudioInputMixer, 0x54C39221, 0x8380, 0x11d0, 0xB3, 0xF0, |
24744 | 471 0x00, 0xAA, 0x00, 0x37, 0x61, 0xC5); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
472 #define IID_IAMTVAudio MP_IID_IAMTVAudio |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
473 static DEFINE_GUID(IID_IAMTVAudio, 0x83EC1C30, 0x23D1, 0x11d1, 0x99, 0xE6, 0x00, |
24744 | 474 0xA0, 0xC9, 0x56, 0x02, 0x66); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
475 #define IID_IAMAnalogVideoDecoder MP_IID_IAMAnalogVideoDecoder |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
476 static DEFINE_GUID(IID_IAMAnalogVideoDecoder, 0xC6E13350, 0x30AC, 0x11d0, 0xA1, |
24744 | 477 0x8C, 0x00, 0xA0, 0xC9, 0x11, 0x89, 0x56); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
478 #define IID_IPropertyBag MP_IID_IPropertyBag |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
479 static DEFINE_GUID(IID_IPropertyBag, 0x55272a00, 0x42cb, 0x11ce, 0x81, 0x35, 0x00, |
24744 | 480 0xaa, 0x00, 0x4b, 0xb8, 0x51); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
481 #define PIN_CATEGORY_CAPTURE MP_PIN_CATEGORY_CAPTURE |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
482 static DEFINE_GUID(PIN_CATEGORY_CAPTURE, 0xfb6c4281, 0x0353, 0x11d1, 0x90, 0x5f, |
24744 | 483 0x00, 0x00, 0xc0, 0xcc, 0x16, 0xba); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
484 #define PIN_CATEGORY_VIDEOPORT MP_PIN_CATEGORY_VIDEOPORT |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
485 static DEFINE_GUID(PIN_CATEGORY_VIDEOPORT, 0xfb6c4285, 0x0353, 0x11d1, 0x90, 0x5f, |
24744 | 486 0x00, 0x00, 0xc0, 0xcc, 0x16, 0xba); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
487 #define PIN_CATEGORY_PREVIEW MP_PIN_CATEGORY_PREVIEW |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
488 static DEFINE_GUID(PIN_CATEGORY_PREVIEW, 0xfb6c4282, 0x0353, 0x11d1, 0x90, 0x5f, |
24744 | 489 0x00, 0x00, 0xc0, 0xcc, 0x16, 0xba); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
490 #define PIN_CATEGORY_VBI MP_PIN_CATEGORY_VBI |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
491 static DEFINE_GUID(PIN_CATEGORY_VBI, 0xfb6c4284, 0x0353, 0x11d1, 0x90, 0x5f, |
24744 | 492 0x00, 0x00, 0xc0, 0xcc, 0x16, 0xba); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
493 #define PROPSETID_TUNER MP_PROPSETID_TUNER |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
494 static DEFINE_GUID(PROPSETID_TUNER, 0x6a2e0605, 0x28e4, 0x11d0, 0xa1, 0x8c, 0x00, |
24744 | 495 0xa0, 0xc9, 0x11, 0x89, 0x56); |
30300
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
496 #define MEDIATYPE_VBI MP_MEDIATYPE_VBI |
191571148d95
Change GUID declarations in tvi_dshow so they are not exported and thus
reimar
parents:
30127
diff
changeset
|
497 static DEFINE_GUID(MEDIATYPE_VBI, 0xf72a76e1, 0xeb0a, 0x11d0, 0xac, 0xe4, 0x00, |
24744 | 498 0x00, 0xc0, 0xcc, 0x16, 0xba); |
499 | |
500 #define INSTANCEDATA_OF_PROPERTY_PTR(x) (((KSPROPERTY*)(x)) + 1) | |
501 #define INSTANCEDATA_OF_PROPERTY_SIZE(x) (sizeof((x)) - sizeof(KSPROPERTY)) | |
502 | |
503 #define DEVICE_NAME_MAX_LEN 2000 | |
504 | |
505 /*--------------------------------------------------------------------------------------- | |
506 * Methods, called only from this file | |
507 *---------------------------------------------------------------------------------------*/ | |
508 | |
33618
bdfb1aeb4b41
tvi_dshow: Mark functions not used outside of the file as static.
diego
parents:
32511
diff
changeset
|
509 static void set_buffer_preference(int nDiv, WAVEFORMATEX *pWF, |
bdfb1aeb4b41
tvi_dshow: Mark functions not used outside of the file as static.
diego
parents:
32511
diff
changeset
|
510 IPin *pOutPin, IPin *pInPin) |
bdfb1aeb4b41
tvi_dshow: Mark functions not used outside of the file as static.
diego
parents:
32511
diff
changeset
|
511 { |
24744 | 512 ALLOCATOR_PROPERTIES prop; |
513 IAMBufferNegotiation* pBN; | |
514 HRESULT hr; | |
515 | |
516 prop.cbAlign = -1; | |
517 prop.cbBuffer = pWF->nAvgBytesPerSec/nDiv; | |
518 if (!prop.cbBuffer) | |
519 prop.cbBuffer = 1; | |
520 prop.cbBuffer += pWF->nBlockAlign - 1; | |
521 prop.cbBuffer -= prop.cbBuffer % pWF->nBlockAlign; | |
522 prop.cbPrefix = -1; | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
523 prop.cBuffers = -1; |
24744 | 524 |
525 hr=OLE_QUERYINTERFACE(pOutPin,IID_IAMBufferNegotiation,pBN); | |
526 if(FAILED(hr)) | |
527 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: pOutPin->QueryInterface(IID_IAMBufferNegotiation) Error: 0x%x\n",(unsigned int)hr); | |
528 else{ | |
529 hr=OLE_CALL_ARGS(pBN,SuggestAllocatorProperties,&prop); | |
530 if(FAILED(hr)) | |
531 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow:pOutPin->SuggestAllocatorProperties Error:0x%x\n",(unsigned int)hr); | |
532 OLE_RELEASE_SAFE(pBN); | |
533 } | |
534 hr=OLE_QUERYINTERFACE(pInPin,IID_IAMBufferNegotiation,pBN); | |
535 if(FAILED(hr)) | |
536 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: pInPin->QueryInterface(IID_IAMBufferNegotiation) Error: 0x%x",(unsigned int)hr); | |
537 else{ | |
538 hr=OLE_CALL_ARGS(pBN,SuggestAllocatorProperties,&prop); | |
539 if(FAILED(hr)) | |
540 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: pInPit->SuggestAllocatorProperties Error:0x%x\n",(unsigned int)hr); | |
541 OLE_RELEASE_SAFE(pBN); | |
542 } | |
543 } | |
544 /* | |
545 *--------------------------------------------------------------------------------------- | |
546 * | |
547 * CSampleGrabberCD class. Used for receiving samples from DirectShow. | |
548 * | |
549 *--------------------------------------------------------------------------------------- | |
550 */ | |
551 /// CSampleGrabberCD destructor | |
552 static void CSampleGrabberCB_Destroy(CSampleGrabberCB * This) | |
553 { | |
554 free(This->lpVtbl); | |
555 free(This); | |
556 } | |
557 | |
558 /// CSampleGrabberCD IUnknown interface methods implementation | |
559 static long STDCALL CSampleGrabberCB_QueryInterface(ISampleGrabberCB * | |
560 This, | |
561 const GUID * riid, | |
562 void **ppvObject) | |
563 { | |
564 CSampleGrabberCB *me = (CSampleGrabberCB *) This; | |
565 GUID *r; | |
566 unsigned int i = 0; | |
567 Debug printf("CSampleGrabberCB_QueryInterface(%p) called\n", This); | |
568 if (!ppvObject) | |
569 return E_POINTER; | |
570 for (r = me->interfaces; | |
571 i < sizeof(me->interfaces) / sizeof(me->interfaces[0]); r++, i++) | |
572 if (!memcmp(r, riid, sizeof(*r))) { | |
573 OLE_CALL(This, AddRef); | |
574 *ppvObject = This; | |
575 return 0; | |
576 } | |
577 Debug printf("Query failed! (GUID: 0x%x)\n", *(unsigned int *) riid); | |
578 return E_NOINTERFACE; | |
579 } | |
580 | |
581 static long STDCALL CSampleGrabberCB_AddRef(ISampleGrabberCB * This) | |
582 { | |
583 CSampleGrabberCB *me = (CSampleGrabberCB *) This; | |
584 Debug printf("CSampleGrabberCB_AddRef(%p) called (ref:%d)\n", This, | |
585 me->refcount); | |
586 return ++(me->refcount); | |
587 } | |
588 | |
589 static long STDCALL CSampleGrabberCB_Release(ISampleGrabberCB * This) | |
590 { | |
591 CSampleGrabberCB *me = (CSampleGrabberCB *) This; | |
592 Debug printf("CSampleGrabberCB_Release(%p) called (new ref:%d)\n", | |
593 This, me->refcount - 1); | |
594 if (--(me->refcount) == 0) | |
595 CSampleGrabberCB_Destroy(me); | |
596 return 0; | |
597 } | |
598 | |
599 | |
33618
bdfb1aeb4b41
tvi_dshow: Mark functions not used outside of the file as static.
diego
parents:
32511
diff
changeset
|
600 static HRESULT STDCALL CSampleGrabberCB_BufferCB(ISampleGrabberCB *This, |
bdfb1aeb4b41
tvi_dshow: Mark functions not used outside of the file as static.
diego
parents:
32511
diff
changeset
|
601 double SampleTime, |
bdfb1aeb4b41
tvi_dshow: Mark functions not used outside of the file as static.
diego
parents:
32511
diff
changeset
|
602 BYTE *pBuffer, |
bdfb1aeb4b41
tvi_dshow: Mark functions not used outside of the file as static.
diego
parents:
32511
diff
changeset
|
603 long lBufferLen) |
24744 | 604 { |
605 CSampleGrabberCB *this = (CSampleGrabberCB *) This; | |
606 grabber_ringbuffer_t *rb = this->pbuf; | |
607 | |
608 if (!lBufferLen) | |
609 return E_FAIL; | |
610 | |
611 if (!rb->ringbuffer) { | |
612 rb->buffersize /= lBufferLen; | |
613 if (init_ringbuffer(rb, rb->buffersize, lBufferLen) != S_OK) | |
614 return E_FAIL; | |
615 } | |
616 mp_msg(MSGT_TV, MSGL_DBG4, | |
617 "tvi_dshow: BufferCB(%p): len=%ld ts=%f\n", This, lBufferLen, SampleTime); | |
618 EnterCriticalSection(rb->pMutex); | |
619 if (rb->count >= rb->buffersize) { | |
620 rb->head = (rb->head + 1) % rb->buffersize; | |
621 rb->count--; | |
622 } | |
623 | |
624 memcpy(rb->ringbuffer[rb->tail], pBuffer, | |
625 lBufferLen < rb->blocksize ? lBufferLen : rb->blocksize); | |
626 rb->dpts[rb->tail] = SampleTime; | |
627 rb->tail = (rb->tail + 1) % rb->buffersize; | |
628 rb->count++; | |
629 LeaveCriticalSection(rb->pMutex); | |
630 | |
631 return S_OK; | |
632 } | |
633 | |
634 /// wrapper. directshow does the same when BufferCB callback is requested | |
33618
bdfb1aeb4b41
tvi_dshow: Mark functions not used outside of the file as static.
diego
parents:
32511
diff
changeset
|
635 static HRESULT STDCALL CSampleGrabberCB_SampleCB(ISampleGrabberCB *This, |
bdfb1aeb4b41
tvi_dshow: Mark functions not used outside of the file as static.
diego
parents:
32511
diff
changeset
|
636 double SampleTime, |
bdfb1aeb4b41
tvi_dshow: Mark functions not used outside of the file as static.
diego
parents:
32511
diff
changeset
|
637 LPMEDIASAMPLE pSample) |
24744 | 638 { |
639 char* buf; | |
640 long len; | |
641 long long tStart,tEnd; | |
642 HRESULT hr; | |
643 grabber_ringbuffer_t *rb = ((CSampleGrabberCB*)This)->pbuf; | |
644 | |
645 len=OLE_CALL(pSample,GetSize); | |
646 tStart=tEnd=0; | |
647 hr=OLE_CALL_ARGS(pSample,GetTime,&tStart,&tEnd); | |
648 if(FAILED(hr)){ | |
649 return hr; | |
650 } | |
651 mp_msg(MSGT_TV, MSGL_DBG4,"tvi_dshow: SampleCB(%p): %d/%d %f\n", This,rb->count,rb->buffersize,1e-7*tStart); | |
652 hr=OLE_CALL_ARGS(pSample,GetPointer,(void*)&buf); | |
653 if(FAILED(hr)){ | |
654 return hr; | |
655 } | |
656 hr=CSampleGrabberCB_BufferCB(This,1e-7*tStart,buf,len); | |
657 return hr; | |
658 | |
659 } | |
660 | |
661 /// main grabbing routine | |
662 static CSampleGrabberCB *CSampleGrabberCB_Create(grabber_ringbuffer_t * | |
663 pbuf) | |
664 { | |
665 CSampleGrabberCB *This = malloc(sizeof(CSampleGrabberCB)); | |
666 if (!This) | |
667 return NULL; | |
668 | |
669 This->lpVtbl = malloc(sizeof(ISampleGrabberVtbl)); | |
670 if (!This->lpVtbl) { | |
671 CSampleGrabberCB_Destroy(This); | |
672 return NULL; | |
673 } | |
674 This->refcount = 1; | |
675 This->lpVtbl->QueryInterface = CSampleGrabberCB_QueryInterface; | |
676 This->lpVtbl->AddRef = CSampleGrabberCB_AddRef; | |
677 This->lpVtbl->Release = CSampleGrabberCB_Release; | |
678 This->lpVtbl->SampleCB = CSampleGrabberCB_SampleCB; | |
679 This->lpVtbl->BufferCB = CSampleGrabberCB_BufferCB; | |
680 | |
681 This->interfaces[0] = IID_IUnknown; | |
682 This->interfaces[1] = IID_ISampleGrabberCB; | |
683 | |
684 This->pbuf = pbuf; | |
685 | |
686 return This; | |
687 } | |
688 | |
689 /* | |
690 *--------------------------------------------------------------------------------------- | |
691 * | |
692 * ROT related methods (register, unregister) | |
693 * | |
694 *--------------------------------------------------------------------------------------- | |
695 */ | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
696 /** |
24744 | 697 Registering graph in ROT. User will be able to connect to graph from GraphEdit. |
698 */ | |
699 static HRESULT AddToRot(IUnknown * pUnkGraph, DWORD * pdwRegister) | |
700 { | |
701 IMoniker *pMoniker; | |
702 IRunningObjectTable *pROT; | |
703 WCHAR wsz[256]; | |
704 HRESULT hr; | |
705 | |
706 if (FAILED(GetRunningObjectTable(0, &pROT))) { | |
707 return E_FAIL; | |
708 } | |
709 wsprintfW(wsz, L"FilterGraph %08x pid %08x", (DWORD_PTR) pUnkGraph, | |
710 GetCurrentProcessId()); | |
711 hr = CreateItemMoniker(L"!", wsz, &pMoniker); | |
712 if (SUCCEEDED(hr)) { | |
713 hr = OLE_CALL_ARGS(pROT, Register, ROTFLAGS_REGISTRATIONKEEPSALIVE, | |
714 pUnkGraph, pMoniker, pdwRegister); | |
715 OLE_RELEASE_SAFE(pMoniker); | |
716 } | |
717 OLE_RELEASE_SAFE(pROT); | |
718 return hr; | |
719 } | |
720 | |
721 /// Unregistering graph in ROT | |
722 static void RemoveFromRot(DWORD dwRegister) | |
723 { | |
724 IRunningObjectTable *pROT; | |
725 if (SUCCEEDED(GetRunningObjectTable(0, &pROT))) { | |
726 OLE_CALL_ARGS(pROT, Revoke, dwRegister); | |
727 OLE_RELEASE_SAFE(pROT); | |
728 } | |
729 } | |
730 | |
731 /* | |
732 *--------------------------------------------------------------------------------------- | |
733 * | |
734 * ringbuffer related methods (init, destroy) | |
735 * | |
736 *--------------------------------------------------------------------------------------- | |
737 */ | |
738 /** | |
739 * \brief ringbuffer destroying routine | |
740 * | |
741 * \param rb pointer to empty (just allocated) ringbuffer structure | |
742 * | |
743 * \note routine does not frees memory, allocated for grabber_rinbuffer_s structure | |
744 */ | |
745 static void destroy_ringbuffer(grabber_ringbuffer_t * rb) | |
746 { | |
747 int i; | |
748 | |
749 if (!rb) | |
750 return; | |
751 | |
752 if (rb->ringbuffer) { | |
753 for (i = 0; i < rb->buffersize; i++) | |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32141
diff
changeset
|
754 free(rb->ringbuffer[i]); |
24744 | 755 free(rb->ringbuffer); |
756 rb->ringbuffer = NULL; | |
757 } | |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32141
diff
changeset
|
758 free(rb->dpts); |
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32141
diff
changeset
|
759 rb->dpts = NULL; |
24744 | 760 if (rb->pMutex) { |
761 DeleteCriticalSection(rb->pMutex); | |
762 free(rb->pMutex); | |
763 rb->pMutex = NULL; | |
764 } | |
765 | |
766 rb->blocksize = 0; | |
767 rb->buffersize = 0; | |
768 rb->head = 0; | |
769 rb->tail = 0; | |
770 rb->count = 0; | |
771 } | |
772 | |
773 /** | |
774 * \brief ringbuffer initialization | |
775 * | |
776 * \param rb pointer to empty (just allocated) ringbuffer structure | |
777 * \param buffersize size of buffer in blocks | |
778 * \param blocksize size of buffer's block | |
779 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
780 * \return S_OK if success |
24744 | 781 * \return E_OUTOFMEMORY not enough memory |
782 * | |
783 * \note routine does not allocates memory for grabber_rinbuffer_s structure | |
784 */ | |
785 static HRESULT init_ringbuffer(grabber_ringbuffer_t * rb, int buffersize, | |
786 int blocksize) | |
787 { | |
788 int i; | |
789 | |
790 if (!rb) | |
791 return E_OUTOFMEMORY; | |
792 | |
793 rb->buffersize = buffersize < 2 ? 2 : buffersize; | |
794 rb->blocksize = blocksize; | |
795 | |
796 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Capture buffer: %d blocks of %d bytes.\n", | |
797 rb->buffersize, rb->blocksize); | |
798 | |
30702 | 799 rb->ringbuffer = malloc(rb->buffersize * sizeof(char *)); |
24744 | 800 if (!rb) |
801 return E_POINTER; | |
802 memset(rb->ringbuffer, 0, rb->buffersize * sizeof(char *)); | |
803 | |
804 for (i = 0; i < rb->buffersize; i++) { | |
30702 | 805 rb->ringbuffer[i] = malloc(rb->blocksize * sizeof(char)); |
24744 | 806 if (!rb->ringbuffer[i]) { |
807 destroy_ringbuffer(rb); | |
808 return E_OUTOFMEMORY; | |
809 } | |
810 } | |
30702 | 811 rb->dpts = malloc(rb->buffersize * sizeof(double)); |
24744 | 812 if (!rb->dpts) { |
813 destroy_ringbuffer(rb); | |
814 return E_OUTOFMEMORY; | |
815 } | |
816 rb->head = 0; | |
817 rb->tail = 0; | |
818 rb->count = 0; | |
819 rb->tStart = -1; | |
30702 | 820 rb->pMutex = malloc(sizeof(CRITICAL_SECTION)); |
24744 | 821 if (!rb->pMutex) { |
822 destroy_ringbuffer(rb); | |
823 return E_OUTOFMEMORY; | |
824 } | |
825 InitializeCriticalSection(rb->pMutex); | |
826 return S_OK; | |
827 } | |
828 | |
829 /* | |
830 *--------------------------------------------------------------------------------------- | |
831 * | |
832 * Tuner related methods (frequency, capabilities, etc | |
833 * | |
834 *--------------------------------------------------------------------------------------- | |
835 */ | |
836 /** | |
837 * \brief returns string with name for givend PsysCon_* constant | |
838 * | |
839 * \param lPhysicalType constant from PhysicalConnectorType enumeration | |
840 * | |
841 * \return pointer to string with apropriate name | |
842 * | |
843 * \note | |
844 * Caller should not free returned pointer | |
845 */ | |
846 static char *physcon2str(const long lPhysicalType) | |
847 { | |
848 int i; | |
849 for(i=0; tv_physcon_types[i].name; i++) | |
850 if(tv_physcon_types[i].type==lPhysicalType) | |
851 return tv_physcon_types[i].name; | |
852 return "Unknown"; | |
853 }; | |
854 | |
855 /** | |
856 * \brief converts MPlayer's chanlist to system country code. | |
857 * | |
858 * \param chanlist MPlayer's chanlist name | |
859 * | |
860 * \return system country code | |
861 * | |
862 * \remarks | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
863 * After call to IAMTVTuner::put_CountryCode with returned value tuner switches to frequency table used in specified |
24744 | 864 * country (which is usually larger then MPlayer's one, so workaround will work fine). |
865 * | |
866 * \todo | |
867 * Resolve trouble with cable channels (DirectShow's tuners must be switched between broadcast and cable channels modes. | |
868 */ | |
869 static int chanlist2country(char *chanlist) | |
870 { | |
871 int i; | |
872 for(i=0; tv_chanlist2country[i].chanlist_name; i++) | |
873 if (!strcmp(chanlist, tv_chanlist2country[i].chanlist_name)) | |
874 break; | |
875 return tv_chanlist2country[i].country_code; | |
876 } | |
877 | |
878 /** | |
879 * \brief loads specified resource from module and return pointer to it | |
880 * | |
881 * \param hDLL valid module desriptor | |
882 * \param index index of resource. resource with name "#<index>" will be loaded | |
883 * | |
884 * \return pointer to loader resource or NULL if error occured | |
885 */ | |
886 static void *GetRC(HMODULE hDLL, int index) | |
887 { | |
888 char szRCDATA[10]; | |
889 char szName[10]; | |
890 HRSRC hRes; | |
891 HGLOBAL hTable; | |
892 | |
893 snprintf(szRCDATA, 10, "#%d", (int)RT_RCDATA); | |
894 snprintf(szName, 10, "#%d", index); | |
895 | |
896 hRes = FindResource(hDLL, szName, szRCDATA); | |
897 if (!hRes) { | |
898 return NULL; | |
899 } | |
900 hTable = LoadResource(hDLL, hRes); | |
901 if (!hTable) { | |
902 return NULL; | |
903 } | |
904 return LockResource(hTable); | |
905 } | |
906 | |
907 /** | |
908 * \brief loads frequency table for given country from kstvtune.ax | |
909 * | |
910 * \param[in] nCountry - country code | |
911 * \param[in] nInputType (TunerInputCable or TunerInputAntenna) | |
912 * \param[out] pplFreqTable - address of variable that receives pointer to array, containing frequencies | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
913 * \param[out] pnLen length of array |
24744 | 914 * \param[out] pnFirst - channel number of first entry in array (nChannelMax) |
915 * | |
916 * \return S_OK if success | |
917 * \return E_POINTER pplFreqTable==NULL || plFirst==NULL || pnLen==NULL | |
918 * \return E_FAIL error occured during load | |
919 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
920 * \remarks |
24744 | 921 * - array must be freed by caller |
922 * - MSDN says that it is not neccessery to unlock or free resource. It will be done after unloading DLL | |
923 */ | |
924 static HRESULT load_freq_table(int nCountry, int nInputType, | |
925 long **pplFreqTable, int *pnLen, | |
926 int *pnFirst) | |
927 { | |
928 HMODULE hDLL; | |
929 long *plFreqTable; | |
930 TRCCountryList *pCountryList; | |
931 int i, index; | |
932 | |
27630
6fe56f6147ea
Add debug message about loaded frequency tables.
voroshil
parents:
27629
diff
changeset
|
933 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: load_freq_table called %d (%s)\n",nCountry,nInputType == TunerInputAntenna ? "broadcast" : "cable"); |
24744 | 934 /* ASSERT(sizeof(TRCCountryList)==10); // need properly aligned structure */ |
935 | |
936 if (!pplFreqTable || !pnFirst || !pnLen) | |
937 return E_POINTER; | |
938 if (!nCountry) | |
939 return E_FAIL; | |
940 | |
941 hDLL = LoadLibrary("kstvtune.ax"); | |
942 if (!hDLL) { | |
943 return E_FAIL; | |
944 } | |
945 pCountryList = GetRC(hDLL, 9999); | |
946 if (!pCountryList) { | |
947 FreeLibrary(hDLL); | |
948 return E_FAIL; | |
949 } | |
950 for (i = 0; pCountryList[i].CountryCode != 0; i++) | |
951 if (pCountryList[i].CountryCode == nCountry) | |
952 break; | |
953 if (pCountryList[i].CountryCode == 0) { | |
954 FreeLibrary(hDLL); | |
955 return E_FAIL; | |
956 } | |
957 if (nInputType == TunerInputCable) | |
958 index = pCountryList[i].CableFreqTable; | |
959 else | |
960 index = pCountryList[i].BroadcastFreqTable; | |
961 | |
962 plFreqTable = GetRC(hDLL, index); //First element is number of first channel, second - number of last channel | |
963 if (!plFreqTable) { | |
964 FreeLibrary(hDLL); | |
965 return E_FAIL; | |
966 } | |
967 *pnFirst = plFreqTable[0]; | |
968 *pnLen = (int) (plFreqTable[1] - plFreqTable[0] + 1); | |
30702 | 969 *pplFreqTable = malloc((*pnLen) * sizeof(long)); |
24744 | 970 if (!*pplFreqTable) { |
971 FreeLibrary(hDLL); | |
972 return E_FAIL; | |
973 } | |
974 for (i = 0; i < *pnLen; i++) { | |
975 (*pplFreqTable)[i] = plFreqTable[i + 2]; | |
27630
6fe56f6147ea
Add debug message about loaded frequency tables.
voroshil
parents:
27629
diff
changeset
|
976 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: load_freq_table #%d => (%ld)\n",i+*pnFirst,(*pplFreqTable)[i]); |
24744 | 977 } |
978 FreeLibrary(hDLL); | |
979 return S_OK; | |
980 } | |
981 | |
982 /** | |
983 * \brief tunes to given frequency through IKsPropertySet call | |
984 * | |
985 * \param pTVTuner IAMTVTuner interface of capture device | |
986 * \param lFreq frequency to tune (in Hz) | |
987 * | |
988 * \return S_OK success | |
989 * \return apropriate error code otherwise | |
990 * | |
991 * \note | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
992 * Due to either bug in driver or error in following code calll to IKsProperty::Set |
24744 | 993 * in this methods always fail with error 0x8007007a. |
994 * | |
995 * \todo test code on other machines and an error | |
996 */ | |
997 static HRESULT set_frequency_direct(IAMTVTuner * pTVTuner, long lFreq) | |
998 { | |
999 HRESULT hr; | |
1000 DWORD dwSupported = 0; | |
1001 DWORD cbBytes = 0; | |
1002 KSPROPERTY_TUNER_MODE_CAPS_S mode_caps; | |
1003 KSPROPERTY_TUNER_FREQUENCY_S frequency; | |
1004 IKsPropertySet *pKSProp; | |
1005 | |
1006 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: set_frequency_direct called\n"); | |
1007 | |
1008 memset(&mode_caps, 0, sizeof(mode_caps)); | |
1009 memset(&frequency, 0, sizeof(frequency)); | |
1010 | |
1011 hr = OLE_QUERYINTERFACE(pTVTuner, IID_IKsPropertySet, pKSProp); | |
1012 if (FAILED(hr)) | |
1013 return hr; //no IKsPropertySet interface | |
1014 | |
1015 mode_caps.Mode = AMTUNER_MODE_TV; | |
1016 hr = OLE_CALL_ARGS(pKSProp, QuerySupported, &PROPSETID_TUNER, | |
1017 KSPROPERTY_TUNER_MODE_CAPS, &dwSupported); | |
1018 if (FAILED(hr)) { | |
1019 OLE_RELEASE_SAFE(pKSProp); | |
1020 return hr; | |
1021 } | |
1022 | |
1023 if (!dwSupported & KSPROPERTY_SUPPORT_GET) { | |
1024 OLE_RELEASE_SAFE(pKSProp); | |
1025 return E_FAIL; //PROPSETID_TINER not supported | |
1026 } | |
1027 | |
1028 hr = OLE_CALL_ARGS(pKSProp, Get, &PROPSETID_TUNER, | |
1029 KSPROPERTY_TUNER_MODE_CAPS, | |
1030 INSTANCEDATA_OF_PROPERTY_PTR(&mode_caps), | |
1031 INSTANCEDATA_OF_PROPERTY_SIZE(mode_caps), | |
1032 &mode_caps, sizeof(mode_caps), &cbBytes); | |
1033 | |
1034 frequency.Frequency = lFreq; | |
1035 | |
1036 if (mode_caps.Strategy == KS_TUNER_STRATEGY_DRIVER_TUNES) | |
1037 frequency.TuningFlags = KS_TUNER_TUNING_FINE; | |
1038 else | |
1039 frequency.TuningFlags = KS_TUNER_TUNING_EXACT; | |
1040 | |
1041 if (lFreq < mode_caps.MinFrequency || lFreq > mode_caps.MaxFrequency) { | |
1042 OLE_RELEASE_SAFE(pKSProp); | |
1043 return E_FAIL; | |
1044 } | |
1045 | |
1046 hr = OLE_CALL_ARGS(pKSProp, Set, &PROPSETID_TUNER, | |
1047 KSPROPERTY_TUNER_FREQUENCY, | |
1048 INSTANCEDATA_OF_PROPERTY_PTR(&frequency), | |
1049 INSTANCEDATA_OF_PROPERTY_SIZE(frequency), | |
1050 &frequency, sizeof(frequency)); | |
1051 if (FAILED(hr)) { | |
1052 OLE_RELEASE_SAFE(pKSProp); | |
1053 return hr; | |
1054 } | |
1055 | |
1056 OLE_RELEASE_SAFE(pKSProp); | |
1057 | |
1058 return S_OK; | |
1059 } | |
1060 | |
1061 /** | |
1062 * \brief find channel with nearest frequency and set it | |
1063 * | |
1064 * \param priv driver's private data | |
1065 * \param lFreq frequency in Hz | |
1066 * | |
1067 * \return S_OK if success | |
1068 * \return E_FAIL if error occured | |
1069 */ | |
1070 static HRESULT set_nearest_freq(priv_t * priv, long lFreq) | |
1071 { | |
1072 HRESULT hr; | |
1073 int i; | |
1074 long lFreqDiff=-1; | |
1075 int nChannel; | |
1076 TunerInputType tunerInput; | |
1077 long lInput; | |
1078 | |
27629
d04568721d39
Make output messages of frequency selection code more useful by
voroshil
parents:
27628
diff
changeset
|
1079 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: set_nearest_freq called: %ld\n", lFreq); |
24744 | 1080 if(priv->freq_table_len == -1 && !priv->freq_table) { |
1081 | |
1082 hr = OLE_CALL_ARGS(priv->pTVTuner, get_ConnectInput, &lInput); | |
1083 if(FAILED(hr)){ //Falling back to 0 | |
1084 lInput=0; | |
1085 } | |
1086 | |
1087 hr = OLE_CALL_ARGS(priv->pTVTuner, get_InputType, lInput, &tunerInput); | |
1088 | |
1089 if (load_freq_table(chanlist2country(priv->tv_param->chanlist), tunerInput, &(priv->freq_table), &(priv->freq_table_len), &(priv->first_channel)) != S_OK) {//FIXME | |
1090 priv->freq_table_len=0; | |
1091 priv->freq_table=NULL; | |
1092 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableExtractFreqTable); | |
1093 return E_FAIL; | |
1094 }; | |
33827
277ec491a8a7
Do not translate console messages of verbosity level MSGL_V and above.
diego
parents:
33622
diff
changeset
|
1095 mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: loaded system (%s) frequency table for country id=%d (channels:%d).\n", tunerInput == TunerInputAntenna ? "broadcast" : "cable", |
24744 | 1096 chanlist2country(priv->tv_param->chanlist), priv->freq_table_len); |
1097 } | |
1098 | |
1099 if (priv->freq_table_len <= 0) | |
1100 return E_FAIL; | |
1101 | |
1102 //FIXME: rewrite search algo | |
1103 nChannel = -1; | |
1104 for (i = 0; i < priv->freq_table_len; i++) { | |
1105 if (nChannel == -1 || labs(lFreq - priv->freq_table[i]) < lFreqDiff) { | |
1106 nChannel = priv->first_channel + i; | |
1107 lFreqDiff = labs(lFreq - priv->freq_table[i]); | |
1108 } | |
27629
d04568721d39
Make output messages of frequency selection code more useful by
voroshil
parents:
27628
diff
changeset
|
1109 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: set_nearest_freq #%d (%ld) => %d (%ld)\n",i+priv->first_channel,priv->freq_table[i], nChannel,lFreqDiff); |
24744 | 1110 } |
1111 if (nChannel == -1) { | |
1112 mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_UnableFindNearestChannel); | |
1113 return E_FAIL; | |
1114 } | |
27629
d04568721d39
Make output messages of frequency selection code more useful by
voroshil
parents:
27628
diff
changeset
|
1115 mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: set_nearest_freq #%d (%ld)\n",nChannel,priv->freq_table[nChannel - priv->first_channel]); |
24744 | 1116 hr = OLE_CALL_ARGS(priv->pTVTuner, put_Channel, nChannel, |
1117 AMTUNER_SUBCHAN_DEFAULT, AMTUNER_SUBCHAN_DEFAULT); | |
1118 if (FAILED(hr)) { | |
1119 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableToSetChannel, (unsigned int)hr); | |
1120 return E_FAIL; | |
1121 } | |
1122 return S_OK; | |
1123 } | |
1124 | |
1125 /** | |
1126 * \brief setting frequency. decides whether use direct call/workaround | |
1127 * | |
1128 * \param priv driver's private data | |
1129 * \param lFreq frequency in Hz | |
1130 * | |
1131 * \return TVI_CONTROL_TRUE if success | |
1132 * \return TVI_CONTROL_FALSE if error occured | |
1133 * | |
1134 * \todo check for freq boundary | |
1135 */ | |
1136 static int set_frequency(priv_t * priv, long lFreq) | |
1137 { | |
1138 HRESULT hr; | |
1139 | |
27629
d04568721d39
Make output messages of frequency selection code more useful by
voroshil
parents:
27628
diff
changeset
|
1140 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: set_frequency called: %ld\n", lFreq); |
24744 | 1141 if (!priv->pTVTuner) |
1142 return TVI_CONTROL_FALSE; | |
1143 if (priv->direct_setfreq_call) { //using direct call to set frequency | |
1144 hr = set_frequency_direct(priv->pTVTuner, lFreq); | |
1145 if (FAILED(hr)) { | |
33827
277ec491a8a7
Do not translate console messages of verbosity level MSGL_V and above.
diego
parents:
33622
diff
changeset
|
1146 mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: Unable to set frequency directly. OS built-in channels table will be used.\n"); |
24744 | 1147 priv->direct_setfreq_call = 0; |
1148 } | |
1149 } | |
1150 if (!priv->direct_setfreq_call) { | |
1151 hr = set_nearest_freq(priv, lFreq); | |
1152 } | |
1153 if (FAILED(hr)) | |
1154 return TVI_CONTROL_FALSE; | |
1155 #ifdef DEPRECATED | |
1156 priv->pGrabber->ClearBuffer(priv->pGrabber); | |
1157 #endif | |
1158 return TVI_CONTROL_TRUE; | |
1159 } | |
1160 | |
1161 /** | |
1162 * \brief return current frequency from tuner (in Hz) | |
1163 * | |
1164 * \param pTVTuner IAMTVTuner interface of tuner | |
1165 * \param plFreq address of variable that receives current frequency | |
1166 * | |
1167 * \return S_OK success | |
1168 * \return E_POINTER pTVTuner==NULL || plFreq==NULL | |
1169 * \return apropriate error code otherwise | |
1170 */ | |
1171 static HRESULT get_frequency_direct(IAMTVTuner * pTVTuner, long *plFreq) | |
1172 { | |
1173 HRESULT hr; | |
1174 KSPROPERTY_TUNER_STATUS_S TunerStatus; | |
1175 DWORD cbBytes; | |
1176 IKsPropertySet *pKSProp; | |
1177 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: get_frequency_direct called\n"); | |
1178 | |
1179 if (!plFreq) | |
1180 return E_POINTER; | |
1181 | |
1182 hr = OLE_QUERYINTERFACE(pTVTuner, IID_IKsPropertySet, pKSProp); | |
1183 if (FAILED(hr)) { | |
1184 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Get freq QueryInterface failed\n"); | |
1185 return hr; | |
1186 } | |
1187 | |
1188 hr = OLE_CALL_ARGS(pKSProp, Get, &PROPSETID_TUNER, | |
1189 KSPROPERTY_TUNER_STATUS, | |
1190 INSTANCEDATA_OF_PROPERTY_PTR(&TunerStatus), | |
1191 INSTANCEDATA_OF_PROPERTY_SIZE(TunerStatus), | |
1192 &TunerStatus, sizeof(TunerStatus), &cbBytes); | |
1193 if (FAILED(hr)) { | |
1194 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Get freq Get failure\n"); | |
1195 return hr; | |
1196 } | |
1197 *plFreq = TunerStatus.CurrentFrequency; | |
1198 return S_OK; | |
1199 } | |
1200 | |
1201 /** | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
1202 * \brief gets current frequency |
24744 | 1203 * |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
1204 * \param priv driver's private data structure |
24744 | 1205 * \param plFreq - pointer to long int to store frequency to (in Hz) |
1206 * | |
1207 * \return TVI_CONTROL_TRUE if success, TVI_CONTROL_FALSE otherwise | |
1208 */ | |
1209 static int get_frequency(priv_t * priv, long *plFreq) | |
1210 { | |
1211 HRESULT hr; | |
1212 | |
1213 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: get_frequency called\n"); | |
1214 | |
1215 if (!plFreq || !priv->pTVTuner) | |
1216 return TVI_CONTROL_FALSE; | |
1217 | |
1218 if (priv->direct_getfreq_call) { //using direct call to get frequency | |
1219 hr = get_frequency_direct(priv->pTVTuner, plFreq); | |
1220 if (FAILED(hr)) { | |
1221 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_DirectGetFreqFailed); | |
1222 priv->direct_getfreq_call = 0; | |
1223 } | |
1224 } | |
1225 if (!priv->direct_getfreq_call) { | |
1226 hr=OLE_CALL_ARGS(priv->pTVTuner, get_VideoFrequency, plFreq); | |
1227 if (FAILED(hr)) | |
1228 return TVI_CONTROL_FALSE; | |
1229 | |
1230 } | |
1231 return TVI_CONTROL_TRUE; | |
1232 } | |
1233 | |
1234 /** | |
1235 * \brief get tuner capabilities | |
1236 * | |
1237 * \param priv driver's private data | |
1238 */ | |
1239 static void get_capabilities(priv_t * priv) | |
1240 { | |
1241 long lAvailableFormats; | |
1242 HRESULT hr; | |
1243 int i; | |
1244 long lInputPins, lOutputPins, lRelated, lPhysicalType; | |
1245 IEnumPins *pEnum; | |
1246 char tmp[200]; | |
1247 IPin *pPin = 0; | |
1248 PIN_DIRECTION ThisPinDir; | |
1249 PIN_INFO pi; | |
1250 IAMAudioInputMixer *pIAMixer; | |
1251 | |
1252 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: get_capabilities called\n"); | |
1253 if (priv->pTVTuner) { | |
1254 | |
33827
277ec491a8a7
Do not translate console messages of verbosity level MSGL_V and above.
diego
parents:
33622
diff
changeset
|
1255 mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: supported norms:"); |
24744 | 1256 hr = OLE_CALL_ARGS(priv->pTVTuner, get_AvailableTVFormats, |
1257 &lAvailableFormats); | |
1258 if (FAILED(hr)) | |
1259 tv_available_norms_count = 0; | |
1260 else { | |
1261 for (i = 0; i < TV_NORMS_COUNT; i++) { | |
1262 if (lAvailableFormats & tv_norms[i].index) { | |
1263 tv_available_norms[tv_available_norms_count] = i; | |
1264 mp_msg(MSGT_TV, MSGL_V, " %d=%s;", | |
1265 tv_available_norms_count + 1, tv_norms[i].name); | |
1266 tv_available_norms_count++; | |
1267 } | |
1268 } | |
1269 } | |
1270 mp_msg(MSGT_TV, MSGL_INFO, "\n"); | |
1271 } | |
1272 if (priv->pCrossbar) { | |
1273 OLE_CALL_ARGS(priv->pCrossbar, get_PinCounts, &lOutputPins, | |
1274 &lInputPins); | |
1275 | |
30702 | 1276 tv_available_inputs = malloc(sizeof(long) * lInputPins); |
24744 | 1277 tv_available_inputs_count = 0; |
1278 | |
33827
277ec491a8a7
Do not translate console messages of verbosity level MSGL_V and above.
diego
parents:
33622
diff
changeset
|
1279 mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: available video inputs:"); |
24744 | 1280 for (i = 0; i < lInputPins; i++) { |
1281 OLE_CALL_ARGS(priv->pCrossbar, get_CrossbarPinInfo, 1, i, | |
1282 &lRelated, &lPhysicalType); | |
1283 | |
1284 if (lPhysicalType < 0x1000) { | |
1285 tv_available_inputs[tv_available_inputs_count++] = i; | |
1286 mp_msg(MSGT_TV, MSGL_V, " %d=%s;", | |
1287 tv_available_inputs_count - 1, | |
1288 physcon2str(lPhysicalType)); | |
1289 } | |
1290 } | |
1291 mp_msg(MSGT_TV, MSGL_INFO, "\n"); | |
1292 | |
1293 set_crossbar_input(priv, 0); | |
1294 } | |
1295 | |
1296 if (priv->adev_index != -1) { | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
1297 hr = OLE_CALL_ARGS(priv->chains[1]->pCaptureFilter, EnumPins, &pEnum); |
24744 | 1298 if (FAILED(hr)) |
1299 return; | |
33827
277ec491a8a7
Do not translate console messages of verbosity level MSGL_V and above.
diego
parents:
33622
diff
changeset
|
1300 mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: available audio inputs:"); |
24744 | 1301 i = 0; |
1302 while (OLE_CALL_ARGS(pEnum, Next, 1, &pPin, NULL) == S_OK) { | |
1303 memset(&pi, 0, sizeof(pi)); | |
1304 memset(tmp, 0, 200); | |
1305 OLE_CALL_ARGS(pPin, QueryDirection, &ThisPinDir); | |
1306 if (ThisPinDir == PINDIR_INPUT) { | |
1307 OLE_CALL_ARGS(pPin, QueryPinInfo, &pi); | |
1308 wtoa(pi.achName, tmp, 200); | |
1309 OLE_RELEASE_SAFE(pi.pFilter); | |
1310 mp_msg(MSGT_TV, MSGL_V, " %d=%s", i, tmp); | |
1311 mp_msg(MSGT_TV, MSGL_DBG3, " (%p)", pPin); | |
1312 hr = OLE_QUERYINTERFACE(pPin, IID_IAMAudioInputMixer,pIAMixer); | |
1313 if (SUCCEEDED(hr)) { | |
1314 if (i == priv->tv_param->audio_id) { | |
1315 OLE_CALL_ARGS(pIAMixer, put_Enable, TRUE); | |
1316 if(priv->tv_param->volume>0) | |
1317 OLE_CALL_ARGS(pIAMixer, put_MixLevel, 0.01 * priv->tv_param->volume); | |
1318 #if 0 | |
1319 else | |
1320 OLE_CALL_ARGS(pIAMixer, put_MixLevel, 1.0); | |
1321 #endif | |
33827
277ec491a8a7
Do not translate console messages of verbosity level MSGL_V and above.
diego
parents:
33622
diff
changeset
|
1322 mp_msg(MSGT_TV, MSGL_V, "(selected)"); |
24744 | 1323 } else { |
1324 OLE_CALL_ARGS(pIAMixer, put_Enable, FALSE); | |
1325 #if 0 | |
1326 OLE_CALL_ARGS(pIAMixer, put_MixLevel, 0.0); | |
1327 #endif | |
1328 } | |
1329 OLE_RELEASE_SAFE(pIAMixer); | |
1330 } | |
1331 mp_msg(MSGT_TV, MSGL_V, ";"); | |
1332 OLE_RELEASE_SAFE(pPin); | |
1333 i++; | |
1334 } | |
1335 } | |
1336 mp_msg(MSGT_TV, MSGL_INFO, "\n"); | |
1337 OLE_RELEASE_SAFE(pEnum); | |
1338 } | |
1339 } | |
1340 | |
1341 /* | |
1342 *--------------------------------------------------------------------------------------- | |
1343 * | |
1344 * Filter related methods | |
1345 * | |
1346 *--------------------------------------------------------------------------------------- | |
1347 */ | |
1348 /** | |
1349 * \brief building in graph audio/video capture chain | |
1350 * | |
1351 * \param priv driver's private data | |
1352 * \param pCaptureFilter pointer to capture device's IBaseFilter interface | |
1353 * \param pbuf ringbuffer data structure | |
1354 * \param pmt media type for chain (AM_MEDIA_TYPE) | |
1355 * | |
1356 * \note routine does not frees memory, allocated for grabber_rinbuffer_s structure | |
1357 */ | |
25084
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
1358 static HRESULT build_sub_graph(priv_t * priv, chain_t * chain, const GUID* ppin_category) |
24744 | 1359 { |
1360 HRESULT hr; | |
25063
29260745e4fa
Pass all available formats to chain building routine and
voroshil
parents:
25061
diff
changeset
|
1361 int nFormatProbed = 0; |
25029
c9f20e41bc13
Make sure that mplayer will receive actual media type
voroshil
parents:
25028
diff
changeset
|
1362 |
24744 | 1363 IPin *pSGOut; |
1364 IPin *pNRIn=NULL; | |
1365 | |
1366 IBaseFilter *pNR = NULL; | |
1367 | |
1368 hr=S_OK; | |
25063
29260745e4fa
Pass all available formats to chain building routine and
voroshil
parents:
25061
diff
changeset
|
1369 |
29260745e4fa
Pass all available formats to chain building routine and
voroshil
parents:
25061
diff
changeset
|
1370 //No supported formats |
25084
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
1371 if(!chain->arpmt[0]) |
25063
29260745e4fa
Pass all available formats to chain building routine and
voroshil
parents:
25061
diff
changeset
|
1372 return E_FAIL; |
29260745e4fa
Pass all available formats to chain building routine and
voroshil
parents:
25061
diff
changeset
|
1373 |
24744 | 1374 do{ |
1375 hr = OLE_CALL_ARGS(priv->pBuilder, FindPin, | |
25084
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
1376 (IUnknown *) chain->pCaptureFilter, |
24744 | 1377 PINDIR_OUTPUT, ppin_category, |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1378 chain->majortype, FALSE, 0, &chain->pCapturePin); |
24744 | 1379 if(FAILED(hr)){ |
1380 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: FindPin(pCapturePin) call failed. Error:0x%x\n", (unsigned int)hr); | |
1381 break; | |
1382 } | |
1383 /* Addinf SampleGrabber filter for video stream */ | |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1384 hr = CoCreateInstance((GUID *) & CLSID_SampleGrabber, NULL,CLSCTX_INPROC_SERVER, &IID_IBaseFilter,(void *) &chain->pSGF); |
24744 | 1385 if(FAILED(hr)){ |
1386 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: CoCreateInstance(SampleGrabber) call failed. Error:0x%x\n", (unsigned int)hr); | |
1387 break; | |
1388 } | |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1389 hr = OLE_CALL_ARGS(priv->pGraph, AddFilter, chain->pSGF, L"Sample Grabber"); |
24744 | 1390 if(FAILED(hr)){ |
1391 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: AddFilter(SampleGrabber) call failed. Error:0x%x\n", (unsigned int)hr); | |
1392 break; | |
1393 } | |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1394 hr = OLE_CALL_ARGS(priv->pBuilder, FindPin, (IUnknown *) chain->pSGF,PINDIR_INPUT, NULL, NULL, FALSE, 0, &chain->pSGIn); |
24744 | 1395 if(FAILED(hr)){ |
1396 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: FindPin(pSGIn) call failed. Error:0x%x\n", (unsigned int)hr); | |
1397 break; | |
1398 } | |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1399 hr = OLE_CALL_ARGS(priv->pBuilder, FindPin, (IUnknown *) chain->pSGF,PINDIR_OUTPUT, NULL, NULL, FALSE, 0, &pSGOut); |
24744 | 1400 if(FAILED(hr)){ |
1401 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: FindPin(pSGOut) call failed. Error:0x%x\n", (unsigned int)hr); | |
1402 break; | |
1403 } | |
1404 | |
1405 /* creating ringbuffer for video samples */ | |
25086
e91503fbf524
Move pointer to SampleGrabber filter into chain structure.
voroshil
parents:
25085
diff
changeset
|
1406 chain->pCSGCB = CSampleGrabberCB_Create(chain->rbuf); |
e91503fbf524
Move pointer to SampleGrabber filter into chain structure.
voroshil
parents:
25085
diff
changeset
|
1407 if(!chain->pCSGCB){ |
24744 | 1408 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: CSampleGrabberCB_Create(pbuf) call failed. Error:0x%x\n", (unsigned int)E_OUTOFMEMORY); |
1409 break; | |
1410 } | |
1411 | |
1412 /* initializing SampleGrabber filter */ | |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1413 hr = OLE_QUERYINTERFACE(chain->pSGF, IID_ISampleGrabber, chain->pSG); |
24744 | 1414 if(FAILED(hr)){ |
1415 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: QueryInterface(IID_ISampleGrabber) call failed. Error:0x%x\n", (unsigned int)hr); | |
1416 break; | |
1417 } | |
1418 // hr = OLE_CALL_ARGS(pSG, SetCallback, (ISampleGrabberCB *) pCSGCB, 1); //we want to receive copy of sample's data | |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1419 hr = OLE_CALL_ARGS(chain->pSG, SetCallback, (ISampleGrabberCB *) chain->pCSGCB, 0); //we want to receive sample |
24744 | 1420 |
1421 if(FAILED(hr)){ | |
1422 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: SetCallback(pSG) call failed. Error:0x%x\n", (unsigned int)hr); | |
1423 break; | |
1424 } | |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1425 hr = OLE_CALL_ARGS(chain->pSG, SetOneShot, FALSE); //... for all frames |
24744 | 1426 if(FAILED(hr)){ |
1427 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: SetOneShot(pSG) call failed. Error:0x%x\n", (unsigned int)hr); | |
1428 break; | |
1429 } | |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1430 hr = OLE_CALL_ARGS(chain->pSG, SetBufferSamples, FALSE); //... do not buffer samples in sample grabber |
24744 | 1431 if(FAILED(hr)){ |
1432 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: SetBufferSamples(pSG) call failed. Error:0x%x\n", (unsigned int)hr); | |
1433 break; | |
1434 } | |
25084
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
1435 |
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
1436 if(priv->tv_param->normalize_audio_chunks && chain->type==audio){ |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1437 set_buffer_preference(20,(WAVEFORMATEX*)(chain->arpmt[nFormatProbed]->pbFormat),chain->pCapturePin,chain->pSGIn); |
25048 | 1438 } |
24744 | 1439 |
25084
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
1440 for(nFormatProbed=0; chain->arpmt[nFormatProbed]; nFormatProbed++) |
25065 | 1441 { |
25084
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
1442 DisplayMediaType("Probing format", chain->arpmt[nFormatProbed]); |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1443 hr = OLE_CALL_ARGS(chain->pSG, SetMediaType, chain->arpmt[nFormatProbed]); //set desired mediatype |
25066 | 1444 if(FAILED(hr)){ |
1445 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: SetMediaType(pSG) call failed. Error:0x%x\n", (unsigned int)hr); | |
1446 continue; | |
1447 } | |
1448 /* connecting filters together: VideoCapture --> SampleGrabber */ | |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1449 hr = OLE_CALL_ARGS(priv->pGraph, Connect, chain->pCapturePin, chain->pSGIn); |
25066 | 1450 if(FAILED(hr)){ |
1451 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: Unable to create pCapturePin<->pSGIn connection. Error:0x%x\n", (unsigned int)hr); | |
1452 continue; | |
1453 } | |
25065 | 1454 break; |
1455 } | |
1456 | |
25084
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
1457 if(!chain->arpmt[nFormatProbed]) |
25065 | 1458 { |
1459 mp_msg(MSGT_TV, MSGL_WARN, "tvi_dshow: Unable to negotiate media format\n"); | |
1460 hr = E_FAIL; | |
24744 | 1461 break; |
1462 } | |
25063
29260745e4fa
Pass all available formats to chain building routine and
voroshil
parents:
25061
diff
changeset
|
1463 |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1464 hr = OLE_CALL_ARGS(chain->pCapturePin, ConnectionMediaType, chain->pmt); |
25029
c9f20e41bc13
Make sure that mplayer will receive actual media type
voroshil
parents:
25028
diff
changeset
|
1465 if(FAILED(hr)) |
c9f20e41bc13
Make sure that mplayer will receive actual media type
voroshil
parents:
25028
diff
changeset
|
1466 { |
c9f20e41bc13
Make sure that mplayer will receive actual media type
voroshil
parents:
25028
diff
changeset
|
1467 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TVI_DS_GetActualMediatypeFailed, (unsigned int)hr); |
c9f20e41bc13
Make sure that mplayer will receive actual media type
voroshil
parents:
25028
diff
changeset
|
1468 } |
24744 | 1469 |
1470 if(priv->tv_param->hidden_video_renderer){ | |
1471 IEnumFilters* pEnum; | |
1472 IBaseFilter* pFilter; | |
1473 | |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
1474 hr=OLE_CALL_ARGS(priv->pBuilder,RenderStream,NULL,NULL,(IUnknown*)chain->pCapturePin,NULL,NULL); |
24744 | 1475 |
1476 OLE_CALL_ARGS(priv->pGraph, EnumFilters, &pEnum); | |
1477 while (OLE_CALL_ARGS(pEnum, Next, 1, &pFilter, NULL) == S_OK) { | |
1478 LPVIDEOWINDOW pVideoWindow; | |
1479 hr = OLE_QUERYINTERFACE(pFilter, IID_IVideoWindow, pVideoWindow); | |
1480 if (SUCCEEDED(hr)) | |
1481 { | |
1482 OLE_CALL_ARGS(pVideoWindow,put_Visible,/* OAFALSE*/ 0); | |
1483 OLE_CALL_ARGS(pVideoWindow,put_AutoShow,/* OAFALSE*/ 0); | |
1484 OLE_RELEASE_SAFE(pVideoWindow); | |
1485 } | |
1486 OLE_RELEASE_SAFE(pFilter); | |
1487 } | |
1488 OLE_RELEASE_SAFE(pEnum); | |
1489 }else | |
1490 { | |
25052
7b2b17b57cf7
Disable terminating directshow chains with NullRenderer filter,
voroshil
parents:
25051
diff
changeset
|
1491 #if 0 |
7b2b17b57cf7
Disable terminating directshow chains with NullRenderer filter,
voroshil
parents:
25051
diff
changeset
|
1492 /* |
7b2b17b57cf7
Disable terminating directshow chains with NullRenderer filter,
voroshil
parents:
25051
diff
changeset
|
1493 Code below is disabled, because terminating chain with NullRenderer leads to jerky video. |
7b2b17b57cf7
Disable terminating directshow chains with NullRenderer filter,
voroshil
parents:
25051
diff
changeset
|
1494 Perhaps, this happens because NullRenderer filter discards each received |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
1495 frame while discarded frames causes live source filter to dramatically reduce frame rate. |
25052
7b2b17b57cf7
Disable terminating directshow chains with NullRenderer filter,
voroshil
parents:
25051
diff
changeset
|
1496 */ |
24744 | 1497 /* adding sink for video stream */ |
1498 hr = CoCreateInstance((GUID *) & CLSID_NullRenderer, NULL,CLSCTX_INPROC_SERVER, &IID_IBaseFilter,(void *) &pNR); | |
1499 if(FAILED(hr)){ | |
1500 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: CoCreateInstance(NullRenderer) call failed. Error:0x%x\n", (unsigned int)hr); | |
1501 break; | |
1502 } | |
1503 hr = OLE_CALL_ARGS(priv->pGraph, AddFilter, pNR, L"Null Renderer"); | |
1504 if(FAILED(hr)){ | |
1505 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: AddFilter(NullRenderer) call failed. Error:0x%x\n", (unsigned int)hr); | |
1506 break; | |
1507 } | |
1508 hr = OLE_CALL_ARGS(priv->pBuilder, FindPin, (IUnknown *) pNR,PINDIR_INPUT, NULL, NULL, FALSE, 0, &pNRIn); | |
1509 if(FAILED(hr)){ | |
1510 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: FindPin(pNRIn) call failed. Error:0x%x\n", (unsigned int)hr); | |
1511 break; | |
1512 } | |
1513 /* | |
1514 Prevent ending VBI chain with NullRenderer filter, because this causes VBI pin disconnection | |
1515 */ | |
25063
29260745e4fa
Pass all available formats to chain building routine and
voroshil
parents:
25061
diff
changeset
|
1516 if(memcmp(&(arpmt[nFormatProbed]->majortype),&MEDIATYPE_VBI,16)){ |
24744 | 1517 /* connecting filters together: SampleGrabber --> NullRenderer */ |
1518 hr = OLE_CALL_ARGS(priv->pGraph, Connect, pSGOut, pNRIn); | |
1519 if(FAILED(hr)){ | |
1520 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: Unable to create pSGOut<->pNRIn connection. Error:0x%x\n", (unsigned int)hr); | |
1521 break; | |
1522 } | |
1523 } | |
25052
7b2b17b57cf7
Disable terminating directshow chains with NullRenderer filter,
voroshil
parents:
25051
diff
changeset
|
1524 #endif |
24744 | 1525 } |
1526 | |
1527 hr = S_OK; | |
1528 } while(0); | |
25029
c9f20e41bc13
Make sure that mplayer will receive actual media type
voroshil
parents:
25028
diff
changeset
|
1529 |
24744 | 1530 OLE_RELEASE_SAFE(pSGOut); |
1531 OLE_RELEASE_SAFE(pNR); | |
1532 OLE_RELEASE_SAFE(pNRIn); | |
1533 | |
1534 return hr; | |
1535 } | |
1536 | |
1537 /** | |
1538 * \brief configures crossbar for grabbing video stream from given input | |
1539 * | |
1540 * \param priv driver's private data | |
1541 * \param input index of available video input to get data from | |
1542 * | |
1543 * \return TVI_CONTROL_TRUE success | |
1544 * \return TVI_CONTROL_FALSE error | |
1545 */ | |
1546 static int set_crossbar_input(priv_t * priv, int input) | |
1547 { | |
1548 HRESULT hr; | |
1549 int i, nVideoDecoder, nAudioDecoder; | |
1550 long lInput, lInputRelated, lRelated, lPhysicalType, lOutputPins, | |
1551 lInputPins; | |
1552 | |
1553 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: Configuring crossbar\n"); | |
1554 if (!priv->pCrossbar || input < 0 | |
1555 || input >= tv_available_inputs_count) | |
1556 return TVI_CONTROL_FALSE; | |
1557 | |
1558 OLE_CALL_ARGS(priv->pCrossbar, get_PinCounts, &lOutputPins, &lInputPins); | |
1559 | |
1560 lInput = tv_available_inputs[input]; | |
1561 | |
1562 if (lInput < 0 || lInput >= lInputPins) | |
1563 return TVI_CONTROL_FALSE; | |
1564 | |
1565 OLE_CALL_ARGS(priv->pCrossbar, get_CrossbarPinInfo, 1 /* input */ , lInput, | |
1566 &lInputRelated, &lPhysicalType); | |
1567 | |
1568 nVideoDecoder = nAudioDecoder = -1; | |
1569 for (i = 0; i < lOutputPins; i++) { | |
1570 OLE_CALL_ARGS(priv->pCrossbar, get_CrossbarPinInfo, 0 /*output */ , i, | |
1571 &lRelated, &lPhysicalType); | |
1572 if (lPhysicalType == PhysConn_Video_VideoDecoder) | |
1573 nVideoDecoder = i; | |
1574 if (lPhysicalType == PhysConn_Audio_AudioDecoder) | |
1575 nAudioDecoder = i; | |
1576 } | |
1577 if (nVideoDecoder >= 0) { | |
1578 //connecting given input with video decoder | |
1579 hr = OLE_CALL_ARGS(priv->pCrossbar, Route, nVideoDecoder, lInput); | |
1580 if (hr != S_OK) { | |
1581 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableConnectInputVideoDecoder, (unsigned int)hr); | |
1582 return TVI_CONTROL_FALSE; | |
1583 } | |
1584 } | |
1585 if (nAudioDecoder >= 0 && lInputRelated >= 0) { | |
1586 hr = OLE_CALL_ARGS(priv->pCrossbar, Route, nAudioDecoder, | |
1587 lInputRelated); | |
1588 if (hr != S_OK) { | |
1589 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableConnectInputAudioDecoder, (unsigned int)hr); | |
1590 return TVI_CONTROL_FALSE; | |
1591 } | |
1592 } | |
1593 return TVI_CONTROL_TRUE; | |
1594 } | |
1595 | |
1596 /** | |
1597 * \brief adjusts video control (hue,saturation,contrast,brightess) | |
1598 * | |
1599 * \param priv driver's private data | |
1600 * \param control which control to adjust | |
1601 * \param value new value for control (0-100) | |
1602 * | |
1603 * \return TVI_CONTROL_TRUE success | |
1604 * \return TVI_CONTROL_FALSE error | |
1605 */ | |
1606 static int set_control(priv_t * priv, int control, int value) | |
1607 { | |
1608 long lMin, lMax, lStepping, lDefault, lFlags, lValue; | |
1609 HRESULT hr; | |
1610 | |
1611 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: set_control called\n"); | |
1612 if (value < -100 || value > 100 || !priv->pVideoProcAmp) | |
1613 return TVI_CONTROL_FALSE; | |
1614 | |
1615 hr = OLE_CALL_ARGS(priv->pVideoProcAmp, GetRange, control, | |
1616 &lMin, &lMax, &lStepping, &lDefault, &lFlags); | |
1617 if (FAILED(hr) || lFlags != VideoProcAmp_Flags_Manual) | |
1618 return TVI_CONTROL_FALSE; | |
1619 | |
1620 lValue = lMin + (value + 100) * (lMax - lMin) / 200; | |
1621 /* | |
1622 Workaround for ATI AIW 7500. The driver reports: max=255, stepping=256 | |
1623 */ | |
1624 if (lStepping > lMax) { | |
1625 mp_msg(MSGT_TV, MSGL_DBG3, | |
1626 "tvi_dshow: Stepping (%ld) is bigger than max value (%ld) for control %d. Assuming 1\n", | |
1627 lStepping, lMax,control); | |
1628 lStepping = 1; | |
1629 } | |
1630 lValue -= lValue % lStepping; | |
1631 hr = OLE_CALL_ARGS(priv->pVideoProcAmp, Set, control, lValue, | |
1632 VideoProcAmp_Flags_Manual); | |
1633 if (FAILED(hr)) | |
1634 return TVI_CONTROL_FALSE; | |
1635 | |
1636 return TVI_CONTROL_TRUE; | |
1637 } | |
1638 | |
1639 /** | |
1640 * \brief get current value of video control (hue,saturation,contrast,brightess) | |
1641 * | |
1642 * \param priv driver's private data | |
1643 * \param control which control to adjust | |
1644 * \param pvalue address of variable thar receives current value | |
1645 * | |
1646 * \return TVI_CONTROL_TRUE success | |
1647 * \return TVI_CONTROL_FALSE error | |
1648 */ | |
1649 static int get_control(priv_t * priv, int control, int *pvalue) | |
1650 { | |
1651 long lMin, lMax, lStepping, lDefault, lFlags, lValue; | |
1652 HRESULT hr; | |
1653 | |
1654 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: get_control called\n"); | |
1655 if (!pvalue || !priv->pVideoProcAmp) | |
1656 return TVI_CONTROL_FALSE; | |
1657 | |
1658 hr = OLE_CALL_ARGS(priv->pVideoProcAmp, GetRange, control, | |
1659 &lMin, &lMax, &lStepping, &lDefault, &lFlags); | |
1660 if (FAILED(hr)) | |
1661 return TVI_CONTROL_FALSE; | |
1662 if (lMin == lMax) { | |
1663 *pvalue = lMin; | |
1664 return TVI_CONTROL_TRUE; | |
1665 } | |
1666 | |
1667 hr = OLE_CALL_ARGS(priv->pVideoProcAmp, Get, control, &lValue, &lFlags); | |
1668 if (FAILED(hr)) | |
1669 return TVI_CONTROL_FALSE; | |
1670 | |
1671 *pvalue = 200 * (lValue - lMin) / (lMax - lMin) - 100; | |
1672 | |
1673 return TVI_CONTROL_TRUE; | |
1674 } | |
1675 | |
1676 /** | |
25053
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1677 * \brief create AM_MEDIA_TYPE structure, corresponding to given FourCC code and width/height/fps |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1678 * \param fcc FourCC code for video format |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1679 * \param width picture width |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1680 * \param height pciture height |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1681 * \param fps frames per second (required for bitrate calculation) |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1682 * |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1683 * \return pointer to AM_MEDIA_TYPE structure if success, NULL - otherwise |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1684 */ |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1685 static AM_MEDIA_TYPE* create_video_format(int fcc, int width, int height, int fps) |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1686 { |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1687 int i; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1688 AM_MEDIA_TYPE mt; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1689 VIDEOINFOHEADER vHdr; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1690 |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1691 /* Check given fcc in lookup table*/ |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1692 for(i=0; img_fmt_list[i].fmt && img_fmt_list[i].fmt!=fcc; i++) /* NOTHING */; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1693 if(!img_fmt_list[i].fmt) |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1694 return NULL; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1695 |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1696 memset(&mt, 0, sizeof(AM_MEDIA_TYPE)); |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1697 memset(&vHdr, 0, sizeof(VIDEOINFOHEADER)); |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1698 |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1699 vHdr.bmiHeader.biSize = sizeof(vHdr.bmiHeader); |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1700 vHdr.bmiHeader.biWidth = width; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1701 vHdr.bmiHeader.biHeight = height; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1702 //FIXME: is biPlanes required too? |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1703 //vHdr.bmiHeader.biPlanes = img_fmt_list[i].nPlanes; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1704 vHdr.bmiHeader.biBitCount = img_fmt_list[i].nBits; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1705 vHdr.bmiHeader.biCompression = img_fmt_list[i].nCompression; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1706 vHdr.bmiHeader.biSizeImage = width * height * img_fmt_list[i].nBits / 8; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1707 vHdr.dwBitRate = vHdr.bmiHeader.biSizeImage * 8 * fps; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1708 |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1709 mt.pbFormat = (char*)&vHdr; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1710 mt.cbFormat = sizeof(vHdr); |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1711 |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1712 mt.majortype = MEDIATYPE_Video; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1713 mt.subtype = *img_fmt_list[i].subtype; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1714 mt.formattype = FORMAT_VideoInfo; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1715 |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1716 mt.bFixedSizeSamples = 1; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1717 mt.bTemporalCompression = 0; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1718 mt.lSampleSize = vHdr.bmiHeader.biSizeImage; |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1719 |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1720 return CreateMediaType(&mt); |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1721 } |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1722 |
086c2accaaa2
Service routine for constructing AM_MEDIA_TYPE structure from
voroshil
parents:
25052
diff
changeset
|
1723 /** |
24744 | 1724 * \brief extracts fcc,width,height from AM_MEDIA_TYPE |
1725 * | |
1726 * \param pmt pointer to AM_MEDIA_TYPE to extract data from | |
1727 * \param pfcc address of variable that receives FourCC | |
1728 * \param pwidth address of variable that receives width | |
1729 * \param pheight address of variable that recevies height | |
1730 * | |
1731 * \return 1 if data extracted successfully, 0 - otherwise | |
1732 */ | |
1733 static int extract_video_format(AM_MEDIA_TYPE * pmt, int *pfcc, | |
1734 int *pwidth, int *pheight) | |
1735 { | |
1736 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: extract_video_format called\n"); | |
1737 if (!pmt) | |
1738 return 0; | |
1739 if (!pmt->pbFormat) | |
1740 return 0; | |
1741 if (memcmp(&(pmt->formattype), &FORMAT_VideoInfo, 16) != 0) | |
1742 return 0; | |
1743 if (pfcc) | |
1744 *pfcc = subtype2imgfmt(&(pmt->subtype)); | |
1745 if (pwidth) | |
1746 *pwidth = ((VIDEOINFOHEADER *) pmt->pbFormat)->bmiHeader.biWidth; | |
1747 if (pheight) | |
1748 *pheight = ((VIDEOINFOHEADER *) pmt->pbFormat)->bmiHeader.biHeight; | |
1749 return 1; | |
1750 } | |
1751 | |
1752 /** | |
1753 * \brief extracts samplerate,bits,channels from AM_MEDIA_TYPE | |
1754 * | |
1755 * \param pmt pointer to AM_MEDIA_TYPE to extract data from | |
1756 * \param pfcc address of variable that receives samplerate | |
1757 * \param pwidth address of variable that receives number of bits per sample | |
1758 * \param pheight address of variable that recevies number of channels | |
1759 * | |
1760 * \return 1 if data extracted successfully, 0 - otherwise | |
1761 */ | |
1762 static int extract_audio_format(AM_MEDIA_TYPE * pmt, int *psamplerate, | |
1763 int *pbits, int *pchannels) | |
1764 { | |
1765 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: extract_audio_format called\n"); | |
1766 if (!pmt) | |
1767 return 0; | |
1768 if (!pmt->pbFormat) | |
1769 return 0; | |
1770 if (memcmp(&(pmt->formattype), &FORMAT_WaveFormatEx, 16) != 0) | |
1771 return 0; | |
1772 if (psamplerate) | |
1773 *psamplerate = ((WAVEFORMATEX *) pmt->pbFormat)->nSamplesPerSec; | |
1774 if (pbits) | |
1775 *pbits = ((WAVEFORMATEX *) pmt->pbFormat)->wBitsPerSample; | |
1776 if (pchannels) | |
1777 *pchannels = ((WAVEFORMATEX *) pmt->pbFormat)->nChannels; | |
1778 return 1; | |
1779 } | |
1780 | |
1781 /** | |
1782 * \brief checks if AM_MEDIA_TYPE compatible with given samplerate,bits,channels | |
1783 * | |
1784 * \param pmt pointer to AM_MEDIA_TYPE for check | |
1785 * \param samplerate audio samplerate | |
1786 * \param bits bits per sample | |
1787 * \param channels number of audio channels | |
1788 * | |
1789 * \return 1 if AM_MEDIA_TYPE compatible | |
1790 * \return 0 if not | |
1791 */ | |
1792 static int check_audio_format(AM_MEDIA_TYPE * pmt, int samplerate, | |
1793 int bits, int channels) | |
1794 { | |
1795 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: check_audio_format called\n"); | |
1796 if (!pmt) | |
1797 return 0; | |
1798 if (memcmp(&(pmt->majortype), &MEDIATYPE_Audio, 16) != 0) | |
1799 return 0; | |
1800 if (memcmp(&(pmt->subtype), &MEDIASUBTYPE_PCM, 16) != 0) | |
1801 return 0; | |
1802 if (memcmp(&(pmt->formattype), &FORMAT_WaveFormatEx, 16) != 0) | |
1803 return 0; | |
1804 if (!pmt->pbFormat) | |
1805 return 0; | |
1806 if (((WAVEFORMATEX *) pmt->pbFormat)->nSamplesPerSec != samplerate) | |
1807 return 0; | |
1808 if (((WAVEFORMATEX *) pmt->pbFormat)->wBitsPerSample != bits) | |
1809 return 0; | |
1810 if (channels > 0 | |
1811 && ((WAVEFORMATEX *) pmt->pbFormat)->nChannels != channels) | |
1812 return 0; | |
1813 | |
1814 return 1; | |
1815 } | |
1816 | |
1817 /** | |
1818 * \brief checks if AM_MEDIA_TYPE compatible with given fcc,width,height | |
1819 * | |
1820 * \param pmt pointer to AM_MEDIA_TYPE for check | |
1821 * \param fcc FourCC (compression) | |
1822 * \param width width of picture | |
1823 * \param height height of picture | |
1824 * | |
1825 * \return 1 if AM_MEDIA_TYPE compatible | |
1826 & \return 0 if not | |
1827 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
1828 * \note |
24744 | 1829 * width and height are currently not used |
1830 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
1831 * \todo |
24744 | 1832 * add width/height check |
1833 */ | |
1834 static int check_video_format(AM_MEDIA_TYPE * pmt, int fcc, int width, | |
1835 int height) | |
1836 { | |
1837 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: check_video_format called\n"); | |
1838 if (!pmt) | |
1839 return 0; | |
1840 if (memcmp(&(pmt->majortype), &MEDIATYPE_Video, 16) != 0) | |
1841 return 0; | |
1842 if (subtype2imgfmt(&(pmt->subtype)) != fcc) | |
1843 return 0; | |
1844 return 1; | |
1845 } | |
1846 | |
1847 /** | |
1848 * \brief converts DirectShow subtype to MPlayer's IMGFMT | |
1849 * | |
1850 * \param subtype DirectShow subtype for video format | |
1851 * | |
1852 * \return MPlayer's IMGFMT or 0 if error occured | |
1853 */ | |
1854 static int subtype2imgfmt(const GUID * subtype) | |
1855 { | |
1856 int i; | |
1857 for (i = 0; img_fmt_list[i].fmt; i++) { | |
1858 if (memcmp(subtype, img_fmt_list[i].subtype, 16) == 0) | |
1859 return img_fmt_list[i].fmt; | |
1860 } | |
1861 return 0; | |
1862 } | |
1863 | |
1864 /** | |
1865 * \brief prints filter name and it pins | |
1866 * | |
1867 * \param pFilter - IBaseFilter to get data from | |
1868 * | |
1869 * \return S_OK if success, error code otherwise | |
1870 */ | |
1871 static HRESULT show_filter_info(IBaseFilter * pFilter) | |
1872 { | |
1873 char tmp[200]; | |
1874 FILTER_INFO fi; | |
1875 LPENUMPINS pEnum = 0; | |
1876 IPin *pPin = 0; | |
1877 PIN_DIRECTION ThisPinDir; | |
1878 PIN_INFO pi; | |
1879 HRESULT hr; | |
1880 int i; | |
1881 | |
1882 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: show_filter_info called\n"); | |
1883 memset(&fi, 0, sizeof(fi)); | |
1884 memset(tmp, 0, 200); | |
1885 | |
1886 OLE_CALL_ARGS(pFilter, QueryFilterInfo, &fi); | |
1887 OLE_RELEASE_SAFE(fi.pGraph); | |
1888 wtoa(fi.achName, tmp, 200); | |
1889 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: BaseFilter (%p): Name=%s, Graph=%p output pins:", | |
1890 pFilter, tmp, fi.pGraph); | |
1891 hr = OLE_CALL_ARGS(pFilter, EnumPins, &pEnum); | |
1892 if (FAILED(hr)) | |
1893 return hr; | |
1894 i = 0; | |
1895 while (OLE_CALL_ARGS(pEnum, Next, 1, &pPin, NULL) == S_OK) { | |
1896 memset(&pi, 0, sizeof(pi)); | |
1897 memset(tmp, 0, 200); | |
1898 OLE_CALL_ARGS(pPin, QueryDirection, &ThisPinDir); | |
1899 if (ThisPinDir == PINDIR_OUTPUT) { | |
1900 OLE_CALL_ARGS(pPin, QueryPinInfo, &pi); | |
1901 wtoa(pi.achName, tmp, 200); | |
1902 OLE_RELEASE_SAFE(pi.pFilter); | |
1903 mp_msg(MSGT_TV, MSGL_DBG2, " %d=%s", i, tmp); | |
1904 mp_msg(MSGT_TV, MSGL_DBG3, " (%p)", pPin); | |
1905 mp_msg(MSGT_TV, MSGL_DBG2, ";"); | |
1906 OLE_RELEASE_SAFE(pPin); | |
1907 i++; | |
1908 } | |
1909 } | |
1910 mp_msg(MSGT_TV, MSGL_DBG2, "\n"); | |
1911 OLE_RELEASE_SAFE(pEnum); | |
1912 return S_OK; | |
1913 } | |
1914 | |
1915 /** | |
1916 * \brief gets device's frendly in ANSI encoding | |
1917 * | |
1918 * \param pM IMoniker interface, got in enumeration process | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
1919 * \param category device category |
24744 | 1920 * |
1921 * \return TVI_CONTROL_TRUE if operation succeded, TVI_CONTROL_FALSE - otherwise | |
1922 */ | |
1923 static int get_device_name(IMoniker * pM, char *pBuf, int nLen) | |
1924 { | |
1925 HRESULT hr; | |
1926 VARIANT var; | |
1927 IPropertyBag *pPropBag; | |
1928 hr = OLE_CALL_ARGS(pM, BindToStorage, 0, 0, &IID_IPropertyBag,(void *) &pPropBag); | |
1929 if (FAILED(hr)) { | |
1930 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Call to BindToStorage failed\n"); | |
1931 return TVI_CONTROL_FALSE; | |
1932 } | |
1933 var.vt = VT_BSTR; | |
1934 hr = OLE_CALL_ARGS(pPropBag, Read, L"Description", (LPVARIANT) & var, | |
1935 NULL); | |
1936 if (FAILED(hr)) { | |
1937 hr = OLE_CALL_ARGS(pPropBag, Read, L"FriendlyName", (LPVARIANT) & var, | |
1938 NULL); | |
1939 } | |
1940 OLE_RELEASE_SAFE(pPropBag); | |
1941 if (SUCCEEDED(hr)) { | |
1942 wtoa(var.bstrVal, pBuf, nLen); | |
1943 return TVI_CONTROL_TRUE; | |
1944 } | |
1945 return TVI_CONTROL_FALSE; | |
1946 } | |
1947 | |
1948 /** | |
1949 * \brief find capture device at given index | |
1950 * | |
1951 * \param index device index to search for (-1 mean only print available) | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
1952 * \param category device category |
24744 | 1953 * |
1954 * \return IBaseFilter interface for capture device with given index | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
1955 * |
24744 | 1956 * Sample values for category: |
1957 * CLSID_VideoInputDeviceCategory - Video Capture Sources | |
1958 * CLSID_AudioInputDeviceCategory - Audio Capture Sources | |
1959 * See DirectShow SDK documentation for other possible values | |
1960 */ | |
1961 static IBaseFilter *find_capture_device(int index, REFCLSID category) | |
1962 { | |
1963 IBaseFilter *pFilter = NULL; | |
1964 ICreateDevEnum *pDevEnum = NULL; | |
1965 IEnumMoniker *pClassEnum = NULL; | |
1966 IMoniker *pM; | |
1967 HRESULT hr; | |
1968 ULONG cFetched; | |
1969 int i; | |
1970 char tmp[DEVICE_NAME_MAX_LEN + 1]; | |
1971 hr = CoCreateInstance((GUID *) & CLSID_SystemDeviceEnum, NULL, | |
1972 CLSCTX_INPROC_SERVER, &IID_ICreateDevEnum, | |
1973 (void *) &pDevEnum); | |
1974 if (FAILED(hr)) { | |
1975 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Unable to create device enumerator\n"); | |
1976 return NULL; | |
1977 } | |
1978 | |
1979 hr = OLE_CALL_ARGS(pDevEnum, CreateClassEnumerator, category, &pClassEnum, 0); | |
1980 OLE_RELEASE_SAFE(pDevEnum); | |
1981 if (FAILED(hr)) { | |
1982 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Unable to create class enumerator\n"); | |
1983 return NULL; | |
1984 } | |
1985 if (hr == S_FALSE) { | |
1986 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: No capture devices found\n"); | |
1987 return NULL; | |
1988 } | |
1989 | |
1990 OLE_CALL(pClassEnum,Reset); | |
1991 for (i = 0; OLE_CALL_ARGS(pClassEnum, Next, 1, &pM, &cFetched) == S_OK; i++) { | |
1992 if(get_device_name(pM, tmp, DEVICE_NAME_MAX_LEN)!=TVI_CONTROL_TRUE) | |
1993 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableGetDeviceName, i); | |
1994 else | |
33827
277ec491a8a7
Do not translate console messages of verbosity level MSGL_V and above.
diego
parents:
33622
diff
changeset
|
1995 mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: Device #%d: %s\n", i, tmp); |
24744 | 1996 if (index != -1 && i == index) { |
1997 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_UsingDevice, index, tmp); | |
1998 hr = OLE_CALL_ARGS(pM, BindToObject, 0, 0, &IID_IBaseFilter,(void *) &pFilter); | |
1999 if (FAILED(hr)) | |
2000 pFilter = NULL; | |
2001 } | |
2002 OLE_RELEASE_SAFE(pM); | |
2003 } | |
2004 if (index != -1 && !pFilter) { | |
2005 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_DeviceNotFound, | |
2006 index); | |
2007 } | |
2008 OLE_RELEASE_SAFE(pClassEnum); | |
2009 | |
2010 return pFilter; | |
2011 } | |
2012 | |
2013 /** | |
2014 * \brief get array of available formats through call to IAMStreamConfig::GetStreamCaps | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2015 * |
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2016 * \praram[in] chain chain data structure |
24744 | 2017 * |
2018 * \return S_OK success | |
2019 * \return E_POINTER one of parameters is NULL | |
2020 * \return E_FAIL required size of buffer is unknown for given media type | |
2021 * \return E_OUTOFMEMORY not enough memory | |
2022 * \return other error code from called methods | |
2023 * | |
2024 * \remarks | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2025 * last items of chain->arpmt and chain->arStreamCaps will be NULL |
24744 | 2026 */ |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2027 static HRESULT get_available_formats_stream(chain_t *chain) |
24744 | 2028 { |
2029 AM_MEDIA_TYPE **arpmt; | |
2030 void **pBuf=NULL; | |
2031 | |
2032 HRESULT hr; | |
2033 int i, count, size; | |
2034 int done; | |
2035 | |
2036 mp_msg(MSGT_TV, MSGL_DBG4, | |
2037 "tvi_dshow: get_available_formats_stream called\n"); | |
2038 | |
25090 | 2039 if (!chain->pStreamConfig) |
24744 | 2040 return E_POINTER; |
2041 | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2042 hr=OLE_CALL_ARGS(chain->pStreamConfig, GetNumberOfCapabilities, &count, &size); |
24744 | 2043 if (FAILED(hr)) { |
2044 mp_msg(MSGT_TV, MSGL_DBG4, | |
2045 "tvi_dshow: Call to GetNumberOfCapabilities failed (get_available_formats_stream)\n"); | |
2046 return hr; | |
2047 } | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2048 if (chain->type == video){ |
24744 | 2049 if (size != sizeof(VIDEO_STREAM_CONFIG_CAPS)) { |
2050 mp_msg(MSGT_TV, MSGL_DBG4, | |
2051 "tvi_dshow: Wrong video structure size for GetNumberOfCapabilities (get_available_formats_stream)\n"); | |
2052 return E_FAIL; | |
25089
791f867d0124
Fix totally wrong (due to mess of brackets) structures size check.
voroshil
parents:
25088
diff
changeset
|
2053 } |
791f867d0124
Fix totally wrong (due to mess of brackets) structures size check.
voroshil
parents:
25088
diff
changeset
|
2054 } else if (chain->type == audio){ |
791f867d0124
Fix totally wrong (due to mess of brackets) structures size check.
voroshil
parents:
25088
diff
changeset
|
2055 if (size != sizeof(AUDIO_STREAM_CONFIG_CAPS)) { |
791f867d0124
Fix totally wrong (due to mess of brackets) structures size check.
voroshil
parents:
25088
diff
changeset
|
2056 mp_msg(MSGT_TV, MSGL_DBG4, |
24744 | 2057 "tvi_dshow: Wrong audio structure size for GetNumberOfCapabilities (get_available_formats_stream)\n"); |
25089
791f867d0124
Fix totally wrong (due to mess of brackets) structures size check.
voroshil
parents:
25088
diff
changeset
|
2058 return E_FAIL; |
791f867d0124
Fix totally wrong (due to mess of brackets) structures size check.
voroshil
parents:
25088
diff
changeset
|
2059 } |
791f867d0124
Fix totally wrong (due to mess of brackets) structures size check.
voroshil
parents:
25088
diff
changeset
|
2060 } else { |
24744 | 2061 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnsupportedMediaType,"get_available_formats_stream"); |
2062 return E_FAIL; | |
2063 } | |
2064 done = 0; | |
2065 | |
30702 | 2066 arpmt = malloc((count + 1) * sizeof(AM_MEDIA_TYPE *)); |
24744 | 2067 if (arpmt) { |
2068 memset(arpmt, 0, (count + 1) * sizeof(AM_MEDIA_TYPE *)); | |
2069 | |
30702 | 2070 pBuf = malloc((count + 1) * sizeof(void *)); |
24744 | 2071 if (pBuf) { |
2072 memset(pBuf, 0, (count + 1) * sizeof(void *)); | |
2073 | |
2074 for (i = 0; i < count; i++) { | |
25127
6e039dd0b5d8
Revert r25089 (Ignore video formats which are supported by device
voroshil
parents:
25126
diff
changeset
|
2075 pBuf[i] = malloc(size); |
6e039dd0b5d8
Revert r25089 (Ignore video formats which are supported by device
voroshil
parents:
25126
diff
changeset
|
2076 |
6e039dd0b5d8
Revert r25089 (Ignore video formats which are supported by device
voroshil
parents:
25126
diff
changeset
|
2077 if (!pBuf[i]) |
24744 | 2078 break; |
2079 | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2080 hr = OLE_CALL_ARGS(chain->pStreamConfig, GetStreamCaps, i, |
25127
6e039dd0b5d8
Revert r25089 (Ignore video formats which are supported by device
voroshil
parents:
25126
diff
changeset
|
2081 &(arpmt[i]), pBuf[i]); |
24744 | 2082 if (FAILED(hr)) |
2083 break; | |
2084 } | |
2085 if (i == count) { | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2086 chain->arpmt = arpmt; |
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2087 chain->arStreamCaps = pBuf; |
24744 | 2088 done = 1; |
2089 } | |
2090 } | |
2091 } | |
2092 if (!done) { | |
2093 for (i = 0; i < count; i++) { | |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32141
diff
changeset
|
2094 if (pBuf) |
24744 | 2095 free(pBuf[i]); |
2096 if (arpmt && arpmt[i]) | |
2097 DeleteMediaType(arpmt[i]); | |
2098 } | |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32141
diff
changeset
|
2099 free(pBuf); |
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32141
diff
changeset
|
2100 free(arpmt); |
24744 | 2101 if (hr != S_OK) { |
2102 mp_msg(MSGT_TV, MSGL_DBG4, "tvi_dshow: Call to GetStreamCaps failed (get_available_formats_stream)\n"); | |
2103 return hr; | |
2104 } else | |
2105 return E_OUTOFMEMORY; | |
2106 } | |
2107 return S_OK; | |
2108 } | |
2109 | |
2110 /** | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2111 * \brief returns allocates an array and store available media formats for given pin type to it |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2112 * |
24744 | 2113 * \param pBuilder ICaptureGraphBuilder2 interface of graph builder |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2114 * \param chain chain data structure |
24744 | 2115 * |
2116 * \return S_OK success | |
2117 * \return E_POINTER one of given pointers is null | |
2118 * \return apropriate error code otherwise | |
2119 */ | |
2120 static HRESULT get_available_formats_pin(ICaptureGraphBuilder2 * pBuilder, | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2121 chain_t *chain) |
24744 | 2122 { |
2123 IEnumMediaTypes *pEnum; | |
2124 int i, count, size; | |
2125 ULONG cFetched; | |
2126 AM_MEDIA_TYPE *pmt; | |
2127 HRESULT hr; | |
2128 void **pBuf; | |
2129 AM_MEDIA_TYPE **arpmt; //This will be real array | |
2130 VIDEO_STREAM_CONFIG_CAPS *pVideoCaps; | |
2131 AUDIO_STREAM_CONFIG_CAPS *pAudioCaps; | |
2132 int p1, p2, p3; | |
2133 | |
2134 mp_msg(MSGT_TV, MSGL_DBG4, | |
2135 "tvi_dshow: get_available_formats_pin called\n"); | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2136 if (!pBuilder || !chain->pCaptureFilter) |
24744 | 2137 return E_POINTER; |
2138 | |
25093 | 2139 if (!chain->pCapturePin) |
2140 { | |
2141 hr = OLE_CALL_ARGS(pBuilder, FindPin, | |
2142 (IUnknown *) chain->pCaptureFilter, | |
2143 PINDIR_OUTPUT, &PIN_CATEGORY_CAPTURE, | |
2144 chain->majortype, FALSE, 0, &chain->pCapturePin); | |
2145 | |
2146 if (!chain->pCapturePin) | |
2147 return E_POINTER; | |
2148 } | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2149 if (chain->type == video) { |
24744 | 2150 size = sizeof(VIDEO_STREAM_CONFIG_CAPS); |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2151 } else if (chain->type == audio) { |
24744 | 2152 size = sizeof(AUDIO_STREAM_CONFIG_CAPS); |
2153 } else { | |
2154 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnsupportedMediaType,"get_available_formats_pin"); | |
2155 return E_FAIL; | |
2156 } | |
2157 | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2158 hr = OLE_CALL_ARGS(chain->pCapturePin, EnumMediaTypes, &pEnum); |
24744 | 2159 if (FAILED(hr)) { |
2160 mp_msg(MSGT_TV, MSGL_DBG4, | |
2161 "tvi_dshow: Call to EnumMediaTypes failed (get_available_formats_pin)\n"); | |
2162 return hr; | |
2163 } | |
2164 for (i = 0; OLE_CALL_ARGS(pEnum, Next, 1, &pmt, &cFetched) == S_OK; i++) { | |
2165 if (!pmt) | |
2166 break; | |
2167 } | |
2168 OLE_CALL(pEnum,Reset); | |
2169 | |
2170 count = i; | |
30702 | 2171 arpmt = malloc((count + 1) * sizeof(AM_MEDIA_TYPE *)); |
24744 | 2172 if (!arpmt) |
2173 return E_OUTOFMEMORY; | |
2174 memset(arpmt, 0, (count + 1) * sizeof(AM_MEDIA_TYPE *)); | |
2175 | |
2176 for (i = 0; | |
2177 i < count | |
2178 && OLE_CALL_ARGS(pEnum, Next, 1, &(arpmt[i]), &cFetched) == S_OK; | |
2179 i++); | |
2180 | |
2181 OLE_RELEASE_SAFE(pEnum); | |
2182 | |
2183 | |
30702 | 2184 pBuf = malloc((count + 1) * sizeof(void *)); |
24744 | 2185 if (!pBuf) { |
2186 for (i = 0; i < count; i++) | |
2187 if (arpmt[i]) | |
2188 DeleteMediaType(arpmt[i]); | |
2189 free(arpmt); | |
2190 return E_OUTOFMEMORY; | |
2191 } | |
2192 memset(pBuf, 0, (count + 1) * sizeof(void *)); | |
2193 | |
2194 for (i = 0; i < count; i++) { | |
2195 pBuf[i] = malloc(size); | |
2196 if (!pBuf[i]) | |
2197 break; | |
2198 memset(pBuf[i], 0, size); | |
2199 | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2200 if (chain->type == video) { |
24744 | 2201 pVideoCaps = (VIDEO_STREAM_CONFIG_CAPS *) pBuf[i]; |
2202 extract_video_format(arpmt[i], NULL, &p1, &p2); | |
2203 pVideoCaps->MaxOutputSize.cx = pVideoCaps->MinOutputSize.cx = | |
2204 p1; | |
2205 pVideoCaps->MaxOutputSize.cy = pVideoCaps->MinOutputSize.cy = | |
2206 p2; | |
2207 } else { | |
2208 pAudioCaps = (AUDIO_STREAM_CONFIG_CAPS *) pBuf[i]; | |
2209 extract_audio_format(arpmt[i], &p1, &p2, &p3); | |
2210 pAudioCaps->MaximumSampleFrequency = | |
2211 pAudioCaps->MinimumSampleFrequency = p1; | |
2212 pAudioCaps->MaximumBitsPerSample = | |
2213 pAudioCaps->MinimumBitsPerSample = p2; | |
2214 pAudioCaps->MaximumChannels = pAudioCaps->MinimumChannels = p3; | |
2215 } | |
2216 | |
2217 } | |
2218 if (i != count) { | |
2219 for (i = 0; i < count; i++) { | |
2220 if (arpmt[i]) | |
2221 DeleteMediaType(arpmt[i]); | |
32511
b39155e98ac3
Remove some useless NULL pointer checks before invoking free() on the pointer.
diego
parents:
32141
diff
changeset
|
2222 free(pBuf[i]); |
24744 | 2223 } |
2224 free(arpmt); | |
2225 free(pBuf); | |
2226 return E_OUTOFMEMORY; | |
2227 } | |
25088
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2228 chain->arpmt = arpmt; |
554bbb45a2f2
Replace several parameters for get_available_formats_stream
voroshil
parents:
25087
diff
changeset
|
2229 chain->arStreamCaps = pBuf; |
24744 | 2230 |
2231 return S_OK; | |
2232 } | |
2233 | |
2234 /* | |
2235 *--------------------------------------------------------------------------------------- | |
2236 * | |
2237 * Public methods | |
2238 * | |
2239 *--------------------------------------------------------------------------------------- | |
2240 */ | |
2241 /** | |
2242 * \brief fills given buffer with audio data (usually one block) | |
2243 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2244 * \param priv driver's private data structure |
24744 | 2245 * \param buffer buffer to store data to |
2246 * \param len buffer's size in bytes (usually one block size) | |
2247 * | |
2248 * \return audio pts if audio present, 1 - otherwise | |
2249 */ | |
2250 static double grab_audio_frame(priv_t * priv, char *buffer, int len) | |
2251 { | |
2252 int bytes = 0; | |
2253 int i; | |
2254 double pts; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2255 grabber_ringbuffer_t *rb = priv->chains[1]->rbuf; |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2256 grabber_ringbuffer_t *vrb = priv->chains[0]->rbuf; |
24744 | 2257 |
2258 if (!rb || !rb->ringbuffer) | |
2259 return 1; | |
2260 | |
2261 if(vrb && vrb->tStart<0){ | |
2262 memset(buffer,0,len); | |
2263 return 0; | |
2264 } | |
2265 if(vrb && rb->tStart<0) | |
2266 rb->tStart=vrb->tStart; | |
2267 | |
2268 if (len < rb->blocksize) | |
2269 bytes = len; | |
2270 else | |
2271 bytes = rb->blocksize; | |
2272 | |
2273 mp_msg(MSGT_TV, MSGL_DBG3,"tvi_dshow: FillBuffer (audio) called. %d blocks in buffer, %d bytes requested\n", | |
2274 rb->count, len); | |
2275 if(!rb->count){ | |
2276 mp_msg(MSGT_TV,MSGL_DBG4,"tvi_dshow: waiting for frame\n"); | |
2277 for(i=0;i<1000 && !rb->count;i++) usec_sleep(1000); | |
2278 if(!rb->count){ | |
2279 mp_msg(MSGT_TV,MSGL_DBG4,"tvi_dshow: waiting timeout\n"); | |
2280 return 0; | |
2281 } | |
2282 mp_msg(MSGT_TV,MSGL_DBG4,"tvi_dshow: got frame!\n"); | |
2283 } | |
2284 | |
2285 EnterCriticalSection(rb->pMutex); | |
2286 pts=rb->dpts[rb->head]-rb->tStart; | |
2287 memcpy(buffer, rb->ringbuffer[rb->head], bytes); | |
2288 rb->head = (rb->head + 1) % rb->buffersize; | |
2289 rb->count--; | |
2290 LeaveCriticalSection(rb->pMutex); | |
2291 return pts; | |
2292 } | |
2293 | |
2294 /** | |
2295 * \brief returns audio frame size | |
2296 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2297 * \param priv driver's private data structure |
24744 | 2298 * |
2299 * \return audio block size if audio enabled and 1 - otherwise | |
2300 */ | |
2301 static int get_audio_framesize(priv_t * priv) | |
2302 { | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2303 if (!priv->chains[1]->rbuf) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2304 return 1; //no audio |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2305 mp_msg(MSGT_TV,MSGL_DBG3,"get_audio_framesize: %d\n",priv->chains[1]->rbuf->blocksize); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2306 return priv->chains[1]->rbuf->blocksize; |
24744 | 2307 } |
2308 | |
2309 static int vbi_get_props(priv_t* priv,tt_stream_props* ptsp) | |
2310 { | |
2311 if(!priv || !ptsp) | |
2312 return TVI_CONTROL_FALSE; | |
2313 | |
2314 //STUBS!!! | |
2315 ptsp->interlaced=0; | |
2316 ptsp->offset=256; | |
2317 | |
2318 ptsp->sampling_rate=27e6; | |
2319 ptsp->samples_per_line=720; | |
2320 | |
2321 ptsp->count[0]=16; | |
2322 ptsp->count[1]=16; | |
2323 //END STUBS!!! | |
2324 ptsp->bufsize = ptsp->samples_per_line * (ptsp->count[0] + ptsp->count[1]); | |
2325 | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2326 mp_msg(MSGT_TV,MSGL_V,"vbi_get_props: sampling_rate=%d,offset:%d,samples_per_line: %d\n interlaced:%s, count=[%d,%d]\n", |
24744 | 2327 ptsp->sampling_rate, |
2328 ptsp->offset, | |
2329 ptsp->samples_per_line, | |
2330 ptsp->interlaced?"Yes":"No", | |
2331 ptsp->count[0], | |
2332 ptsp->count[1]); | |
2333 | |
2334 return TVI_CONTROL_TRUE; | |
2335 } | |
2336 | |
2337 static void vbi_grabber(priv_t* priv) | |
2338 { | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2339 grabber_ringbuffer_t *rb = priv->chains[2]->rbuf; |
24744 | 2340 int i; |
2341 unsigned char* buf; | |
2342 if (!rb || !rb->ringbuffer) | |
2343 return; | |
2344 | |
2345 buf=calloc(1,rb->blocksize); | |
2346 for(i=0; i<23 && rb->count; i++){ | |
2347 memcpy(buf,rb->ringbuffer[rb->head],rb->blocksize); | |
2348 teletext_control(priv->priv_vbi,TV_VBI_CONTROL_DECODE_PAGE,&buf); | |
2349 rb->head = (rb->head + 1) % rb->buffersize; | |
2350 rb->count--; | |
2351 } | |
2352 free(buf); | |
2353 } | |
2354 | |
2355 /** | |
2356 * \brief fills given buffer with video data (usually one frame) | |
2357 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2358 * \param priv driver's private data structure |
24744 | 2359 * \param buffer buffer to store data to |
2360 * \param len buffer's size in bytes (usually one frame size) | |
2361 * | |
2362 * \return frame size if video present, 0 - otherwise | |
2363 */ | |
2364 static double grab_video_frame(priv_t * priv, char *buffer, int len) | |
2365 { | |
2366 int bytes = 0; | |
2367 int i; | |
2368 double pts; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2369 grabber_ringbuffer_t *rb = priv->chains[0]->rbuf; |
24744 | 2370 |
2371 if (!rb || !rb->ringbuffer) | |
2372 return 1; | |
2373 if (len < rb->blocksize) | |
2374 bytes = len; | |
2375 else | |
2376 bytes = rb->blocksize; | |
2377 | |
2378 mp_msg(MSGT_TV, MSGL_DBG3,"tvi_dshow: FillBuffer (video) called. %d blocks in buffer, %d bytes requested\n", | |
2379 rb->count, len); | |
2380 if(!rb->count){ | |
2381 mp_msg(MSGT_TV,MSGL_DBG4,"tvi_dshow: waiting for frame\n"); | |
2382 for(i=0;i<1000 && !rb->count;i++) usec_sleep(1000); | |
2383 if(!rb->count){ | |
2384 mp_msg(MSGT_TV,MSGL_DBG4,"tvi_dshow: waiting timeout\n"); | |
2385 return 0; | |
2386 } | |
2387 mp_msg(MSGT_TV,MSGL_DBG4,"tvi_dshow: got frame!\n"); | |
2388 } | |
2389 EnterCriticalSection(rb->pMutex); | |
2390 if(rb->tStart<0) | |
2391 rb->tStart=rb->dpts[rb->head]; | |
2392 pts=rb->dpts[rb->head]-rb->tStart; | |
2393 memcpy(buffer, rb->ringbuffer[rb->head], bytes); | |
2394 rb->head = (rb->head + 1) % rb->buffersize; | |
2395 rb->count--; | |
2396 LeaveCriticalSection(rb->pMutex); | |
2397 | |
2398 vbi_grabber(priv); | |
2399 return pts; | |
2400 } | |
2401 | |
2402 /** | |
2403 * \brief returns frame size | |
2404 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2405 * \param priv driver's private data structure |
24744 | 2406 * |
2407 * \return frame size if video present, 0 - otherwise | |
2408 */ | |
2409 static int get_video_framesize(priv_t * priv) | |
2410 { | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2411 // if(!priv->pmtVideo) return 1; //no video |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
2412 // return priv->pmtVideo->lSampleSize; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2413 if (!priv->chains[0]->rbuf) |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2414 return 1; //no video |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2415 mp_msg(MSGT_TV,MSGL_DBG3,"geT_video_framesize: %d\n",priv->chains[0]->rbuf->blocksize); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2416 return priv->chains[0]->rbuf->blocksize; |
24744 | 2417 } |
2418 | |
2419 /** | |
2420 * \brief calculate audio buffer size | |
2421 * \param video_buf_size size of video buffer in bytes | |
2422 * \param video_bitrate video bit rate | |
2423 * \param audio_bitrate audio bit rate | |
2424 * \return audio buffer isze in bytes | |
2425 * | |
2426 * \remarks length of video buffer and resulted audio buffer calculated in | |
2427 * seconds will be the same. | |
2428 */ | |
2429 static inline int audio_buf_size_from_video(int video_buf_size, int video_bitrate, int audio_bitrate) | |
2430 { | |
2431 int audio_buf_size = audio_bitrate * (video_buf_size / video_bitrate); | |
2432 mp_msg(MSGT_TV,MSGL_DBG2,"tvi_dshow: Audio capture buffer: %d * %d / %d = %d\n", | |
2433 audio_bitrate,video_buf_size,video_bitrate,audio_buf_size); | |
2434 return audio_buf_size; | |
2435 } | |
2436 | |
2437 /** | |
25094
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2438 * \brief common chain initialization routine |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2439 * \param chain chain data structure |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2440 * |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2441 * \note pCaptureFilter member should be initialized before call to this routine |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2442 */ |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2443 static HRESULT init_chain_common(ICaptureGraphBuilder2 *pBuilder, chain_t *chain) |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2444 { |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2445 HRESULT hr; |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2446 int i; |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2447 |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2448 if(!chain->pCaptureFilter) |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2449 return E_POINTER; |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2450 |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2451 show_filter_info(chain->pCaptureFilter); |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2452 |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2453 hr = OLE_CALL_ARGS(pBuilder, FindPin, |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2454 (IUnknown *) chain->pCaptureFilter, |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2455 PINDIR_OUTPUT, chain->pin_category, |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2456 chain->majortype, FALSE, 0, &chain->pCapturePin); |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2457 |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2458 if (FAILED(hr)) { |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2459 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: FindPin(pCapturePin) call failed. Error:0x%x\n", (unsigned int)hr); |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2460 return hr; |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2461 } |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2462 |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2463 hr = OLE_CALL_ARGS(pBuilder, FindInterface, |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2464 chain->pin_category, |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2465 chain->majortype, |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2466 chain->pCaptureFilter, |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2467 &IID_IAMStreamConfig, |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2468 (void **) &(chain->pStreamConfig)); |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2469 if (FAILED(hr)) |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2470 chain->pStreamConfig = NULL; |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2471 |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2472 /* |
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2473 Getting available video formats (last pointer in array will be NULL) |
25094
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2474 First tryin to call IAMStreamConfig::GetStreamCaos. this will give us additional information such as |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2475 min/max picture dimensions, etc. If this call fails trying IPIn::EnumMediaTypes with default |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2476 min/max values. |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2477 */ |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2478 hr = get_available_formats_stream(chain); |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2479 if (FAILED(hr)) { |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2480 mp_msg(MSGT_TV, MSGL_DBG2, "Unable to use IAMStreamConfig for retriving available formats (Error:0x%x). Using EnumMediaTypes instead\n", (unsigned int)hr); |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2481 hr = get_available_formats_pin(pBuilder, chain); |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2482 if(FAILED(hr)){ |
25125
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2483 return hr; |
25094
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2484 } |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2485 } |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2486 chain->nFormatUsed = 0; |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2487 |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2488 //If argument to CreateMediaType is NULL then result will be NULL too. |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2489 chain->pmt = CreateMediaType(chain->arpmt[0]); |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2490 |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2491 for (i = 0; chain->arpmt[i]; i++) |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2492 DisplayMediaType("Available format", chain->arpmt[i]); |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2493 |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2494 return S_OK; |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2495 } |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2496 /** |
25057
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2497 * \brief build video stream chain in graph |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2498 * \param priv private data structure |
24744 | 2499 * |
25057
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2500 * \return S_OK if chain was built successfully, apropriate error code otherwise |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2501 */ |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2502 static HRESULT build_video_chain(priv_t *priv) |
24744 | 2503 { |
2504 HRESULT hr; | |
2505 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2506 if(priv->chains[0]->rbuf) |
25059 | 2507 return S_OK; |
2508 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2509 if (priv->chains[0]->pStreamConfig) { |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2510 hr = OLE_CALL_ARGS(priv->chains[0]->pStreamConfig, SetFormat, priv->chains[0]->pmt); |
24744 | 2511 if (FAILED(hr)) { |
2512 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableSelectVideoFormat, (unsigned int)hr); | |
2513 } | |
2514 } | |
2515 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2516 priv->chains[0]->rbuf=calloc(1,sizeof(grabber_ringbuffer_t)); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2517 if(!priv->chains[0]->rbuf) |
25058 | 2518 return E_OUTOFMEMORY; |
24744 | 2519 |
2520 if (priv->tv_param->buffer_size >= 0) { | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2521 priv->chains[0]->rbuf->buffersize = priv->tv_param->buffer_size; |
24744 | 2522 } else { |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2523 priv->chains[0]->rbuf->buffersize = 16; |
24744 | 2524 } |
2525 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2526 priv->chains[0]->rbuf->buffersize *= 1024 * 1024; |
25084
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
2527 hr=build_sub_graph(priv, priv->chains[0], &PIN_CATEGORY_CAPTURE); |
24744 | 2528 if(FAILED(hr)){ |
2529 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildVideoSubGraph,(unsigned int)hr); | |
25057
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2530 return hr; |
24744 | 2531 } |
25057
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2532 return S_OK; |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2533 } |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2534 |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2535 /** |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2536 * \brief build audio stream chain in graph |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2537 * \param priv private data structure |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2538 * |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2539 * \return S_OK if chain was built successfully, apropriate error code otherwise |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2540 */ |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2541 static HRESULT build_audio_chain(priv_t *priv) |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2542 { |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2543 HRESULT hr; |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2544 |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2545 if(priv->chains[1]->rbuf) |
25059 | 2546 return S_OK; |
2547 | |
25057
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2548 if(priv->immediate_mode) |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2549 return S_OK; |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2550 |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2551 if (priv->chains[1]->pStreamConfig) { |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2552 hr = OLE_CALL_ARGS(priv->chains[1]->pStreamConfig, SetFormat, |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2553 priv->chains[1]->pmt); |
25057
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2554 if (FAILED(hr)) { |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2555 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableSelectAudioFormat, (unsigned int)hr); |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2556 } |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2557 } |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2558 |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2559 if(priv->chains[1]->pmt){ |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2560 priv->chains[1]->rbuf=calloc(1,sizeof(grabber_ringbuffer_t)); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2561 if(!priv->chains[1]->rbuf) |
25058 | 2562 return E_OUTOFMEMORY; |
24744 | 2563 |
2564 /* let the audio buffer be the same size (in seconds) than video one */ | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2565 priv->chains[1]->rbuf->buffersize=audio_buf_size_from_video( |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2566 priv->chains[0]->rbuf->buffersize, |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2567 (((VIDEOINFOHEADER *) priv->chains[0]->pmt->pbFormat)->dwBitRate), |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2568 (((WAVEFORMATEX *) (priv->chains[1]->pmt->pbFormat))->nAvgBytesPerSec)); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2569 |
25084
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
2570 hr=build_sub_graph(priv, priv->chains[1],&PIN_CATEGORY_CAPTURE); |
24744 | 2571 if(FAILED(hr)){ |
2572 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildAudioSubGraph,(unsigned int)hr); | |
2573 return 0; | |
2574 } | |
2575 } | |
25057
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2576 return S_OK; |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2577 } |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2578 |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2579 /** |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2580 * \brief build VBI stream chain in graph |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2581 * \param priv private data structure |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2582 * |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2583 * \return S_OK if chain was built successfully, apropriate error code otherwise |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2584 */ |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2585 static HRESULT build_vbi_chain(priv_t *priv) |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2586 { |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2587 HRESULT hr; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2588 |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2589 if(priv->chains[2]->rbuf) |
25059 | 2590 return S_OK; |
2591 | |
29806 | 2592 if(priv->tv_param->teletext.device) |
24744 | 2593 { |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2594 priv->chains[2]->rbuf=calloc(1,sizeof(grabber_ringbuffer_t)); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2595 if(!priv->chains[2]->rbuf) |
25058 | 2596 return E_OUTOFMEMORY; |
2597 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2598 init_ringbuffer(priv->chains[2]->rbuf,24,priv->tsp.bufsize); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2599 |
25084
f72ebba1e6d1
pass chain structure instead of several variables to build_sub_graph
voroshil
parents:
25083
diff
changeset
|
2600 hr=build_sub_graph(priv, priv->chains[2],&PIN_CATEGORY_VBI); |
24744 | 2601 if(FAILED(hr)){ |
2602 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_UnableBuildVBISubGraph,(unsigned int)hr); | |
2603 return 0; | |
2604 } | |
2605 } | |
25057
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2606 return S_OK; |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2607 } |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2608 |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2609 /** |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2610 * \brief playback/capture real start |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2611 * |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2612 * \param priv driver's private data structure |
25057
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2613 * |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2614 * \return 1 if success, 0 - otherwise |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2615 * |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2616 * TODO: move some code from init() here |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2617 */ |
25057
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2618 static int start(priv_t * priv) |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2619 { |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2620 HRESULT hr; |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2621 |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2622 hr = build_video_chain(priv); |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2623 if(FAILED(hr)) |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2624 return 0; |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2625 |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2626 hr = build_audio_chain(priv); |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2627 if(FAILED(hr)) |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2628 return 0; |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2629 |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2630 hr = build_vbi_chain(priv); |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2631 if(FAILED(hr)) |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2632 return 0; |
7d74c1a2c840
Move chains building code into separate routines.
voroshil
parents:
25054
diff
changeset
|
2633 |
24744 | 2634 /* |
2635 Graph is ready to capture. Starting graph. | |
2636 */ | |
2637 if (mp_msg_test(MSGT_TV, MSGL_DBG2)) { | |
2638 mp_msg(MSGT_TV, MSGL_DBG2, "Debug pause 10sec\n"); | |
2639 usec_sleep(10000000); | |
2640 mp_msg(MSGT_TV, MSGL_DBG2, "Debug pause end\n"); | |
2641 } | |
2642 if (!priv->pMediaControl) { | |
2643 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableGetMediaControlInterface,(unsigned int)E_POINTER); | |
2644 return 0; | |
2645 } | |
2646 hr = OLE_CALL(priv->pMediaControl, Run); | |
2647 if (FAILED(hr)) { | |
2648 mp_msg(MSGT_TV,MSGL_ERR,MSGTR_TVI_DS_UnableStartGraph, (unsigned int)hr); | |
2649 return 0; | |
2650 } | |
2651 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Graph is started.\n"); | |
2652 priv->state = 1; | |
2653 | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
2654 return 1; |
24744 | 2655 } |
2656 | |
2657 /** | |
2658 * \brief driver initialization | |
2659 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2660 * \param priv driver's private data structure |
24744 | 2661 * |
2662 * \return 1 if success, 0 - otherwise | |
2663 */ | |
2664 static int init(priv_t * priv) | |
2665 { | |
2666 HRESULT hr; | |
2667 int result = 0; | |
2668 long lInput, lTunerInput; | |
2669 IEnumFilters *pEnum; | |
2670 IBaseFilter *pFilter; | |
2671 IPin *pVPOutPin; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2672 int i; |
24744 | 2673 |
2674 priv->state=0; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2675 |
24744 | 2676 CoInitialize(NULL); |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2677 |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2678 for(i=0; i<3;i++) |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2679 priv->chains[i] = calloc(1, sizeof(chain_t)); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2680 |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2681 priv->chains[0]->type=video; |
25080 | 2682 priv->chains[0]->majortype=&MEDIATYPE_Video; |
25094
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2683 priv->chains[0]->pin_category=&PIN_CATEGORY_CAPTURE; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2684 priv->chains[1]->type=audio; |
25080 | 2685 priv->chains[1]->majortype=&MEDIATYPE_Audio; |
25094
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2686 priv->chains[1]->pin_category=&PIN_CATEGORY_CAPTURE; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2687 priv->chains[2]->type=vbi; |
25080 | 2688 priv->chains[2]->majortype=&MEDIATYPE_VBI; |
25094
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2689 priv->chains[2]->pin_category=&PIN_CATEGORY_VBI; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2690 |
24744 | 2691 do{ |
2692 hr = CoCreateInstance((GUID *) & CLSID_FilterGraph, NULL, | |
2693 CLSCTX_INPROC_SERVER, &IID_IGraphBuilder, | |
2694 (void **) &priv->pGraph); | |
2695 if(FAILED(hr)){ | |
2696 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: CoCreateInstance(FilterGraph) call failed. Error:0x%x\n", (unsigned int)hr); | |
2697 break; | |
2698 } | |
2699 //Debug | |
2700 if (mp_msg_test(MSGT_TV, MSGL_DBG2)) { | |
2701 AddToRot((IUnknown *) priv->pGraph, &(priv->dwRegister)); | |
2702 } | |
2703 | |
2704 hr = CoCreateInstance((GUID *) & CLSID_CaptureGraphBuilder2, NULL, | |
2705 CLSCTX_INPROC_SERVER, &IID_ICaptureGraphBuilder2, | |
2706 (void **) &priv->pBuilder); | |
2707 if(FAILED(hr)){ | |
2708 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: CoCreateInstance(CaptureGraphBuilder) call failed. Error:0x%x\n", (unsigned int)hr); | |
2709 break; | |
2710 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2711 |
24744 | 2712 hr = OLE_CALL_ARGS(priv->pBuilder, SetFiltergraph, priv->pGraph); |
2713 if(FAILED(hr)){ | |
2714 mp_msg(MSGT_TV,MSGL_ERR, "tvi_dshow: SetFiltergraph call failed. Error:0x%x\n",(unsigned int)hr); | |
2715 break; | |
2716 } | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
2717 |
24744 | 2718 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Searching for available video capture devices\n"); |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2719 priv->chains[0]->pCaptureFilter = find_capture_device(priv->dev_index, &CLSID_VideoInputDeviceCategory); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2720 if(!priv->chains[0]->pCaptureFilter){ |
24744 | 2721 mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_NoVideoCaptureDevice); |
2722 break; | |
2723 } | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2724 hr = OLE_CALL_ARGS(priv->pGraph, AddFilter, priv->chains[0]->pCaptureFilter, NULL); |
24744 | 2725 if(FAILED(hr)){ |
2726 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Unable to add video capture device to Directshow graph. Error:0x%x\n", (unsigned int)hr); | |
2727 break; | |
2728 } | |
2729 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Searching for available audio capture devices\n"); | |
2730 if (priv->adev_index != -1) { | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2731 priv->chains[1]->pCaptureFilter = find_capture_device(priv->adev_index, &CLSID_AudioInputDeviceCategory); //output available audio edevices |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2732 if(!priv->chains[1]->pCaptureFilter){ |
24744 | 2733 mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_NoAudioCaptureDevice); |
2734 break; | |
2735 } | |
2736 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2737 hr = OLE_CALL_ARGS(priv->pGraph, AddFilter, priv->chains[1]->pCaptureFilter, NULL); |
24744 | 2738 if(FAILED(hr)){ |
2739 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: Unable to add audio capture device to Directshow graph. Error:0x%x\n", (unsigned int)hr); | |
2740 break; | |
2741 } | |
2742 } else | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2743 hr = OLE_QUERYINTERFACE(priv->chains[0]->pCaptureFilter, IID_IBaseFilter, priv->chains[1]->pCaptureFilter); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2744 |
25082
b63b4b599cbe
Add capture filter's pointer to vbi chain structure too.
voroshil
parents:
25081
diff
changeset
|
2745 /* increase refrence counter for capture filter ad store pointer into vbi chain structure too */ |
b63b4b599cbe
Add capture filter's pointer to vbi chain structure too.
voroshil
parents:
25081
diff
changeset
|
2746 hr = OLE_QUERYINTERFACE(priv->chains[0]->pCaptureFilter, IID_IBaseFilter, priv->chains[2]->pCaptureFilter); |
b63b4b599cbe
Add capture filter's pointer to vbi chain structure too.
voroshil
parents:
25081
diff
changeset
|
2747 |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2748 hr = OLE_QUERYINTERFACE(priv->chains[0]->pCaptureFilter, IID_IAMVideoProcAmp,priv->pVideoProcAmp); |
24744 | 2749 if (FAILED(hr) && hr != E_NOINTERFACE) |
2750 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Get IID_IAMVideoProcAmp failed (0x%x).\n", (unsigned int)hr); | |
2751 | |
2752 if (hr != S_OK) { | |
2753 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_VideoAdjustigNotSupported); | |
2754 priv->pVideoProcAmp = NULL; | |
2755 } | |
2756 | |
2757 hr = OLE_CALL_ARGS(priv->pBuilder, FindInterface, | |
2758 &PIN_CATEGORY_CAPTURE, | |
25080 | 2759 priv->chains[0]->majortype, |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2760 priv->chains[0]->pCaptureFilter, |
24744 | 2761 &IID_IAMCrossbar, (void **) &(priv->pCrossbar)); |
2762 if (FAILED(hr)) { | |
2763 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_SelectingInputNotSupported); | |
2764 priv->pCrossbar = NULL; | |
2765 } | |
2766 | |
2767 if (priv->tv_param->amode >= 0) { | |
2768 IAMTVAudio *pTVAudio; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2769 hr = OLE_CALL_ARGS(priv->pBuilder, FindInterface, NULL, NULL,priv->chains[0]->pCaptureFilter,&IID_IAMTVAudio, (void *) &pTVAudio); |
24744 | 2770 if (hr == S_OK) { |
2771 switch (priv->tv_param->amode) { | |
2772 case 0: | |
2773 hr = OLE_CALL_ARGS(pTVAudio, put_TVAudioMode, AMTVAUDIO_MODE_MONO); | |
2774 break; | |
2775 case 1: | |
2776 hr = OLE_CALL_ARGS(pTVAudio, put_TVAudioMode, AMTVAUDIO_MODE_STEREO); | |
2777 break; | |
2778 case 2: | |
2779 hr = OLE_CALL_ARGS(pTVAudio, put_TVAudioMode, | |
2780 AMTVAUDIO_MODE_LANG_A); | |
2781 break; | |
2782 case 3: | |
2783 hr = OLE_CALL_ARGS(pTVAudio, put_TVAudioMode, | |
2784 AMTVAUDIO_MODE_LANG_B); | |
2785 break; | |
2786 } | |
2787 OLE_RELEASE_SAFE(pTVAudio); | |
2788 if (FAILED(hr)) | |
2789 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TVI_DS_UnableSetAudioMode, priv->tv_param->amode,(unsigned int)hr); | |
2790 } | |
2791 } | |
25094
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2792 |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2793 // Video chain initialization |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2794 hr = init_chain_common(priv->pBuilder, priv->chains[0]); |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2795 if(FAILED(hr)) |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2796 break; |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2797 |
25125
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2798 /* |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2799 Audio chain initialization |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2800 Since absent audio stream is not fatal, |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2801 at least one NULL pointer should be kept in format arrays |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2802 (to avoid another additional check everywhere for array presence). |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2803 */ |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2804 hr = init_chain_common(priv->pBuilder, priv->chains[1]); |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2805 if(FAILED(hr)) |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2806 { |
33622
27f7a3196e18
tvi_dshow: Adjust mp_msg printf conversion specifier to avoid warnings.
diego
parents:
33618
diff
changeset
|
2807 mp_msg(MSGT_TV, MSGL_V, |
27f7a3196e18
tvi_dshow: Adjust mp_msg printf conversion specifier to avoid warnings.
diego
parents:
33618
diff
changeset
|
2808 "tvi_dshow: Unable to initialize audio chain (Error:0x%lx). Audio disabled\n", |
27f7a3196e18
tvi_dshow: Adjust mp_msg printf conversion specifier to avoid warnings.
diego
parents:
33618
diff
changeset
|
2809 (unsigned long)hr); |
25125
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2810 priv->chains[1]->arpmt=calloc(1, sizeof(AM_MEDIA_TYPE*)); |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2811 priv->chains[1]->arStreamCaps=calloc(1, sizeof(void*)); |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2812 } |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2813 |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2814 /* |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2815 VBI chain initialization |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2816 Since absent VBI stream is not fatal, |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2817 at least one NULL pointer should be kept in format arrays |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2818 (to avoid another additional check everywhere for array presence). |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2819 */ |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2820 hr = init_chain_common(priv->pBuilder, priv->chains[2]); |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2821 if(FAILED(hr)) |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2822 { |
33622
27f7a3196e18
tvi_dshow: Adjust mp_msg printf conversion specifier to avoid warnings.
diego
parents:
33618
diff
changeset
|
2823 mp_msg(MSGT_TV, MSGL_V, |
27f7a3196e18
tvi_dshow: Adjust mp_msg printf conversion specifier to avoid warnings.
diego
parents:
33618
diff
changeset
|
2824 "tvi_dshow: Unable to initialize VBI chain (Error:0x%lx). Teletext disabled\n", |
27f7a3196e18
tvi_dshow: Adjust mp_msg printf conversion specifier to avoid warnings.
diego
parents:
33618
diff
changeset
|
2825 (unsigned long)hr); |
25125
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2826 priv->chains[2]->arpmt=calloc(1, sizeof(AM_MEDIA_TYPE*)); |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2827 priv->chains[2]->arStreamCaps=calloc(1, sizeof(void*)); |
a1e6345207a1
§³reate empty format arrays in case of error in init_chain_common.
voroshil
parents:
25105
diff
changeset
|
2828 } |
25094
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2829 |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2830 if (!priv->chains[0]->pStreamConfig) |
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2831 mp_msg(MSGT_TV, MSGL_INFO, MSGTR_TVI_DS_ChangingWidthHeightNotSupported); |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2832 |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2833 if (!priv->chains[0]->arpmt[priv->chains[0]->nFormatUsed] |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2834 || !extract_video_format(priv->chains[0]->arpmt[priv->chains[0]->nFormatUsed], |
24744 | 2835 &(priv->fcc), &(priv->width), |
2836 &(priv->height))) { | |
2837 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_ErrorParsingVideoFormatStruct); | |
2838 break; | |
2839 } | |
25094
e27cb70d2302
Move code related to chain initialization and similar
voroshil
parents:
25093
diff
changeset
|
2840 |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2841 if (priv->chains[1]->arpmt[priv->chains[1]->nFormatUsed]) { |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2842 if (!extract_audio_format(priv->chains[1]->pmt, &(priv->samplerate), NULL, NULL)) { |
24744 | 2843 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_ErrorParsingAudioFormatStruct); |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2844 DisplayMediaType("audio format failed",priv->chains[1]->arpmt[priv->chains[1]->nFormatUsed]); |
24744 | 2845 break; |
2846 } | |
2847 } | |
2848 | |
2849 hr = OLE_QUERYINTERFACE(priv->pGraph, IID_IMediaControl,priv->pMediaControl); | |
2850 if(FAILED(hr)){ | |
2851 mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_UnableGetMediaControlInterface,(unsigned int)hr); | |
2852 break; | |
2853 } | |
2854 hr = OLE_CALL_ARGS(priv->pBuilder, FindInterface, | |
2855 &PIN_CATEGORY_CAPTURE, NULL, | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2856 priv->chains[0]->pCaptureFilter, |
24744 | 2857 &IID_IAMTVTuner, (void **) &(priv->pTVTuner)); |
2858 | |
2859 if (!priv->pTVTuner) { | |
2860 mp_msg(MSGT_TV, MSGL_DBG2, "tvi_dshow: Unable to access IAMTVTuner (0x%x)\n", (unsigned int)hr); | |
2861 } | |
2862 | |
2863 // shows Tuner capabilities | |
2864 get_capabilities(priv); | |
2865 | |
2866 if (priv->pTVTuner) { | |
2867 hr = OLE_CALL_ARGS(priv->pTVTuner, put_CountryCode, | |
2868 chanlist2country(priv->tv_param->chanlist)); | |
2869 if(FAILED(hr)){ | |
2870 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: Call to put_CountryCode failed. Error:0x%x\n",(unsigned int)hr); | |
2871 } | |
2872 | |
2873 hr = OLE_CALL_ARGS(priv->pTVTuner, put_Mode, AMTUNER_MODE_TV); | |
2874 if(FAILED(hr)){ | |
2875 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: Call to put_Mode failed. Error:0x%x\n",(unsigned int)hr); | |
2876 break; | |
2877 } | |
2878 | |
2879 hr = OLE_CALL_ARGS(priv->pTVTuner, get_ConnectInput, &lInput); | |
2880 if(FAILED(hr)){ | |
2881 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: Call to get_ConnectInput failed. Error:0x%x\n",(unsigned int)hr); | |
2882 break; | |
2883 } | |
2884 | |
2885 /* small hack */ | |
2886 lTunerInput = strstr(priv->tv_param->chanlist, "cable") ? TunerInputCable : TunerInputAntenna; | |
2887 | |
2888 hr = OLE_CALL_ARGS(priv->pTVTuner, put_InputType, lInput, lTunerInput); | |
2889 if(FAILED(hr)){ | |
2890 mp_msg(MSGT_TV,MSGL_DBG2, "tvi_dshow: Call to put_InputType failed. Error:0x%x\n",(unsigned int)hr); | |
2891 break; | |
2892 } | |
2893 | |
2894 } | |
2895 | |
2896 /** | |
2897 for VIVO cards we should check if preview pin is available on video capture device. | |
2898 If it is not, we have to connect Video Port Manager filter to VP pin of capture device filter. | |
2899 Otherwise we will get 0x8007001f (Device is not functioning properly) when attempting to start graph | |
2900 */ | |
2901 hr = OLE_CALL_ARGS(priv->pBuilder, FindPin, | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
2902 (IUnknown *) priv->chains[0]->pCaptureFilter, |
24744 | 2903 PINDIR_OUTPUT, |
2904 &PIN_CATEGORY_VIDEOPORT, NULL, FALSE, | |
2905 0, (IPin **) & pVPOutPin); | |
2906 if (SUCCEEDED(hr)) { | |
2907 hr = OLE_CALL_ARGS(priv->pGraph, Render, pVPOutPin); | |
2908 OLE_RELEASE_SAFE(pVPOutPin); | |
2909 | |
2910 if (FAILED(hr)) { | |
2911 mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_UnableTerminateVPPin, (unsigned int)hr); | |
2912 break; | |
2913 } | |
2914 } | |
2915 | |
2916 OLE_CALL_ARGS(priv->pGraph, EnumFilters, &pEnum); | |
2917 while (OLE_CALL_ARGS(pEnum, Next, 1, &pFilter, NULL) == S_OK) { | |
2918 LPVIDEOWINDOW pVideoWindow; | |
2919 hr = OLE_QUERYINTERFACE(pFilter, IID_IVideoWindow, pVideoWindow); | |
2920 if (SUCCEEDED(hr)) | |
2921 { | |
2922 if(priv->tv_param->hidden_vp_renderer){ | |
2923 OLE_CALL_ARGS(pVideoWindow,put_Visible,/* OAFALSE*/ 0); | |
2924 OLE_CALL_ARGS(pVideoWindow,put_AutoShow,/* OAFALSE*/ 0); | |
2925 }else | |
2926 { | |
2927 OLE_CALL_ARGS(priv->pGraph, RemoveFilter, pFilter); | |
2928 } | |
2929 OLE_RELEASE_SAFE(pVideoWindow); | |
2930 } | |
2931 OLE_RELEASE_SAFE(pFilter); | |
2932 } | |
2933 OLE_RELEASE_SAFE(pEnum); | |
2934 if(priv->tv_param->system_clock) | |
2935 { | |
2936 LPREFERENCECLOCK rc; | |
2937 IBaseFilter* pBF; | |
2938 hr = CoCreateInstance((GUID *) & CLSID_SystemClock, NULL, | |
2939 CLSCTX_INPROC_SERVER, &IID_IReferenceClock, | |
2940 (void *) &rc); | |
2941 | |
2942 OLE_QUERYINTERFACE(priv->pBuilder,IID_IBaseFilter,pBF); | |
2943 OLE_CALL_ARGS(pBF,SetSyncSource,rc); | |
2944 } | |
2945 if(vbi_get_props(priv,&(priv->tsp))!=TVI_CONTROL_TRUE) | |
2946 break; | |
2947 result = 1; | |
2948 } while(0); | |
2949 | |
2950 if (!result){ | |
2951 mp_msg(MSGT_TV,MSGL_ERR, MSGTR_TVI_DS_GraphInitFailure); | |
2952 uninit(priv); | |
2953 } | |
2954 return result; | |
2955 } | |
2956 | |
2957 /** | |
25085
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2958 * \brief chain uninitialization |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2959 * \param chain chain data structure |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2960 */ |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2961 static void destroy_chain(chain_t *chain) |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2962 { |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2963 int i; |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2964 |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2965 if(!chain) |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2966 return; |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2967 |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2968 OLE_RELEASE_SAFE(chain->pStreamConfig); |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2969 OLE_RELEASE_SAFE(chain->pCaptureFilter); |
25086
e91503fbf524
Move pointer to SampleGrabber filter into chain structure.
voroshil
parents:
25085
diff
changeset
|
2970 OLE_RELEASE_SAFE(chain->pCSGCB); |
25087
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
2971 OLE_RELEASE_SAFE(chain->pCapturePin); |
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
2972 OLE_RELEASE_SAFE(chain->pSGIn); |
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
2973 OLE_RELEASE_SAFE(chain->pSG); |
edc7391db7f5
New routine for reconnecting two pins with new media type
voroshil
parents:
25086
diff
changeset
|
2974 OLE_RELEASE_SAFE(chain->pSGF); |
25086
e91503fbf524
Move pointer to SampleGrabber filter into chain structure.
voroshil
parents:
25085
diff
changeset
|
2975 |
25085
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2976 if (chain->pmt) |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2977 DeleteMediaType(chain->pmt); |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2978 |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2979 if (chain->arpmt) { |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2980 for (i = 0; chain->arpmt[i]; i++) { |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2981 DeleteMediaType(chain->arpmt[i]); |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2982 } |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2983 free(chain->arpmt); |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2984 } |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2985 |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2986 if (chain->arStreamCaps) { |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2987 for (i = 0; chain->arStreamCaps[i]; i++) { |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2988 free(chain->arStreamCaps[i]); |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2989 } |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2990 free(chain->arStreamCaps); |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2991 } |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2992 |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2993 if (chain->rbuf) { |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2994 destroy_ringbuffer(chain->rbuf); |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2995 free(chain->rbuf); |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2996 chain->rbuf = NULL; |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2997 } |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2998 free(chain); |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
2999 } |
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
3000 /** |
24744 | 3001 * \brief driver uninitialization |
3002 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
3003 * \param priv driver's private data structure |
24744 | 3004 * |
3005 * \return always 1 | |
3006 */ | |
3007 static int uninit(priv_t * priv) | |
3008 { | |
3009 int i; | |
3010 if (!priv) | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3011 return 1; |
24744 | 3012 //Debug |
3013 if (priv->dwRegister) { | |
3014 RemoveFromRot(priv->dwRegister); | |
3015 } | |
3016 teletext_control(priv->priv_vbi,TV_VBI_CONTROL_STOP,(void*)1); | |
3017 //stop audio grabber thread | |
3018 | |
3019 if (priv->state && priv->pMediaControl) { | |
3020 OLE_CALL(priv->pMediaControl, Stop); | |
3021 } | |
3022 OLE_RELEASE_SAFE(priv->pMediaControl); | |
3023 priv->state = 0; | |
3024 | |
3025 if (priv->pGraph) { | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3026 if (priv->chains[0]->pCaptureFilter) |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3027 OLE_CALL_ARGS(priv->pGraph, RemoveFilter, priv->chains[0]->pCaptureFilter); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3028 if (priv->chains[1]->pCaptureFilter) |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3029 OLE_CALL_ARGS(priv->pGraph, RemoveFilter, priv->chains[1]->pCaptureFilter); |
24744 | 3030 } |
3031 OLE_RELEASE_SAFE(priv->pCrossbar); | |
3032 OLE_RELEASE_SAFE(priv->pVideoProcAmp); | |
3033 OLE_RELEASE_SAFE(priv->pGraph); | |
3034 OLE_RELEASE_SAFE(priv->pBuilder); | |
3035 if(priv->freq_table){ | |
3036 priv->freq_table_len=-1; | |
3037 free(priv->freq_table); | |
3038 priv->freq_table=NULL; | |
3039 } | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3040 |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3041 for(i=0; i<3;i++) |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3042 { |
25085
da7c8d1b7a36
Move common chain uninit code into separate routine.
voroshil
parents:
25084
diff
changeset
|
3043 destroy_chain(priv->chains[i]); |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3044 priv->chains[i] = NULL; |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3045 } |
24744 | 3046 CoUninitialize(); |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3047 return 1; |
24744 | 3048 } |
3049 | |
3050 /** | |
3051 * \brief driver pre-initialization | |
3052 * | |
3053 * \param device string, containing device name in form "x[.y]", where x is video capture device | |
3054 * (default: 0, first available); y (if given) sets audio capture device | |
3055 * | |
3056 * \return 1 if success,0 - otherwise | |
3057 */ | |
3058 static tvi_handle_t *tvi_init_dshow(tv_param_t* tv_param) | |
3059 { | |
3060 tvi_handle_t *h; | |
3061 priv_t *priv; | |
3062 int a; | |
3063 | |
32141
2802b8095bf7
Move TV input new_handle static function to tv.c and make it non-static.
diego
parents:
32090
diff
changeset
|
3064 h = tv_new_handle(sizeof(priv_t), &functions); |
24744 | 3065 if (!h) |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3066 return NULL; |
24744 | 3067 |
3068 priv = h->priv; | |
3069 | |
3070 memset(priv, 0, sizeof(priv_t)); | |
3071 priv->direct_setfreq_call = 1; //first using direct call. if it fails, workaround will be enabled | |
3072 priv->direct_getfreq_call = 1; //first using direct call. if it fails, workaround will be enabled | |
3073 priv->adev_index = -1; | |
3074 priv->freq_table_len=-1; | |
3075 priv->tv_param=tv_param; | |
3076 | |
3077 if (tv_param->device) { | |
3078 if (sscanf(tv_param->device, "%d", &a) == 1) { | |
3079 priv->dev_index = a; | |
3080 } else { | |
3081 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_WrongDeviceParam, tv_param->device); | |
32090
535ebcd085e4
Move TV input free_handle static function to tv.c and make it non-static.
diego
parents:
31322
diff
changeset
|
3082 tv_free_handle(h); |
24744 | 3083 return NULL; |
3084 } | |
3085 if (priv->dev_index < 0) { | |
3086 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_WrongDeviceIndex, a); | |
32090
535ebcd085e4
Move TV input free_handle static function to tv.c and make it non-static.
diego
parents:
31322
diff
changeset
|
3087 tv_free_handle(h); |
24744 | 3088 return NULL; |
3089 } | |
3090 } | |
3091 if (tv_param->adevice) { | |
3092 if (sscanf(tv_param->adevice, "%d", &a) == 1) { | |
3093 priv->adev_index = a; | |
3094 } else { | |
3095 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_WrongADeviceParam, tv_param->adevice); | |
32090
535ebcd085e4
Move TV input free_handle static function to tv.c and make it non-static.
diego
parents:
31322
diff
changeset
|
3096 tv_free_handle(h); |
24744 | 3097 return NULL; |
3098 } | |
3099 if (priv->dev_index < 0) { | |
3100 mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TVI_DS_WrongADeviceIndex, a); | |
32090
535ebcd085e4
Move TV input free_handle static function to tv.c and make it non-static.
diego
parents:
31322
diff
changeset
|
3101 tv_free_handle(h); |
24744 | 3102 return NULL; |
3103 } | |
3104 } | |
3105 return h; | |
3106 } | |
3107 | |
3108 /** | |
3109 * \brief driver's ioctl handler | |
3110 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
3111 * \param priv driver's private data structure |
24744 | 3112 * \param cmd ioctl command |
3113 * \param arg ioct command's parameter | |
3114 * | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
3115 * \return TVI_CONTROL_TRUE if success |
24744 | 3116 * \return TVI_CONTROL_FALSE if failure |
3117 * \return TVI_CONTROL_UNKNOWN if unknowm cmd called | |
3118 */ | |
3119 static int control(priv_t * priv, int cmd, void *arg) | |
3120 { | |
3121 switch (cmd) { | |
3122 /* need rewrite */ | |
3123 case TVI_CONTROL_VID_SET_FORMAT: | |
3124 { | |
25126
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3125 int fcc, i,j; |
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3126 void* tmp,*tmp2; |
25068
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3127 int result = TVI_CONTROL_TRUE; |
25063
29260745e4fa
Pass all available formats to chain building routine and
voroshil
parents:
25061
diff
changeset
|
3128 |
24744 | 3129 if (priv->state) |
3130 return TVI_CONTROL_FALSE; | |
3131 fcc = *(int *) arg; | |
3132 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3133 if(!priv->chains[0]->arpmt) |
24744 | 3134 return TVI_CONTROL_FALSE; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3135 for (i = 0; priv->chains[0]->arpmt[i]; i++) |
24744 | 3136 if (check_video_format |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3137 (priv->chains[0]->arpmt[i], fcc, priv->width, priv->height)) |
24744 | 3138 break; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3139 if (!priv->chains[0]->arpmt[i]) |
25068
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3140 { |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3141 int fps = 0; |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3142 VIDEOINFOHEADER* Vhdr = NULL; |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3143 AM_MEDIA_TYPE *pmt; |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3144 |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3145 mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: will try also use undeclared video format: %dx%d, %s\n",priv->width, priv->height, vo_format_name(fcc)); |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3146 |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3147 if (priv->chains[0]->arpmt[0]) |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3148 Vhdr = (VIDEOINFOHEADER *) priv->chains[0]->arpmt[0]->pbFormat; |
25068
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3149 |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3150 if(Vhdr && Vhdr->bmiHeader.biSizeImage) |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3151 fps = Vhdr->dwBitRate / (8 * Vhdr->bmiHeader.biSizeImage); |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3152 |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3153 pmt=create_video_format(fcc, priv->width, priv->height, fps); |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3154 if(!pmt) |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3155 { |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3156 mp_msg(MSGT_TV, MSGL_V, "tvi_dshow: Unable to create AM_MEDIA_TYPE structure for given format\n"); |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3157 return TVI_CONTROL_FALSE; |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3158 } |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3159 priv->chains[0]->arpmt=realloc(priv->chains[0]->arpmt, (i+2)*sizeof(AM_MEDIA_TYPE*)); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3160 priv->chains[0]->arpmt[i+1] = NULL; |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3161 priv->chains[0]->arpmt[i] = pmt; |
25068
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3162 |
25105 | 3163 priv->chains[0]->arStreamCaps=realloc(priv->chains[0]->arStreamCaps, (i+2)*sizeof(void*)); |
25096 | 3164 priv->chains[0]->arpmt[i+1] = NULL; |
3165 | |
25068
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3166 result = TVI_CONTROL_FALSE; |
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3167 } |
24744 | 3168 |
25126
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3169 |
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3170 tmp=priv->chains[0]->arpmt[i]; |
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3171 tmp2=priv->chains[0]->arStreamCaps[i]; |
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3172 for(j=i; j>0; j--) |
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3173 { |
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3174 priv->chains[0]->arpmt[j] = priv->chains[0]->arpmt[j-1]; |
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3175 priv->chains[0]->arStreamCaps[j] = priv->chains[0]->arStreamCaps[j-1]; |
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3176 } |
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3177 priv->chains[0]->arpmt[0] = tmp; |
8152446e42b1
Move requested format at top and shift all oters down
voroshil
parents:
25125
diff
changeset
|
3178 priv->chains[0]->arStreamCaps[0] = tmp2; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3179 |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3180 priv->chains[0]->nFormatUsed = 0; |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3181 |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3182 if (priv->chains[0]->pmt) |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3183 DeleteMediaType(priv->chains[0]->pmt); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3184 priv->chains[0]->pmt = |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3185 CreateMediaType(priv->chains[0]->arpmt[priv->chains[0]->nFormatUsed]); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3186 DisplayMediaType("VID_SET_FORMAT", priv->chains[0]->pmt); |
24744 | 3187 /* |
3188 Setting width & height to preferred by driver values | |
3189 */ | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3190 extract_video_format(priv->chains[0]->arpmt[priv->chains[0]->nFormatUsed], |
24744 | 3191 &(priv->fcc), &(priv->width), |
3192 &(priv->height)); | |
25068
4b14d188ed34
Add all passed to VID_SET_FORMAT formats to the end of
voroshil
parents:
25067
diff
changeset
|
3193 return result; |
24744 | 3194 } |
3195 case TVI_CONTROL_VID_GET_FORMAT: | |
3196 { | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3197 if(!priv->chains[0]->pmt) |
24744 | 3198 return TVI_CONTROL_FALSE; |
25067
5abe2c29b7d8
Ensure that when VID_GET_FORMAT ioctl is called,
voroshil
parents:
25066
diff
changeset
|
3199 /* |
5abe2c29b7d8
Ensure that when VID_GET_FORMAT ioctl is called,
voroshil
parents:
25066
diff
changeset
|
3200 Build video chain (for video format negotiation). |
5abe2c29b7d8
Ensure that when VID_GET_FORMAT ioctl is called,
voroshil
parents:
25066
diff
changeset
|
3201 If this was done before, routine will do nothing. |
5abe2c29b7d8
Ensure that when VID_GET_FORMAT ioctl is called,
voroshil
parents:
25066
diff
changeset
|
3202 */ |
5abe2c29b7d8
Ensure that when VID_GET_FORMAT ioctl is called,
voroshil
parents:
25066
diff
changeset
|
3203 build_video_chain(priv); |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3204 DisplayMediaType("VID_GET_FORMAT", priv->chains[0]->pmt); |
24744 | 3205 if (priv->fcc) { |
3206 *(int *) arg = priv->fcc; | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3207 return TVI_CONTROL_TRUE; |
24744 | 3208 } else |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3209 return TVI_CONTROL_FALSE; |
24744 | 3210 } |
3211 case TVI_CONTROL_VID_SET_WIDTH: | |
3212 { | |
3213 VIDEO_STREAM_CONFIG_CAPS *pCaps; | |
3214 VIDEOINFOHEADER *Vhdr; | |
3215 int width = *(int *) arg; | |
3216 if (priv->state) | |
3217 return TVI_CONTROL_FALSE; | |
3218 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3219 pCaps = priv->chains[0]->arStreamCaps[priv->chains[0]->nFormatUsed]; |
24744 | 3220 if (!pCaps) |
3221 return TVI_CONTROL_FALSE; | |
3222 if (width < pCaps->MinOutputSize.cx | |
3223 || width > pCaps->MaxOutputSize.cx) | |
3224 return TVI_CONTROL_FALSE; | |
3225 | |
3226 if (width % pCaps->OutputGranularityX) | |
3227 return TVI_CONTROL_FALSE; | |
3228 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3229 if (!priv->chains[0]->pmt || !priv->chains[0]->pmt->pbFormat) |
24744 | 3230 return TVI_CONTROL_FALSE; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3231 Vhdr = (VIDEOINFOHEADER *) priv->chains[0]->pmt->pbFormat; |
24744 | 3232 Vhdr->bmiHeader.biWidth = width; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3233 priv->chains[0]->pmt->lSampleSize = Vhdr->bmiHeader.biSizeImage = |
24744 | 3234 labs(Vhdr->bmiHeader.biBitCount * Vhdr->bmiHeader.biWidth * |
3235 Vhdr->bmiHeader.biHeight) >> 3; | |
3236 | |
3237 priv->width = width; | |
3238 | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3239 return TVI_CONTROL_TRUE; |
24744 | 3240 } |
3241 case TVI_CONTROL_VID_GET_WIDTH: | |
3242 { | |
3243 if (priv->width) { | |
3244 *(int *) arg = priv->width; | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3245 return TVI_CONTROL_TRUE; |
24744 | 3246 } else |
3247 return TVI_CONTROL_FALSE; | |
3248 } | |
3249 case TVI_CONTROL_VID_CHK_WIDTH: | |
3250 { | |
3251 VIDEO_STREAM_CONFIG_CAPS *pCaps; | |
3252 int width = *(int *) arg; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3253 pCaps = priv->chains[0]->arStreamCaps[priv->chains[0]->nFormatUsed]; |
24744 | 3254 if (!pCaps) |
3255 return TVI_CONTROL_FALSE; | |
3256 if (width < pCaps->MinOutputSize.cx | |
3257 || width > pCaps->MaxOutputSize.cx) | |
3258 return TVI_CONTROL_FALSE; | |
3259 | |
3260 if (width % pCaps->OutputGranularityX) | |
3261 return TVI_CONTROL_FALSE; | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3262 return TVI_CONTROL_TRUE; |
24744 | 3263 } |
3264 case TVI_CONTROL_VID_SET_HEIGHT: | |
3265 { | |
3266 VIDEO_STREAM_CONFIG_CAPS *pCaps; | |
3267 VIDEOINFOHEADER *Vhdr; | |
3268 int height = *(int *) arg; | |
3269 if (priv->state) | |
3270 return TVI_CONTROL_FALSE; | |
3271 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3272 pCaps = priv->chains[0]->arStreamCaps[priv->chains[0]->nFormatUsed]; |
24744 | 3273 if (!pCaps) |
3274 return TVI_CONTROL_FALSE; | |
3275 if (height < pCaps->MinOutputSize.cy | |
3276 || height > pCaps->MaxOutputSize.cy) | |
3277 return TVI_CONTROL_FALSE; | |
3278 | |
3279 if (height % pCaps->OutputGranularityY) | |
3280 return TVI_CONTROL_FALSE; | |
3281 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3282 if (!priv->chains[0]->pmt || !priv->chains[0]->pmt->pbFormat) |
24744 | 3283 return TVI_CONTROL_FALSE; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3284 Vhdr = (VIDEOINFOHEADER *) priv->chains[0]->pmt->pbFormat; |
24744 | 3285 |
3286 if (Vhdr->bmiHeader.biHeight < 0) | |
3287 Vhdr->bmiHeader.biHeight = -height; | |
3288 else | |
3289 Vhdr->bmiHeader.biHeight = height; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3290 priv->chains[0]->pmt->lSampleSize = Vhdr->bmiHeader.biSizeImage = |
24744 | 3291 labs(Vhdr->bmiHeader.biBitCount * Vhdr->bmiHeader.biWidth * |
3292 Vhdr->bmiHeader.biHeight) >> 3; | |
3293 | |
3294 priv->height = height; | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3295 return TVI_CONTROL_TRUE; |
24744 | 3296 } |
3297 case TVI_CONTROL_VID_GET_HEIGHT: | |
3298 { | |
3299 if (priv->height) { | |
3300 *(int *) arg = priv->height; | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3301 return TVI_CONTROL_TRUE; |
24744 | 3302 } else |
3303 return TVI_CONTROL_FALSE; | |
3304 } | |
3305 case TVI_CONTROL_VID_CHK_HEIGHT: | |
3306 { | |
3307 VIDEO_STREAM_CONFIG_CAPS *pCaps; | |
3308 int height = *(int *) arg; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3309 pCaps = priv->chains[0]->arStreamCaps[priv->chains[0]->nFormatUsed]; |
24744 | 3310 if (!pCaps) |
3311 return TVI_CONTROL_FALSE; | |
3312 if (height < pCaps->MinOutputSize.cy | |
3313 || height > pCaps->MaxOutputSize.cy) | |
3314 return TVI_CONTROL_FALSE; | |
3315 | |
3316 if (height % pCaps->OutputGranularityY) | |
3317 return TVI_CONTROL_FALSE; | |
3318 | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3319 return TVI_CONTROL_TRUE; |
24744 | 3320 } |
3321 case TVI_CONTROL_IS_AUDIO: | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3322 if (!priv->chains[1]->pmt) |
24744 | 3323 return TVI_CONTROL_FALSE; |
3324 else | |
3325 return TVI_CONTROL_TRUE; | |
3326 case TVI_CONTROL_IS_VIDEO: | |
3327 return TVI_CONTROL_TRUE; | |
3328 case TVI_CONTROL_AUD_GET_FORMAT: | |
3329 { | |
3330 *(int *) arg = AF_FORMAT_S16_LE; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3331 if (!priv->chains[1]->pmt) |
24744 | 3332 return TVI_CONTROL_FALSE; |
3333 else | |
3334 return TVI_CONTROL_TRUE; | |
3335 } | |
3336 case TVI_CONTROL_AUD_GET_CHANNELS: | |
3337 { | |
3338 *(int *) arg = priv->channels; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3339 if (!priv->chains[1]->pmt) |
24744 | 3340 return TVI_CONTROL_FALSE; |
3341 else | |
3342 return TVI_CONTROL_TRUE; | |
3343 } | |
3344 case TVI_CONTROL_AUD_SET_SAMPLERATE: | |
3345 { | |
3346 int i, samplerate; | |
3347 if (priv->state) | |
3348 return TVI_CONTROL_FALSE; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3349 if (!priv->chains[1]->arpmt[0]) |
24744 | 3350 return TVI_CONTROL_FALSE; |
3351 | |
28576 | 3352 samplerate = *(int *) arg; |
24744 | 3353 |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3354 for (i = 0; priv->chains[1]->arpmt[i]; i++) |
24744 | 3355 if (check_audio_format |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3356 (priv->chains[1]->arpmt[i], samplerate, 16, priv->channels)) |
24744 | 3357 break; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
3358 if (!priv->chains[1]->arpmt[i]) { |
24744 | 3359 //request not found. failing back to first available |
3360 mp_msg(MSGT_TV, MSGL_WARN, MSGTR_TVI_DS_SamplerateNotsupported, samplerate); | |
3361 i = 0; | |
3362 } | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3363 if (priv->chains[1]->pmt) |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3364 DeleteMediaType(priv->chains[1]->pmt); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3365 priv->chains[1]->pmt = CreateMediaType(priv->chains[1]->arpmt[i]); |
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3366 extract_audio_format(priv->chains[1]->arpmt[i], &(priv->samplerate), |
24744 | 3367 NULL, &(priv->channels)); |
3368 return TVI_CONTROL_TRUE; | |
3369 } | |
3370 case TVI_CONTROL_AUD_GET_SAMPLERATE: | |
3371 { | |
3372 *(int *) arg = priv->samplerate; | |
3373 if (!priv->samplerate) | |
3374 return TVI_CONTROL_FALSE; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3375 if (!priv->chains[1]->pmt) |
24744 | 3376 return TVI_CONTROL_FALSE; |
3377 else | |
3378 return TVI_CONTROL_TRUE; | |
3379 } | |
3380 case TVI_CONTROL_AUD_GET_SAMPLESIZE: | |
3381 { | |
3382 WAVEFORMATEX *pWF; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3383 if (!priv->chains[1]->pmt) |
24744 | 3384 return TVI_CONTROL_FALSE; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3385 if (!priv->chains[1]->pmt->pbFormat) |
24744 | 3386 return TVI_CONTROL_FALSE; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3387 pWF = (WAVEFORMATEX *) priv->chains[1]->pmt->pbFormat; |
24744 | 3388 *(int *) arg = pWF->wBitsPerSample / 8; |
3389 return TVI_CONTROL_TRUE; | |
3390 } | |
3391 case TVI_CONTROL_IS_TUNER: | |
3392 { | |
3393 if (!priv->pTVTuner) | |
3394 return TVI_CONTROL_FALSE; | |
3395 | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3396 return TVI_CONTROL_TRUE; |
24744 | 3397 } |
3398 case TVI_CONTROL_TUN_SET_NORM: | |
3399 { | |
3400 IAMAnalogVideoDecoder *pVD; | |
3401 long lAnalogFormat; | |
3402 int i; | |
3403 HRESULT hr; | |
3404 | |
3405 i = *(int *) arg; | |
3406 i--; | |
3407 if (i < 0 || i >= tv_available_norms_count) | |
3408 return TVI_CONTROL_FALSE; | |
3409 lAnalogFormat = tv_norms[tv_available_norms[i]].index; | |
3410 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3411 hr = OLE_QUERYINTERFACE(priv->chains[0]->pCaptureFilter,IID_IAMAnalogVideoDecoder, pVD); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28576
diff
changeset
|
3412 if (hr != S_OK) |
24744 | 3413 return TVI_CONTROL_FALSE; |
25077 | 3414 hr = OLE_CALL_ARGS(pVD, put_TVFormat, lAnalogFormat); |
24744 | 3415 OLE_RELEASE_SAFE(pVD); |
3416 if (FAILED(hr)) | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3417 return TVI_CONTROL_FALSE; |
24744 | 3418 else |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3419 return TVI_CONTROL_TRUE; |
24744 | 3420 } |
3421 case TVI_CONTROL_TUN_GET_NORM: | |
3422 { | |
3423 long lAnalogFormat; | |
3424 int i; | |
3425 HRESULT hr; | |
3426 IAMAnalogVideoDecoder *pVD; | |
3427 | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3428 hr = OLE_QUERYINTERFACE(priv->chains[0]->pCaptureFilter,IID_IAMAnalogVideoDecoder, pVD); |
24744 | 3429 if (hr == S_OK) { |
3430 hr = OLE_CALL_ARGS(pVD, get_TVFormat, &lAnalogFormat); | |
3431 OLE_RELEASE_SAFE(pVD); | |
3432 } | |
3433 | |
3434 if (FAILED(hr)) { //trying another method | |
3435 if (!priv->pTVTuner) | |
3436 return TVI_CONTROL_FALSE; | |
3437 hr=OLE_CALL_ARGS(priv->pTVTuner, get_TVFormat, &lAnalogFormat); | |
3438 if (FAILED(hr)) | |
3439 return TVI_CONTROL_FALSE; | |
3440 } | |
3441 for (i = 0; i < tv_available_norms_count; i++) { | |
3442 if (tv_norms[tv_available_norms[i]].index == lAnalogFormat) { | |
3443 *(int *) arg = i + 1; | |
3444 return TVI_CONTROL_TRUE; | |
3445 } | |
3446 } | |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3447 return TVI_CONTROL_FALSE; |
24744 | 3448 } |
3449 case TVI_CONTROL_SPC_GET_NORMID: | |
3450 { | |
3451 int i; | |
3452 if (!priv->pTVTuner) | |
3453 return TVI_CONTROL_FALSE; | |
3454 for (i = 0; i < tv_available_norms_count; i++) { | |
3455 if (!strcasecmp | |
3456 (tv_norms[tv_available_norms[i]].name, (char *) arg)) { | |
3457 *(int *) arg = i + 1; | |
3458 return TVI_CONTROL_TRUE; | |
3459 } | |
3460 } | |
3461 return TVI_CONTROL_FALSE; | |
3462 } | |
3463 case TVI_CONTROL_SPC_SET_INPUT: | |
3464 { | |
3465 return set_crossbar_input(priv, *(int *) arg); | |
3466 } | |
3467 case TVI_CONTROL_TUN_GET_FREQ: | |
3468 { | |
3469 unsigned long lFreq; | |
3470 int ret; | |
3471 if (!priv->pTVTuner) | |
3472 return TVI_CONTROL_FALSE; | |
3473 | |
3474 ret = get_frequency(priv, &lFreq); | |
27628
1779bbc0733a
Fix overflow in frequency conversion code inside tvi_dshow.
voroshil
parents:
27370
diff
changeset
|
3475 lFreq = lFreq / (1000000/16); //convert from Hz to 1/16 MHz units |
24744 | 3476 |
3477 *(unsigned long *) arg = lFreq; | |
3478 return ret; | |
3479 } | |
3480 case TVI_CONTROL_TUN_SET_FREQ: | |
3481 { | |
3482 unsigned long nFreq = *(unsigned long *) arg; | |
3483 if (!priv->pTVTuner) | |
3484 return TVI_CONTROL_FALSE; | |
3485 //convert to Hz | |
27628
1779bbc0733a
Fix overflow in frequency conversion code inside tvi_dshow.
voroshil
parents:
27370
diff
changeset
|
3486 nFreq = (1000000/16) * nFreq; //convert from 1/16 MHz units to Hz |
24744 | 3487 return set_frequency(priv, nFreq); |
3488 } | |
3489 case TVI_CONTROL_VID_SET_HUE: | |
3490 return set_control(priv, VideoProcAmp_Hue, *(int *) arg); | |
3491 case TVI_CONTROL_VID_GET_HUE: | |
3492 return get_control(priv, VideoProcAmp_Hue, (int *) arg); | |
3493 case TVI_CONTROL_VID_SET_CONTRAST: | |
3494 return set_control(priv, VideoProcAmp_Contrast, *(int *) arg); | |
3495 case TVI_CONTROL_VID_GET_CONTRAST: | |
3496 return get_control(priv, VideoProcAmp_Contrast, (int *) arg); | |
3497 case TVI_CONTROL_VID_SET_SATURATION: | |
3498 return set_control(priv, VideoProcAmp_Saturation, *(int *) arg); | |
3499 case TVI_CONTROL_VID_GET_SATURATION: | |
3500 return get_control(priv, VideoProcAmp_Saturation, (int *) arg); | |
3501 case TVI_CONTROL_VID_SET_BRIGHTNESS: | |
3502 return set_control(priv, VideoProcAmp_Brightness, *(int *) arg); | |
3503 case TVI_CONTROL_VID_GET_BRIGHTNESS: | |
3504 return get_control(priv, VideoProcAmp_Brightness, (int *) arg); | |
3505 | |
3506 case TVI_CONTROL_VID_GET_FPS: | |
3507 { | |
3508 VIDEOINFOHEADER *Vhdr; | |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3509 if (!priv->chains[0]->pmt) |
24744 | 3510 return TVI_CONTROL_FALSE; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3511 if (!priv->chains[0]->pmt->pbFormat) |
24744 | 3512 return TVI_CONTROL_FALSE; |
25079
3dcf8e3e65d9
One step of code cleanup: move all variables, related
voroshil
parents:
25077
diff
changeset
|
3513 Vhdr = (VIDEOINFOHEADER *) priv->chains[0]->pmt->pbFormat; |
24744 | 3514 *(float *) arg = |
25028
2cae9470f53b
Fix FPS from bitrate calculation (was 8 times larger than real value).
voroshil
parents:
25019
diff
changeset
|
3515 (1.0 * Vhdr->dwBitRate) / (Vhdr->bmiHeader.biSizeImage * 8); |
24744 | 3516 return TVI_CONTROL_TRUE; |
3517 } | |
3518 case TVI_CONTROL_IMMEDIATE: | |
3519 priv->immediate_mode = 1; | |
3520 return TVI_CONTROL_TRUE; | |
3521 case TVI_CONTROL_VBI_INIT: | |
3522 { | |
3523 void* ptr; | |
3524 ptr=&(priv->tsp); | |
29760
1cc8a20520e8
Add MSGT_TELETEXT, rename TVI_CONTROL as VBI_CONTROL and fix some paths
cehoyos
parents:
29759
diff
changeset
|
3525 if(teletext_control(NULL,TV_VBI_CONTROL_START,&ptr)==VBI_CONTROL_TRUE) |
24744 | 3526 priv->priv_vbi=ptr; |
3527 else | |
3528 priv->priv_vbi=NULL; | |
3529 return TVI_CONTROL_TRUE; | |
3530 } | |
29806 | 3531 case TVI_CONTROL_GET_VBI_PTR: |
3532 *(void **)arg=priv->priv_vbi; | |
3533 return TVI_CONTROL_TRUE; | |
24744 | 3534 } |
26756
c43ce7268677
cosmetics: Remove useless parentheses from return statements.
diego
parents:
26737
diff
changeset
|
3535 return TVI_CONTROL_UNKNOWN; |
24744 | 3536 } |