forked from Perlmint/go-vlc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmisc.go
129 lines (102 loc) · 3.03 KB
/
misc.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// This work is subject to the CC0 1.0 Universal (CC0 1.0) Public Domain Dedication
// license. Its contents can be found at:
// http://creativecommons.org/publicdomain/zero/1.0
package vlc
//#include <stdlib.h>
//#include <vlc/vlc.h>
import "C"
import (
"syscall"
"unsafe"
)
// Medis discovery service.
type Discoverer struct {
ptr *C.libvlc_media_discoverer_t
}
// Release media discover object
func (this *Discoverer) Release() {
if this.ptr != nil {
C.libvlc_media_discoverer_release(this.ptr)
this.ptr = nil
}
}
// LocalizedName return the localzied discovery service name.
func (this *Discoverer) LocalizedName() (s string, err error) {
if this.ptr != nil {
return "", syscall.EINVAL
}
if c := C.libvlc_media_discoverer_localized_name(this.ptr); c != nil {
s = C.GoString(c)
C.free(unsafe.Pointer(c))
return
}
return "", checkError()
}
// MediaList returns a list of media items.
func (this *Discoverer) MediaList() (m *MediaList, err error) {
if this.ptr != nil {
return nil, syscall.EINVAL
}
if c := C.libvlc_media_discoverer_media_list(this.ptr); c != nil {
return &MediaList{c}, nil
}
return nil, checkError()
}
// Events returns an event manager for this instance.
// Note: This method does not increment the media reference count.
func (this *Discoverer) Events() (*EventManager, error) {
if this.ptr == nil {
return nil, syscall.EINVAL
}
if c := C.libvlc_media_discoverer_event_manager(this.ptr); c != nil {
return NewEventManager(c), nil
}
return nil, checkError()
}
// IsRunning returns true if the discovery service is currently running.
func (this *Discoverer) IsRunning() (bool, error) {
if this.ptr == nil {
return false, syscall.EINVAL
}
return C.libvlc_media_discoverer_is_running(this.ptr) != 0, checkError()
}
// Description for audio output.
type AudioOutput struct {
ptr *C.libvlc_audio_output_t
}
// Name returns the track name.
func (this *AudioOutput) Name() string { return C.GoString(this.ptr.psz_name) }
// Description returns the track description.
func (this *AudioOutput) Description() string { return C.GoString(this.ptr.psz_description) }
func (this *AudioOutput) Release() {
if this.ptr != nil {
C.libvlc_audio_output_list_release(this.ptr)
this.ptr = nil
}
}
// List of track descriptions.
type AudioOutputList []*AudioOutput
func (this *AudioOutputList) fromC(p *C.libvlc_audio_output_t) {
for ; p != nil; p = (*C.libvlc_audio_output_t)(p.p_next) {
*this = append(*this, &AudioOutput{p})
}
}
func (this *AudioOutputList) Release() {
if len(*this) == 0 {
return
}
(*this)[0].Release()
*this = nil
}
// Rectangle type for video geometry.
type Rect struct {
ptr *C.libvlc_rectangle_t
}
// Top returns the top coordinate.
func (this *Rect) Top() int { return int(this.ptr.top) }
// Left returns the left coordinate.
func (this *Rect) Left() int { return int(this.ptr.left) }
// Bottom returns the bottom coordinate.
func (this *Rect) Bottom() int { return int(this.ptr.bottom) }
// Right returns the right coordinate.
func (this *Rect) Right() int { return int(this.ptr.right) }