Implement ResetDC and PHYSICALOFFSET[X|Y] devcaps.
[wine] / dlls / quartz / parser.h
1 /*
2  * Implements Parser.
3  *
4  * Copyright (C) Hidenori TAKESHIMA <hidenori@a2.ctktv.ne.jp>
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #ifndef WINE_DSHOW_PARSER_H
22 #define WINE_DSHOW_PARSER_H
23
24 #include "iunk.h"
25 #include "basefilt.h"
26
27 typedef struct CParserImpl CParserImpl;
28 typedef struct CParserInPinImpl CParserInPinImpl;
29 typedef struct CParserOutPinImpl CParserOutPinImpl;
30 typedef struct ParserHandlers ParserHandlers;
31
32 /* {D51BD5A1-7548-11CF-A520-0080C77EF58A} */
33 DEFINE_GUID(CLSID_quartzWaveParser,
34 0xD51BD5A1,0x7548,0x11CF,0xA5,0x20,0x00,0x80,0xC7,0x7E,0xF5,0x8A);
35
36 struct CParserImpl
37 {
38         QUARTZ_IUnkImpl unk;
39         CBaseFilterImpl basefilter;
40
41         CParserInPinImpl* m_pInPin;
42         ULONG   m_cOutStreams;
43         CParserOutPinImpl**     m_ppOutPins;
44         GUID    m_guidTimeFormat;
45
46         CRITICAL_SECTION        m_csParser;
47         IAsyncReader*   m_pReader;
48         IMemAllocator*  m_pAllocator;
49         ALLOCATOR_PROPERTIES    m_propAlloc;
50         HANDLE  m_hEventInit;
51         DWORD   m_dwThreadId;
52         HANDLE  m_hThread;
53         BOOL    m_bSendEOS;
54
55         const ParserHandlers*   m_pHandler;
56         void*   m_pUserData;
57 };
58
59 struct CParserInPinImpl
60 {
61         QUARTZ_IUnkImpl unk;
62         CPinBaseImpl    pin;
63         CMemInputPinBaseImpl    meminput;
64
65         CParserImpl*    pParser;
66 };
67
68 struct CParserOutPinImpl
69 {
70         QUARTZ_IUnkImpl unk;
71         CPinBaseImpl    pin;
72         CQualityControlPassThruImpl     qcontrol;
73         struct { ICOM_VFIELD(IMediaSeeking); } mediaseeking;
74         struct { ICOM_VFIELD(IMediaPosition); } mediaposition;
75
76         CParserImpl*    pParser;
77         ULONG   nStreamIndex;
78
79         AM_MEDIA_TYPE   m_mtOut;
80         IMemAllocator*  m_pOutPinAllocator;
81         void*   m_pUserData;
82
83         /* for parser */
84         BOOL    m_bReqUsed;
85         IMediaSample*   m_pReqSample;
86         LONGLONG        m_llReqStart;
87         LONG    m_lReqLength;
88         REFERENCE_TIME  m_rtReqStart;
89         REFERENCE_TIME  m_rtReqStop;
90         DWORD   m_dwSampleFlags;
91 };
92
93
94
95 struct ParserHandlers
96 {
97         HRESULT (*pInitParser)( CParserImpl* pImpl, ULONG* pcStreams );
98         HRESULT (*pUninitParser)( CParserImpl* pImpl );
99         LPCWSTR (*pGetOutPinName)( CParserImpl* pImpl, ULONG nStreamIndex );
100         HRESULT (*pGetStreamType)( CParserImpl* pImpl, ULONG nStreamIndex, AM_MEDIA_TYPE* pmt );
101         HRESULT (*pCheckStreamType)( CParserImpl* pImpl, ULONG nStreamIndex, const AM_MEDIA_TYPE* pmt );
102         HRESULT (*pGetAllocProp)( CParserImpl* pImpl, ALLOCATOR_PROPERTIES* pReqProp );
103         /* S_OK - ok, S_FALSE - end of stream */
104         HRESULT (*pGetNextRequest)( CParserImpl* pImpl, ULONG* pnStreamIndex, LONGLONG* pllStart, LONG* plLength, REFERENCE_TIME* prtStart, REFERENCE_TIME* prtStop, DWORD* pdwSampleFlags );
105         HRESULT (*pProcessSample)( CParserImpl* pImpl, ULONG nStreamIndex, LONGLONG llStart, LONG lLength, IMediaSample* pSample );
106
107         /* for IQualityControl */
108         HRESULT (*pQualityNotify)( CParserImpl* pImpl, ULONG nStreamIndex, Quality q );
109
110         /* for seeking */
111         HRESULT (*pGetSeekingCaps)( CParserImpl* pImpl, DWORD* pdwCaps );
112         HRESULT (*pIsTimeFormatSupported)( CParserImpl* pImpl, const GUID* pTimeFormat );
113         HRESULT (*pGetCurPos)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG* pllPos );
114         HRESULT (*pSetCurPos)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG llPos );
115         HRESULT (*pGetDuration)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG* pllDuration );
116         HRESULT (*pGetStopPos)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG* pllPos );
117         HRESULT (*pSetStopPos)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG llPos );
118         HRESULT (*pGetPreroll)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG* pllPreroll );
119 };
120
121 #define CParserImpl_THIS(iface,member)  CParserImpl*    This = ((CParserImpl*)(((char*)iface)-offsetof(CParserImpl,member)))
122 #define CParserInPinImpl_THIS(iface,member)     CParserInPinImpl*       This = ((CParserInPinImpl*)(((char*)iface)-offsetof(CParserInPinImpl,member)))
123 #define CParserOutPinImpl_THIS(iface,member)    CParserOutPinImpl*      This = ((CParserOutPinImpl*)(((char*)iface)-offsetof(CParserOutPinImpl,member)))
124
125
126 #define CParserOutPinImpl_IMediaSeeking(th)     ((IMediaSeeking*)&((th)->mediaseeking))
127 #define CParserOutPinImpl_IMediaPosition(th)    ((IMediaPosition*)&((th)->mediaposition))
128
129 HRESULT QUARTZ_CreateParser(
130         IUnknown* punkOuter,void** ppobj,
131         const CLSID* pclsidParser,
132         LPCWSTR pwszParserName,
133         LPCWSTR pwszInPinName,
134         const ParserHandlers* pHandler );
135 HRESULT QUARTZ_CreateParserInPin(
136         CParserImpl* pFilter,
137         CRITICAL_SECTION* pcsPin,
138         CParserInPinImpl** ppPin,
139         LPCWSTR pwszPinName );
140 HRESULT QUARTZ_CreateParserOutPin(
141         CParserImpl* pFilter,
142         CRITICAL_SECTION* pcsPin,
143         CParserOutPinImpl** ppPin,
144         ULONG nStreamIndex,
145         LPCWSTR pwszPinName );
146
147
148 #define PARSER_POLL_INTERVAL    100
149
150 #define PARSER_RIFF_OfsFirst 12
151 #define PARSER_WAVE mmioFOURCC('W','A','V','E')
152 #define PARSER_AVI  mmioFOURCC('A','V','I',' ')
153 #define PARSER_AVIX mmioFOURCC('A','V','I','X')
154
155 #define PARSER_fmt  mmioFOURCC('f','m','t',' ')
156 #define PARSER_fact mmioFOURCC('f','a','c','t')
157 #define PARSER_data mmioFOURCC('d','a','t','a')
158
159 #define PARSER_LIST mmioFOURCC('L','I','S','T')
160
161 #define PARSER_hdrl mmioFOURCC('h','d','r','l')
162 #define PARSER_avih mmioFOURCC('a','v','i','h')
163 #define PARSER_strl mmioFOURCC('s','t','r','l')
164 #define PARSER_strh mmioFOURCC('s','t','r','h')
165 #define PARSER_strf mmioFOURCC('s','t','r','f')
166 #define PARSER_idx1 mmioFOURCC('i','d','x','1')
167 #define PARSER_indx mmioFOURCC('i','n','d','x')
168 #define PARSER_movi mmioFOURCC('m','o','v','i')
169 #define PARSER_JUNK mmioFOURCC('J','U','N','K')
170
171 #define PARSER_vids mmioFOURCC('v','i','d','s')
172 #define PARSER_auds mmioFOURCC('a','u','d','s')
173 #define PARSER_mids mmioFOURCC('m','i','d','s')
174 #define PARSER_txts mmioFOURCC('t','x','t','s')
175
176 #define PARSER_LE_UINT16(ptr)   (((DWORD)(ptr)[0])|((DWORD)(ptr)[1]<<8))
177 #define PARSER_LE_UINT32(ptr)   (((DWORD)(ptr)[0])|((DWORD)(ptr)[1]<<8)|((DWORD)(ptr)[2]<<16)|((DWORD)(ptr)[3]<<24))
178 #define PARSER_BE_UINT16(ptr)   (((DWORD)(ptr)[0]<<8)|((DWORD)(ptr)[1]))
179 #define PARSER_BE_UINT32(ptr)   (((DWORD)(ptr)[0]<<24)|((DWORD)(ptr)[1]<<16)|((DWORD)(ptr)[2]<<8)|((DWORD)(ptr)[3]))
180
181 HRESULT QUARTZ_CreateWaveParser(IUnknown* punkOuter,void** ppobj);
182 HRESULT QUARTZ_CreateAVISplitter(IUnknown* punkOuter,void** ppobj);
183 HRESULT QUARTZ_CreateMPEG1Splitter(IUnknown* punkOuter,void** ppobj);
184
185
186 HRESULT RIFF_GetNext(
187         CParserImpl* pImpl, LONGLONG llOfs,
188         DWORD* pdwCode, DWORD* pdwLength );
189 HRESULT RIFF_SearchChunk(
190         CParserImpl* pImpl,
191         DWORD dwSearchLengthMax,
192         LONGLONG llOfs, DWORD dwChunk,
193         LONGLONG* pllOfs, DWORD* pdwChunkLength );
194 HRESULT RIFF_SearchList(
195         CParserImpl* pImpl,
196         DWORD dwSearchLengthMax,
197         LONGLONG llOfs, DWORD dwListChunk,
198         LONGLONG* pllOfs, DWORD* pdwChunkLength );
199
200
201 #endif  /* WINE_DSHOW_PARSER_H */