fix(video): force h264 and trace frame pipeline
Some checks failed
Build Release Binaries / build-amd64 (push) Failing after 3m32s
Mirror to GitHub / mirror (push) Failing after 28s

This commit is contained in:
Siavash Sameni
2026-05-25 20:03:11 +04:00
parent 7eca79846f
commit d57ebe3d2c
9 changed files with 761 additions and 43 deletions

View File

@@ -160,8 +160,11 @@ impl VideoEncoder for MediaCodecEncoder {
if packet.is_empty() {
return false;
}
let nal_type = packet[0] & 0x1F;
nal_type == 5
let nals = split_annex_b(packet);
if nals.is_empty() {
return (packet[0] & 0x1F) == 5;
}
nals.iter().any(|nal| !nal.is_empty() && (nal[0] & 0x1F) == 5)
}
}
@@ -1135,6 +1138,11 @@ mod tests {
};
assert!(enc.is_keyframe(&[0x65, 0x01]));
assert!(!enc.is_keyframe(&[0x41, 0x01]));
assert!(enc.is_keyframe(&[
0x00, 0x00, 0x00, 0x01, 0x67, 0x01, // SPS
0x00, 0x00, 0x00, 0x01, 0x68, 0x02, // PPS
0x00, 0x00, 0x00, 0x01, 0x65, 0x03, // IDR
]));
}
#[test]

View File

@@ -160,9 +160,11 @@ impl VideoEncoder for VideoToolboxEncoder {
if packet.is_empty() {
return false;
}
let nal_type = packet[0] & 0x1F;
// NAL type 5 = IDR slice (keyframe).
nal_type == 5
let nals = split_annex_b(packet);
if nals.is_empty() {
return (packet[0] & 0x1F) == 5;
}
nals.iter().any(|nal| !nal.is_empty() && (nal[0] & 0x1F) == 5)
}
}
@@ -791,6 +793,11 @@ mod tests {
let enc = VideoToolboxEncoder::new(1280, 720, 2_000_000).unwrap();
assert!(enc.is_keyframe(&[0x65, 0x01, 0x02]));
assert!(!enc.is_keyframe(&[0x41, 0x01, 0x02]));
assert!(enc.is_keyframe(&[
0x00, 0x00, 0x00, 0x01, 0x67, 0x01, // SPS
0x00, 0x00, 0x00, 0x01, 0x68, 0x02, // PPS
0x00, 0x00, 0x00, 0x01, 0x65, 0x03, // IDR
]));
}
#[test]

View File

@@ -177,9 +177,9 @@ fn missing_fragment_blocks_reassembly() {
#[test]
fn video_codec_selection_semantics() {
// The relay's selection rule is: first codec offered by the caller.
let offered = vec![CodecId::Av1Main, CodecId::H264Baseline, CodecId::H265Main];
let offered = vec![CodecId::H264Baseline];
let chosen = offered.into_iter().next();
assert_eq!(chosen, Some(CodecId::Av1Main));
assert_eq!(chosen, Some(CodecId::H264Baseline));
// When no codecs are offered, video is audio-only.
let empty: Vec<CodecId> = vec![];