1 /// \file CVDShowUtil.h
2 /// \brief DirectShow utility functions straight out of the DirectX 9 documentation.
3 ///
4 /// These provide easy calls to connect between Direct Show filters and manage
5 /// the memory associated with media type objects.
6 ///
7 
8 #ifndef CVDShowUtil_H_
9 #define CVDShowUtil_H_
10 
11 #include <windows.h>
12 #include <Dshow.h>   // DirectShow (using DirectX 9.0 for dev)
13 #include <qedit.h>   // Sample grabber defines
14 
15 
16 
17 /// GetUnconnectedPin finds an unconnected pin on a filter
18 /// in the desired direction.
19 ///
20 /// \param pFilter - pointer to filter
21 /// \param PinDir - direction of pin (PINDIR_INPUT or PINDIR_OUTPUT)
22 /// \param ppPin - Receives pointer to pin interface
23 ///
24 /// \return HRESULT - S_OK on success
25 /// \sa ConnectFilters(), CVVidCaptureDSWin32
26 HRESULT GetUnconnectedPin(
27     IBaseFilter *pFilter,
28     PIN_DIRECTION PinDir,
29     IPin **ppPin);
30 
31 ///
32 /// ConnectFilters connects a pin of an upstream filter to the
33 /// downstream filter pDest.
34 ///
35 /// \param pGraph - Filter graph (both filters must be already added)
36 /// \param pOut - Output pin on upstream filter. See GetUnconnectedPin()
37 /// \param pDest - Downstream filter to be connected
38 ///
39 /// \return HRESULT - S_OK on success
40 /// \sa GetUnconnectedPin(), CVVidCaptureDSWin32
41 HRESULT ConnectFilters(
42     IGraphBuilder *pGraph,
43     IPin *pOut,
44     IBaseFilter *pDest);
45 
46 ///
47 /// DisconnectPins() disconnects any attached filters.
48 ///
49 /// \param pFilter - filter to disconnect
50 /// \return HRESULT - S_OK on success
51 ///
52 HRESULT DisconnectPins(IBaseFilter *pFilter);
53 
54 ///
55 /// ConnectFilters connects two filters together.
56 ///
57 /// \param pGraph - Filter graph (both filters must be already added)
58 /// \param pSrc - Upstream filter
59 /// \param pDest - Downstream filter to be connected
60 ///
61 /// \return HRESULT - S_OK on success
62 /// \sa GetUnconnectedPin(), CVVidCaptureDSWin32
63 HRESULT ConnectFilters(
64     IGraphBuilder *pGraph,
65     IBaseFilter *pSrc,
66     IBaseFilter *pDest);
67 
68 ///
69 /// LocalFreeMediaType frees the format block of a media type object
70 /// \param mt - reference to media type
71 /// \sa LocalDeleteMediaType
72 void LocalFreeMediaType(AM_MEDIA_TYPE& mt);
73 
74 /// LocalDeleteMediaType frees the format block of a media type object,
75 /// then deletes it.
76 /// \param pmt - pointer to media type
77 /// \sa LocalFreeMediaType
78 void LocalDeleteMediaType(AM_MEDIA_TYPE *pmt);
79 
80 #endif //CVDShowUtil_H_
81 
82