ReactOS  0.4.14-dev-337-gf981a68
pin.h
Go to the documentation of this file.
1 /*
2  * IPin function declarations to allow inheritance
3  *
4  * Copyright 2003 Robert Shearman
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19  */
20 
21 #pragma once
22 
23 /* This function will process incoming samples to the pin.
24  * Any return value valid in IMemInputPin::Receive is allowed here
25  *
26  * Cookie is the cookie that was set when requesting the buffer, if you don't
27  * implement custom requesting, you can safely ignore this
28  */
29 typedef HRESULT (* SAMPLEPROC_PULL)(LPVOID userdata, IMediaSample * pSample, DWORD_PTR cookie);
30 
31 /* This function will determine whether a type is supported or not.
32  * It is allowed to return any error value (within reason), as opposed
33  * to IPin::QueryAccept which is only allowed to return S_OK or S_FALSE.
34  */
35 typedef HRESULT (* QUERYACCEPTPROC)(LPVOID userdata, const AM_MEDIA_TYPE * pmt);
36 
37 /* This function is called prior to finalizing a connection with
38  * another pin and can be used to get things from the other pin
39  * like IMemInput interfaces.
40  *
41  * props contains some defaults, but you can safely override them to your liking
42  */
43 typedef HRESULT (* PRECONNECTPROC)(IPin * iface, IPin * pConnectPin, ALLOCATOR_PROPERTIES *props);
44 
45 /* This function is called whenever a cleanup operation has to occur,
46  * this is usually after a flush, seek, or end of stream notification.
47  * This code may even be repeated multiple times, so build your code to
48  * tolerate this behavior. Return value is ignored and should be S_OK.
49  */
50 typedef HRESULT (* CLEANUPPROC) (LPVOID userdata);
51 
52 /* This function is called whenever a request for a new sample is made,
53  * If you implement it (it can be NULL for default behavior), you have to
54  * call IMemAllocator_GetBuffer and IMemAllocator_RequestBuffer
55  * This is useful if you want to request more than 1 buffer at simultaneously
56  *
57  * This will also cause the Sample Proc to be called with empty buffers to indicate
58  * failure in retrieving the sample.
59  */
60 typedef HRESULT (* REQUESTPROC) (LPVOID userdata);
61 
62 /* This function is called after processing is done (for whatever reason that is caused)
63  * This is useful if you create processing threads that need to die
64  */
65 typedef HRESULT (* STOPPROCESSPROC) (LPVOID userdata);
66 
67 #define ALIGNDOWN(value,boundary) ((value)/(boundary)*(boundary))
68 #define ALIGNUP(value,boundary) (ALIGNDOWN((value)+(boundary)-1, (boundary)))
69 
70 typedef struct PullPin
71 {
72  /* inheritance C style! */
75 
86  double dRate;
89 
90  /* Any code that touches the thread must hold the thread lock,
91  * lock order: thread_lock and then the filter critical section
92  * also signal thread_sleepy so the thread knows to wake up
93  */
99 } PullPin;
100 
101 #define Req_Sleepy 0
102 #define Req_Die 1
103 #define Req_Run 2
104 #define Req_Pause 3
105 
106 /*** Constructors ***/
107 HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO * pPinInfo,
108  SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept,
109  CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone,
110  LPCRITICAL_SECTION pCritSec, IPin ** ppPin);
111 
112 /**************************/
113 /*** Pin Implementation ***/
114 
115 /* Pull Pin */
116 HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
121 HRESULT WINAPI PullPin_QueryAccept(IPin * iface, const AM_MEDIA_TYPE * pmt);
124 HRESULT WINAPI PullPin_NewSegment(IPin * iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);
125 
126 /* Thread interaction functions: Hold the thread_lock before calling them */
130 
131 /* COM helpers */
132 static inline PullPin *impl_PullPin_from_IPin( IPin *iface )
133 {
134  return CONTAINING_RECORD(iface, PullPin, pin.IPin_iface);
135 }
HRESULT(* REQUESTPROC)(LPVOID userdata)
Definition: pin.h:60
#define HRESULT
Definition: msvc.h:9
HRESULT WINAPI PullPin_BeginFlush(IPin *iface)
Definition: pin.c:739
IAsyncReader * pReader
Definition: pin.h:77
#define REFIID
Definition: guiddef.h:118
PRECONNECTPROC fnPreConnect
Definition: pin.h:82
HRESULT WINAPI PullPin_EndOfStream(IPin *iface)
Definition: pin.c:724
REFIID riid
Definition: precomp.h:44
HRESULT(* PRECONNECTPROC)(IPin *iface, IPin *pConnectPin, ALLOCATOR_PROPERTIES *props)
Definition: pin.h:43
CLEANUPPROC fnCleanProc
Definition: pin.h:84
REFIID LPVOID * ppv
Definition: atlbase.h:39
HRESULT WINAPI PullPin_ReceiveConnection(IPin *iface, IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
Definition: pin.c:253
HRESULT WINAPI PullPin_Disconnect(IPin *iface)
Definition: pin.c:803
HRESULT PullPin_PauseProcessing(PullPin *This)
Definition: pin.c:646
HANDLE hEventStateChanged
Definition: pin.h:97
static PullPin * impl_PullPin_from_IPin(IPin *iface)
Definition: pin.h:132
DWORD state
Definition: pin.h:98
Definition: regsvr.c:103
REFERENCE_TIME rtCurrent
Definition: pin.h:76
QUERYACCEPTPROC fnQueryAccept
Definition: pin.h:80
ULONG WINAPI PullPin_Release(IPin *iface)
Definition: pin.c:374
Definition: pin.h:70
REFERENCE_TIME rtNext
Definition: pin.h:76
REFERENCE_TIME rtStop
Definition: pin.h:76
unsigned int BOOL
Definition: ntddk_ex.h:94
HRESULT WINAPI PullPin_EndFlush(IPin *iface)
Definition: pin.c:773
LPVOID pUserData
Definition: pin.h:74
CRITICAL_SECTION thread_lock
Definition: pin.h:94
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
REQUESTPROC fnCustomRequest
Definition: pin.h:83
IMemAllocator * pAlloc
Definition: pin.h:79
HANDLE hThread
Definition: pin.h:95
struct PullPin PullPin
REFERENCE_TIME rtStart
Definition: pin.h:76
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
DWORD requested_state
Definition: pin.h:96
LONG HRESULT
Definition: typedefs.h:77
HRESULT(* SAMPLEPROC_PULL)(LPVOID userdata, IMediaSample *pSample, DWORD_PTR cookie)
Definition: pin.h:29
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
BasePin pin
Definition: pin.h:73
HRESULT(* QUERYACCEPTPROC)(LPVOID userdata, const AM_MEDIA_TYPE *pmt)
Definition: pin.h:35
HRESULT PullPin_WaitForStateChange(PullPin *This, DWORD dwMilliseconds)
Definition: pin.c:708
uint32_t DWORD_PTR
Definition: typedefs.h:63
HRESULT WINAPI PullPin_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *pmt)
Definition: pin.c:715
HRESULT(* CLEANUPPROC)(LPVOID userdata)
Definition: pin.h:50
HRESULT(* STOPPROCESSPROC)(LPVOID userdata)
Definition: pin.h:65
Definition: axcore.idl:91
HRESULT PullPin_StartProcessing(PullPin *This)
Definition: pin.c:623
BOOL stop_playback
Definition: pin.h:87
IMemAllocator * prefAlloc
Definition: pin.h:78
HRESULT WINAPI PullPin_QueryInterface(IPin *iface, REFIID riid, LPVOID *ppv)
Definition: pin.c:345
static const WCHAR props[]
Definition: wbemdisp.c:288
unsigned int ULONG
Definition: retypes.h:1
HRESULT WINAPI PullPin_NewSegment(IPin *iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
Definition: pin.c:837
SAMPLEPROC_PULL fnSampleProc
Definition: pin.h:81
DWORD cbAlign
Definition: pin.h:88
HRESULT PullPin_Construct(const IPinVtbl *PullPin_Vtbl, const PIN_INFO *pPinInfo, SAMPLEPROC_PULL pSampleProc, LPVOID pUserData, QUERYACCEPTPROC pQueryAccept, CLEANUPPROC pCleanUp, REQUESTPROC pCustomRequest, STOPPROCESSPROC pDone, LPCRITICAL_SECTION pCritSec, IPin **ppPin)
Definition: pin.c:221
HANDLE thread_sleepy
Definition: pin.h:97
double dRate
Definition: pin.h:86
STOPPROCESSPROC fnDone
Definition: pin.h:85