encoder.go | 16 +++------------- opus.go | 15 ++++----------- diff --git a/encoder.go b/encoder.go index cd67484a0fe820bc4ec90d168ffd415f78dde97a..0ffaa66bb29d2ba6ac3d1400d6dfb757a290bbd7 100644 --- a/encoder.go +++ b/encoder.go @@ -68,22 +68,12 @@ { return opus_encoder_ctl(st, OPUS_GET_MAX_BANDWIDTH(max_bw)); } -// Access the preprocessor from CGO -const int CONST_BANDWIDTH_NARROWBAND = OPUS_BANDWIDTH_NARROWBAND; -const int CONST_BANDWIDTH_MEDIUMBAND = OPUS_BANDWIDTH_MEDIUMBAND; -const int CONST_BANDWIDTH_WIDEBAND = OPUS_BANDWIDTH_WIDEBAND; -const int CONST_BANDWIDTH_SUPERWIDEBAND = OPUS_BANDWIDTH_SUPERWIDEBAND; -const int CONST_BANDWIDTH_FULLBAND = OPUS_BANDWIDTH_FULLBAND; - -const int CONST_BITRATE_AUTO = OPUS_AUTO; -const int CONST_BITRATE_MAX = OPUS_BITRATE_MAX; - */ import "C" type Bandwidth int -var ( +const ( // 4 kHz passband Narrowband = Bandwidth(C.OPUS_BANDWIDTH_NARROWBAND) // 6 kHz passband @@ -246,7 +236,7 @@ } // SetBitrateToAuto will allow the encoder to automatically set the bitrate func (enc *Encoder) SetBitrateToAuto() error { - res := C.bridge_encoder_set_bitrate(enc.p, C.opus_int32(C.CONST_BITRATE_AUTO)) + res := C.bridge_encoder_set_bitrate(enc.p, C.opus_int32(C.OPUS_AUTO)) if res != C.OPUS_OK { return Error(res) } @@ -256,7 +246,7 @@ // SetBitrateToMax causes the encoder to use as much rate as it can. This can be // useful for controlling the rate by adjusting the output buffer size. func (enc *Encoder) SetBitrateToMax() error { - res := C.bridge_encoder_set_bitrate(enc.p, C.opus_int32(C.CONST_BITRATE_MAX)) + res := C.bridge_encoder_set_bitrate(enc.p, C.opus_int32(C.OPUS_BITRATE_MAX)) if res != C.OPUS_OK { return Error(res) } diff --git a/opus.go b/opus.go index a7436e21befccaf5e536f8d6f7bbc5a041ca8875..e4e67e01901fd3babbd1805b7e674b5680844205 100644 --- a/opus.go +++ b/opus.go @@ -8,25 +8,18 @@ /* // Link opus using pkg-config. #cgo pkg-config: opus #include - -// Access the preprocessor from CGO -const int CONST_APPLICATION_VOIP = OPUS_APPLICATION_VOIP; -const int CONST_APPLICATION_AUDIO = OPUS_APPLICATION_AUDIO; -const int CONST_APPLICATION_RESTRICTED_LOWDELAY = OPUS_APPLICATION_RESTRICTED_LOWDELAY; */ import "C" type Application int -// These variables should be constants, but for interoperability with CGO -// they're var. Don't change them, though! -var ( +const ( // Optimize encoding for VoIP - AppVoIP = Application(C.CONST_APPLICATION_VOIP) + AppVoIP = Application(C.OPUS_APPLICATION_VOIP) // Optimize encoding for non-voice signals like music - AppAudio = Application(C.CONST_APPLICATION_AUDIO) + AppAudio = Application(C.OPUS_APPLICATION_AUDIO) // Optimize encoding for low latency applications - AppRestrictedLowdelay = Application(C.CONST_APPLICATION_RESTRICTED_LOWDELAY) + AppRestrictedLowdelay = Application(C.OPUS_APPLICATION_RESTRICTED_LOWDELAY) ) const (