]> git.sesse.net Git - vlc/blob - modules/access/dshow/common.h
Win32: prepare for Dshow freq and video standard options
[vlc] / modules / access / dshow / common.h
1 /*****************************************************************************
2  * common.h : DirectShow access module for vlc
3  *****************************************************************************
4  * Copyright (C) 2002 the VideoLAN team
5  * $Id$
6  *
7  * Author: Gildas Bazin <gbazin@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <string>
28 #include <list>
29 #include <deque>
30 using namespace std;
31
32 #ifndef _MSC_VER
33 #   include <wtypes.h>
34 #   include <unknwn.h>
35 #   include <ole2.h>
36 #   include <limits.h>
37 #   ifdef _WINGDI_
38 #      undef _WINGDI_
39 #   endif
40 #   define _WINGDI_ 1
41 #   define AM_NOVTABLE
42 #   define _OBJBASE_H_
43 #   undef _X86_
44 #   ifndef _I64_MAX
45 #     define _I64_MAX LONG_LONG_MAX
46 #   endif
47 #   define LONGLONG long long
48 #endif
49
50 #include <dshow.h>
51
52 typedef struct dshow_stream_t dshow_stream_t;
53
54 /****************************************************************************
55  * Crossbar stuff
56  ****************************************************************************/
57 #define MAX_CROSSBAR_DEPTH 10
58
59 typedef struct CrossbarRouteRec
60 {
61     IAMCrossbar *pXbar;
62     LONG        VideoInputIndex;
63     LONG        VideoOutputIndex;
64     LONG        AudioInputIndex;
65     LONG        AudioOutputIndex;
66
67 } CrossbarRoute;
68
69 void DeleteCrossbarRoutes( access_sys_t * );
70 HRESULT FindCrossbarRoutes( vlc_object_t *, access_sys_t *,
71                             IPin *, LONG, int = 0 );
72
73 /****************************************************************************
74  * Access descriptor declaration
75  ****************************************************************************/
76 struct access_sys_t
77 {
78     /* These 2 must be left at the beginning */
79     vlc_mutex_t lock;
80     vlc_cond_t  wait;
81
82     IFilterGraph           *p_graph;
83     ICaptureGraphBuilder2  *p_capture_graph_builder2;
84     IMediaControl          *p_control;
85
86     int                     i_crossbar_route_depth;
87     CrossbarRoute           crossbar_routes[MAX_CROSSBAR_DEPTH];
88
89     /* list of elementary streams */
90     dshow_stream_t **pp_streams;
91     int            i_streams;
92     int            i_current_stream;
93
94     /* misc properties */
95     int            i_width;
96     int            i_height;
97     int            i_chroma;
98     bool           b_chroma; /* Force a specific chroma on the dshow input */
99 };
100
101
102 /****************************************************************************
103  * The following should be in ks.h and ksmedia.h, but since they are not in
104  * the current version of Mingw, we will be defined here.
105  ****************************************************************************/
106
107 /* http://msdn.microsoft.com/en-us/library/ff567297%28VS.85%29.aspx */
108 typedef enum  {
109         KS_AnalogVideo_None          = 0x00000000,
110         KS_AnalogVideo_NTSC_M        = 0x00000001,
111         KS_AnalogVideo_NTSC_M_J      = 0x00000002,
112         KS_AnalogVideo_NTSC_433      = 0x00000004,
113         KS_AnalogVideo_PAL_B         = 0x00000010,
114         KS_AnalogVideo_PAL_D         = 0x00000020,
115         KS_AnalogVideo_PAL_G         = 0x00000040,
116         KS_AnalogVideo_PAL_H         = 0x00000080,
117         KS_AnalogVideo_PAL_I         = 0x00000100,
118         KS_AnalogVideo_PAL_M         = 0x00000200,
119         KS_AnalogVideo_PAL_N         = 0x00000400,
120         KS_AnalogVideo_PAL_60        = 0x00000800,
121         KS_AnalogVideo_SECAM_B       = 0x00001000,
122         KS_AnalogVideo_SECAM_D       = 0x00002000,
123         KS_AnalogVideo_SECAM_G       = 0x00004000,
124         KS_AnalogVideo_SECAM_H       = 0x00008000,
125         KS_AnalogVideo_SECAM_K       = 0x00010000,
126         KS_AnalogVideo_SECAM_K1      = 0x00020000,
127         KS_AnalogVideo_SECAM_L       = 0x00040000,
128         KS_AnalogVideo_SECAM_L1      = 0x00080000,
129         KS_AnalogVideo_PAL_N_COMBO   = 0x00100000
130 } KS_AnalogVideoStandard;
131
132 /* http://msdn.microsoft.com/en-us/library/ff567800%28VS.85%29.aspx and following */
133 typedef enum {
134     KSPROPERTY_TUNER_CAPS,              // R  -overall device capabilities
135     KSPROPERTY_TUNER_MODE_CAPS,         // R  -capabilities in this mode
136     KSPROPERTY_TUNER_MODE,              // RW -set a mode (TV, FM, AM, DSS)
137     KSPROPERTY_TUNER_STANDARD,          // R  -get TV standard (only if TV mode)
138     KSPROPERTY_TUNER_FREQUENCY,         // RW -set/get frequency
139     KSPROPERTY_TUNER_INPUT,             // RW -select an input
140     KSPROPERTY_TUNER_STATUS,            // R  -tuning status
141
142     /* Optional */
143     KSPROPERTY_TUNER_IF_MEDIUM,         // R O-Medium for IF or Transport Pin
144
145     /* Mandatory for Vista and + */
146     KSPROPERTY_TUNER_SCAN_CAPS,         // R  -overall device capabilities for scanning
147
148     /* Optional ones */
149     KSPROPERTY_TUNER_SCAN_STATUS,       // R  -status of scan
150     KSPROPERTY_TUNER_STANDARD_MODE,     // RW -autodetect mode for signal standard
151     KSPROPERTY_TUNER_NETWORKTYPE_SCAN_CAPS // R -network type specific tuner capabilities
152 } KSPROPERTY_TUNER;
153
154 /* http://msdn.microsoft.com/en-us/library/ff567689%28v=VS.85%29.aspx */
155 typedef enum {
156     KS_TUNER_TUNING_EXACT = 1,        // Tunes directly to the right freq
157     KS_TUNER_TUNING_FINE,             // Comprehensive search to the right freq
158     KS_TUNER_TUNING_COARSE,           // Fast search
159 }KS_TUNER_TUNING_FLAGS;
160
161 /* http://msdn.microsoft.com/en-us/library/ff567687%28v=VS.85%29.aspx */
162 typedef enum {
163     KS_TUNER_STRATEGY_PLL             = 0X01, // Phase locked loop (PLL) offset tuning
164     KS_TUNER_STRATEGY_SIGNAL_STRENGTH = 0X02, // Signal strength tuning
165     KS_TUNER_STRATEGY_DRIVER_TUNES    = 0X04, // Driver tunes
166 }KS_TUNER_STRATEGY;
167
168 /* http://msdn.microsoft.com/en-us/library/ff562676%28VS.85%29.aspx */
169 typedef struct {
170     union {
171         struct {
172             GUID    Set;
173             ULONG   Id;
174             ULONG   Flags;
175         };
176         LONGLONG    Alignment;
177     };
178 } KSIDENTIFIER, *PKSIDENTIFIER;
179
180 typedef KSIDENTIFIER KSPROPERTY, *PKSPROPERTY;
181
182 /* http://msdn.microsoft.com/en-us/library/ff565872%28v=VS.85%29.aspx */
183 typedef struct {
184     KSPROPERTY Property;
185     ULONG  Mode;                        // KSPROPERTY_TUNER_MODE_*
186     ULONG  StandardsSupported;          // KS_AnalogVideo_* (if Mode is TV or DSS)
187     ULONG  MinFrequency;                // Hz
188     ULONG  MaxFrequency;                // Hz
189     ULONG  TuningGranularity;           // Hz
190     ULONG  NumberOfInputs;              // number of inputs
191     ULONG  SettlingTime;                // milliSeconds
192     ULONG  Strategy;                    // KS_TUNER_STRATEGY
193 } KSPROPERTY_TUNER_MODE_CAPS_S, *PKSPROPERTY_TUNER_MODE_CAPS_S;
194
195 /* http://msdn.microsoft.com/en-us/library/ff565839%28v=VS.85%29.aspx */
196 typedef struct {
197     KSPROPERTY Property;
198     ULONG  Frequency;                   // Hz
199     ULONG  LastFrequency;               // Hz (last tuned)
200     ULONG  TuningFlags;                 // KS_TUNER_TUNING_FLAGS
201     ULONG  VideoSubChannel;             // DSS
202     ULONG  AudioSubChannel;             // DSS
203     ULONG  Channel;                     // VBI decoders
204     ULONG  Country;                     // VBI decoders
205 } KSPROPERTY_TUNER_FREQUENCY_S, *PKSPROPERTY_TUNER_FREQUENCY_S;
206
207 /* http://msdn.microsoft.com/en-us/library/ff565918%28v=VS.85%29.aspx */
208 typedef struct {
209     KSPROPERTY Property;
210     ULONG  Standard;                    // KS_AnalogVideo_*
211 } KSPROPERTY_TUNER_STANDARD_S, *PKSPROPERTY_TUNER_STANDARD_S;
212