mirror of
https://github.com/l1npengtul/nokhwa.git
synced 2026-07-04 10:37:26 +00:00
stable camera index, fix #215
This commit is contained in:
@@ -35,4 +35,3 @@ pub mod stream;
|
||||
pub mod traits;
|
||||
pub mod types;
|
||||
pub mod utils;
|
||||
mod metadata;
|
||||
|
||||
@@ -23,6 +23,7 @@ use std::{
|
||||
pub enum CameraIndex {
|
||||
Index(u32),
|
||||
String(String),
|
||||
Stable(String)
|
||||
}
|
||||
|
||||
impl CameraIndex {
|
||||
@@ -32,7 +33,7 @@ impl CameraIndex {
|
||||
pub fn as_index(&self) -> Result<u32, NokhwaError> {
|
||||
match self {
|
||||
CameraIndex::Index(i) => Ok(*i),
|
||||
CameraIndex::String(s) => s
|
||||
CameraIndex::String(s) | CameraIndex::Stable(s) => s
|
||||
.parse::<u32>()
|
||||
.map_err(|why| NokhwaError::GeneralError(why.to_string())),
|
||||
}
|
||||
@@ -44,6 +45,7 @@ impl CameraIndex {
|
||||
match self {
|
||||
CameraIndex::Index(i) => i.to_string(),
|
||||
CameraIndex::String(s) => s.to_string(),
|
||||
CameraIndex::Stable(s) => s.to_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +54,7 @@ impl CameraIndex {
|
||||
pub fn is_index(&self) -> bool {
|
||||
match self {
|
||||
CameraIndex::Index(_) => true,
|
||||
CameraIndex::String(_) => false,
|
||||
CameraIndex::String(_) | CameraIndex::Stable(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@ ffmpeg = ["ffmpeg-the-third"]
|
||||
av1 = ["rav1e"]
|
||||
yuyv = ["dcv-color-primitives", "yuv"]
|
||||
mjpeg = ["zune-jpeg", "zune-core"]
|
||||
browser = []
|
||||
general = ["ffmpeg", "av1", "yuyv", "mjpeg"]
|
||||
static = ["ffmpeg-the-third/static"]
|
||||
async = []
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#[cfg(feature = "ffmpeg")]
|
||||
pub mod ffmpeg;
|
||||
#[cfg(feature = "general")]
|
||||
pub mod general;
|
||||
#[cfg(feature = "mjpeg")]
|
||||
pub mod mjpeg;
|
||||
#[cfg(feature = "yuyv")]
|
||||
|
||||
Reference in New Issue
Block a user