Migrate modules/video_coding to webrtc::Mutex.

Bug: webrtc:11567
Change-Id: I8023fbe7595f7ba8ae7c7db3583fc2e560ec3df2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178803
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Erik Språng <sprang@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31644}
diff --git a/modules/video_coding/deprecated/BUILD.gn b/modules/video_coding/deprecated/BUILD.gn
index f333b3f..fd3a5fa 100644
--- a/modules/video_coding/deprecated/BUILD.gn
+++ b/modules/video_coding/deprecated/BUILD.gn
@@ -26,6 +26,7 @@
     "../../../rtc_base:macromagic",
     "../../../rtc_base:rtc_numerics",
     "../../../rtc_base/experiments:field_trial_parser",
+    "../../../rtc_base/synchronization:mutex",
     "../../../system_wrappers",
     "../../../system_wrappers:field_trial",
     "../../utility",
diff --git a/modules/video_coding/deprecated/nack_module.cc b/modules/video_coding/deprecated/nack_module.cc
index 8658729..f8cfd34 100644
--- a/modules/video_coding/deprecated/nack_module.cc
+++ b/modules/video_coding/deprecated/nack_module.cc
@@ -115,7 +115,7 @@
 int DEPRECATED_NackModule::OnReceivedPacket(uint16_t seq_num,
                                             bool is_keyframe,
                                             bool is_recovered) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   // TODO(philipel): When the packet includes information whether it is
   //                 retransmitted or not, use that value instead. For
   //                 now set it to true, which will cause the reordering
@@ -184,7 +184,7 @@
 }
 
 void DEPRECATED_NackModule::ClearUpTo(uint16_t seq_num) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   nack_list_.erase(nack_list_.begin(), nack_list_.lower_bound(seq_num));
   keyframe_list_.erase(keyframe_list_.begin(),
                        keyframe_list_.lower_bound(seq_num));
@@ -193,12 +193,12 @@
 }
 
 void DEPRECATED_NackModule::UpdateRtt(int64_t rtt_ms) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   rtt_ms_ = rtt_ms;
 }
 
 void DEPRECATED_NackModule::Clear() {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   nack_list_.clear();
   keyframe_list_.clear();
   recovered_list_.clear();
@@ -213,7 +213,7 @@
   if (nack_sender_) {
     std::vector<uint16_t> nack_batch;
     {
-      rtc::CritScope lock(&crit_);
+      MutexLock lock(&mutex_);
       nack_batch = GetNackBatch(kTimeOnly);
     }
 
diff --git a/modules/video_coding/deprecated/nack_module.h b/modules/video_coding/deprecated/nack_module.h
index d704a05..f9580ae 100644
--- a/modules/video_coding/deprecated/nack_module.h
+++ b/modules/video_coding/deprecated/nack_module.h
@@ -21,9 +21,9 @@
 #include "modules/include/module.h"
 #include "modules/include/module_common_types.h"
 #include "modules/video_coding/histogram.h"
-#include "rtc_base/critical_section.h"
 #include "rtc_base/deprecation.h"
 #include "rtc_base/numerics/sequence_number_util.h"
+#include "rtc_base/synchronization/mutex.h"
 #include "rtc_base/thread_annotations.h"
 #include "system_wrappers/include/clock.h"
 
@@ -80,24 +80,24 @@
   };
 
   void AddPacketsToNack(uint16_t seq_num_start, uint16_t seq_num_end)
-      RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+      RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
   // Removes packets from the nack list until the next keyframe. Returns true
   // if packets were removed.
-  bool RemovePacketsUntilKeyFrame() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+  bool RemovePacketsUntilKeyFrame() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
   std::vector<uint16_t> GetNackBatch(NackFilterOptions options)
-      RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+      RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
   // Update the reordering distribution.
   void UpdateReorderingStatistics(uint16_t seq_num)
-      RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+      RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
   // Returns how many packets we have to wait in order to receive the packet
   // with probability |probabilty| or higher.
   int WaitNumberOfPackets(float probability) const
-      RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+      RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
-  rtc::CriticalSection crit_;
+  Mutex mutex_;
   Clock* const clock_;
   NackSender* const nack_sender_;
   KeyFrameRequestSender* const keyframe_request_sender_;
@@ -106,15 +106,15 @@
   // known thread (e.g. see |initialized_|). Those probably do not need
   // synchronized access.
   std::map<uint16_t, NackInfo, DescendingSeqNumComp<uint16_t>> nack_list_
-      RTC_GUARDED_BY(crit_);
+      RTC_GUARDED_BY(mutex_);
   std::set<uint16_t, DescendingSeqNumComp<uint16_t>> keyframe_list_
-      RTC_GUARDED_BY(crit_);
+      RTC_GUARDED_BY(mutex_);
   std::set<uint16_t, DescendingSeqNumComp<uint16_t>> recovered_list_
-      RTC_GUARDED_BY(crit_);
-  video_coding::Histogram reordering_histogram_ RTC_GUARDED_BY(crit_);
-  bool initialized_ RTC_GUARDED_BY(crit_);
-  int64_t rtt_ms_ RTC_GUARDED_BY(crit_);
-  uint16_t newest_seq_num_ RTC_GUARDED_BY(crit_);
+      RTC_GUARDED_BY(mutex_);
+  video_coding::Histogram reordering_histogram_ RTC_GUARDED_BY(mutex_);
+  bool initialized_ RTC_GUARDED_BY(mutex_);
+  int64_t rtt_ms_ RTC_GUARDED_BY(mutex_);
+  uint16_t newest_seq_num_ RTC_GUARDED_BY(mutex_);
 
   // Only touched on the process thread.
   int64_t next_process_time_ms_;