espressif / esp-adf-libs

56 stars 41 forks source link

Opus encoder: Add confgurable parameters, to better match usecases (fec, packet_loss) #23

Open expresspotato opened 1 year ago

expresspotato commented 1 year ago

Hi,

Having the opus encoder is great, but the problem is Opus and AMR are the only codecs part of esp-adf-libs that support some sort of FEC (Foward Error Correction) against packet loss. The AMD decoder frankly doesn't work very well, when there is packetloss it simply dies with _E (15829) AMR_DECODER: packet size(-1) < 0, line:324, amrtype:2, which defeats the purpose of using such a specialty codec in the first place.

Since the source is closed to esp-adf-libs, I can't make the necessary modifications to support opus better for various use cases. Some of these options are already available, but at a bare minimum fec, packet_loss and dtx options are desired to be added.

type | None |   | false | Must be of type 'opus'. packet_loss | Integer | 0 | false | Encoder's packet loss percentage. complexity | Integer | 10 | false | Encoder's computational complexity. max_bandwidth | Custom | full | false | Encoder's maximum bandwidth allowed. signal | Custom | auto | false | Encoder's signal type. application | Custom | voip | false | Encoder's application type. max_playback_rate | Custom | 48000 | false | Encoder's maximum playback rate. bitrate | Custom | auto | false | Encoder's bit rate. cbr | Boolean | no | false | Encoder's constant bit rate value. fec | Boolean | yes | false | Encoder's forward error correction value. dtx | Boolean | no | false | Encoder's discontinuous transmission value.