forked from mirrors/gstreamer-rs
examples: Quartz support for the gtkvideooverlay example
Fixes https://github.com/sdroege/gstreamer-rs/pull/31
This commit is contained in:
parent
dae1a51764
commit
facaae6be9
2 changed files with 24 additions and 4 deletions
|
@ -22,6 +22,8 @@ byte-slice-cast = "0.1"
|
||||||
gst-player = ["gstreamer-player"]
|
gst-player = ["gstreamer-player"]
|
||||||
gtksink = ["gtk", "gio"]
|
gtksink = ["gtk", "gio"]
|
||||||
gtkvideooverlay = ["gtk", "gdk", "gio"]
|
gtkvideooverlay = ["gtk", "gdk", "gio"]
|
||||||
|
gtkvideooverlay-x11 = ["gtkvideooverlay"]
|
||||||
|
gtkvideooverlay-quartz = ["gtkvideooverlay"]
|
||||||
tokio = ["gstreamer/futures", "futures", "tokio-core"]
|
tokio = ["gstreamer/futures", "futures", "tokio-core"]
|
||||||
default-features = []
|
default-features = []
|
||||||
|
|
||||||
|
|
|
@ -47,8 +47,10 @@ fn create_ui(app: >k::Application) {
|
||||||
let pipeline = gst::Pipeline::new(None);
|
let pipeline = gst::Pipeline::new(None);
|
||||||
let src = gst::ElementFactory::make("videotestsrc", None).unwrap();
|
let src = gst::ElementFactory::make("videotestsrc", None).unwrap();
|
||||||
|
|
||||||
let sink = if cfg!(unix) {
|
let sink = if cfg!(feature = "gtkvideooverlay-x11") {
|
||||||
gst::ElementFactory::make("xvimagesink", None).unwrap()
|
gst::ElementFactory::make("xvimagesink", None).unwrap()
|
||||||
|
} else if cfg!(feature = "gtkvideooverlay-quartz") {
|
||||||
|
gst::ElementFactory::make("glimagesink", None).unwrap()
|
||||||
} else {
|
} else {
|
||||||
unreachable!()
|
unreachable!()
|
||||||
};
|
};
|
||||||
|
@ -76,10 +78,9 @@ fn create_ui(app: >k::Application) {
|
||||||
process::exit(-1);
|
process::exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(unix)]
|
|
||||||
{
|
|
||||||
let display_type_name = gdk_window.get_display().get_type().name();
|
let display_type_name = gdk_window.get_display().get_type().name();
|
||||||
|
|
||||||
|
if cfg!(feature = "gtkvideooverlay-x11") {
|
||||||
// Check if we're using X11 or ...
|
// Check if we're using X11 or ...
|
||||||
if display_type_name == "GdkX11Display" {
|
if display_type_name == "GdkX11Display" {
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -96,7 +97,24 @@ fn create_ui(app: >k::Application) {
|
||||||
println!("Add support for display type '{}'", display_type_name);
|
println!("Add support for display type '{}'", display_type_name);
|
||||||
process::exit(-1);
|
process::exit(-1);
|
||||||
}
|
}
|
||||||
|
} else if cfg!(feature = "gtkvideooverlay-quartz") {
|
||||||
|
if display_type_name == "GdkQuartzDisplay" {
|
||||||
|
extern "C" {
|
||||||
|
pub fn gdk_quartz_window_get_nsview(
|
||||||
|
window: *mut glib::object::GObject,
|
||||||
|
) -> *mut c_void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe {
|
||||||
|
let window = gdk_quartz_window_get_nsview(gdk_window.to_glib_none().0);
|
||||||
|
video_overlay.set_window_handle(window as usize);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
println!("Unsupported display type '{}", display_type_name);
|
||||||
|
process::exit(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
vbox.pack_start(&video_window, true, true, 0);
|
vbox.pack_start(&video_window, true, true, 0);
|
||||||
|
|
Loading…
Reference in a new issue