pub struct FakeFrameInjector { /* private fields */ }Expand description
Test-only handle for simulating a live Frame::Video arrival in
unit tests. See
StreamSource::start_inert_for_test_with_gap_and_injector.
pub (not pub(crate)) so tests/fixture_replay.rs can drive
production’s gap-detection ticker from an integration test. The
#[cfg(any(test, feature = "test-util"))] gate on the struct + impl
keeps this out of release builds; the test-util feature is only
pulled in by bairelay’s own [dev-dependencies] self-reference.
Implementations§
Source§impl FakeFrameInjector
impl FakeFrameInjector
Sourcepub fn inject_fake_video_frame(&self)
pub fn inject_fake_video_frame(&self)
Mark the source as having just received a real live video frame.
Mirrors a SUBSET of the state updates that reader_task performs
after a successful BcMedia::Iframe / Pframe translation.
Of production’s four live-frame state mutations, this helper replicates two and skips two:
Replicated:
last_live_frame_at— bumped toInstant::now()so the gap ticker sees a fresh live frame.gap_state— forced back toGapState::Live.
Skipped:
last_emitted_pts_90khz— real reader advances this from the decoded frame’s PTS so replay can synthesize continuous timestamps; tests that assert PTS continuity must set it manually.last_emit_wallclock_at— real reader stamps wall-clock per emit so the Bridging ticker knows when to fire; tests that depend on ticker phase must set it manually.
Does NOT broadcast — use Self::broadcast_live_video_frame
when a downstream subscriber needs to actually see the frame.
Sourcepub fn broadcast_live_video_frame(&self, frame: Frame)
pub fn broadcast_live_video_frame(&self, frame: Frame)
Near-reader-task-equivalent “live video frame arrived” event:
broadcast frame on the source’s tx channel AND update the
gap-detection markers so the ticker stays in Live state.
Used by the Task 11 integration test in
tests/fixture_replay.rs to drive a real StreamSource through
Live → Bridging → Live transitions with frames that actually
reach attached RTSP subscribers.
NOT a full production mock. Delegates to
Self::inject_fake_video_frame for state updates, which only
touches last_live_frame_at + gap_state. Production’s
last_emitted_pts_90khz and last_emit_wallclock_at are NOT
advanced here — a future test author who needs PTS-continuity or
ticker-phase accuracy must write those directly.