feat(video): recover camera previews and reduce encoding and playout cost

Improve camera recovery, shared preview lifecycle and receiver playout diagnostics. Preserve qualified X4 runtime changes and restore async admission in loopback media tests.
This commit is contained in:
DCCONSTRUCTIONS
2026-10-29 09:10:01 +03:00
parent e06ff9a214
commit fa8bde584f
94 changed files with 8892 additions and 375 deletions
+20
View File
@@ -0,0 +1,20 @@
/** Numeric projection of the existing peer; no image, SDP, second stream or timer. */
const object=(value:unknown):Record<string,unknown>=>value&&typeof value==='object'&&!Array.isArray(value)?value as Record<string,unknown>:{};
export function previewEvidence(peer:string,session:string,runtime:unknown,timing:unknown,width:number,height:number,sourceAge:number){
const r=object(runtime),b=object(r.media_budget),e=object(b.egress),d=object(r.decoder),t=object(timing),reset=object(b.last_encoder_reset);
const result:Record<string,unknown>={peer_id:peer,device_session:session};
const fields:Record<string,unknown>={width,height,source_age_ms:sourceAge,sender_mono_ms:b.sample_mono_ms,
allocation_bps:b.allocation_bps,target_bps:b.target_bps,encoder_bps:b.encoder_bps,receiver_bps:b.receiver_bps,
max_width:b.max_width,max_fps:b.max_fps,encoder_frames:b.encoder_frames,encoder_reinitializations:b.encoder_reinitializations,
encode_ms:b.encode_ms,sent_bytes:e.sent_bytes,queue_dropped:e.queue_dropped,expired_frames:e.expired_frames,
expired_datagrams:e.expired_datagrams,stale_rtp_packets:e.stale_rtp_packets,max_permit_wait_ms:e.max_permit_wait_ms,
decoder_errors:d.decode_errors,decoder_frames:d.frames,decoder_gaps:d.gaps,
receiver_sampled_at_ms:t.sampled_at_ms,interval_ms:t.interval_ms,fps:t.fps,mbps:t.mbps,
round_trip_ms:t.round_trip_ms,jitter_buffer_ms:t.jitter_buffer_ms,
requested_jitter_ms:t.requested_jitter_ms,jitter_target_ms:t.jitter_target_ms,jitter_minimum_ms:t.jitter_minimum_ms,
decode_ms:t.decode_ms,processing_ms:t.processing_ms,assembly_ms:t.assembly_ms,frames_dropped:t.frames_dropped,
packets_lost:t.packets_lost,freezes:t.freezes,reset_frame:reset.frame,reset_mono_ms:reset.mono_ms};
for(const [key,value] of Object.entries(fields))if(typeof value==='number'&&Number.isFinite(value)&&value>=0&&value<=Number.MAX_SAFE_INTEGER)result[key]=value;
if(b.mode==='observing'||b.mode==='control_reserved')result.mode=b.mode;
return result;
}