OSVR-Core
GetPin.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_GetPin_h_GUID_5AABE0CF_8981_4785_0078_147205EEFABF
26 #define INCLUDED_GetPin_h_GUID_5AABE0CF_8981_4785_0078_147205EEFABF
27 
28 // Internal Includes
29 #include "comutils/ComPtr.h"
30 
31 // Library/third-party includes
32 #include <strmif.h>
33 
34 // Standard includes
35 // - none
36 
38 inline comutils::Ptr<IPin> GetPin(IBaseFilter &pFilter,
39  PIN_DIRECTION const PinDir) {
40  auto pEnum = comutils::Ptr<IEnumPins>{};
41  pFilter.EnumPins(AttachPtr(pEnum));
42  auto pPin = comutils::Ptr<IPin>{};
43  while (pEnum->Next(1, AttachPtr(pPin), nullptr) == S_OK) {
44  PIN_DIRECTION PinDirThis;
45  pPin->QueryDirection(&PinDirThis);
46  if (PinDir == PinDirThis) {
47  return pPin;
48  }
49  }
50  return comutils::Ptr<IPin>{};
51 }
52 
53 template <typename IfaceType>
55 GetPinInterface(ICaptureGraphBuilder2 &builder, IBaseFilter &src,
56  const GUID *pinCategory = nullptr,
57  const GUID *mediaType = nullptr) {
59  builder.FindInterface(pinCategory, mediaType, &src, __uuidof(IfaceType),
60  AttachPtr(ret));
61  return ret;
62 }
63 
64 template <typename IfaceType>
66 GetVideoCapturePinInterface(ICaptureGraphBuilder2 &builder, IBaseFilter &src) {
67  return GetPinInterface<IfaceType>(builder, src, &PIN_CATEGORY_CAPTURE,
68  &MEDIATYPE_Video);
69 }
70 
71 #endif // INCLUDED_GetPin_h_GUID_5AABE0CF_8981_4785_0078_147205EEFABF
Header with a template alias for the desired COM smart pointer.
boost::intrusive_ptr< T > Ptr
Template alias for our desired COM smart pointer.
Definition: ComPtr.h:40
comutils::Ptr< IPin > GetPin(IBaseFilter &pFilter, PIN_DIRECTION const PinDir)
Helper function to get a pin of a particular direction.
Definition: GetPin.h:38