ReactOS 0.4.16-dev-297-gc569aee
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 */
29typedef 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 */
35typedef 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 */
43typedef 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 */
50typedef 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 */
60typedef 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 */
65typedef HRESULT (* STOPPROCESSPROC) (LPVOID userdata);
66
67#define ALIGNDOWN(value,boundary) ((value)/(boundary)*(boundary))
68#define ALIGNUP(value,boundary) (ALIGNDOWN((value)+(boundary)-1, (boundary)))
69
70typedef 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 */
100
101#define Req_Sleepy 0
102#define Req_Die 1
103#define Req_Run 2
104#define Req_Pause 3
105
106/*** Constructors ***/
107HRESULT 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 */
116HRESULT WINAPI PullPin_ReceiveConnection(IPin * iface, IPin * pReceivePin, const AM_MEDIA_TYPE * pmt);
124HRESULT 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 */
132static inline PullPin *impl_PullPin_from_IPin( IPin *iface )
133{
134 return CONTAINING_RECORD(iface, PullPin, pin.IPin_iface);
135}
LONGLONG REFERENCE_TIME
Definition: dmusicks.h:9
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
REFIID riid
Definition: atlbase.h:39
REFIID LPVOID * ppv
Definition: atlbase.h:39
Definition: axcore.idl:92
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
HRESULT(* QUERYACCEPTPROC)(LPVOID userdata, const AM_MEDIA_TYPE *pmt)
Definition: pin.h:35
HRESULT PullPin_StartProcessing(PullPin *This)
Definition: pin.c:623
HRESULT WINAPI PullPin_ReceiveConnection(IPin *iface, IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)
Definition: pin.c:253
HRESULT WINAPI PullPin_EndFlush(IPin *iface)
Definition: pin.c:773
HRESULT WINAPI PullPin_QueryAccept(IPin *iface, const AM_MEDIA_TYPE *pmt)
Definition: pin.c:715
HRESULT WINAPI PullPin_NewSegment(IPin *iface, REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)
Definition: pin.c:837
HRESULT WINAPI PullPin_QueryInterface(IPin *iface, REFIID riid, LPVOID *ppv)
Definition: pin.c:345
HRESULT WINAPI PullPin_EndOfStream(IPin *iface)
Definition: pin.c:724
HRESULT(* STOPPROCESSPROC)(LPVOID userdata)
Definition: pin.h:65
HRESULT WINAPI PullPin_BeginFlush(IPin *iface)
Definition: pin.c:739
HRESULT WINAPI PullPin_Disconnect(IPin *iface)
Definition: pin.c:803
HRESULT PullPin_WaitForStateChange(PullPin *This, DWORD dwMilliseconds)
Definition: pin.c:708
HRESULT(* PRECONNECTPROC)(IPin *iface, IPin *pConnectPin, ALLOCATOR_PROPERTIES *props)
Definition: pin.h:43
ULONG WINAPI PullPin_Release(IPin *iface)
Definition: pin.c:374
HRESULT(* SAMPLEPROC_PULL)(LPVOID userdata, IMediaSample *pSample, DWORD_PTR cookie)
Definition: pin.h:29
HRESULT(* REQUESTPROC)(LPVOID userdata)
Definition: pin.h:60
HRESULT PullPin_PauseProcessing(PullPin *This)
Definition: pin.c:646
HRESULT(* CLEANUPPROC)(LPVOID userdata)
Definition: pin.h:50
static PullPin * impl_PullPin_from_IPin(IPin *iface)
Definition: pin.h:132
#define REFIID
Definition: guiddef.h:118
Definition: pin.h:71
REFERENCE_TIME rtNext
Definition: pin.h:76
REFERENCE_TIME rtStop
Definition: pin.h:76
DWORD cbAlign
Definition: pin.h:88
QUERYACCEPTPROC fnQueryAccept
Definition: pin.h:80
DWORD requested_state
Definition: pin.h:96
SAMPLEPROC_PULL fnSampleProc
Definition: pin.h:81
LPVOID pUserData
Definition: pin.h:74
HANDLE hThread
Definition: pin.h:95
CRITICAL_SECTION thread_lock
Definition: pin.h:94
PRECONNECTPROC fnPreConnect
Definition: pin.h:82
double dRate
Definition: pin.h:86
IMemAllocator * pAlloc
Definition: pin.h:79
REFERENCE_TIME rtCurrent
Definition: pin.h:76
DWORD state
Definition: pin.h:98
BasePin pin
Definition: pin.h:73
HANDLE hEventStateChanged
Definition: pin.h:97
IAsyncReader * pReader
Definition: pin.h:77
STOPPROCESSPROC fnDone
Definition: pin.h:85
CLEANUPPROC fnCleanProc
Definition: pin.h:84
BOOL stop_playback
Definition: pin.h:87
REQUESTPROC fnCustomRequest
Definition: pin.h:83
REFERENCE_TIME rtStart
Definition: pin.h:76
HANDLE thread_sleepy
Definition: pin.h:97
IMemAllocator * prefAlloc
Definition: pin.h:78
Definition: cookie.c:34
Definition: regsvr.c:104
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
static const WCHAR props[]
Definition: wbemdisp.c:288
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6