Skip to content
Snippets Groups Projects
Commit 7c960d55 authored by Philip-Dylan Gleonec's avatar Philip-Dylan Gleonec Committed by Pierre Lespagnol
Browse files

media_encoder: enable libopus FEC encoding

Adds a function to initialize the opus encoder with FEC support and a
default packet loss of 10%.
In future iterations, the default value should be set to 0 and the
packet loss adapted accordingly to RTCP control packets.

Issue: #5156
Change-Id: I79b9c5e38ed388466d7b71a394f961d2ff9b001f
parent b318b93f
No related branches found
No related tags found
No related merge requests found
......@@ -761,6 +761,13 @@ MediaEncoder::initCodec(AVMediaType mediaType, AVCodecID avcodecId, uint64_t br)
}
}
/* Enable libopus FEC encoding support */
if (mediaType == AVMEDIA_TYPE_AUDIO) {
if (avcodecId == AV_CODEC_ID_OPUS) {
initOpus(encoderCtx);
}
}
/* let x264 preset override our encoder settings */
if (avcodecId == AV_CODEC_ID_H264) {
auto profileLevelId = libav_utils::getDictValue(options_, "parameters");
......@@ -951,6 +958,15 @@ MediaEncoder::initH263(AVCodecContext* encoderCtx, uint64_t br)
JAMI_DBG("H263 encoder setup: maxrate=%lu, bufsize=%lu", maxBitrate, bufSize);
}
void
MediaEncoder::initOpus(AVCodecContext* encoderCtx)
{
int ret;
// Enable FEC support by default with 10% packet loss
av_opt_set_int(encoderCtx, "enable_fec", 1, AV_OPT_SEARCH_CHILDREN);
av_opt_set_int(encoderCtx, "packet_loss", 10, AV_OPT_SEARCH_CHILDREN);
}
void
MediaEncoder::initAccel(AVCodecContext* encoderCtx, uint64_t br)
{
......
......@@ -132,6 +132,7 @@ private:
void initVP8(AVCodecContext* encoderCtx, uint64_t br);
void initMPEG4(AVCodecContext* encoderCtx, uint64_t br);
void initH263(AVCodecContext* encoderCtx, uint64_t br);
void initOpus(AVCodecContext* encoderCtx);
bool isDynBitrateSupported(AVCodecID codecid);
void initAccel(AVCodecContext* encoderCtx, uint64_t br);
int getHWFrame(const std::shared_ptr<VideoFrame>& input, std::shared_ptr<VideoFrame>& output);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment