Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Zeeshan Ali
gstreamer-rs
Commits
3a755219
Commit
3a755219
authored
Mar 15, 2018
by
Sebastian Dröge
🍵
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Promise bindings
parent
0112d228
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
203 additions
and
0 deletions
+203
-0
Gir_Gst.toml
Gir_Gst.toml
+6
-0
gstreamer/src/auto/enums.rs
gstreamer/src/auto/enums.rs
+70
-0
gstreamer/src/auto/mod.rs
gstreamer/src/auto/mod.rs
+2
-0
gstreamer/src/lib.rs
gstreamer/src/lib.rs
+5
-0
gstreamer/src/promise.rs
gstreamer/src/promise.rs
+120
-0
No files found.
Gir_Gst.toml
View file @
3a755219
...
...
@@ -71,6 +71,7 @@ generate = [
"Gst.DateTime"
,
"Gst.TypeFindProbability"
,
"Gst.BufferPoolAcquireFlags"
,
"Gst.PromiseResult"
,
]
manual
=
[
...
...
@@ -217,6 +218,11 @@ name = "Gst.TocEntry"
status
=
"manual"
ref_mode
=
"ref"
[[object]]
name
=
"Gst.Promise"
status
=
"manual"
ref_mode
=
"ref"
[[object]]
name
=
"Gst.Clock"
status
=
"generate"
...
...
gstreamer/src/auto/enums.rs
View file @
3a755219
...
...
@@ -1505,6 +1505,76 @@ impl SetValue for ProgressType {
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
#[derive(Clone,
Copy,
Debug,
Eq,
PartialEq,
Hash)]
pub
enum
PromiseResult
{
Pending
,
Interrupted
,
Replied
,
Expired
,
#[doc(hidden)]
__
Unknown
(
i32
),
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
#[doc(hidden)]
impl
ToGlib
for
PromiseResult
{
type
GlibType
=
ffi
::
GstPromiseResult
;
fn
to_glib
(
&
self
)
->
ffi
::
GstPromiseResult
{
match
*
self
{
PromiseResult
::
Pending
=>
ffi
::
GST_PROMISE_RESULT_PENDING
,
PromiseResult
::
Interrupted
=>
ffi
::
GST_PROMISE_RESULT_INTERRUPTED
,
PromiseResult
::
Replied
=>
ffi
::
GST_PROMISE_RESULT_REPLIED
,
PromiseResult
::
Expired
=>
ffi
::
GST_PROMISE_RESULT_EXPIRED
,
PromiseResult
::
__
Unknown
(
value
)
=>
value
}
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
#[doc(hidden)]
impl
FromGlib
<
ffi
::
GstPromiseResult
>
for
PromiseResult
{
fn
from_glib
(
value
:
ffi
::
GstPromiseResult
)
->
Self
{
skip_assert_initialized!
();
match
value
{
0
=>
PromiseResult
::
Pending
,
1
=>
PromiseResult
::
Interrupted
,
2
=>
PromiseResult
::
Replied
,
3
=>
PromiseResult
::
Expired
,
value
=>
PromiseResult
::
__
Unknown
(
value
),
}
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
impl
StaticType
for
PromiseResult
{
fn
static_type
()
->
Type
{
unsafe
{
from_glib
(
ffi
::
gst_promise_result_get_type
())
}
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
impl
<
'a
>
FromValueOptional
<
'a
>
for
PromiseResult
{
unsafe
fn
from_value_optional
(
value
:
&
Value
)
->
Option
<
Self
>
{
Some
(
FromValue
::
from_value
(
value
))
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
impl
<
'a
>
FromValue
<
'a
>
for
PromiseResult
{
unsafe
fn
from_value
(
value
:
&
Value
)
->
Self
{
from_glib
(
gobject_ffi
::
g_value_get_enum
(
value
.to_glib_none
()
.0
))
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
impl
SetValue
for
PromiseResult
{
unsafe
fn
set_value
(
value
:
&
mut
Value
,
this
:
&
Self
)
{
gobject_ffi
::
g_value_set_enum
(
value
.to_glib_none_mut
()
.0
,
this
.to_glib
())
}
}
#[derive(Clone,
Copy,
Debug,
Eq,
PartialEq,
Hash)]
pub
enum
QOSType
{
Overflow
,
...
...
gstreamer/src/auto/mod.rs
View file @
3a755219
...
...
@@ -132,6 +132,8 @@ pub use self::enums::PadProbeReturn;
pub
use
self
::
enums
::
ParseError
;
pub
use
self
::
enums
::
PluginError
;
pub
use
self
::
enums
::
ProgressType
;
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
pub
use
self
::
enums
::
PromiseResult
;
pub
use
self
::
enums
::
QOSType
;
pub
use
self
::
enums
::
Rank
;
pub
use
self
::
enums
::
ResourceError
;
...
...
gstreamer/src/lib.rs
View file @
3a755219
...
...
@@ -94,6 +94,11 @@ pub use static_caps::*;
mod
static_pad_template
;
pub
use
static_pad_template
::
*
;
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
mod
promise
;
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
pub
use
promise
::
*
;
mod
element
;
mod
bin
;
mod
bus
;
...
...
gstreamer/src/promise.rs
0 → 100644
View file @
3a755219
// Copyright (C) 2018 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
StructureRef
;
use
Structure
;
use
ffi
;
use
glib
::
translate
::
*
;
use
glib_ffi
;
use
gobject_ffi
;
use
std
::
mem
;
use
std
::
ptr
;
use
PromiseResult
;
glib_wrapper!
{
pub
struct
Promise
(
Shared
<
ffi
::
GstPromise
>
);
match
fn
{
ref
=>
|
ptr
|
ffi
::
gst_mini_object_ref
(
ptr
as
*
mut
_
)
as
*
mut
ffi
::
GstPromise
,
unref
=>
|
ptr
|
ffi
::
gst_mini_object_unref
(
ptr
as
*
mut
_
),
get_type
=>
||
ffi
::
gst_promise_get_type
(),
}
}
impl
Promise
{
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
pub
fn
new
()
->
Promise
{
assert_initialized_main_thread!
();
unsafe
{
from_glib_full
(
ffi
::
gst_promise_new
())
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
pub
fn
new_with_change_func
<
F
>
(
func
:
F
)
->
Promise
where
F
:
FnOnce
(
&
Promise
)
+
Send
+
'static
{
let
user_data
:
Box
<
Option
<
Box
<
F
>>>
=
Box
::
new
(
Some
(
Box
::
new
(
func
)));
unsafe
extern
"C"
fn
trampoline
<
F
:
FnOnce
(
&
Promise
)
+
Send
+
'static
>
(
promise
:
*
mut
ffi
::
GstPromise
,
user_data
:
glib_ffi
::
gpointer
,
)
{
callback_guard!
();
let
user_data
:
&
mut
Option
<
Box
<
F
>>
=
&
mut
*
(
user_data
as
*
mut
_
);
let
callback
=
user_data
.take
()
.unwrap
();
callback
(
&
from_glib_borrow
(
promise
));
}
unsafe
extern
"C"
fn
free_user_data
<
F
:
FnOnce
(
&
Promise
)
+
Send
+
'static
>
(
user_data
:
glib_ffi
::
gpointer
,
)
{
let
_
:
Box
<
Option
<
Box
<
F
>>>
=
Box
::
from_raw
(
user_data
as
*
mut
_
);
}
let
trampoline
=
trampoline
::
<
F
>
;
let
free_user_data
=
free_user_data
::
<
F
>
;
unsafe
{
from_glib_full
(
ffi
::
gst_promise_new_with_change_func
(
Some
(
trampoline
),
Box
::
into_raw
(
user_data
)
as
*
mut
_
,
Some
(
free_user_data
),
))
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
pub
fn
expire
(
&
self
)
{
unsafe
{
ffi
::
gst_promise_expire
(
self
.to_glib_none
()
.0
);
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
pub
fn
get_reply
(
&
self
)
->
Option
<&
StructureRef
>
{
unsafe
{
let
s
=
ffi
::
gst_promise_get_reply
(
self
.to_glib_none
()
.0
);
if
s
.is_null
()
{
None
}
else
{
Some
(
StructureRef
::
from_glib_borrow
(
s
))
}
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
pub
fn
interrupt
(
&
self
)
{
unsafe
{
ffi
::
gst_promise_interrupt
(
self
.to_glib_none
()
.0
);
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
pub
fn
reply
(
&
self
,
s
:
Structure
)
{
unsafe
{
ffi
::
gst_promise_reply
(
self
.to_glib_none
()
.0
,
s
.into_ptr
());
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
pub
fn
wait
(
&
self
)
->
PromiseResult
{
unsafe
{
from_glib
(
ffi
::
gst_promise_wait
(
self
.to_glib_none
()
.0
))
}
}
}
#[cfg(any(feature
=
"v1_14"
,
feature
=
"dox"
))]
impl
Default
for
Promise
{
fn
default
()
->
Self
{
Self
::
new
()
}
}
unsafe
impl
Send
for
Promise
{}
unsafe
impl
Sync
for
Promise
{}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment