mirror of
https://github.com/l1npengtul/nokhwa.git
synced 2026-07-04 02:27:26 +00:00
Merge remote-tracking branch 'origin/senpai' into senpai
# Conflicts: # nokhwa-bindings-macos/src/lib.rs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
# 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<!--
|
||||
~ Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
~ 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
#
|
||||
# Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
# 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
@@ -13,6 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// hello, future peng here
|
||||
// whatever is written here will induce horrors uncomprehendable.
|
||||
// save yourselves. write apple code in swift and bind it to rust.
|
||||
|
||||
#![allow(clippy::not_unsafe_ptr_arg_deref)]
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
@@ -51,6 +56,14 @@ pub enum AVFError {
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "macos", target_os = "ios"))]
|
||||
#[cfg_attr(
|
||||
any(target_os = "macos", target_os = "ios"),
|
||||
link(name = "CoreMedia", kind = "framework")
|
||||
)]
|
||||
#[cfg_attr(
|
||||
any(target_os = "macos", target_os = "ios"),
|
||||
link(name = "AVFoundation", kind = "framework")
|
||||
)]
|
||||
#[allow(non_snake_case)]
|
||||
pub mod core_media {
|
||||
// all of this is stolen from bindgen
|
||||
@@ -98,8 +111,20 @@ pub mod core_media {
|
||||
|
||||
pub type AVMediaType = NSString;
|
||||
|
||||
extern "C" {
|
||||
pub static AVMediaTypeVideo: AVMediaType;
|
||||
pub static AVMediaTypeAudio: AVMediaType;
|
||||
pub static AVMediaTypeText: AVMediaType;
|
||||
pub static AVMediaTypeClosedCaption: AVMediaType;
|
||||
pub static AVMediaTypeSubtitle: AVMediaType;
|
||||
pub static AVMediaTypeTimecode: AVMediaType;
|
||||
pub static AVMediaTypeMetadata: AVMediaType;
|
||||
pub static AVMediaTypeMuxed: AVMediaType;
|
||||
pub static AVMediaTypeMetadataObject: AVMediaType;
|
||||
pub static AVMediaTypeDepthData: AVMediaType;
|
||||
}
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
#[link(name = "CoreMedia", kind = "framework")]
|
||||
extern "C" {
|
||||
pub fn CMVideoFormatDescriptionGetDimensions(
|
||||
videoDesc: CMFormatDescriptionRef,
|
||||
@@ -117,16 +142,38 @@ pub mod core_media {
|
||||
) -> std::os::raw::c_int;
|
||||
|
||||
pub fn CMSampleBufferGetDataBuffer(sbuf: CMSampleBufferRef) -> CMBlockBufferRef;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn dispatch_queue_create(
|
||||
label: *const ::std::os::raw::c_char,
|
||||
attr: NSObject,
|
||||
) -> NSObject;
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
pub fn dispatch_release(object: NSObject);
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct __CVBuffer {
|
||||
_unused: [u8; 0],
|
||||
}
|
||||
pub type CVBufferRef = *mut __CVBuffer;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
extern "C" {
|
||||
pub fn CMSampleBufferGetImageBuffer(sbuf: CMSampleBufferRef) -> CVImageBufferRef;
|
||||
}
|
||||
|
||||
pub type CVImageBufferRef = CVBufferRef;
|
||||
pub type CVPixelBufferRef = CVImageBufferRef;
|
||||
pub type CVPixelBufferLockFlags = u64;
|
||||
pub type CVReturn = i32;
|
||||
|
||||
#[allow(non_snake_case)]
|
||||
extern "C" {
|
||||
pub fn CVPixelBufferLockBaseAddress(
|
||||
pixelBuffer: CVPixelBufferRef,
|
||||
lockFlags: CVPixelBufferLockFlags,
|
||||
@@ -142,28 +189,14 @@ pub mod core_media {
|
||||
pub fn CVPixelBufferGetBaseAddress(
|
||||
pixelBuffer: CVPixelBufferRef,
|
||||
) -> *mut ::std::os::raw::c_void;
|
||||
|
||||
pub fn CVPixelBufferGetPixelFormatType(pixelBuffer: CVPixelBufferRef) -> OSType;
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
pub struct __CVBuffer {
|
||||
_unused: [u8; 0],
|
||||
}
|
||||
pub type CVBufferRef = *mut __CVBuffer;
|
||||
|
||||
pub type CVImageBufferRef = CVBufferRef;
|
||||
pub type CVPixelBufferRef = CVImageBufferRef;
|
||||
pub type CVPixelBufferLockFlags = u64;
|
||||
pub type CVReturn = i32;
|
||||
|
||||
pub type OSType = FourCharCode;
|
||||
pub type AVVideoCodecType = NSString;
|
||||
|
||||
#[link(name = "AVFoundation", kind = "framework")]
|
||||
extern "C" {
|
||||
pub static AVVideoCodecKey: NSString;
|
||||
}
|
||||
pub type OSType = FourCharCode;
|
||||
pub type AVVideoCodecType = NSString;
|
||||
extern "C" {
|
||||
pub static AVVideoCodecTypeHEVC: AVVideoCodecType;
|
||||
pub static AVVideoCodecTypeH264: AVVideoCodecType;
|
||||
pub static AVVideoCodecTypeJPEG: AVVideoCodecType;
|
||||
@@ -181,17 +214,8 @@ pub mod core_media {
|
||||
pub static AVVideoWidthKey: NSString;
|
||||
pub static AVVideoHeightKey: NSString;
|
||||
pub static AVVideoExpectedSourceFrameRateKey: NSString;
|
||||
pub fn CVPixelBufferGetPixelFormatType(pixelBuffer: CVPixelBufferRef) -> OSType;
|
||||
|
||||
pub static AVMediaTypeVideo: AVMediaType;
|
||||
pub static AVMediaTypeAudio: AVMediaType;
|
||||
pub static AVMediaTypeText: AVMediaType;
|
||||
pub static AVMediaTypeClosedCaption: AVMediaType;
|
||||
pub static AVMediaTypeSubtitle: AVMediaType;
|
||||
pub static AVMediaTypeTimecode: AVMediaType;
|
||||
pub static AVMediaTypeMetadata: AVMediaType;
|
||||
pub static AVMediaTypeMuxed: AVMediaType;
|
||||
pub static AVMediaTypeMetadataObject: AVMediaType;
|
||||
pub static AVMediaTypeDepthData: AVMediaType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
@@ -14,10 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use crate::{
|
||||
mjpeg_to_rgb, yuyv422_to_rgb, CameraControl, CameraFormat, CameraInfo, CaptureAPIBackend,
|
||||
CaptureBackendTrait, FrameFormat, KnownCameraControl, NokhwaError, Resolution,
|
||||
};
|
||||
use crate::{mjpeg_to_rgb, yuyv422_to_rgb, CameraControl, CameraFormat, CameraInfo, CaptureAPIBackend, CaptureBackendTrait, ControlValueSetter, FrameFormat, KnownCameraControl, NokhwaError, PixelFormat, Resolution, nokhwa_initialize, nokhwa_check};
|
||||
use image::{ImageBuffer, Rgb};
|
||||
use nokhwa_bindings_macos::avfoundation::{
|
||||
query_avfoundation, AVCaptureDevice, AVCaptureDeviceInput, AVCaptureSession,
|
||||
@@ -32,6 +29,7 @@ use std::{any::Any, borrow::Borrow, borrow::Cow, collections::HashMap, ops::Dere
|
||||
/// - You **must** call [`nokhwa_initialize`](crate::nokhwa_initialize) **before** doing anything with `AVFoundation`.
|
||||
/// - This only works on 64 bit platforms.
|
||||
/// - FPS adjustment does not work.
|
||||
/// - If permission has not been granted and you call `init()` it will error.
|
||||
#[cfg_attr(feature = "docs-features", doc(cfg(feature = "input-avfoundation")))]
|
||||
pub struct AVFoundationCaptureDevice {
|
||||
device: AVCaptureDevice,
|
||||
@@ -97,6 +95,14 @@ impl AVFoundationCaptureDevice {
|
||||
}
|
||||
|
||||
impl CaptureBackendTrait for AVFoundationCaptureDevice {
|
||||
fn init(&mut self) -> Result<CameraFormat, NokhwaError> {
|
||||
if !nokhwa_check() {
|
||||
return Err(NokhwaError::InitializeError { backend: CaptureAPIBackend::AVFoundation, error: "User permission not granted yet.".to_string() })
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
fn backend(&self) -> CaptureAPIBackend {
|
||||
CaptureAPIBackend::AVFoundation
|
||||
}
|
||||
@@ -105,6 +111,10 @@ impl CaptureBackendTrait for AVFoundationCaptureDevice {
|
||||
&self.info
|
||||
}
|
||||
|
||||
fn refresh_camera_format(&mut self) -> Result<(), NokhwaError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn camera_format(&self) -> CameraFormat {
|
||||
self.format
|
||||
}
|
||||
@@ -182,37 +192,23 @@ impl CaptureBackendTrait for AVFoundationCaptureDevice {
|
||||
self.set_camera_format(format)
|
||||
}
|
||||
|
||||
fn supported_camera_controls(&self) -> Result<Vec<KnownCameraControl>, NokhwaError> {
|
||||
Err(NokhwaError::NotImplementedError(
|
||||
"Not Implemented".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
fn camera_control(&self, _: KnownCameraControl) -> Result<CameraControl, NokhwaError> {
|
||||
Err(NokhwaError::NotImplementedError(
|
||||
"Not Implemented".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
fn set_camera_control(&mut self, _: CameraControl) -> Result<(), NokhwaError> {
|
||||
fn camera_controls(&self) -> Result<Vec<CameraControl>, NokhwaError> {
|
||||
Err(NokhwaError::NotImplementedError(
|
||||
"Not Implemented".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
fn raw_supported_camera_controls(&self) -> Result<Vec<Box<dyn Any>>, NokhwaError> {
|
||||
Err(NokhwaError::NotImplementedError(
|
||||
"Not Implemented".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
fn raw_camera_control(&self, _: &dyn Any) -> Result<Box<dyn Any>, NokhwaError> {
|
||||
Err(NokhwaError::NotImplementedError(
|
||||
"Not Implemented".to_string(),
|
||||
))
|
||||
}
|
||||
|
||||
fn set_raw_camera_control(&mut self, _: &dyn Any, _: &dyn Any) -> Result<(), NokhwaError> {
|
||||
fn set_camera_control(
|
||||
&mut self,
|
||||
_: KnownCameraControl,
|
||||
_: ControlValueSetter,
|
||||
) -> Result<(), NokhwaError> {
|
||||
Err(NokhwaError::NotImplementedError(
|
||||
"Not Implemented".to_string(),
|
||||
))
|
||||
@@ -268,6 +264,12 @@ impl CaptureBackendTrait for AVFoundationCaptureDevice {
|
||||
Ok(image_buf)
|
||||
}
|
||||
|
||||
fn frame_typed<F: PixelFormat>(
|
||||
&mut self,
|
||||
) -> Result<ImageBuffer<crate::pixel_format::Output, Vec<u8>>, NokhwaError> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn frame_raw(&mut self) -> Result<Cow<[u8]>, NokhwaError> {
|
||||
match &self.session {
|
||||
Some(session) => {
|
||||
@@ -295,6 +297,7 @@ impl CaptureBackendTrait for AVFoundationCaptureDevice {
|
||||
let data = match data.1 {
|
||||
AVFourCC::YUV2 => Cow::from(yuyv422_to_rgb(data.0.borrow(), false)),
|
||||
AVFourCC::MJPEG => Cow::from(mjpeg_to_rgb(data.0.borrow(), false)),
|
||||
AVFourCC::GRAY8 => {}
|
||||
};
|
||||
Ok(data)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* 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 crate::{
|
||||
js_camera::JSCameraResizeMode,
|
||||
js_camera::{query_js_cameras, JSCameraConstraintsBuilder},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
+19
-22
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
@@ -20,7 +20,7 @@ use crate::{
|
||||
utils::{
|
||||
buf_mjpeg_to_rgb, buf_yuyv422_to_rgb, CameraFormat, CameraInfo, FrameFormat, Resolution,
|
||||
},
|
||||
Buffer, CameraControl, CaptureAPIBackend, KnownCameraControl, PixelFormat,
|
||||
Buffer, CameraControl, CaptureAPIBackend, ControlValueSetter, KnownCameraControl, PixelFormat,
|
||||
};
|
||||
use enum_dispatch::enum_dispatch;
|
||||
use image::{buffer::ConvertBuffer, ImageBuffer, RgbaImage};
|
||||
@@ -82,23 +82,20 @@ pub trait CaptureBackendTrait {
|
||||
) -> Result<HashMap<Resolution, Vec<u32>>, NokhwaError>;
|
||||
|
||||
fn compatible_camera_formats(&mut self) -> Result<Vec<CameraFormat>, NokhwaError> {
|
||||
let mut compatible_formats = vec![];
|
||||
frame_formats().map(|ff| {
|
||||
if let Ok(mut fmts) = self.compatible_list_by_resolution(ff).map(|compatible| {
|
||||
compatible
|
||||
let compatible_formats = self
|
||||
.compatible_fourcc()?
|
||||
.into_iter()
|
||||
.map(|ffmt| {
|
||||
self.compatible_list_by_resolution(ffmt)?
|
||||
.into_iter()
|
||||
.map(|(res, fps)| {
|
||||
fps.into_iter().map(|rate| CameraFormat {
|
||||
resolution: res,
|
||||
format: ff,
|
||||
frame_rate: rate,
|
||||
})
|
||||
.map(|(resolution, fpses)| {
|
||||
fpses
|
||||
.into_iter()
|
||||
.map(|fps| CameraFormat::new(resolution, ffmt, fps))
|
||||
})
|
||||
.collect::<Vec<CameraFormat>>()
|
||||
}) {
|
||||
compatible_formats.append(&mut fmts)
|
||||
}
|
||||
})
|
||||
})
|
||||
.collect::<Vec<CameraFormat>>();
|
||||
Ok(compatible_formats)
|
||||
}
|
||||
|
||||
/// A Vector of compatible [`FrameFormat`]s. Will only return 2 elements at most.
|
||||
@@ -227,9 +224,9 @@ pub trait CaptureBackendTrait {
|
||||
FrameFormat::GRAY8 => 1,
|
||||
};
|
||||
if alpha {
|
||||
return (resolution.width() * resolution.height() * (pxwidth + 1)) as usize;
|
||||
return Ok((resolution.width() * resolution.height() * (pxwidth + 1)) as usize);
|
||||
}
|
||||
(resolution.width() * resolution.height() * pxwidth) as usize
|
||||
Ok((resolution.width() * resolution.height() * pxwidth) as usize)
|
||||
}
|
||||
|
||||
/// Directly writes the current frame(RGB24) into said `buffer`. If `convert_rgba` is true, the buffer written will be written as an RGBA frame instead of a RGB frame. Returns the amount of bytes written on successful capture.
|
||||
@@ -243,9 +240,9 @@ pub trait CaptureBackendTrait {
|
||||
// FIXME: ??????
|
||||
let cfmt = self.camera_format()?;
|
||||
let frame = self.frame_raw()?;
|
||||
let data = match cfmt.format() {
|
||||
FrameFormat::MJPEG => buf_mjpeg_to_rgb(&frame, buffer, write_alpha),
|
||||
FrameFormat::YUYV => buf_yuyv422_to_rgb(&frame, buffer, write_alpha),
|
||||
match cfmt.format() {
|
||||
FrameFormat::MJPEG => buf_mjpeg_to_rgb(&frame, buffer, write_alpha)?,
|
||||
FrameFormat::YUYV => buf_yuyv422_to_rgb(&frame, buffer, write_alpha)?,
|
||||
FrameFormat::GRAY8 => {
|
||||
let data = if write_alpha {
|
||||
frame
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
#![deny(clippy::pedantic)]
|
||||
#![warn(clippy::all)]
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2021 l1npengtul <l1npengtul@protonmail.com> / The Nokhwa Contributors
|
||||
* 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.
|
||||
|
||||
Reference in New Issue
Block a user