-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathffmpeg_config.go
57 lines (49 loc) · 1.21 KB
/
ffmpeg_config.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
package ffmpeg
// DefaultConfig returns a new Config with default values.
func DefaultConfig() *Config {
return &Config{
Exec: Exec,
SampleRate: SampleRate,
Channels: Channels,
BufferSize: BufferSize,
}
}
// Config is used to configure a ffmpeg audio source.
type Config struct {
Exec string
SampleRate int
Channels int
BufferSize int
}
// ConfigOpt is used to functionally configure a Config.
type ConfigOpt func(config *Config)
// Apply applies the ConfigOpt(s) to the Config.
func (c *Config) Apply(opts []ConfigOpt) {
for _, opt := range opts {
opt(c)
}
}
// WithExec sets the Config(s) used Exec.
func WithExec(exec string) ConfigOpt {
return func(config *Config) {
config.Exec = exec
}
}
// WithSampleRate sets the Config(s) used SampleRate.
func WithSampleRate(sampleRate int) ConfigOpt {
return func(config *Config) {
config.SampleRate = sampleRate
}
}
// WithChannels sets the Config(s) used Channels.
func WithChannels(channels int) ConfigOpt {
return func(config *Config) {
config.Channels = channels
}
}
// WithBufferSize sets the Config(s) used BufferSize.
func WithBufferSize(bufferSize int) ConfigOpt {
return func(config *Config) {
config.BufferSize = bufferSize
}
}