mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-16 16:07:07 +08:00
feat(video): 事务化切换与前端统一编排,增强视频输入格式支持
- 后端:切换事务+transition_id,/stream/mode 返回 switching/transition_id 与实际 codec - 事件:新增 mode_switching/mode_ready,config/webrtc_ready/mode_changed 关联事务 - 编码/格式:扩展 NV21/NV16/NV24/RGB/BGR 输入与转换链路,RKMPP direct input 优化 - 前端:useVideoSession 统一切换,失败回退真实切回 MJPEG,菜单格式同步修复 - 清理:useVideoStream 降级为 MJPEG-only
This commit is contained in:
@@ -7,7 +7,8 @@ use tracing::{debug, error, info, warn};
|
||||
|
||||
use super::configfs::{
|
||||
create_dir, find_udc, is_configfs_available, remove_dir, write_file, CONFIGFS_PATH,
|
||||
DEFAULT_GADGET_NAME, DEFAULT_USB_BCD_DEVICE, USB_BCD_USB, DEFAULT_USB_PRODUCT_ID, DEFAULT_USB_VENDOR_ID,
|
||||
DEFAULT_GADGET_NAME, DEFAULT_USB_BCD_DEVICE, DEFAULT_USB_PRODUCT_ID, DEFAULT_USB_VENDOR_ID,
|
||||
USB_BCD_USB,
|
||||
};
|
||||
use super::endpoint::{EndpointAllocator, DEFAULT_MAX_ENDPOINTS};
|
||||
use super::function::{FunctionMeta, GadgetFunction};
|
||||
@@ -77,7 +78,11 @@ impl OtgGadgetManager {
|
||||
}
|
||||
|
||||
/// Create a new gadget manager with custom descriptor
|
||||
pub fn with_descriptor(gadget_name: &str, max_endpoints: u8, descriptor: GadgetDescriptor) -> Self {
|
||||
pub fn with_descriptor(
|
||||
gadget_name: &str,
|
||||
max_endpoints: u8,
|
||||
descriptor: GadgetDescriptor,
|
||||
) -> Self {
|
||||
let gadget_path = PathBuf::from(CONFIGFS_PATH).join(gadget_name);
|
||||
let config_path = gadget_path.join("configs/c.1");
|
||||
|
||||
@@ -303,10 +308,22 @@ impl OtgGadgetManager {
|
||||
|
||||
/// Set USB device descriptors
|
||||
fn set_device_descriptors(&self) -> Result<()> {
|
||||
write_file(&self.gadget_path.join("idVendor"), &format!("0x{:04x}", self.descriptor.vendor_id))?;
|
||||
write_file(&self.gadget_path.join("idProduct"), &format!("0x{:04x}", self.descriptor.product_id))?;
|
||||
write_file(&self.gadget_path.join("bcdDevice"), &format!("0x{:04x}", self.descriptor.device_version))?;
|
||||
write_file(&self.gadget_path.join("bcdUSB"), &format!("0x{:04x}", USB_BCD_USB))?;
|
||||
write_file(
|
||||
&self.gadget_path.join("idVendor"),
|
||||
&format!("0x{:04x}", self.descriptor.vendor_id),
|
||||
)?;
|
||||
write_file(
|
||||
&self.gadget_path.join("idProduct"),
|
||||
&format!("0x{:04x}", self.descriptor.product_id),
|
||||
)?;
|
||||
write_file(
|
||||
&self.gadget_path.join("bcdDevice"),
|
||||
&format!("0x{:04x}", self.descriptor.device_version),
|
||||
)?;
|
||||
write_file(
|
||||
&self.gadget_path.join("bcdUSB"),
|
||||
&format!("0x{:04x}", USB_BCD_USB),
|
||||
)?;
|
||||
write_file(&self.gadget_path.join("bDeviceClass"), "0x00")?; // Composite device
|
||||
write_file(&self.gadget_path.join("bDeviceSubClass"), "0x00")?;
|
||||
write_file(&self.gadget_path.join("bDeviceProtocol"), "0x00")?;
|
||||
@@ -319,8 +336,14 @@ impl OtgGadgetManager {
|
||||
let strings_path = self.gadget_path.join("strings/0x409");
|
||||
create_dir(&strings_path)?;
|
||||
|
||||
write_file(&strings_path.join("serialnumber"), &self.descriptor.serial_number)?;
|
||||
write_file(&strings_path.join("manufacturer"), &self.descriptor.manufacturer)?;
|
||||
write_file(
|
||||
&strings_path.join("serialnumber"),
|
||||
&self.descriptor.serial_number,
|
||||
)?;
|
||||
write_file(
|
||||
&strings_path.join("manufacturer"),
|
||||
&self.descriptor.manufacturer,
|
||||
)?;
|
||||
write_file(&strings_path.join("product"), &self.descriptor.product)?;
|
||||
debug!("Created USB strings");
|
||||
Ok(())
|
||||
@@ -349,7 +372,10 @@ impl OtgGadgetManager {
|
||||
|
||||
/// Get endpoint usage info
|
||||
pub fn endpoint_info(&self) -> (u8, u8) {
|
||||
(self.endpoint_allocator.used(), self.endpoint_allocator.max())
|
||||
(
|
||||
self.endpoint_allocator.used(),
|
||||
self.endpoint_allocator.max(),
|
||||
)
|
||||
}
|
||||
|
||||
/// Get gadget path
|
||||
|
||||
Reference in New Issue
Block a user