Request a keyframe whenever we're going to wait for a keyframe

This commit is contained in:
Sebastian Dröge 2017-12-10 12:34:53 +02:00
parent 9250ca4ccc
commit 86d1676a67
3 changed files with 23 additions and 6 deletions

View file

@ -7,6 +7,7 @@ license = "LGPL-2.1+"
[dependencies]
glib = { git = "https://github.com/gtk-rs/glib" }
gstreamer = { git = "https://github.com/sdroege/gstreamer-rs", features = ["v1_10"] }
gstreamer-video = { git = "https://github.com/sdroege/gstreamer-rs", features = ["v1_10"] }
gst-plugin = { path = "../gst-plugin" }
gtk = { git = "https://github.com/gtk-rs/gtk", features = ["v3_6"], optional = true }
gio = { git = "https://github.com/gtk-rs/gio", optional = true }

View file

@ -22,6 +22,7 @@ extern crate glib;
extern crate gst_plugin;
#[macro_use]
extern crate gstreamer as gst;
extern crate gstreamer_video as gst_video;
mod togglerecord;

View file

@ -19,6 +19,7 @@ use glib;
use glib::prelude::*;
use gst;
use gst::prelude::*;
use gst_video;
use gst_plugin::properties::*;
use gst_plugin::object::*;
@ -376,16 +377,30 @@ impl ToggleRecord {
// First check if we have to update our recording state
let mut rec_state = self.state.lock().unwrap();
match rec_state.recording_state {
RecordingState::Recording => if !settings.record {
let settings_changed = match rec_state.recording_state {
RecordingState::Recording if !settings.record => {
gst_debug!(self.cat, obj: pad, "Stopping recording");
rec_state.recording_state = RecordingState::Stopping;
},
RecordingState::Stopped => if settings.record {
true
}
RecordingState::Stopped if settings.record => {
gst_debug!(self.cat, obj: pad, "Starting recording");
rec_state.recording_state = RecordingState::Starting;
},
_ => (),
true
}
_ => false,
};
if settings_changed {
drop(rec_state);
drop(state);
gst_debug!(self.cat, obj: pad, "Requesting a new keyframe");
stream.sinkpad.push_event(
gst_video::new_upstream_force_key_unit_event(gst::CLOCK_TIME_NONE, true, 0).build(),
);
state = stream.state.lock().unwrap();
rec_state = self.state.lock().unwrap();
}
match rec_state.recording_state {