Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpDirectShowDevice.cpp
1/*
2 * ViSP, open source Visual Servoing Platform software.
3 * Copyright (C) 2005 - 2025 by Inria. All rights reserved.
4 *
5 * This software is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 * See the file LICENSE.txt at the root directory of this source
10 * distribution for additional information about the GNU GPL.
11 *
12 * For using ViSP with software that can not be combined with the GNU
13 * GPL, please contact Inria about acquiring a ViSP Professional
14 * Edition License.
15 *
16 * See https://visp.inria.fr for more information.
17 *
18 * This software was developed at:
19 * Inria Rennes - Bretagne Atlantique
20 * Campus Universitaire de Beaulieu
21 * 35042 Rennes Cedex
22 * France
23 *
24 * If you have questions regarding the use of this file, please contact
25 * Inria at visp@inria.fr
26 *
27 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29 *
30 * Description:
31 * DirectShow device description.
32 */
33
34#ifndef DOXYGEN_SHOULD_SKIP_THIS
35
36#include <stdio.h>
37#include <visp3/core/vpConfig.h>
38#if (defined(VISP_HAVE_DIRECTSHOW))
39
40#include <visp3/sensor/vpDirectShowDevice.h>
41
48bool vpDirectShowDevice::init(const CComPtr<IMoniker> &pMoniker)
49{
50 HRESULT hr;
51
52 // Get the properties
53 CComPtr<IPropertyBag> pPropBag;
54 pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)(&pPropBag));
55
56 // get the name of the input
57 VARIANT varName;
58 VARIANT varDesc;
59 VARIANT varDevPath;
60 VariantInit(&varName);
61 VariantInit(&varDesc);
62 VariantInit(&varDevPath);
63 char tmp[FILENAME_MAX];
64
65 hr = pPropBag->Read(L"FriendlyName", &varName, 0);
66
67 // successfully got the name
68 if (SUCCEEDED(hr)) {
69 snprintf(tmp, FILENAME_MAX, "%S", varName.bstrVal);
70 name = tmp;
71 }
72
73 VariantClear(&varName);
74
75 hr = pPropBag->Read(L"Description", &varDesc, 0);
76
77 // successfully got the description
78 if (SUCCEEDED(hr)) {
79 snprintf(tmp, FILENAME_MAX, "%S", varDesc.bstrVal);
80 desc = tmp;
81 }
82
83 VariantClear(&varDesc);
84
85 hr = pPropBag->Read(L"DevicePath", &varDevPath, 0);
86
87 // successfully got the device path
88 if (SUCCEEDED(hr)) {
89 snprintf(tmp, FILENAME_MAX, "%S", varDevPath.bstrVal);
90 devPath = tmp;
91 }
92
93 VariantClear(&varDevPath);
94
95 inUse = false;
96
97 return true;
98}
99
104bool vpDirectShowDevice::operator==(vpDirectShowDevice &dev)
105{
106 return name == dev.name && desc == dev.desc && devPath == dev.devPath;
107}
108
109VISP_EXPORT std::ostream &operator<<(std::ostream &os, vpDirectShowDevice &dev)
110{
111 return os << dev.name << std::endl << dev.desc << std::endl << dev.devPath;
112}
113END_VISP_NAMESPACE
114#elif !defined(VISP_BUILD_SHARED_LIBS)
115// Work around to avoid warning: libvisp_sensor.a(vpDirectShowDevice.cpp.o)
116// has no symbols
117void dummy_vpDirectShowDevice() { }
118#endif
119#endif