MCPcopy Create free account
hub / github.com/RustCV/RustCV / create_media_source

Function create_media_source

rustcv-backend-msmf/src/device.rs:244–265  ·  view source on GitHub ↗

Creates a MediaSource for a specific camera device # Arguments `id` - Device symbolic link ID # Returns The created IMFMediaSource interface for the device

(id: &str)

Source from the content-addressed store, hash-verified

242/// # Returns
243/// The created IMFMediaSource interface for the device
244unsafe fn create_media_source(id: &str) -> Result<IMFMediaSource> {
245 let mut attributes = None;
246 MFCreateAttributes(&mut attributes, 2).map_err(hresult_to_camera_error)?;
247 let attributes = attributes.unwrap();
248
249 attributes
250 .SetGUID(
251 &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE,
252 &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_GUID,
253 )
254 .map_err(hresult_to_camera_error)?;
255
256 let id_hstring = HSTRING::from(id);
257 attributes
258 .SetString(
259 &MF_DEVSOURCE_ATTRIBUTE_SOURCE_TYPE_VIDCAP_SYMBOLIC_LINK,
260 &id_hstring,
261 )
262 .map_err(hresult_to_camera_error)?;
263
264 MFCreateDeviceSource(&attributes).map_err(hresult_to_camera_error)
265}
266
267/// Negotiates and selects the best video format from available options
268///

Callers 1

openFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected