Skip to content

Commit

Permalink
recover from crashed video encoder (security-union#14)
Browse files Browse the repository at this point in the history
Co-authored-by: Dario Lencina <dario@securityunion.dev>
  • Loading branch information
darioalessandro and darioalessandro authored Nov 9, 2022
1 parent e0581c8 commit c863193
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions yew-ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ features = [
"GainNode",
"HtmlDocument",
"console",
"CodecState",
"CanvasRenderingContext2d",
"EncodedAudioChunk",
"EncodedAudioChunkInit",
Expand Down
9 changes: 7 additions & 2 deletions yew-ui/src/components/attendants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,13 @@ impl Component for AttendandsComponent {
&& chunk_type == EncodedVideoChunkType::Key
|| !peer.waiting_for_video_keyframe
{
peer.video_decoder.decode(&encoded_video_chunk);
peer.waiting_for_video_keyframe = false;
if peer.video_decoder.state() == CodecState::Configured {
peer.video_decoder.decode(&encoded_video_chunk);
peer.waiting_for_video_keyframe = false;
} else if peer.video_decoder.state() == CodecState::Closed {
// Codec crashed, reconfigure it...
self.connected_peers.remove(&email.clone());
}
}
}
media_packet::MediaType::AUDIO => {
Expand Down
2 changes: 1 addition & 1 deletion yew-ui/src/components/host.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ impl Component for Host {
let mut opts = VideoEncoderEncodeOptions::new();
counter = (counter + 1) % 50;
opts.key_frame(counter == 0);
video_encoder.encode(&video_frame);
video_encoder.encode_with_options(&video_frame, &opts);
video_frame.close();
}
Err(e) => {
Expand Down

0 comments on commit c863193

Please sign in to comment.