I am trying to implement a Opus transcoder in C++, and I have some conceptual questions. As for the useinbandfec parameter, I don't quite understand the meaning of "unidirectional receive-only parameter", as written in RFC7587, section 7.1:
The "useinbandfec" parameter is a unidirectional receive-only parameter.
For example, Alice is calling Bob. Alice uses Opus codec with useinbandfec=1, while Bob doesn't use Opus. Therefore, there should be a Opus transcoder between the two. If so, how can I configure the settings of Opus encoder and decoder?
As for Alice->Bob where opus_decode()
is needed, what value should be sent as the 5th parameter (fecFlag)? And as for Bob->Alice where a Opus encoder is needed, what value should be sent with OPUS_SET_INBAND_FEC()
in opus_encoder_ctl()
?
Thank you!
Parameter useinbandfec
This parameter means that encoder puts additional information to the stream to recover lost packets. How it works, when encoder encodes number N+1 packet it add there some information about packet N that is useful for decoder if it supports recovery.
If decoder does not support recovery then this information is useless and wasting bandwidth.
Unidirectional receive only parameter meaning
This means that if you specify it in session descriptor (SDP) then this parameters describes capability of receiver and advise sender to use or not to use inbound FEC
Questions:
1
For example, Alice is calling Bob. Alice uses Opus codec with useinbandfec=1, while Bob doesn't use Opus. Therefore, there should be a Opus transcoder between the two. If so, how can I configure the settings of Opus encoder and decoder?
In this configuration you need transcoder between Alice and Bob. If transcoder supports FEC you may prefer to include useinbandfec=1 to SDP fmtp attribute. If encoder (sender on Alice device) is also under your control you MAY set ask encoder to add FEC to the stream in following condtions:
2
As for Alice->Bob where opus_decode() is needed, what value should be sent as the 5th parameter (fecFlag)?
opus_decode FEC flag is used when you detect packet loss (for example by RTP sequence number). Lets assume that you receive packet N and N-1 packet is lost. Then you may restore packet N-1 by calling opus_decode with fecFlag set to true and then decode packet N:
packets[N-1] = decode_opus(pktN, fecFlag=true)
packets[N] = decode_opus(pktN, fecFlag=false)
3
And as for Bob->Alice where a Opus encoder is needed, what value should be sent with OPUS_SET_INBAND_FEC() in opus_encoder_ctl()?
OPUS_SET_INBAND_FEC is better to set from useinbandfec parameter retrieved from Alice SDP. Also beware that FEC is not included into encoded stream unless you do not set OPUS_SET_PACKET_LOSS_PERC