Rename tokio example to futures

It has nothing to do with tokio anymore with the newer futures version,
tokio would only come in if actual tokio API (e.g. for sockets) is used.
This commit is contained in:
Sebastian Dröge 2018-04-23 20:27:51 +03:00
parent a276c226fd
commit 4b4f369200
2 changed files with 30 additions and 32 deletions

View file

@ -17,8 +17,7 @@ gstreamer-rtsp-server-sys = { git = "https://github.com/sdroege/gstreamer-sys",
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 }
gdk = { git = "https://github.com/gtk-rs/gdk", optional = true } gdk = { git = "https://github.com/gtk-rs/gdk", optional = true }
gio = { git = "https://github.com/gtk-rs/gio", optional = true } gio = { git = "https://github.com/gtk-rs/gio", optional = true }
futures = { version = "0.1", optional = true } futures = { version = "0.2", optional = true }
tokio-core = { version = "0.1", optional = true }
send-cell = "0.1" send-cell = "0.1"
byte-slice-cast = "0.1" byte-slice-cast = "0.1"
failure = "0.1" failure = "0.1"
@ -30,7 +29,7 @@ gtksink = ["gtk", "gio"]
gtkvideooverlay = ["gtk", "gdk", "gio"] gtkvideooverlay = ["gtk", "gdk", "gio"]
gtkvideooverlay-x11 = ["gtkvideooverlay"] gtkvideooverlay-x11 = ["gtkvideooverlay"]
gtkvideooverlay-quartz = ["gtkvideooverlay"] gtkvideooverlay-quartz = ["gtkvideooverlay"]
tokio = ["gstreamer/futures", "futures", "tokio-core"] generic-futures = ["gstreamer/futures", "futures"]
gst-rtsp-server = ["gstreamer-rtsp-server"] gst-rtsp-server = ["gstreamer-rtsp-server"]
gst-rtsp-server-record = ["gstreamer-rtsp-server", "gstreamer-rtsp", "gio"] gst-rtsp-server-record = ["gstreamer-rtsp-server", "gstreamer-rtsp", "gio"]
default-features = [] default-features = []
@ -98,8 +97,8 @@ name = "tagsetter"
name = "toc" name = "toc"
[[bin]] [[bin]]
name = "tokio" name = "futures"
required-features = ["tokio"] required-features = ["generic-futures"]
[[bin]] [[bin]]
name = "rtsp-server-record" name = "rtsp-server-record"

View file

@ -2,9 +2,8 @@ extern crate gstreamer as gst;
use gst::prelude::*; use gst::prelude::*;
extern crate futures; extern crate futures;
use futures::stream::Stream; use futures::executor::block_on;
extern crate tokio_core; use futures::prelude::*;
use tokio_core::reactor::Core;
use std::env; use std::env;
@ -16,39 +15,39 @@ fn example_main() {
gst::init().unwrap(); gst::init().unwrap();
let mut core = Core::new().unwrap();
let pipeline = gst::parse_launch(&pipeline_str).unwrap(); let pipeline = gst::parse_launch(&pipeline_str).unwrap();
let bus = pipeline.get_bus().unwrap(); let bus = pipeline.get_bus().unwrap();
let ret = pipeline.set_state(gst::State::Playing); let ret = pipeline.set_state(gst::State::Playing);
assert_ne!(ret, gst::StateChangeReturn::Failure); assert_ne!(ret, gst::StateChangeReturn::Failure);
let messages = gst::BusStream::new(&bus).for_each(|msg| { let messages = gst::BusStream::new(&bus)
use gst::MessageView; .for_each(|msg| {
use gst::MessageView;
let quit = match msg.view() { let quit = match msg.view() {
MessageView::Eos(..) => true, MessageView::Eos(..) => true,
MessageView::Error(err) => { MessageView::Error(err) => {
println!( println!(
"Error from {:?}: {} ({:?})", "Error from {:?}: {} ({:?})",
err.get_src().map(|s| s.get_path_string()), err.get_src().map(|s| s.get_path_string()),
err.get_error(), err.get_error(),
err.get_debug() err.get_debug()
); );
true true
}
_ => false,
};
if quit {
Err(())
} else {
Ok(())
} }
_ => false, })
}; .and_then(|_| Ok(()));
if quit { let _ = block_on(messages);
Err(())
} else {
Ok(())
}
});
let _ = core.run(messages);
let ret = pipeline.set_state(gst::State::Null); let ret = pipeline.set_state(gst::State::Null);
assert_ne!(ret, gst::StateChangeReturn::Failure); assert_ne!(ret, gst::StateChangeReturn::Failure);