Files
nokhwa/src/camera.rs
T
2023-08-31 15:23:19 +09:00

160 lines
4.0 KiB
Rust

/*
* Copyright 2022 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
use nokhwa_core::format_request::FormatFilter;
use nokhwa_core::frame_format::SourceFrameFormat;
use nokhwa_core::traits::Backend;
use nokhwa_core::{
buffer::Buffer,
error::NokhwaError,
pixel_format::FormatDecoder,
traits::CaptureTrait,
types::{
ApiBackend, CameraControl, CameraFormat, CameraIndex, CameraInfo, ControlValueSetter,
FrameFormat, KnownCameraControl, RequestedFormatType, Resolution,
},
};
use std::{borrow::Cow, collections::HashMap};
#[cfg(feature = "output-wgpu")]
use wgpu::{Device as WgpuDevice, Queue as WgpuQueue, Texture as WgpuTexture};
/// The main `Camera` struct. This is the struct that abstracts over all the backends, providing a simplified interface for use.
pub struct Camera {
idx: CameraIndex,
api: ApiBackend,
device: Box<dyn CaptureTrait + Backend>,
}
impl Camera {
pub fn new() -> Result<Self, NokhwaError> {}
pub fn with_api_backend() -> Result<Self, NokhwaError> {}
pub fn with_custom_backend() -> Result<Self, NokhwaError> {}
}
impl CaptureTrait for Camera {
fn init(&mut self) -> Result<(), NokhwaError> {
todo!()
}
fn init_with_format(&mut self, format: FormatFilter) -> Result<CameraFormat, NokhwaError> {
todo!()
}
fn backend(&self) -> ApiBackend {
todo!()
}
fn camera_info(&self) -> &CameraInfo {
todo!()
}
fn refresh_camera_format(&mut self) -> Result<(), NokhwaError> {
todo!()
}
fn camera_format(&self) -> Option<CameraFormat> {
todo!()
}
fn set_camera_format(&mut self, new_fmt: CameraFormat) -> Result<(), NokhwaError> {
todo!()
}
fn compatible_list_by_resolution(
&mut self,
fourcc: SourceFrameFormat,
) -> Result<HashMap<Resolution, Vec<u32>>, NokhwaError> {
todo!()
}
fn compatible_fourcc(&mut self) -> Result<Vec<SourceFrameFormat>, NokhwaError> {
todo!()
}
fn resolution(&self) -> Option<Resolution> {
todo!()
}
fn set_resolution(&mut self, new_res: Resolution) -> Result<(), NokhwaError> {
todo!()
}
fn frame_rate(&self) -> Option<u32> {
todo!()
}
fn set_frame_rate(&mut self, new_fps: u32) -> Result<(), NokhwaError> {
todo!()
}
fn frame_format(&self) -> SourceFrameFormat {
todo!()
}
fn set_frame_format(
&mut self,
fourcc: impl Into<SourceFrameFormat>,
) -> Result<(), NokhwaError> {
todo!()
}
fn camera_control(&self, control: KnownCameraControl) -> Result<CameraControl, NokhwaError> {
todo!()
}
fn camera_controls(&self) -> Result<Vec<CameraControl>, NokhwaError> {
todo!()
}
fn set_camera_control(
&mut self,
id: KnownCameraControl,
value: ControlValueSetter,
) -> Result<(), NokhwaError> {
todo!()
}
fn open_stream(&mut self) -> Result<(), NokhwaError> {
todo!()
}
fn is_stream_open(&self) -> bool {
todo!()
}
fn frame(&mut self) -> Result<Buffer, NokhwaError> {
todo!()
}
fn frame_raw(&mut self) -> Result<Cow<[u8]>, NokhwaError> {
todo!()
}
fn stop_stream(&mut self) -> Result<(), NokhwaError> {
todo!()
}
}
impl Drop for Camera {
fn drop(&mut self) {
self.stop_stream().unwrap();
}
}
unsafe impl Send for Camera {}