annotate stream/tvi_dshow.c @ 24762:1ed81edfac75

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