mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-25 19:11:06 +00:00
event: add constructor on target types
... and deprecate the `Event::new_*` forms.
This commit is contained in:
parent
f421d878b6
commit
884e5e4e4a
5 changed files with 539 additions and 12 deletions
|
@ -23,7 +23,7 @@ impl ExampleCustomEvent {
|
||||||
let s = gst::Structure::builder(Self::EVENT_NAME)
|
let s = gst::Structure::builder(Self::EVENT_NAME)
|
||||||
.field("send_eos", &send_eos)
|
.field("send_eos", &send_eos)
|
||||||
.build();
|
.build();
|
||||||
gst::Event::new_custom_downstream(s).build()
|
gst::event::CustomDownstream::new(s)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn from_event(ev: &gst::Event) -> Option<ExampleCustomEvent> {
|
pub fn from_event(ev: &gst::Event) -> Option<ExampleCustomEvent> {
|
||||||
|
@ -85,7 +85,7 @@ fn example_main() {
|
||||||
/* Send EOS event to shut down the pipeline, but from an async callback, as we're
|
/* Send EOS event to shut down the pipeline, but from an async callback, as we're
|
||||||
* in a pad probe blocking the stream thread here... */
|
* in a pad probe blocking the stream thread here... */
|
||||||
println!("Got custom event with send_eos=true. Sending EOS");
|
println!("Got custom event with send_eos=true. Sending EOS");
|
||||||
let ev = gst::Event::new_eos().build();
|
let ev = gst::event::Eos::new();
|
||||||
let pipeline_weak = pipeline_weak.clone();
|
let pipeline_weak = pipeline_weak.clone();
|
||||||
pipeline.call_async(move |_| {
|
pipeline.call_async(move |_| {
|
||||||
if let Some(pipeline) = pipeline_weak.upgrade() {
|
if let Some(pipeline) = pipeline_weak.upgrade() {
|
||||||
|
|
|
@ -74,8 +74,7 @@ fn example_main() {
|
||||||
// Once all sinks are done handling the EOS event (and all buffers that were before the
|
// Once all sinks are done handling the EOS event (and all buffers that were before the
|
||||||
// EOS event in the pipeline already), the pipeline would post an EOS message on the bus,
|
// EOS event in the pipeline already), the pipeline would post an EOS message on the bus,
|
||||||
// essentially telling the application that the pipeline is completely drained.
|
// essentially telling the application that the pipeline is completely drained.
|
||||||
let ev = gst::Event::new_eos().build();
|
pipeline.send_event(gst::event::Eos::new());
|
||||||
pipeline.send_event(ev);
|
|
||||||
|
|
||||||
// Remove this handler, the pipeline will shutdown anyway, now that we
|
// Remove this handler, the pipeline will shutdown anyway, now that we
|
||||||
// sent the EOS event.
|
// sent the EOS event.
|
||||||
|
|
|
@ -671,7 +671,7 @@ fn main_loop(mut app: App) -> Result<glutin::WindowedContext<glutin::PossiblyCur
|
||||||
windowed_context.swap_buffers()?;
|
windowed_context.swap_buffers()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
app.pipeline.send_event(gst::Event::new_eos().build());
|
app.pipeline.send_event(gst::event::Eos::new());
|
||||||
app.pipeline.set_state(gst::State::Null)?;
|
app.pipeline.set_state(gst::State::Null)?;
|
||||||
|
|
||||||
Ok(app.into_context())
|
Ok(app.into_context())
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -2137,9 +2137,9 @@ mod tests {
|
||||||
|
|
||||||
pad.set_active(true).unwrap();
|
pad.set_active(true).unwrap();
|
||||||
|
|
||||||
assert!(pad.send_event(::Event::new_stream_start("test").build()));
|
assert!(pad.send_event(::event::StreamStart::new("test")));
|
||||||
let segment = ::FormattedSegment::<::ClockTime>::new();
|
let segment = ::FormattedSegment::<::ClockTime>::new();
|
||||||
assert!(pad.send_event(::Event::new_segment(segment.as_ref()).build()));
|
assert!(pad.send_event(::event::Segment::new(segment.as_ref())));
|
||||||
|
|
||||||
assert_eq!(pad.chain(::Buffer::new()), Ok(FlowSuccess::Ok));
|
assert_eq!(pad.chain(::Buffer::new()), Ok(FlowSuccess::Ok));
|
||||||
|
|
||||||
|
@ -2290,9 +2290,9 @@ mod tests {
|
||||||
|
|
||||||
pad.set_active(true).unwrap();
|
pad.set_active(true).unwrap();
|
||||||
|
|
||||||
assert!(pad.push_event(::Event::new_stream_start("test").build()));
|
assert!(pad.push_event(::event::StreamStart::new("test")));
|
||||||
let segment = ::FormattedSegment::<::ClockTime>::new();
|
let segment = ::FormattedSegment::<::ClockTime>::new();
|
||||||
assert!(pad.push_event(::Event::new_segment(segment.as_ref()).build()));
|
assert!(pad.push_event(::event::Segment::new(segment.as_ref())));
|
||||||
|
|
||||||
assert_eq!(pad.push(::Buffer::new()), Ok(FlowSuccess::Ok));
|
assert_eq!(pad.push(::Buffer::new()), Ok(FlowSuccess::Ok));
|
||||||
assert_eq!(pad.push(::Buffer::new()), flow_override.into_result());
|
assert_eq!(pad.push(::Buffer::new()), flow_override.into_result());
|
||||||
|
|
Loading…
Reference in a new issue