forked from mirrors/gstreamer-rs
glupload: panic if target OS is not Linux
For now this is the only OS supported by this test.
This commit is contained in:
parent
07ddf2f370
commit
c378167573
1 changed files with 50 additions and 44 deletions
|
@ -29,8 +29,6 @@ use failure::Error;
|
||||||
extern crate failure_derive;
|
extern crate failure_derive;
|
||||||
|
|
||||||
extern crate glutin;
|
extern crate glutin;
|
||||||
use glutin::os::unix::RawHandle;
|
|
||||||
use glutin::os::ContextTraitExt;
|
|
||||||
use glutin::ContextTrait;
|
use glutin::ContextTrait;
|
||||||
|
|
||||||
#[path = "../examples-common.rs"]
|
#[path = "../examples-common.rs"]
|
||||||
|
@ -350,57 +348,65 @@ impl App {
|
||||||
|
|
||||||
let combined_context_ = combined_context.clone();
|
let combined_context_ = combined_context.clone();
|
||||||
let context = combined_context_.context();
|
let context = combined_context_.context();
|
||||||
let egl_context = match unsafe { context.raw_handle() } {
|
|
||||||
RawHandle::Egl(egl_context) => egl_context as usize,
|
|
||||||
_ => panic!("Invalid platform"),
|
|
||||||
};
|
|
||||||
let egl_display = match unsafe { context.get_egl_display() } {
|
|
||||||
Some(display) => display as usize,
|
|
||||||
_ => panic!("Invalid platform"),
|
|
||||||
};
|
|
||||||
let api = App::map_gl_api(context.get_api());
|
|
||||||
let platform = gst_gl::GLPlatform::EGL;
|
|
||||||
|
|
||||||
let gl_display =
|
if cfg!(target_os = "linux") {
|
||||||
unsafe { gst_gl::GLDisplayEGL::new_with_egl_display(egl_display) }.unwrap();
|
use glutin::os::unix::RawHandle;
|
||||||
let gl_context =
|
use glutin::os::ContextTraitExt;
|
||||||
unsafe { gst_gl::GLContext::new_wrapped(&gl_display, egl_context, platform, api) }
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
bus.set_sync_handler(move |_, msg| {
|
let egl_context = match unsafe { context.raw_handle() } {
|
||||||
use gst::MessageView;
|
RawHandle::Egl(egl_context) => egl_context as usize,
|
||||||
|
_ => panic!("Invalid platform"),
|
||||||
|
};
|
||||||
|
let egl_display = match unsafe { context.get_egl_display() } {
|
||||||
|
Some(display) => display as usize,
|
||||||
|
_ => panic!("Invalid platform"),
|
||||||
|
};
|
||||||
|
let api = App::map_gl_api(context.get_api());
|
||||||
|
let platform = gst_gl::GLPlatform::EGL;
|
||||||
|
|
||||||
match msg.view() {
|
let gl_display =
|
||||||
MessageView::NeedContext(ctxt) => {
|
unsafe { gst_gl::GLDisplayEGL::new_with_egl_display(egl_display) }.unwrap();
|
||||||
let context_type = ctxt.get_context_type();
|
let gl_context =
|
||||||
if context_type == *gst_gl::GL_DISPLAY_CONTEXT_TYPE {
|
unsafe { gst_gl::GLContext::new_wrapped(&gl_display, egl_context, platform, api) }
|
||||||
if let Some(el) =
|
.unwrap();
|
||||||
msg.get_src().map(|s| s.downcast::<gst::Element>().unwrap())
|
|
||||||
{
|
bus.set_sync_handler(move |_, msg| {
|
||||||
let context = gst::Context::new(context_type, true);
|
use gst::MessageView;
|
||||||
context.set_gl_display(&gl_display);
|
|
||||||
el.set_context(&context);
|
match msg.view() {
|
||||||
}
|
MessageView::NeedContext(ctxt) => {
|
||||||
}
|
let context_type = ctxt.get_context_type();
|
||||||
if context_type == "gst.gl.app_context" {
|
if context_type == *gst_gl::GL_DISPLAY_CONTEXT_TYPE {
|
||||||
if let Some(el) =
|
if let Some(el) =
|
||||||
msg.get_src().map(|s| s.downcast::<gst::Element>().unwrap())
|
msg.get_src().map(|s| s.downcast::<gst::Element>().unwrap())
|
||||||
{
|
|
||||||
let mut context = gst::Context::new(context_type, true);
|
|
||||||
{
|
{
|
||||||
let context = context.get_mut().unwrap();
|
let context = gst::Context::new(context_type, true);
|
||||||
let mut s = context.get_mut_structure();
|
context.set_gl_display(&gl_display);
|
||||||
s.set_value("context", gl_context.to_send_value());
|
el.set_context(&context);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if context_type == "gst.gl.app_context" {
|
||||||
|
if let Some(el) =
|
||||||
|
msg.get_src().map(|s| s.downcast::<gst::Element>().unwrap())
|
||||||
|
{
|
||||||
|
let mut context = gst::Context::new(context_type, true);
|
||||||
|
{
|
||||||
|
let context = context.get_mut().unwrap();
|
||||||
|
let mut s = context.get_mut_structure();
|
||||||
|
s.set_value("context", gl_context.to_send_value());
|
||||||
|
}
|
||||||
|
el.set_context(&context);
|
||||||
}
|
}
|
||||||
el.set_context(&context);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => (),
|
||||||
}
|
}
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
|
|
||||||
gst::BusSyncReply::Pass
|
gst::BusSyncReply::Pass
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
panic!("This example only has Linux support");
|
||||||
|
}
|
||||||
|
|
||||||
Ok(App {
|
Ok(App {
|
||||||
pipeline,
|
pipeline,
|
||||||
|
|
Loading…
Reference in a new issue