forked from ziutek/gst
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bus.go
91 lines (71 loc) · 1.79 KB
/
bus.go
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
83
84
85
86
87
88
89
90
91
package gst
/*
#include <stdlib.h>
#include <gst/gst.h>
*/
import "C"
import (
"github.com/Xeralux/glib"
)
type Bus struct {
GstObj
}
func (b *Bus) g() *C.GstBus {
return (*C.GstBus)(b.GetPtr())
}
func (b *Bus) AsBus() *Bus {
return b
}
func (b *Bus) Post(msg *Message) bool {
return C.gst_bus_post(b.g(), msg.g()) != 0
}
func (b *Bus) HavePending() bool {
return C.gst_bus_have_pending(b.g()) != 0
}
func (b *Bus) Peek() *Message {
return (*Message)(C.gst_bus_peek(b.g()))
}
func (b *Bus) Pop() *Message {
return (*Message)(C.gst_bus_pop(b.g()))
}
func (b *Bus) PopFiltered(types MessageType) *Message {
return (*Message)(C.gst_bus_pop_filtered(b.g(), C.GstMessageType(types)))
}
func (b *Bus) TimedPop(timeout uint64) *Message {
return (*Message)(C.gst_bus_timed_pop(b.g(), C.GstClockTime(timeout)))
}
func (b *Bus) TimedPopFiltered(timeout uint64, types MessageType) *Message {
return (*Message)(C.gst_bus_timed_pop_filtered(b.g(),
C.GstClockTime(timeout), C.GstMessageType(types)))
}
func (b *Bus) SetFlushing(flushing bool) {
var f C.gboolean
if flushing {
f = 1
}
C.gst_bus_set_flushing(b.g(), f)
}
func (b *Bus) DisableSyncMessageEmission() {
C.gst_bus_disable_sync_message_emission(b.g())
}
func (b *Bus) EnableSyncMessageEmission() {
C.gst_bus_enable_sync_message_emission(b.g())
}
func (b *Bus) AddSignalWatch() {
C.gst_bus_add_signal_watch(b.g())
}
func (b *Bus) AddSignalWatchFull(priority int) {
C.gst_bus_add_signal_watch_full(b.g(), C.gint(priority))
}
func (b *Bus) RemoveSignalWatch() {
C.gst_bus_remove_signal_watch(b.g())
}
func (b *Bus) Poll(events MessageType, timeout int64) *Message {
return (*Message)(C.gst_bus_poll(b.g(), C.GstMessageType(events),
C.GstClockTime(timeout)))
}
func NewBus() *Bus {
b := new(Bus)
b.SetPtr(glib.Pointer(C.gst_bus_new()))
return b
}