mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-03-22 10:56:38 +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:
@@ -21,9 +21,9 @@ use tokio::sync::Mutex;
|
||||
use tracing::{debug, error, trace};
|
||||
use webrtc::media::io::h264_reader::H264Reader;
|
||||
use webrtc::media::Sample;
|
||||
use webrtc::rtp_transceiver::rtp_codec::RTCRtpCodecCapability;
|
||||
use webrtc::track::track_local::track_local_static_sample::TrackLocalStaticSample;
|
||||
use webrtc::track::track_local::TrackLocal;
|
||||
use webrtc::rtp_transceiver::rtp_codec::RTCRtpCodecCapability;
|
||||
|
||||
use crate::error::{AppError, Result};
|
||||
use crate::video::format::Resolution;
|
||||
@@ -168,7 +168,12 @@ impl H264VideoTrack {
|
||||
/// * `data` - H264 Annex B encoded frame data
|
||||
/// * `duration` - Frame duration (typically 1/fps seconds)
|
||||
/// * `is_keyframe` - Whether this is a keyframe (IDR frame)
|
||||
pub async fn write_frame(&self, data: &[u8], _duration: Duration, is_keyframe: bool) -> Result<()> {
|
||||
pub async fn write_frame(
|
||||
&self,
|
||||
data: &[u8],
|
||||
_duration: Duration,
|
||||
is_keyframe: bool,
|
||||
) -> Result<()> {
|
||||
if data.is_empty() {
|
||||
return Ok(());
|
||||
}
|
||||
@@ -324,9 +329,9 @@ impl H264VideoTrack {
|
||||
let mut payloader = self.payloader.lock().await;
|
||||
let bytes = Bytes::copy_from_slice(data);
|
||||
|
||||
payloader.payload(mtu, &bytes).map_err(|e| {
|
||||
AppError::VideoError(format!("H264 packetization failed: {}", e))
|
||||
})
|
||||
payloader
|
||||
.payload(mtu, &bytes)
|
||||
.map_err(|e| AppError::VideoError(format!("H264 packetization failed: {}", e)))
|
||||
}
|
||||
|
||||
/// Get configuration
|
||||
@@ -423,7 +428,10 @@ impl OpusAudioTrack {
|
||||
let mut stats = self.stats.lock().await;
|
||||
stats.errors += 1;
|
||||
error!("Failed to write Opus sample: {}", e);
|
||||
Err(AppError::WebRtcError(format!("Failed to write audio sample: {}", e)))
|
||||
Err(AppError::WebRtcError(format!(
|
||||
"Failed to write audio sample: {}",
|
||||
e
|
||||
)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user