-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathdynsrc.h
146 lines (99 loc) · 4.37 KB
/
dynsrc.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//------------------------------------------------------------------------------
// File: DynSrc.h
//
//
// Copyright (c) Corey Auger. All rights reserved.
//------------------------------------------------------------------------------
#ifndef __CDYNAMICSOURCE__
#define __CDYNAMICSOURCE__
class CDynamicSourceStream; // The class that will handle each pin
class CDynamicSource: public CBaseFilter {
public:
CDynamicSource(TCHAR *pName, LPUNKNOWN lpunk, CLSID clsid, HRESULT *phr);
#ifdef UNICODE
CDynamicSource(CHAR *pName, LPUNKNOWN lpunk, CLSID clsid, HRESULT *phr);
#endif
~CDynamicSource();
int GetPinCount(void);
CBasePin *GetPin(int n);
// -- Utilities --
CCritSec* pStateLock(void) { return &m_cStateLock; } // provide our critical section
HRESULT AddPin(CDynamicSourceStream *);
HRESULT RemovePin(CDynamicSourceStream *);
STDMETHODIMP FindPin(
LPCWSTR Id,
IPin ** ppPin
);
int FindPinNumber(IPin *iPin);
STDMETHODIMP JoinFilterGraph(IFilterGraph* pGraph, LPCWSTR pName);
STDMETHODIMP Stop(void);
STDMETHODIMP Pause(void);
STDMETHODIMP SetSyncSource(IReferenceClock *pClock);
protected:
CAMEvent m_evFilterStoppingEvent;
int m_iPins; // The number of pins on this filter. Updated by
// CDynamicSourceStream constructors & destructors.
CDynamicSourceStream **m_paStreams; // the pins on this filter.
CCritSec m_csPinStateLock;
CCritSec m_cStateLock;
};
class CDynamicSourceStream : public CAMThread, public CDynamicOutputPin {
public:
CDynamicSourceStream(TCHAR *pObjectName,
HRESULT *phr,
CDynamicSource*pms,
LPCWSTR pName);
#ifdef UNICODE
CDynamicSourceStream(CHAR *pObjectName,
HRESULT *phr,
CDynamicSource*pms,
LPCWSTR pName);
#endif
virtual ~CDynamicSourceStream(void); // virtual destructor ensures derived
// class destructors are called too
HRESULT DestroySourceThread(void);
virtual HRESULT SetSyncSource(IReferenceClock *pClock) PURE; // CA - added this..
protected:
CDynamicSource*m_pFilter; // The parent of this stream
virtual HRESULT FillBuffer(IMediaSample *pSamp) PURE;
// Called as the thread is created/destroyed - use to perform
// jobs such as start/stop streaming mode
// If OnThreadCreate returns an error the thread will exit.
virtual HRESULT OnThreadCreate(void) {return NOERROR;};
virtual HRESULT OnThreadDestroy(void) {return NOERROR;};
virtual HRESULT OnThreadStartPlay(void) {return NOERROR;};
HRESULT Active(void); // Starts up the worker thread
HRESULT BreakConnect(void);
public:
// thread commands
enum Command {CMD_INIT, CMD_PAUSE, CMD_RUN, CMD_STOP, CMD_EXIT};
HRESULT Init(void) { return CallWorker(CMD_INIT); }
HRESULT Exit(void) { return CallWorker(CMD_EXIT); }
HRESULT Run(void) { return CallWorker(CMD_RUN); }
HRESULT Pause(void) { return CallWorker(CMD_PAUSE); }
HRESULT Stop(void) { return CallWorker(CMD_STOP); }
void OutputPinNeedsToBeReconnected(void);
protected:
Command GetRequest(void) { return (Command) CAMThread::GetRequest(); }
BOOL CheckRequest(Command *pCom) { return CAMThread::CheckRequest( (DWORD *) pCom); }
// override these if you want to add thread commands
virtual DWORD ThreadProc(void); // the thread function
virtual HRESULT DoBufferProcessingLoop(void); // the loop executed whilst running
void FatalError(HRESULT hr);
// *
// * AM_MEDIA_TYPE support
// *
// If you support more than one media type then override these 2 functions
virtual HRESULT CheckMediaType(const CMediaType *pMediaType);
virtual HRESULT GetMediaType(int iPosition, CMediaType *pMediaType); // List pos. 0-n
// If you support only one type then override this fn.
// This will only be called by the default implementations
// of CheckMediaType and GetMediaType(int, CMediaType*)
// You must override this fn. or the above 2!
virtual HRESULT GetMediaType(CMediaType *pMediaType) {return E_UNEXPECTED;}
STDMETHODIMP QueryId(
LPWSTR * Id
);
bool m_fReconnectOutputPin;
};
#endif // __CDYNAMICSOURCE__