webrtc_codecs_opus (webrtc_codecs v0.1.0)

View Source

Opus codec plugin, on libopus.

webrtc:add_transceiver(Pc, audio, #{frames => true, codec_plugin => {webrtc_codecs_opus, #{}}}).

decode/2 gives webrtc_codecs:audio/0. When frames were lost before the one it is given, it first gives the audio that fills the gap: recovered from the redundancy in the packet (in-band FEC) for the last lost frame, synthesized for the others.

encode/2 takes webrtc_codecs:audio/0 at 8000, 12000, 16000, 24000 or 48000 Hz, one or two channels, 2.5, 5, 10, 20, 40 or 60 ms at a time. It follows bitrate (bits per second) and packet_loss (percent the peer reports, which sizes the redundancy) given in the raw map.

Options, each defaulting to what the negotiated fmtp says:

  • sample_rate: of decoded audio, default 48000
  • channels: of decoded audio, default 2 with stereo=1, else 1
  • bitrate: of the encoder at start, default chosen by libopus
  • fec: in-band FEC, default useinbandfec
  • dtx: send nothing during silence, default usedtx
  • packet_loss: percent expected at start, default 0
  • application: voip (default), audio or lowdelay
  • complexity: 0 to 10, default chosen by libopus