Let NetEq use the PLC output from a decoder

This change enables NetEq to use the packet concealment audio (aka
PLC) produced by a decoder. The change also includes a new API to the
AudioDecoder interface, which lets the decoder implementation generate
and deliver concealment audio.

Bug: webrtc:9180
Change-Id: Icaacebccf645d4694b0d2d6310f6f2c7132881c4
Reviewed-on: https://webrtc-review.googlesource.com/96340
Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24738}
diff --git a/api/audio_codecs/audio_decoder.cc b/api/audio_codecs/audio_decoder.cc
index 00e45d9..aaba175 100644
--- a/api/audio_codecs/audio_decoder.cc
+++ b/api/audio_codecs/audio_decoder.cc
@@ -130,6 +130,12 @@
   return 0;
 }
 
+// TODO(bugs.webrtc.org/9676): Remove default impementation.
+void AudioDecoder::GeneratePlc(size_t /*requested_samples_per_channel*/,
+                               rtc::BufferT<int16_t>* /*concealment_audio*/) {
+  return;
+}
+
 int AudioDecoder::IncomingPacket(const uint8_t* payload,
                                  size_t payload_len,
                                  uint16_t rtp_sequence_number,
diff --git a/api/audio_codecs/audio_decoder.h b/api/audio_codecs/audio_decoder.h
index 9a955a6..b01a66a 100644
--- a/api/audio_codecs/audio_decoder.h
+++ b/api/audio_codecs/audio_decoder.h
@@ -119,6 +119,20 @@
   // memory allocated in |decoded| should accommodate |num_frames| frames.
   virtual size_t DecodePlc(size_t num_frames, int16_t* decoded);
 
+  // Asks the decoder to generate packet-loss concealment and append it to the
+  // end of |concealment_audio|. The concealment audio should be in
+  // channel-interleaved format, with as many channels as the last decoded
+  // packet produced. The implementation must produce at least
+  // requested_samples_per_channel, or nothing at all. This is a signal to the
+  // caller to conceal the loss with other means. If the implementation provides
+  // concealment samples, it is also responsible for "stitching" it together
+  // with the decoded audio on either side of the concealment.
+  // Note: The default implementation of GeneratePlc will be deleted soon. All
+  // implementations must provide their own, which can be a simple as a no-op.
+  // TODO(bugs.webrtc.org/9676): Remove default impementation.
+  virtual void GeneratePlc(size_t requested_samples_per_channel,
+                           rtc::BufferT<int16_t>* concealment_audio);
+
   // Resets the decoder state (empty buffers etc.).
   virtual void Reset() = 0;