From: elinor Date: Mon, 2 Apr 2018 12:54:07 +0000 (+0300) Subject: Readme and godoc strings X-Git-Tag: v2.0.0~21^2 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=5429761d8778d00cb97d0268bb4aad3e9002e2e4;p=go-opus.git Readme and godoc strings --- diff --git a/README.md b/README.md index 152737d..28a67f8 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,15 @@ for i := 0; i < n; i++ { } ``` +Note regarding Forward Error Correction (FEC): +> When a packet is considered "lost", `DecodeFEC` and `DecodeFECFloat32` methods +> can be called on the next packet in order to try and recover some of the lost +> data. The PCM needs to be exactly the duration of audio that is missing. +> `LastPacketDuration()` can be used on the decoder to get the length of the +> last packet. +> Note also that in order to use this feature the encoder needs to be configured +> with `SetInBandFEC(true)` and `SetPacketLossPerc(x)` options. + ### Streams (and files) To decode a .opus file (or .ogg with Opus data), or to decode a "Opus stream" diff --git a/decoder.go b/decoder.go index fe888ac..a3760ce 100644 --- a/decoder.go +++ b/decoder.go @@ -113,7 +113,8 @@ func (dec *Decoder) DecodeFloat32(data []byte, pcm []float32) (int, error) { } // DecodeFEC encoded Opus data into the supplied buffer with forward error -// correction. The supplied buffer will be entirely filled. +// correction. It is to be used on the packet directly following the lost one. +// The supplied buffer needs to be exactly the duration of audio that is missing func (dec *Decoder) DecodeFEC(data []byte, pcm []int16) error { if dec.p == nil { return errDecUninitialized @@ -139,7 +140,8 @@ func (dec *Decoder) DecodeFEC(data []byte, pcm []int16) error { } // DecodeFECFloat32 encoded Opus data into the supplied buffer with forward error -// correction. The supplied buffer will be entirely filled. +// correction. It is to be used on the packet directly following the lost one. +// The supplied buffer needs to be exactly the duration of audio that is missing func (dec *Decoder) DecodeFECFloat32(data []byte, pcm []float32) error { if dec.p == nil { return errDecUninitialized