• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_
12 #define WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_
13 
14 #include <Streams.h> // Include base DS filter header files
15 
16 #include "webrtc/modules/video_capture/video_capture_defines.h"
17 
18 namespace webrtc
19 {
20 namespace videocapturemodule
21 {
22 //forward declaration
23 
24 class CaptureSinkFilter;
25 /**
26  *	input pin for camera input
27  *
28  */
29 class CaptureInputPin: public CBaseInputPin
30 {
31 public:
32     int32_t _moduleId;
33 
34     VideoCaptureCapability _requestedCapability;
35     VideoCaptureCapability _resultingCapability;
36     HANDLE _threadHandle;
37 
38     CaptureInputPin(int32_t moduleId,
39                     IN TCHAR* szName,
40                     IN CaptureSinkFilter* pFilter,
41                     IN CCritSec * pLock,
42                     OUT HRESULT * pHr,
43                     IN LPCWSTR pszName);
44     virtual ~CaptureInputPin();
45 
46     HRESULT GetMediaType (IN int iPos, OUT CMediaType * pmt);
47     HRESULT CheckMediaType (IN const CMediaType * pmt);
48     STDMETHODIMP Receive (IN IMediaSample *);
49     HRESULT SetMatchingMediaType(const VideoCaptureCapability& capability);
50 };
51 
52 class CaptureSinkFilter: public CBaseFilter
53 {
54 
55 public:
56     CaptureSinkFilter(IN TCHAR * tszName,
57                       IN LPUNKNOWN punk,
58                       OUT HRESULT * phr,
59                       VideoCaptureExternal& captureObserver,
60                       int32_t moduleId);
61     virtual ~CaptureSinkFilter();
62 
63     //  --------------------------------------------------------------------
64     //  class methods
65 
66     void ProcessCapturedFrame(unsigned char* pBuffer, size_t length,
67                               const VideoCaptureCapability& frameInfo);
68     //  explicit receiver lock aquisition and release
LockReceive()69     void LockReceive()  { m_crtRecv.Lock();}
UnlockReceive()70     void UnlockReceive() {m_crtRecv.Unlock();}
71     //  explicit filter lock aquisition and release
LockFilter()72     void LockFilter() {m_crtFilter.Lock();}
UnlockFilter()73     void UnlockFilter() { m_crtFilter.Unlock(); }
74     void SetFilterGraph(IGraphBuilder* graph); // Used if EVR
75 
76     //  --------------------------------------------------------------------
77     //  COM interfaces
78 DECLARE_IUNKNOWN    ;
79     STDMETHODIMP SetMatchingMediaType(const VideoCaptureCapability& capability);
80 
81     //  --------------------------------------------------------------------
82     //  CBaseFilter methods
83     int GetPinCount ();
84     CBasePin * GetPin ( IN int Index);
85     STDMETHODIMP Pause ();
86     STDMETHODIMP Stop ();
87     STDMETHODIMP GetClassID ( OUT CLSID * pCLSID);
88     //  --------------------------------------------------------------------
89     //  class factory calls this
90     static CUnknown * CreateInstance (IN LPUNKNOWN punk, OUT HRESULT * phr);
91 private:
92     CCritSec m_crtFilter; //  filter lock
93     CCritSec m_crtRecv;  //  receiver lock; always acquire before filter lock
94     CaptureInputPin * m_pInput;
95     VideoCaptureExternal& _captureObserver;
96     int32_t _moduleId;
97 };
98 }  // namespace videocapturemodule
99 }  // namespace webrtc
100 #endif // WEBRTC_MODULES_VIDEO_CAPTURE_MAIN_SOURCE_WINDOWS_SINK_FILTER_DS_H_
101