Re-add UVC and GST as availible query backends, but with a deprecation flag. Add dbg! to address issue #50

This commit is contained in:
l1npengtul
2022-07-23 19:58:55 +09:00
parent 23b41bc0c1
commit e1e0e35bf1
2 changed files with 19 additions and 8 deletions
+10 -3
View File
@@ -55,6 +55,7 @@ pub fn query_devices(api: CaptureAPIBackend) -> Result<Vec<CameraInfo>, NokhwaEr
} else if cfg!(feature = "input-opencv") {
query_devices(CaptureAPIBackend::OpenCv)
} else {
dbg!("Error: No suitable Backends availible. Perhaps you meant to enable one of the backends such as `input-v4l`? (Please read the docs.)");
Err(NokhwaError::UnsupportedOperationError(
CaptureAPIBackend::Auto,
))
@@ -66,6 +67,7 @@ pub fn query_devices(api: CaptureAPIBackend) -> Result<Vec<CameraInfo>, NokhwaEr
} else if cfg!(feature = "input-opencv") {
query_devices(CaptureAPIBackend::OpenCv)
} else {
dbg!("Error: No suitable Backends availible. Perhaps you meant to enable one of the backends such as `input-msmf`? (Please read the docs.)");
Err(NokhwaError::UnsupportedOperationError(
CaptureAPIBackend::Auto,
))
@@ -77,6 +79,7 @@ pub fn query_devices(api: CaptureAPIBackend) -> Result<Vec<CameraInfo>, NokhwaEr
} else if cfg!(feature = "input-opencv") {
query_devices(CaptureAPIBackend::OpenCv)
} else {
dbg!("Error: No suitable Backends availible. Perhaps you meant to enable one of the backends such as `input-avfoundation`? (Please read the docs.)");
Err(NokhwaError::UnsupportedOperationError(
CaptureAPIBackend::Auto,
))
@@ -86,14 +89,18 @@ pub fn query_devices(api: CaptureAPIBackend) -> Result<Vec<CameraInfo>, NokhwaEr
if cfg!(feature = "input-avfoundation") {
query_devices(CaptureAPIBackend::AVFoundation)
} else {
dbg!("Error: No suitable Backends availible. Perhaps you meant to enable one of the backends such as `input-avfoundation`? (Please read the docs.)");
Err(NokhwaError::UnsupportedOperationError(
CaptureAPIBackend::Auto,
))
}
}
_ => Err(NokhwaError::UnsupportedOperationError(
CaptureAPIBackend::Auto,
)),
_ => {
dbg!("Error: No suitable Backends availible. You are on an unsupported platform.");
Err(NokhwaError::NotImplementedError(
"Bad Platform".to_string()
))
}
}
}
CaptureAPIBackend::AVFoundation => query_avfoundation(),
+9 -5
View File
@@ -482,8 +482,8 @@ impl From<CameraFormat> for CaptureDeviceFormatDescriptor {
/// `index` is a camera's index given to it by (usually) the OS usually in the order it is known to the system.
/// # JS-WASM
/// This is exported as a `JSCameraInfo`.
#[cfg_attr(feature = "output-wasm", wasm_bindgen(js_name = JSCameraInfo))]
#[derive(Clone, Debug, Hash, PartialEq, PartialOrd)]
#[cfg_attr(feature = "output-wasm", wasm_bindgen(js_name = JSCameraInfo))]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub struct CameraInfo {
human_name: String,
@@ -627,7 +627,7 @@ impl From<MediaFoundationDeviceDescriptor<'_>> for CameraInfo {
human_name: dev_desc.name_as_string(),
description: "Media Foundation Device".to_string(),
misc: dev_desc.link_as_string(),
index: dev_desc.index() as usize,
index: dev_desc.index() as u32,
}
}
}
@@ -650,7 +650,7 @@ impl From<AVCaptureDeviceDescriptor> for CameraInfo {
human_name: descriptor.name,
description: descriptor.description,
misc: descriptor.misc,
index: descriptor.index as usize,
index: descriptor.index as u32,
}
}
}
@@ -733,6 +733,8 @@ impl From<MediaFoundationControls> for KnownCameraControl {
MediaFoundationControls::Exposure => KnownCameraControl::Exposure,
MediaFoundationControls::Iris => KnownCameraControl::Iris,
MediaFoundationControls::Focus => KnownCameraControl::Focus,
MediaFoundationControls::ColorEnable => KnownCameraControl::Other(0),
MediaFoundationControls::Roll => KnownCameraControl::Other(1),
}
}
}
@@ -1104,10 +1106,12 @@ pub enum CaptureAPIBackend {
Auto,
AVFoundation,
Video4Linux,
// UniversalVideoClass,
#[deprecated]
UniversalVideoClass,
MediaFoundation,
OpenCv,
// GStreamer,
#[deprecated]
GStreamer,
Network,
Browser,
}