1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright (C) 2017 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.

use glib::translate::*;
use glib::IsA;
use gst;
use gst_player_sys;
use PlayerVideoOverlayVideoRenderer;

use std::ptr;

use libc::uintptr_t;

impl PlayerVideoOverlayVideoRenderer {
    /// ## `window_handle`
    /// Window handle to use or `None`
    pub unsafe fn new(window_handle: uintptr_t) -> PlayerVideoOverlayVideoRenderer {
        assert_initialized_main_thread!();

        from_glib_full(gst_player_sys::gst_player_video_overlay_video_renderer_new(
            window_handle as *mut _,
        ) as *mut _)
    }

    pub unsafe fn new_with_handle_and_sink<P: IsA<gst::Element>>(
        window_handle: uintptr_t,
        video_sink: &P,
    ) -> PlayerVideoOverlayVideoRenderer {
        assert_initialized_main_thread!();

        from_glib_full(
            gst_player_sys::gst_player_video_overlay_video_renderer_new_with_sink(
                window_handle as *mut _,
                video_sink.as_ref().to_glib_none().0,
            ) as *mut _,
        )
    }

    /// ## `window_handle`
    /// Window handle to use or `None`
    /// ## `video_sink`
    /// the custom video_sink element to be set for the video renderer
    pub fn new_with_sink<P: IsA<gst::Element>>(video_sink: &P) -> PlayerVideoOverlayVideoRenderer {
        assert_initialized_main_thread!();

        unsafe {
            from_glib_full(
                gst_player_sys::gst_player_video_overlay_video_renderer_new_with_sink(
                    ptr::null_mut(),
                    video_sink.as_ref().to_glib_none().0,
                ) as *mut _,
            )
        }
    }

    ///
    /// # Returns
    ///
    /// The currently set, platform specific window
    /// handle
    pub unsafe fn get_window_handle(&self) -> uintptr_t {
        gst_player_sys::gst_player_video_overlay_video_renderer_get_window_handle(
            self.to_glib_none().0,
        ) as uintptr_t
    }

    /// Sets the platform specific window handle into which the video
    /// should be rendered
    /// ## `window_handle`
    /// handle referencing to the platform specific window
    pub unsafe fn set_window_handle(&self, window_handle: uintptr_t) {
        gst_player_sys::gst_player_video_overlay_video_renderer_set_window_handle(
            self.to_glib_none().0,
            window_handle as *mut _,
        )
    }
}