]> Sergey Matveev's repositories - go-opus.git/commitdiff
(Set)InBandFEC - set and return bool instead of int
authorelinor <elinor.alp@gmail.com>
Mon, 2 Apr 2018 10:31:07 +0000 (13:31 +0300)
committerelinor <elinor.alp@gmail.com>
Mon, 2 Apr 2018 10:31:07 +0000 (13:31 +0300)
encoder.go

index f8e890a4b6861bced1bc17158bd53b9bff23ae6e..c3581e656203bdf6c3c3437d253cbf1a363c0e07 100644 (file)
@@ -326,11 +326,14 @@ func (enc *Encoder) MaxBandwidth() (Bandwidth, error) {
        return Bandwidth(maxBw), nil
 }
 
-
 // SetInBandFEC configures the encoder's use of inband forward error
 // correction (FEC)
-func (enc *Encoder) SetInBandFEC(fec int) error {
-       res := C.bridge_encoder_set_inband_fec(enc.p, C.opus_int32(fec))
+func (enc *Encoder) SetInBandFEC(fec bool) error {
+       i := 0
+       if fec {
+               i = 1
+       }
+       res := C.bridge_encoder_set_inband_fec(enc.p, C.opus_int32(i))
        if res != C.OPUS_OK {
                return Error(res)
        }
@@ -338,13 +341,13 @@ func (enc *Encoder) SetInBandFEC(fec int) error {
 }
 
 // InBandFEC gets the encoder's configured inband forward error correction (FEC)
-func (enc *Encoder) InBandFEC() (int, error) {
+func (enc *Encoder) InBandFEC() (bool, error) {
        var fec C.opus_int32
        res := C.bridge_encoder_get_inband_fec(enc.p, &fec)
        if res != C.OPUS_OK {
-               return 0, Error(res)
+               return false, Error(res)
        }
-       return int(fec), nil
+       return fec != 0, nil
 }
 
 // SetPacketLossPerc configures the encoder's expected packet loss percentage.