Reland of "Reporting of decoding_codec_plc events""

This is a reland of 0a88ea050cda58de81d624cf2764d46929447ed5.

The new stat will not be reported unless it is GT 0.

Reporting of decoding_codec_plc events

Bug: webrtc:10838
Change-Id: Ic8585b4eeae9a2643374f15bc2578d1141e59683
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/148448
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Commit-Queue: Alex Narest <alexnarest@google.com>
Cr-Commit-Position: refs/heads/master@{#28797}
diff --git a/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
index 64a681d..f7513f7 100644
--- a/modules/audio_coding/acm2/audio_coding_module_unittest.cc
+++ b/modules/audio_coding/acm2/audio_coding_module_unittest.cc
@@ -266,7 +266,7 @@
   EXPECT_EQ(0, stats.calls_to_silence_generator);
   EXPECT_EQ(0, stats.decoded_normal);
   EXPECT_EQ(0, stats.decoded_cng);
-  EXPECT_EQ(0, stats.decoded_plc);
+  EXPECT_EQ(0, stats.decoded_neteq_plc);
   EXPECT_EQ(0, stats.decoded_plc_cng);
   EXPECT_EQ(0, stats.decoded_muted_output);
 }
@@ -292,7 +292,7 @@
   EXPECT_EQ(0, stats.calls_to_silence_generator);
   EXPECT_EQ(kNumNormalCalls, stats.decoded_normal);
   EXPECT_EQ(0, stats.decoded_cng);
-  EXPECT_EQ(0, stats.decoded_plc);
+  EXPECT_EQ(0, stats.decoded_neteq_plc);
   EXPECT_EQ(0, stats.decoded_plc_cng);
   EXPECT_EQ(0, stats.decoded_muted_output);
 
@@ -308,7 +308,7 @@
   EXPECT_EQ(0, stats.calls_to_silence_generator);
   EXPECT_EQ(kNumNormalCalls, stats.decoded_normal);
   EXPECT_EQ(0, stats.decoded_cng);
-  EXPECT_EQ(kNumPlc, stats.decoded_plc);
+  EXPECT_EQ(kNumPlc, stats.decoded_neteq_plc);
   EXPECT_EQ(kNumPlcCng, stats.decoded_plc_cng);
   EXPECT_EQ(0, stats.decoded_muted_output);
   // TODO(henrik.lundin) Add a test with muted state enabled.
diff --git a/modules/audio_coding/acm2/call_statistics.cc b/modules/audio_coding/acm2/call_statistics.cc
index a506ead..e97e529 100644
--- a/modules/audio_coding/acm2/call_statistics.cc
+++ b/modules/audio_coding/acm2/call_statistics.cc
@@ -28,7 +28,11 @@
       break;
     }
     case AudioFrame::kPLC: {
-      ++decoding_stat_.decoded_plc;
+      ++decoding_stat_.decoded_neteq_plc;
+      break;
+    }
+    case AudioFrame::kCodecPLC: {
+      ++decoding_stat_.decoded_codec_plc;
       break;
     }
     case AudioFrame::kCNG: {
diff --git a/modules/audio_coding/acm2/call_statistics_unittest.cc b/modules/audio_coding/acm2/call_statistics_unittest.cc
index d7ac953..b96977b 100644
--- a/modules/audio_coding/acm2/call_statistics_unittest.cc
+++ b/modules/audio_coding/acm2/call_statistics_unittest.cc
@@ -25,7 +25,7 @@
   EXPECT_EQ(0, stats.calls_to_silence_generator);
   EXPECT_EQ(0, stats.decoded_normal);
   EXPECT_EQ(0, stats.decoded_cng);
-  EXPECT_EQ(0, stats.decoded_plc);
+  EXPECT_EQ(0, stats.decoded_neteq_plc);
   EXPECT_EQ(0, stats.decoded_plc_cng);
   EXPECT_EQ(0, stats.decoded_muted_output);
 }
@@ -37,15 +37,17 @@
   call_stats.DecodedBySilenceGenerator();
   call_stats.DecodedByNetEq(AudioFrame::kNormalSpeech, false);
   call_stats.DecodedByNetEq(AudioFrame::kPLC, false);
+  call_stats.DecodedByNetEq(AudioFrame::kCodecPLC, false);
   call_stats.DecodedByNetEq(AudioFrame::kPLCCNG, true);  // Let this be muted.
   call_stats.DecodedByNetEq(AudioFrame::kCNG, false);
 
   stats = call_stats.GetDecodingStatistics();
-  EXPECT_EQ(4, stats.calls_to_neteq);
+  EXPECT_EQ(5, stats.calls_to_neteq);
   EXPECT_EQ(1, stats.calls_to_silence_generator);
   EXPECT_EQ(1, stats.decoded_normal);
   EXPECT_EQ(1, stats.decoded_cng);
-  EXPECT_EQ(1, stats.decoded_plc);
+  EXPECT_EQ(1, stats.decoded_neteq_plc);
+  EXPECT_EQ(1, stats.decoded_codec_plc);
   EXPECT_EQ(1, stats.decoded_plc_cng);
   EXPECT_EQ(1, stats.decoded_muted_output);
 }
diff --git a/modules/audio_coding/include/audio_coding_module_typedefs.h b/modules/audio_coding/include/audio_coding_module_typedefs.h
index d256fd1..95314a3 100644
--- a/modules/audio_coding/include/audio_coding_module_typedefs.h
+++ b/modules/audio_coding/include/audio_coding_module_typedefs.h
@@ -57,7 +57,8 @@
       : calls_to_silence_generator(0),
         calls_to_neteq(0),
         decoded_normal(0),
-        decoded_plc(0),
+        decoded_neteq_plc(0),
+        decoded_codec_plc(0),
         decoded_cng(0),
         decoded_plc_cng(0),
         decoded_muted_output(0) {}
@@ -66,7 +67,8 @@
                                    // and NetEq was disengaged from decoding.
   int calls_to_neteq;              // Number of calls to NetEq.
   int decoded_normal;  // Number of calls where audio RTP packet decoded.
-  int decoded_plc;     // Number of calls resulted in PLC.
+  int decoded_neteq_plc;  // Number of calls resulted in NetEq PLC.
+  int decoded_codec_plc;  // Number of calls resulted in codec PLC.
   int decoded_cng;  // Number of calls where comfort noise generated due to DTX.
   int decoded_plc_cng;       // Number of calls resulted where PLC faded to CNG.
   int decoded_muted_output;  // Number of calls returning a muted state output.
diff --git a/modules/audio_coding/neteq/neteq_impl.cc b/modules/audio_coding/neteq/neteq_impl.cc
index 8ef08ce..5466409 100644
--- a/modules/audio_coding/neteq/neteq_impl.cc
+++ b/modules/audio_coding/neteq/neteq_impl.cc
@@ -203,6 +203,11 @@
       audio_frame->vad_activity_ = AudioFrame::kVadPassive;
       break;
     }
+    case NetEqImpl::OutputType::kCodecPLC: {
+      audio_frame->speech_type_ = AudioFrame::kCodecPLC;
+      audio_frame->vad_activity_ = last_vad_activity;
+      break;
+    }
     default:
       RTC_NOTREACHED();
   }
@@ -2088,6 +2093,8 @@
     return OutputType::kPLC;
   } else if (vad_->running() && !vad_->active_speech()) {
     return OutputType::kVadPassive;
+  } else if (last_mode_ == kModeCodecPlc) {
+    return OutputType::kCodecPLC;
   } else {
     return OutputType::kNormalSpeech;
   }
diff --git a/modules/audio_coding/neteq/neteq_impl.h b/modules/audio_coding/neteq/neteq_impl.h
index 9e1af10..c4887a7 100644
--- a/modules/audio_coding/neteq/neteq_impl.h
+++ b/modules/audio_coding/neteq/neteq_impl.h
@@ -64,7 +64,14 @@
 
 class NetEqImpl : public webrtc::NetEq {
  public:
-  enum class OutputType { kNormalSpeech, kPLC, kCNG, kPLCCNG, kVadPassive };
+  enum class OutputType {
+    kNormalSpeech,
+    kPLC,
+    kCNG,
+    kPLCCNG,
+    kVadPassive,
+    kCodecPLC
+  };
 
   enum ErrorCodes {
     kNoError = 0,