mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer-rs.git
synced 2024-11-29 13:01:05 +00:00
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"
|
version = "0.17.0"
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
authors = ["Sebastian Dröge <sebastian@centricular.com>"]
|
authors = ["Sebastian Dröge <sebastian@centricular.com>"]
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
glib = { git = "https://github.com/gtk-rs/glib" }
|
glib = { git = "https://github.com/gtk-rs/glib" }
|
||||||
gdk = { git = "https://github.com/gtk-rs/gdk", optional = true }
|
gdk = { git = "https://github.com/gtk-rs/gdk", optional = true }
|
||||||
gtk = { git = "https://github.com/gtk-rs/gtk", optional = true }
|
gtk = { git = "https://github.com/gtk-rs/gtk", optional = true }
|
||||||
gstreamer = { path = "../gstreamer" }
|
gst = { package = "gstreamer", path = "../gstreamer" }
|
||||||
gstreamer-audio = { path = "../gstreamer-audio" }
|
gst-audio = { package = "gstreamer-audio", path = "../gstreamer-audio" }
|
||||||
gstreamer-video = { path = "../gstreamer-video" }
|
gst-video = { package = "gstreamer-video", path = "../gstreamer-video" }
|
||||||
gstreamer-app = { path = "../gstreamer-app" }
|
gst-app = { package = "gstreamer-app", path = "../gstreamer-app" }
|
||||||
gstreamer-pbutils = { path = "../gstreamer-pbutils" }
|
gst-pbutils = { package = "gstreamer-pbutils", path = "../gstreamer-pbutils" }
|
||||||
byte-slice-cast = "0.3"
|
byte-slice-cast = "0.3"
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
extern crate gstreamer as gst;
|
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
#[path = "../tutorials-common.rs"]
|
#[path = "../tutorials-common.rs"]
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
extern crate glib;
|
|
||||||
extern crate gstreamer as gst;
|
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
extern crate anyhow;
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
|
|
||||||
#[path = "../tutorials-common.rs"]
|
#[path = "../tutorials-common.rs"]
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
extern crate gstreamer as gst;
|
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
#[path = "../tutorials-common.rs"]
|
#[path = "../tutorials-common.rs"]
|
||||||
|
@ -33,6 +32,7 @@ fn tutorial_main() {
|
||||||
let bus = pipeline.get_bus().unwrap();
|
let bus = pipeline.get_bus().unwrap();
|
||||||
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
||||||
use gst::MessageView;
|
use gst::MessageView;
|
||||||
|
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Error(err) => {
|
MessageView::Error(err) => {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
extern crate gstreamer as gst;
|
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
#[path = "../tutorials-common.rs"]
|
#[path = "../tutorials-common.rs"]
|
||||||
|
@ -85,6 +84,7 @@ fn tutorial_main() {
|
||||||
let bus = pipeline.get_bus().unwrap();
|
let bus = pipeline.get_bus().unwrap();
|
||||||
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
||||||
use gst::MessageView;
|
use gst::MessageView;
|
||||||
|
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Error(err) => {
|
MessageView::Error(err) => {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
extern crate gstreamer as gst;
|
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
use gst::MessageView;
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
|
@ -100,6 +98,8 @@ fn tutorial_main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_message(custom_data: &mut CustomData, msg: &gst::Message) {
|
fn handle_message(custom_data: &mut CustomData, msg: &gst::Message) {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Error(err) => {
|
MessageView::Error(err) => {
|
||||||
println!(
|
println!(
|
||||||
|
|
|
@ -3,19 +3,11 @@ mod tutorial5 {
|
||||||
use std::os::raw::c_void;
|
use std::os::raw::c_void;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
extern crate glib;
|
use gdk::prelude::*;
|
||||||
use self::glib::object::ObjectType;
|
use gtk::prelude::*;
|
||||||
use self::glib::*;
|
|
||||||
|
|
||||||
extern crate gdk;
|
use gst::prelude::*;
|
||||||
use self::gdk::prelude::*;
|
use gst_video::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 std::ops;
|
use std::ops;
|
||||||
|
|
||||||
|
@ -24,14 +16,14 @@ mod tutorial5 {
|
||||||
// it from the main context again later and drop the
|
// it from the main context again later and drop the
|
||||||
// references it keeps inside its closures
|
// references it keeps inside its closures
|
||||||
struct AppWindow {
|
struct AppWindow {
|
||||||
main_window: Window,
|
main_window: gtk::Window,
|
||||||
timeout_id: Option<glib::SourceId>,
|
timeout_id: Option<glib::SourceId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ops::Deref for AppWindow {
|
impl ops::Deref for AppWindow {
|
||||||
type Target = Window;
|
type Target = gtk::Window;
|
||||||
|
|
||||||
fn deref(&self) -> &Window {
|
fn deref(&self) -> >k::Window {
|
||||||
&self.main_window
|
&self.main_window
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -106,7 +98,7 @@ mod tutorial5 {
|
||||||
|
|
||||||
// This creates all the GTK+ widgets that compose our application, and registers the callbacks
|
// This creates all the GTK+ widgets that compose our application, and registers the callbacks
|
||||||
fn create_ui(playbin: &gst::Element) -> AppWindow {
|
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(|_, _| {
|
main_window.connect_delete_event(|_, _| {
|
||||||
gtk::main_quit();
|
gtk::main_quit();
|
||||||
Inhibit(false)
|
Inhibit(false)
|
||||||
|
@ -186,13 +178,13 @@ mod tutorial5 {
|
||||||
Continue(true)
|
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(&play_button, false, false, 0);
|
||||||
controls.pack_start(&pause_button, false, false, 0);
|
controls.pack_start(&pause_button, false, false, 0);
|
||||||
controls.pack_start(&stop_button, false, false, 0);
|
controls.pack_start(&stop_button, false, false, 0);
|
||||||
controls.pack_start(&slider, true, true, 2);
|
controls.pack_start(&slider, true, true, 2);
|
||||||
|
|
||||||
let video_window = DrawingArea::new();
|
let video_window = gtk::DrawingArea::new();
|
||||||
|
|
||||||
let video_overlay = playbin
|
let video_overlay = playbin
|
||||||
.clone()
|
.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(&video_window, true, true, 0);
|
||||||
vbox.pack_start(&streams_list, false, false, 2);
|
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(&vbox, true, true, 0);
|
||||||
main_box.pack_start(&controls, false, false, 0);
|
main_box.pack_start(&controls, false, false, 0);
|
||||||
main_window.add(&main_box);
|
main_window.add(&main_box);
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
extern crate gstreamer as gst;
|
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
use gst::MessageView;
|
|
||||||
|
|
||||||
#[path = "../tutorials-common.rs"]
|
#[path = "../tutorials-common.rs"]
|
||||||
mod tutorials_common;
|
mod tutorials_common;
|
||||||
|
@ -127,6 +125,8 @@ fn tutorial_main() {
|
||||||
let bus = pipeline.get_bus().unwrap();
|
let bus = pipeline.get_bus().unwrap();
|
||||||
|
|
||||||
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
||||||
|
use gst::MessageView;
|
||||||
|
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Error(err) => {
|
MessageView::Error(err) => {
|
||||||
println!(
|
println!(
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
extern crate gstreamer as gst;
|
|
||||||
use gst::prelude::*;
|
use gst::prelude::*;
|
||||||
|
|
||||||
#[path = "../tutorials-common.rs"]
|
#[path = "../tutorials-common.rs"]
|
||||||
|
@ -70,6 +69,7 @@ fn tutorial_main() {
|
||||||
let bus = pipeline.get_bus().unwrap();
|
let bus = pipeline.get_bus().unwrap();
|
||||||
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
for msg in bus.iter_timed(gst::CLOCK_TIME_NONE) {
|
||||||
use gst::MessageView;
|
use gst::MessageView;
|
||||||
|
|
||||||
match msg.view() {
|
match msg.view() {
|
||||||
MessageView::Error(err) => {
|
MessageView::Error(err) => {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
|
|
|
@ -1,16 +1,11 @@
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
extern crate byte_slice_cast;
|
|
||||||
use 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 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 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
|
const SAMPLE_RATE: u32 = 44_100; // Samples per second we are sending
|
||||||
|
|
|
@ -1,9 +1,5 @@
|
||||||
extern crate anyhow;
|
|
||||||
use anyhow::Error;
|
use anyhow::Error;
|
||||||
|
|
||||||
extern crate glib;
|
|
||||||
extern crate gstreamer as gst;
|
|
||||||
extern crate gstreamer_pbutils as gst_pbutils;
|
|
||||||
use gst_pbutils::{
|
use gst_pbutils::{
|
||||||
prelude::*, Discoverer, DiscovererContainerInfo, DiscovererInfo, DiscovererResult,
|
prelude::*, Discoverer, DiscovererContainerInfo, DiscovererInfo, DiscovererResult,
|
||||||
DiscovererStreamInfo,
|
DiscovererStreamInfo,
|
||||||
|
|
Loading…
Reference in a new issue