Creates a MediaSource for a specific camera device # Arguments `id` - Device symbolic link ID # Returns The created IMFMediaSource interface for the device
(id: &str)
| 242 | /// # Returns |
| 243 | /// The created IMFMediaSource interface for the device |
| 244 | unsafe 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 | /// |