forked from 3d0c/gmf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
codecDesc.go
72 lines (51 loc) · 1.22 KB
/
codecDesc.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
package gmf
/*
#cgo pkg-config: libavcodec
#include "libavcodec/avcodec.h"
*/
import "C"
import (
"log"
)
type CodecDescriptor struct {
avDesc *C.struct_AVCodecDescriptor
IsEncoder bool
}
var Codecs []*CodecDescriptor
func InitDesc() {
var desc *C.struct_AVCodecDescriptor = nil
var c *C.struct_AVCodec
if Codecs != nil {
log.Println("Wrong method call. Map 'Codecs' is already initialized. Ignoring...")
return
}
Codecs = make([]*CodecDescriptor, 0)
for {
if c = C.av_codec_next(c); c == nil {
break
}
if desc = C.avcodec_descriptor_get(c.id); desc == nil {
log.Printf("Unable to get descriptor for codec id: %d\n", int(c.id))
}
result := &CodecDescriptor{avDesc: desc, IsEncoder: false}
if C.av_codec_is_encoder(c) > 0 {
result.IsEncoder = true
}
Codecs = append(Codecs, result)
}
}
func (this *CodecDescriptor) Id() int {
return int(this.avDesc.id)
}
func (this *CodecDescriptor) Type() int {
return int(this.avDesc._type)
}
func (this *CodecDescriptor) Name() string {
return C.GoString(this.avDesc.name)
}
func (this *CodecDescriptor) LongName() string {
return C.GoString(this.avDesc.long_name)
}
func (this *CodecDescriptor) Props() int {
return int(this.avDesc.props)
}