From: Hraban Luyat Date: Wed, 11 Jan 2017 00:05:02 +0000 (+0000) Subject: Clearer function names for SetBitrateTo*() X-Git-Tag: v2.0.0~33^2~2 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=1269d97adf5e807ae187d7bf55b945ad0a47193d;p=go-opus.git Clearer function names for SetBitrateTo*() There is also a MaxBitrate property; once implemented that would become SetMaxBitrate(). Too confusing to also have SetBitrateMax(). The extra To hopefully helps disambiguate. --- diff --git a/encoder.go b/encoder.go index ffd9b6c..b7217b6 100644 --- a/encoder.go +++ b/encoder.go @@ -245,7 +245,7 @@ func (enc *Encoder) SetBitrate(bitrate int) error { } // SetBitrateAuto will allow the encoder to automatically set the bitrate -func (enc *Encoder) SetBitrateAuto() error { +func (enc *Encoder) SetBitrateToAuto() error { res := C.bridge_encoder_set_bitrate(enc.p, C.opus_int32(C.CONST_BITRATE_AUTO)) if res != C.OPUS_OK { return Error(res) @@ -255,7 +255,7 @@ func (enc *Encoder) SetBitrateAuto() error { // SetBitrateMax 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) SetBitrateMax() error { +func (enc *Encoder) SetBitrateToMax() error { res := C.bridge_encoder_set_bitrate(enc.p, C.opus_int32(C.CONST_BITRATE_MAX)) if res != C.OPUS_OK { return Error(res) diff --git a/encoder_test.go b/encoder_test.go index b1defe1..086d789 100644 --- a/encoder_test.go +++ b/encoder_test.go @@ -88,7 +88,7 @@ func TestEncoder_SetGetBitrate(t *testing.T) { } } -func TestEncoder_SetBitrateAuto(t *testing.T) { +func TestEncoder_SetBitrateToAuto(t *testing.T) { enc, err := NewEncoder(8000, 1, AppVoIP) if err != nil || enc == nil { t.Errorf("Error creating new encoder: %v", err) @@ -108,7 +108,7 @@ func TestEncoder_SetBitrateAuto(t *testing.T) { t.Errorf("Unexpected bitrate. Got %d, but expected %d", br, bitrate) } - err = enc.SetBitrateAuto() + err = enc.SetBitrateToAuto() if err != nil { t.Error("Error setting Auto bitrate:", err) } @@ -124,7 +124,7 @@ func TestEncoder_SetBitrateAuto(t *testing.T) { } } -func TestEncoder_SetBitrateMax(t *testing.T) { +func TestEncoder_SetBitrateToMax(t *testing.T) { enc, err := NewEncoder(8000, 1, AppVoIP) if err != nil || enc == nil { t.Errorf("Error creating new encoder: %v", err) @@ -144,7 +144,7 @@ func TestEncoder_SetBitrateMax(t *testing.T) { t.Errorf("Unexpected bitrate. Got %d, but expected %d", br, bitrate) } - err = enc.SetBitrateMax() + err = enc.SetBitrateToMax() if err != nil { t.Error("Error setting Max bitrate:", err) }