5 #include "../backend.h" 9 #include <mfreadwrite.h> 10 #include <atlcomcli.h> 14 #include <unordered_map> 18 #ifndef KSCATEGORY_SENSOR_CAMERA 20 #define KSCATEGORY_SENSOR_CAMERA DEFINE_GUIDNAMED(KSCATEGORY_SENSOR_CAMERA) 21 #endif // !KSCATEGORY_SENSOR_CAMERA 24 static const std::vector<std::vector<std::pair<GUID, GUID>>> attributes_params = {
26 { MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID },
30 { MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE, MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID }
46 typedef std::function<void(const uvc_device_info&, IMFActivate*)>
58 void start_callbacks()
override;
59 void stop_callbacks()
override;
63 std::vector<stream_profile> get_profiles()
const override;
69 bool set_xu(
const extension_unit& xu, uint8_t ctrl,
const uint8_t* data,
int len)
override;
70 bool get_xu(
const extension_unit& xu, uint8_t ctrl, uint8_t* data,
int len)
const override;
74 bool set_pu(
rs2_option opt,
int value)
override;
77 void lock()
const override { _systemwide_lock.lock(); }
78 void unlock()
const override { _systemwide_lock.unlock(); }
86 throw std::runtime_error(
"The device does not support adjusting the qualities of an incoming video signal, such as brightness, contrast, hue, saturation, gamma, and sharpness.");
92 if (!_camera_control.p)
93 throw std::runtime_error(
"The device does not support camera settings such as zoom, pan, aperture adjustment, or shutter speed.");
94 return _camera_control.p;
101 void stop_stream_cleanup(
const stream_profile& profile, std::vector<profile_and_callback>::iterator& elem);
102 void flush(
int sIndex);
103 void check_connection()
const;
105 std::vector<std::pair<stream_profile, int>> get_stream_profiles_and_indexes()
const;
106 int get_stream_index_by_profile(
const stream_profile& profile)
const;
111 CComPtr<source_reader_callback> _callback =
nullptr;
112 CComPtr<IMFSourceReader> _reader =
nullptr;
113 CComPtr<IMFMediaSource> _source =
nullptr;
114 CComPtr<IMFActivate> _activate =
nullptr;
115 CComPtr<IMFAttributes> _device_attrs =
nullptr;
116 CComPtr<IMFAttributes> _reader_attrs =
nullptr;
118 CComPtr<IAMCameraControl> _camera_control =
nullptr;
119 CComPtr<IAMVideoProcAmp> _video_proc =
nullptr;
120 std::unordered_map<int, CComPtr<IKsControl>> _ks_controls;
124 HRESULT _readsample_result = S_OK;
126 uint16_t _streamIndex;
127 std::vector<profile_and_callback> _streams;
128 std::mutex _streams_mutex;
130 std::shared_ptr<const wmf_backend> _backend;
133 std::string _location;
135 std::vector<stream_profile> _profiles;
136 std::vector<frame_callback> _frame_callbacks;
137 bool _streaming =
false;
138 std::atomic<bool> _is_started =
false;
148 STDMETHODIMP QueryInterface(REFIID iid,
void** ppv)
override;
149 STDMETHODIMP_(ULONG) AddRef()
override;
150 STDMETHODIMP_(ULONG) Release()
override;
151 STDMETHODIMP OnReadSample(HRESULT ,
155 IMFSample *sample)
override;
156 STDMETHODIMP OnEvent(DWORD , IMFMediaEvent* )
override;
157 STDMETHODIMP OnFlush(DWORD)
override;
159 std::weak_ptr<wmf_uvc_device> _owner;
rs2_option
Defines general configuration controls. These can generally be mapped to camera UVC controls...
Definition: rs_option.h:22
#define KSCATEGORY_SENSOR_CAMERA
Definition: win-uvc.h:20
DEFINE_GUIDSTRUCT("24E552D7-6523-47F7-A647-D3465BF1F5CA", KSCATEGORY_SENSOR_CAMERA)