Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenpin.h
Go to the documentation of this file.
00001 /* 00002 * IPin function declarations to allow inheritance 00003 * 00004 * Copyright 2003 Robert Shearman 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 00019 */ 00020 00021 /* This function will process incoming samples to the pin. 00022 * Any return value valid in IMemInputPin::Receive is allowed here 00023 * 00024 * Cookie is the cookie that was set when requesting the buffer, if you don't 00025 * implement custom requesting, you can safely ignore this 00026 */ 00027 typedef HRESULT (* SAMPLEPROC_PUSH)(LPVOID userdata, IMediaSample * pSample); 00028 typedef HRESULT (* SAMPLEPROC_PULL)(LPVOID userdata, IMediaSample * pSample, DWORD_PTR cookie); 00029 00030 /* This function will determine whether a type is supported or not. 00031 * It is allowed to return any error value (within reason), as opposed 00032 * to IPin::QueryAccept which is only allowed to return S_OK or S_FALSE. 00033 */ 00034 typedef HRESULT (* QUERYACCEPTPROC)(LPVOID userdata, const AM_MEDIA_TYPE * pmt); 00035 00036 /* This function is called prior to finalizing a connection with 00037 * another pin and can be used to get things from the other pin 00038 * like IMemInput interfaces. 00039 * 00040 * props contains some defaults, but you can safely override them to your liking 00041 */ 00042 typedef HRESULT (* PRECONNECTPROC)(IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *props); 00043 00044 /* This function is called whenever a cleanup operation has to occur, 00045 * this is usually after a flush, seek, or end of stream notification. 00046 * This code may even be repeated multiple times, so build your code to 00047 * tolerate this behavior. Return value is ignored and should be S_OK. 00048 */ 00049 typedef HRESULT (* CLEANUPPROC) (LPVOID userdata); 00050 00051 /* This function is called whenever a request for a new sample is made, 00052 * If you implement it (it can be NULL for default behavior), you have to 00053 * call IMemAllocator_GetBuffer and IMemAllocator_RequestBuffer 00054 * This is useful if you want to request more than 1 buffer at simultaneously 00055 * 00056 * This will also cause the Sample Proc to be called with empty buffers to indicate 00057 * failure in retrieving the sample. 00058 */ 00059 typedef HRESULT (* REQUESTPROC) (LPVOID userdata); 00060 00061 /* This function is called after processing is done (for whatever reason that is caused) 00062 * This is useful if you create processing threads that need to die 00063 */ 00064 typedef HRESULT (* STOPPROCESSPROC) (LPVOID userdata); 00065 00066 #define ALIGNDOWN(value,boundary) ((value)/(boundary)*(boundary)) 00067 #define ALIGNUP(value,boundary) (ALIGNDOWN((value)+(boundary)-1, (boundary))) 00068 00069 typedef struct IPinImpl 00070 { 00071 const struct IPinVtbl * lpVtbl; 00072 LONG refCount; 00073 LPCRITICAL_SECTION pCritSec; 00074 PIN_INFO pinInfo; 00075 IPin * pConnectedTo; 00076 AM_MEDIA_TYPE mtCurrent; 00077 ENUMMEDIADETAILS enumMediaDetails; 00078 QUERYACCEPTPROC fnQueryAccept; 00079 LPVOID pUserData; 00080 } IPinImpl; 00081 00082 typedef struct InputPin 00083 { 00084 /* inheritance C style! */ 00085 IPinImpl pin; 00086 00087 const IMemInputPinVtbl * lpVtblMemInput; 00088 IMemAllocator * pAllocator; 00089 SAMPLEPROC_PUSH fnSampleProc; 00090 CLEANUPPROC fnCleanProc; 00091 REFERENCE_TIME tStart; 00092 REFERENCE_TIME tStop; 00093 double dRate; 00094 BOOL flushing, end_of_stream; 00095 IMemAllocator *preferred_allocator; 00096 } InputPin; 00097 00098 typedef struct OutputPin 00099 { 00100 /* inheritance C style! */ 00101 IPinImpl pin; 00102 00103 IMemInputPin * pMemInputPin; 00104 HRESULT (* pConnectSpecific)(IPin * iface, IPin * pReceiver, const AM_MEDIA_TYPE * pmt); 00105 BOOL custom_allocator; 00106 IMemAllocator *alloc; 00107 BOOL readonly; 00108 ALLOCATOR_PROPERTIES allocProps; 00109 } OutputPin; 00110 00111 typedef struct PullPin 00112 { 00113 /* inheritance C style! */ 00114 IPinImpl pin; 00115 00116 REFERENCE_TIME rtStart, rtCurrent, rtNext, rtStop; 00117 IAsyncReader * pReader; 00118 IMemAllocator * pAlloc; 00119 SAMPLEPROC_PULL fnSampleProc; 00120 PRECONNECTPROC fnPreConnect; 00121 REQUESTPROC fnCustomRequest; 00122 CLEANUPPROC fnCleanProc; 00123 STOPPROCESSPROC fnDone; 00124 double dRate; 00125 BOOL stop_playback; 00126 DWORD cbAlign; 00127 00128 /* Any code that touches the thread must hold the thread lock, 00129 * lock order: thread_lock and then the filter critical section 00130 * also signal thread_sleepy so the thread knows to wake up 00131 */ 00132 CRITICAL_SECTION thread_lock; 00133 HANDLE hThread; 00134 DWORD requested_state; 00135 HANDLE hEventStateChanged, thread_sleepy; 00136 DWORD state; 00137 } PullPin; 00138 00139 #define Req_Sleepy 0 00140 #define Req_Die 1 00141 #define Req_Run 2 00142 #define Req_Pause 3 00143 00144 /*** Constructors ***/ 00145 HRESULT InputPin_Construct(const IPinVtbl *InputPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PUSH pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, LPCRITICAL_SECTION pCritSec, IMemAllocator *, IPin ** ppPin); 00146 HRESULT OutputPin_Construct(const IPinVtbl *OutputPin_Vtbl, LONG outputpin_size, const PIN_INFO * pPinInfo, ALLOCATOR_PROPERTIES *props, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, LPCRITICAL_SECTION pCritSec, IPin ** ppPin); 00147 HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInfo, SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, STOPPROCESSPROC, REQUESTPROC pCustomRequest, LPCRITICAL_SECTION pCritSec, IPin ** ppPin); 00148 00149 /**************************/ 00150 /*** Pin Implementation ***/ 00151 00152 /* Common */ 00153 ULONG WINAPI IPinImpl_AddRef(IPin * iface); 00154 HRESULT WINAPI IPinImpl_Disconnect(IPin * iface); 00155 HRESULT WINAPI IPinImpl_ConnectedTo(IPin * iface, IPin ** ppPin); 00156 HRESULT WINAPI IPinImpl_ConnectionMediaType(IPin * iface, AM_MEDIA_TYPE * pmt); 00157 HRESULT WINAPI IPinImpl_QueryPinInfo(IPin * iface, PIN_INFO * pInfo); 00158 HRESULT WINAPI IPinImpl_QueryDirection(IPin * iface, PIN_DIRECTION * pPinDir); 00159 HRESULT WINAPI IPinImpl_QueryId(IPin * iface, LPWSTR * Id); 00160 HRESULT WINAPI IPinImpl_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt); 00161 HRESULT WINAPI IPinImpl_EnumMediaTypes(IPin * iface, IEnumMediaTypes ** ppEnum); 00162 HRESULT WINAPI IPinImpl_QueryInternalConnections(IPin * iface, IPin ** apPin, ULONG * cPin); 00163 00164 /* Input Pin */ 00165 HRESULT WINAPI InputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv); 00166 ULONG WINAPI InputPin_Release(IPin * iface); 00167 HRESULT WINAPI InputPin_Connect(IPin * iface, IPin * pConnector, const AM_MEDIA_TYPE * pmt); 00168 HRESULT WINAPI InputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt); 00169 HRESULT WINAPI InputPin_EndOfStream(IPin * iface); 00170 HRESULT WINAPI InputPin_BeginFlush(IPin * iface); 00171 HRESULT WINAPI InputPin_EndFlush(IPin * iface); 00172 HRESULT WINAPI InputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); 00173 00174 /* Output Pin */ 00175 HRESULT WINAPI OutputPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv); 00176 ULONG WINAPI OutputPin_Release(IPin * iface); 00177 HRESULT WINAPI OutputPin_Connect(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt); 00178 HRESULT WINAPI OutputPin_Disconnect(IPin * iface); 00179 HRESULT WINAPI OutputPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt); 00180 HRESULT WINAPI OutputPin_EndOfStream(IPin * iface); 00181 HRESULT WINAPI OutputPin_BeginFlush(IPin * iface); 00182 HRESULT WINAPI OutputPin_EndFlush(IPin * iface); 00183 HRESULT WINAPI OutputPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); 00184 00185 HRESULT OutputPin_CommitAllocator(OutputPin * This); 00186 HRESULT OutputPin_DecommitAllocator(OutputPin * This); 00187 HRESULT OutputPin_GetDeliveryBuffer(OutputPin * This, IMediaSample ** ppSample, REFERENCE_TIME * tStart, REFERENCE_TIME * tStop, DWORD dwFlags); 00188 HRESULT OutputPin_SendSample(OutputPin * This, IMediaSample * pSample); 00189 HRESULT OutputPin_DeliverDisconnect(OutputPin * This); 00190 00191 /* Pull Pin */ 00192 HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt); 00193 HRESULT WINAPI PullPin_Disconnect(IPin * iface); 00194 HRESULT WINAPI PullPin_QueryInterface(IPin * iface, REFIID riid, LPVOID * ppv); 00195 ULONG WINAPI PullPin_Release(IPin * iface); 00196 HRESULT WINAPI PullPin_EndOfStream(IPin * iface); 00197 HRESULT WINAPI PullPin_BeginFlush(IPin * iface); 00198 HRESULT WINAPI PullPin_EndFlush(IPin * iface); 00199 HRESULT WINAPI PullPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate); 00200 00201 /* Thread interaction functions: Hold the thread_lock before calling them */ 00202 HRESULT PullPin_StartProcessing(PullPin * This); 00203 HRESULT PullPin_PauseProcessing(PullPin * This); 00204 HRESULT PullPin_WaitForStateChange(PullPin * This, DWORD dwMilliseconds); Generated on Sun May 27 2012 04:21:59 for ReactOS by
1.7.6.1
|