forked from mirrors/gstreamer-rs
examples: Move to Rust 2018 edition
This commit is contained in:
parent
096ce958a4
commit
ad1d78b599
11 changed files with 28 additions and 48 deletions
|
@ -3,16 +3,17 @@ name = "tutorials"
|
|||
version = "0.17.0"
|
||||
license = "MIT"
|
||||
authors = ["Sebastian Dröge <sebastian@centricular.com>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
glib = { git = "https://github.com/gtk-rs/glib" }
|
||||
gdk = { git = "https://github.com/gtk-rs/gdk", optional = true }
|
||||
gtk = { git = "https://github.com/gtk-rs/gtk", optional = true }
|
||||
gstreamer = { path = "../gstreamer" }
|
||||
gstreamer-audio = { path = "../gstreamer-audio" }
|
||||
gstreamer-video = { path = "../gstreamer-video" }
|
||||
gstreamer-app = { path = "../gstreamer-app" }
|
||||
gstreamer-pbutils = { path = "../gstreamer-pbutils" }
|
||||
gst = { package = "gstreamer", path = "../gstreamer" }
|
||||
gst-audio = { package = "gstreamer-audio", path = "../gstreamer-audio" }
|
||||
gst-video = { package = "gstreamer-video", path = "../gstreamer-video" }
|
||||
gst-app = { package = "gstreamer-app", path = "../gstreamer-app" }
|
||||
gst-pbutils = { package = "gstreamer-pbutils", path = "../gstreamer-pbutils" }
|
||||
byte-slice-cast = "0.3"
|
||||
anyhow = "1"
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
extern crate gstreamer as gst;
|
||||
use gst::prelude::*;
|
||||
|
||||
#[path = "../tutorials-common.rs"]
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
extern crate glib;
|
||||
extern crate gstreamer as gst;
|
||||
use gst::prelude::*;
|
||||
use std::io::Write;
|
||||
|
||||
extern crate anyhow;
|
||||
use anyhow::Error;
|
||||
|
||||
#[path = "../tutorials-common.rs"]
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
extern crate gstreamer as gst;
|
||||
use gst::prelude::*;
|
||||
|
||||
#[path = "../tutorials-common.rs"]
|
||||
|
@ -33,6 +32,7 @@ fn tutorial_main() {
|
|||
let bus = pipeline.get_bus().unwrap();
|
||||
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
||||
use gst::MessageView;
|
||||
|
||||
match msg.view() {
|
||||
MessageView::Error(err) => {
|
||||
eprintln!(
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
extern crate gstreamer as gst;
|
||||
use gst::prelude::*;
|
||||
|
||||
#[path = "../tutorials-common.rs"]
|
||||
|
@ -85,6 +84,7 @@ fn tutorial_main() {
|
|||
let bus = pipeline.get_bus().unwrap();
|
||||
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
||||
use gst::MessageView;
|
||||
|
||||
match msg.view() {
|
||||
MessageView::Error(err) => {
|
||||
eprintln!(
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
extern crate gstreamer as gst;
|
||||
use gst::prelude::*;
|
||||
use gst::MessageView;
|
||||
use std::io;
|
||||
use std::io::Write;
|
||||
|
||||
|
@ -100,6 +98,8 @@ fn tutorial_main() {
|
|||
}
|
||||
|
||||
fn handle_message(custom_data: &mut CustomData, msg: &gst::Message) {
|
||||
use gst::MessageView;
|
||||
|
||||
match msg.view() {
|
||||
MessageView::Error(err) => {
|
||||
println!(
|
||||
|
|
|
@ -3,19 +3,11 @@ mod tutorial5 {
|
|||
use std::os::raw::c_void;
|
||||
use std::process;
|
||||
|
||||
extern crate glib;
|
||||
use self::glib::object::ObjectType;
|
||||
use self::glib::*;
|
||||
use gdk::prelude::*;
|
||||
use gtk::prelude::*;
|
||||
|
||||
extern crate gdk;
|
||||
use self::gdk::prelude::*;
|
||||
|
||||
extern crate gtk;
|
||||
use self::gtk::*;
|
||||
|
||||
extern crate gstreamer as gst;
|
||||
extern crate gstreamer_video as gst_video;
|
||||
use self::gst_video::prelude::*;
|
||||
use gst::prelude::*;
|
||||
use gst_video::prelude::*;
|
||||
|
||||
use std::ops;
|
||||
|
||||
|
@ -24,14 +16,14 @@ mod tutorial5 {
|
|||
// it from the main context again later and drop the
|
||||
// references it keeps inside its closures
|
||||
struct AppWindow {
|
||||
main_window: Window,
|
||||
main_window: gtk::Window,
|
||||
timeout_id: Option<glib::SourceId>,
|
||||
}
|
||||
|
||||
impl ops::Deref for AppWindow {
|
||||
type Target = Window;
|
||||
type Target = gtk::Window;
|
||||
|
||||
fn deref(&self) -> &Window {
|
||||
fn deref(&self) -> >k::Window {
|
||||
&self.main_window
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +98,7 @@ mod tutorial5 {
|
|||
|
||||
// This creates all the GTK+ widgets that compose our application, and registers the callbacks
|
||||
fn create_ui(playbin: &gst::Element) -> AppWindow {
|
||||
let main_window = Window::new(WindowType::Toplevel);
|
||||
let main_window = gtk::Window::new(gtk::WindowType::Toplevel);
|
||||
main_window.connect_delete_event(|_, _| {
|
||||
gtk::main_quit();
|
||||
Inhibit(false)
|
||||
|
@ -186,13 +178,13 @@ mod tutorial5 {
|
|||
Continue(true)
|
||||
});
|
||||
|
||||
let controls = Box::new(Orientation::Horizontal, 0);
|
||||
let controls = gtk::Box::new(gtk::Orientation::Horizontal, 0);
|
||||
controls.pack_start(&play_button, false, false, 0);
|
||||
controls.pack_start(&pause_button, false, false, 0);
|
||||
controls.pack_start(&stop_button, false, false, 0);
|
||||
controls.pack_start(&slider, true, true, 2);
|
||||
|
||||
let video_window = DrawingArea::new();
|
||||
let video_window = gtk::DrawingArea::new();
|
||||
|
||||
let video_overlay = playbin
|
||||
.clone()
|
||||
|
@ -282,11 +274,11 @@ mod tutorial5 {
|
|||
_ => (),
|
||||
});
|
||||
|
||||
let vbox = Box::new(Orientation::Horizontal, 0);
|
||||
let vbox = gtk::Box::new(gtk::Orientation::Horizontal, 0);
|
||||
vbox.pack_start(&video_window, true, true, 0);
|
||||
vbox.pack_start(&streams_list, false, false, 2);
|
||||
|
||||
let main_box = Box::new(Orientation::Vertical, 0);
|
||||
let main_box = gtk::Box::new(gtk::Orientation::Vertical, 0);
|
||||
main_box.pack_start(&vbox, true, true, 0);
|
||||
main_box.pack_start(&controls, false, false, 0);
|
||||
main_window.add(&main_box);
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
extern crate gstreamer as gst;
|
||||
use gst::prelude::*;
|
||||
use gst::MessageView;
|
||||
|
||||
#[path = "../tutorials-common.rs"]
|
||||
mod tutorials_common;
|
||||
|
@ -127,6 +125,8 @@ fn tutorial_main() {
|
|||
let bus = pipeline.get_bus().unwrap();
|
||||
|
||||
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
||||
use gst::MessageView;
|
||||
|
||||
match msg.view() {
|
||||
MessageView::Error(err) => {
|
||||
println!(
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
extern crate gstreamer as gst;
|
||||
use gst::prelude::*;
|
||||
|
||||
#[path = "../tutorials-common.rs"]
|
||||
|
@ -70,6 +69,7 @@ fn tutorial_main() {
|
|||
let bus = pipeline.get_bus().unwrap();
|
||||
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
||||
use gst::MessageView;
|
||||
|
||||
match msg.view() {
|
||||
MessageView::Error(err) => {
|
||||
eprintln!(
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
use std::sync::{Arc, Mutex};
|
||||
|
||||
extern crate byte_slice_cast;
|
||||
use byte_slice_cast::*;
|
||||
|
||||
extern crate gstreamer as gst;
|
||||
use gst::prelude::*;
|
||||
extern crate gstreamer_audio as gst_audio;
|
||||
use gst_audio::AudioInfo;
|
||||
extern crate gstreamer_app as gst_app;
|
||||
use gst_app::{AppSink, AppSrc};
|
||||
extern crate glib;
|
||||
use glib::source::SourceId;
|
||||
use gst::prelude::*;
|
||||
use gst_app::{AppSink, AppSrc};
|
||||
use gst_audio::AudioInfo;
|
||||
|
||||
const CHUNK_SIZE: usize = 1024; // Amount of bytes we are sending in each buffer
|
||||
const SAMPLE_RATE: u32 = 44_100; // Samples per second we are sending
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
extern crate anyhow;
|
||||
use anyhow::Error;
|
||||
|
||||
extern crate glib;
|
||||
extern crate gstreamer as gst;
|
||||
extern crate gstreamer_pbutils as gst_pbutils;
|
||||
use gst_pbutils::{
|
||||
prelude::*, Discoverer, DiscovererContainerInfo, DiscovererInfo, DiscovererResult,
|
||||
DiscovererStreamInfo,
|
||||
|
|
Loading…
Reference in a new issue