mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-09-27 14:30:27 +00:00
Request a keyframe whenever we're going to wait for a keyframe
This commit is contained in:
parent
9250ca4ccc
commit
86d1676a67
3 changed files with 23 additions and 6 deletions
|
@ -7,6 +7,7 @@ license = "LGPL-2.1+"
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glib = { git = "https://github.com/gtk-rs/glib" }
|
glib = { git = "https://github.com/gtk-rs/glib" }
|
||||||
gstreamer = { git = "https://github.com/sdroege/gstreamer-rs", features = ["v1_10"] }
|
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" }
|
gst-plugin = { path = "../gst-plugin" }
|
||||||
gtk = { git = "https://github.com/gtk-rs/gtk", features = ["v3_6"], optional = true }
|
gtk = { git = "https://github.com/gtk-rs/gtk", features = ["v3_6"], optional = true }
|
||||||
gio = { git = "https://github.com/gtk-rs/gio", optional = true }
|
gio = { git = "https://github.com/gtk-rs/gio", optional = true }
|
||||||
|
|
|
@ -22,6 +22,7 @@ extern crate glib;
|
||||||
extern crate gst_plugin;
|
extern crate gst_plugin;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate gstreamer as gst;
|
extern crate gstreamer as gst;
|
||||||
|
extern crate gstreamer_video as gst_video;
|
||||||
|
|
||||||
mod togglerecord;
|
mod togglerecord;
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@ use glib;
|
||||||
use glib::prelude::*;
|
use glib::prelude::*;
|
||||||
use gst;
|
use gst;
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
|
use gst_video;
|
||||||
|
|
||||||
use gst_plugin::properties::*;
|
use gst_plugin::properties::*;
|
||||||
use gst_plugin::object::*;
|
use gst_plugin::object::*;
|
||||||
|
@ -376,16 +377,30 @@ impl ToggleRecord {
|
||||||
|
|
||||||
// First check if we have to update our recording state
|
// First check if we have to update our recording state
|
||||||
let mut rec_state = self.state.lock().unwrap();
|
let mut rec_state = self.state.lock().unwrap();
|
||||||
match rec_state.recording_state {
|
let settings_changed = match rec_state.recording_state {
|
||||||
RecordingState::Recording => if !settings.record {
|
RecordingState::Recording if !settings.record => {
|
||||||
gst_debug!(self.cat, obj: pad, "Stopping recording");
|
gst_debug!(self.cat, obj: pad, "Stopping recording");
|
||||||
rec_state.recording_state = RecordingState::Stopping;
|
rec_state.recording_state = RecordingState::Stopping;
|
||||||
},
|
true
|
||||||
RecordingState::Stopped => if settings.record {
|
}
|
||||||
|
RecordingState::Stopped if settings.record => {
|
||||||
gst_debug!(self.cat, obj: pad, "Starting recording");
|
gst_debug!(self.cat, obj: pad, "Starting recording");
|
||||||
rec_state.recording_state = RecordingState::Starting;
|
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 {
|
match rec_state.recording_state {
|
||||||
|
|
Loading…
Reference in a new issue