forked from 3d0c/gmf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathswr.go
More file actions
49 lines (34 loc) · 867 Bytes
/
swr.go
File metadata and controls
49 lines (34 loc) · 867 Bytes
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
package gmf
/*
#cgo pkg-config: libswresample
#include "libswresample/swresample.h"
*/
import "C"
//
// Unfinished.
//
type SwrCtx struct {
swrCtx *C.struct_SwrContext
cc *CodecCtx
}
func NewSwrCtx(options []*Option, cc *CodecCtx) *SwrCtx {
this := &SwrCtx{swrCtx: C.swr_alloc(), cc: cc}
for _, option := range options {
option.Set(this.swrCtx)
}
if int(C.swr_init(this.swrCtx)) < 0 {
return nil
}
return this
}
func (this *SwrCtx) Free() {
C.swr_free(&this.swrCtx)
}
func (this *SwrCtx) Convert(input *Frame) *Frame {
panic("This stuff is unfinished.")
// frame := NewFrame()
// dstNbSamples := C.av_rescale_rnd(C.swr_get_delay(this.swrCtx, this.cc.avCodecCtx.sample_rate)+input.avFrame.nb_samples, C.int64_t(this.cc.SampleRate()), this.cc.SampleRate(), C.AV_ROUND_UP)
// if dstNbSamples > input.NbSamples() {
// }
return nil
}