Added test for GetFullPathNamesA, GetLongPathNamesA,
[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         BOOL    m_bIsRunning;
52         DWORD   m_dwThreadId;
53         HANDLE  m_hThread;
54         BOOL    m_bSendEOS;
55
56         const ParserHandlers*   m_pHandler;
57         void*   m_pUserData;
58 };
59
60 struct CParserInPinImpl
61 {
62         QUARTZ_IUnkImpl unk;
63         CPinBaseImpl    pin;
64         CMemInputPinBaseImpl    meminput;
65
66         CParserImpl*    pParser;
67 };
68
69 struct CParserOutPinImpl
70 {
71         QUARTZ_IUnkImpl unk;
72         CPinBaseImpl    pin;
73         CQualityControlPassThruImpl     qcontrol;
74         struct { ICOM_VFIELD(IMediaSeeking); } mediaseeking;
75         struct { ICOM_VFIELD(IMediaPosition); } mediaposition;
76
77         CParserImpl*    pParser;
78         ULONG   nStreamIndex;
79
80         AM_MEDIA_TYPE   m_mtOut;
81         IMemAllocator*  m_pOutPinAllocator;
82         void*   m_pUserData;
83
84         /* for parser */
85         BOOL    m_bReqUsed;
86         IMediaSample*   m_pReqSample;
87         LONGLONG        m_llReqStart;
88         LONG    m_lReqLength;
89         REFERENCE_TIME  m_rtReqStart;
90         REFERENCE_TIME  m_rtReqStop;
91         DWORD   m_dwSampleFlags;
92 };
93
94
95
96 struct ParserHandlers
97 {
98         HRESULT (*pInitParser)( CParserImpl* pImpl, ULONG* pcStreams );
99         HRESULT (*pUninitParser)( CParserImpl* pImpl );
100         LPCWSTR (*pGetOutPinName)( CParserImpl* pImpl, ULONG nStreamIndex );
101         HRESULT (*pGetStreamType)( CParserImpl* pImpl, ULONG nStreamIndex, AM_MEDIA_TYPE* pmt );
102         HRESULT (*pCheckStreamType)( CParserImpl* pImpl, ULONG nStreamIndex, const AM_MEDIA_TYPE* pmt );
103         HRESULT (*pGetAllocProp)( CParserImpl* pImpl, ALLOCATOR_PROPERTIES* pReqProp );
104         /* S_OK - ok, S_FALSE - end of stream */
105         HRESULT (*pGetNextRequest)( CParserImpl* pImpl, ULONG* pnStreamIndex, LONGLONG* pllStart, LONG* plLength, REFERENCE_TIME* prtStart, REFERENCE_TIME* prtStop, DWORD* pdwSampleFlags );
106         HRESULT (*pProcessSample)( CParserImpl* pImpl, ULONG nStreamIndex, LONGLONG llStart, LONG lLength, IMediaSample* pSample );
107
108         /* for IQualityControl */
109         HRESULT (*pQualityNotify)( CParserImpl* pImpl, ULONG nStreamIndex, Quality q );
110
111         /* for seeking */
112         HRESULT (*pGetSeekingCaps)( CParserImpl* pImpl, DWORD* pdwCaps );
113         HRESULT (*pIsTimeFormatSupported)( CParserImpl* pImpl, const GUID* pTimeFormat );
114         HRESULT (*pGetCurPos)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG* pllPos );
115         HRESULT (*pSetCurPos)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG llPos );
116         HRESULT (*pGetDuration)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG* pllDuration );
117         HRESULT (*pGetStopPos)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG* pllPos );
118         HRESULT (*pSetStopPos)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG llPos );
119         HRESULT (*pGetPreroll)( CParserImpl* pImpl, const GUID* pTimeFormat, DWORD nStreamIndex, LONGLONG* pllPreroll );
120 };
121
122 #define CParserImpl_THIS(iface,member)  CParserImpl*    This = ((CParserImpl*)(((char*)iface)-offsetof(CParserImpl,member)))
123 #define CParserInPinImpl_THIS(iface,member)     CParserInPinImpl*       This = ((CParserInPinImpl*)(((char*)iface)-offsetof(CParserInPinImpl,member)))
124 #define CParserOutPinImpl_THIS(iface,member)    CParserOutPinImpl*      This = ((CParserOutPinImpl*)(((char*)iface)-offsetof(CParserOutPinImpl,member)))
125
126
127 #define CParserOutPinImpl_IMediaSeeking(th)     ((IMediaSeeking*)&((th)->mediaseeking))
128 #define CParserOutPinImpl_IMediaPosition(th)    ((IMediaPosition*)&((th)->mediaposition))
129
130 HRESULT QUARTZ_CreateParser(
131         IUnknown* punkOuter,void** ppobj,
132         const CLSID* pclsidParser,
133         LPCWSTR pwszParserName,
134         LPCWSTR pwszInPinName,
135         const ParserHandlers* pHandler );
136 HRESULT QUARTZ_CreateParserInPin(
137         CParserImpl* pFilter,
138         CRITICAL_SECTION* pcsPin,
139         CParserInPinImpl** ppPin,
140         LPCWSTR pwszPinName );
141 HRESULT QUARTZ_CreateParserOutPin(
142         CParserImpl* pFilter,
143         CRITICAL_SECTION* pcsPin,
144         CParserOutPinImpl** ppPin,
145         ULONG nStreamIndex,
146         LPCWSTR pwszPinName );
147
148
149 #define PARSER_POLL_INTERVAL    100
150
151 #define PARSER_RIFF_OfsFirst 12
152 #define PARSER_WAVE mmioFOURCC('W','A','V','E')
153 #define PARSER_AVI  mmioFOURCC('A','V','I',' ')
154 #define PARSER_AVIX mmioFOURCC('A','V','I','X')
155
156 #define PARSER_fmt  mmioFOURCC('f','m','t',' ')
157 #define PARSER_fact mmioFOURCC('f','a','c','t')
158 #define PARSER_data mmioFOURCC('d','a','t','a')
159
160 #define PARSER_LIST mmioFOURCC('L','I','S','T')
161
162 #define PARSER_hdrl mmioFOURCC('h','d','r','l')
163 #define PARSER_avih mmioFOURCC('a','v','i','h')
164 #define PARSER_strl mmioFOURCC('s','t','r','l')
165 #define PARSER_strh mmioFOURCC('s','t','r','h')
166 #define PARSER_strf mmioFOURCC('s','t','r','f')
167 #define PARSER_idx1 mmioFOURCC('i','d','x','1')
168 #define PARSER_indx mmioFOURCC('i','n','d','x')
169 #define PARSER_movi mmioFOURCC('m','o','v','i')
170 #define PARSER_JUNK mmioFOURCC('J','U','N','K')
171
172 #define PARSER_vids mmioFOURCC('v','i','d','s')
173 #define PARSER_auds mmioFOURCC('a','u','d','s')
174 #define PARSER_mids mmioFOURCC('m','i','d','s')
175 #define PARSER_txts mmioFOURCC('t','x','t','s')
176
177 #define PARSER_LE_UINT16(ptr)   (((DWORD)(ptr)[0])|((DWORD)(ptr)[1]<<8))
178 #define PARSER_LE_UINT32(ptr)   (((DWORD)(ptr)[0])|((DWORD)(ptr)[1]<<8)|((DWORD)(ptr)[2]<<16)|((DWORD)(ptr)[3]<<24))
179 #define PARSER_BE_UINT16(ptr)   (((DWORD)(ptr)[0]<<8)|((DWORD)(ptr)[1]))
180 #define PARSER_BE_UINT32(ptr)   (((DWORD)(ptr)[0]<<24)|((DWORD)(ptr)[1]<<16)|((DWORD)(ptr)[2]<<8)|((DWORD)(ptr)[3]))
181
182 HRESULT QUARTZ_CreateWaveParser(IUnknown* punkOuter,void** ppobj);
183 HRESULT QUARTZ_CreateAVISplitter(IUnknown* punkOuter,void** ppobj);
184 HRESULT QUARTZ_CreateMPEG1Splitter(IUnknown* punkOuter,void** ppobj);
185
186
187 HRESULT RIFF_GetNext(
188         CParserImpl* pImpl, LONGLONG llOfs,
189         DWORD* pdwCode, DWORD* pdwLength );
190 HRESULT RIFF_SearchChunk(
191         CParserImpl* pImpl,
192         DWORD dwSearchLengthMax,
193         LONGLONG llOfs, DWORD dwChunk,
194         LONGLONG* pllOfs, DWORD* pdwChunkLength );
195 HRESULT RIFF_SearchList(
196         CParserImpl* pImpl,
197         DWORD dwSearchLengthMax,
198         LONGLONG llOfs, DWORD dwListChunk,
199         LONGLONG* pllOfs, DWORD* pdwChunkLength );
200
201
202 #endif  /* WINE_DSHOW_PARSER_H */