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/frame_buffer2.h b/modules/video_coding/frame_buffer2.h
index d824ddf..7909000 100644
--- a/modules/video_coding/frame_buffer2.h
+++ b/modules/video_coding/frame_buffer2.h
@@ -24,10 +24,10 @@
 #include "modules/video_coding/jitter_estimator.h"
 #include "modules/video_coding/utility/decoded_frames_history.h"
 #include "rtc_base/constructor_magic.h"
-#include "rtc_base/critical_section.h"
 #include "rtc_base/event.h"
 #include "rtc_base/experiments/rtt_mult_experiment.h"
 #include "rtc_base/numerics/sequence_number_util.h"
+#include "rtc_base/synchronization/mutex.h"
 #include "rtc_base/synchronization/sequence_checker.h"
 #include "rtc_base/task_queue.h"
 #include "rtc_base/task_utils/repeating_task.h"
@@ -118,40 +118,40 @@
   // Check that the references of |frame| are valid.
   bool ValidReferences(const EncodedFrame& frame) const;
 
-  int64_t FindNextFrame(int64_t now_ms) RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
-  EncodedFrame* GetNextFrame() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+  int64_t FindNextFrame(int64_t now_ms) RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
+  EncodedFrame* GetNextFrame() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
-  void StartWaitForNextFrameOnQueue() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
-  void CancelCallback() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+  void StartWaitForNextFrameOnQueue() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
+  void CancelCallback() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
   // Update all directly dependent and indirectly dependent frames and mark
   // them as continuous if all their references has been fulfilled.
   void PropagateContinuity(FrameMap::iterator start)
-      RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+      RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
   // Marks the frame as decoded and updates all directly dependent frames.
   void PropagateDecodability(const FrameInfo& info)
-      RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+      RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
   // Update the corresponding FrameInfo of |frame| and all FrameInfos that
   // |frame| references.
   // Return false if |frame| will never be decodable, true otherwise.
   bool UpdateFrameInfoWithIncomingFrame(const EncodedFrame& frame,
                                         FrameMap::iterator info)
-      RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+      RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
-  void UpdateJitterDelay() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+  void UpdateJitterDelay() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
-  void UpdateTimingFrameInfo() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+  void UpdateTimingFrameInfo() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
-  void ClearFramesAndHistory() RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+  void ClearFramesAndHistory() RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
   // Checks if the superframe, which current frame belongs to, is complete.
   bool IsCompleteSuperFrame(const EncodedFrame& frame)
-      RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+      RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
   bool HasBadRenderTiming(const EncodedFrame& frame, int64_t now_ms)
-      RTC_EXCLUSIVE_LOCKS_REQUIRED(crit_);
+      RTC_EXCLUSIVE_LOCKS_REQUIRED(mutex_);
 
   // The cleaner solution would be to have the NextFrame function return a
   // vector of frames, but until the decoding pipeline can support decoding
@@ -164,29 +164,29 @@
   SequenceChecker callback_checker_;
 
   // Stores only undecoded frames.
-  FrameMap frames_ RTC_GUARDED_BY(crit_);
-  DecodedFramesHistory decoded_frames_history_ RTC_GUARDED_BY(crit_);
+  FrameMap frames_ RTC_GUARDED_BY(mutex_);
+  DecodedFramesHistory decoded_frames_history_ RTC_GUARDED_BY(mutex_);
 
-  rtc::CriticalSection crit_;
+  Mutex mutex_;
   Clock* const clock_;
 
-  rtc::TaskQueue* callback_queue_ RTC_GUARDED_BY(crit_);
-  RepeatingTaskHandle callback_task_ RTC_GUARDED_BY(crit_);
+  rtc::TaskQueue* callback_queue_ RTC_GUARDED_BY(mutex_);
+  RepeatingTaskHandle callback_task_ RTC_GUARDED_BY(mutex_);
   std::function<void(std::unique_ptr<EncodedFrame>, ReturnReason)>
-      frame_handler_ RTC_GUARDED_BY(crit_);
-  int64_t latest_return_time_ms_ RTC_GUARDED_BY(crit_);
-  bool keyframe_required_ RTC_GUARDED_BY(crit_);
+      frame_handler_ RTC_GUARDED_BY(mutex_);
+  int64_t latest_return_time_ms_ RTC_GUARDED_BY(mutex_);
+  bool keyframe_required_ RTC_GUARDED_BY(mutex_);
 
-  VCMJitterEstimator jitter_estimator_ RTC_GUARDED_BY(crit_);
-  VCMTiming* const timing_ RTC_GUARDED_BY(crit_);
-  VCMInterFrameDelay inter_frame_delay_ RTC_GUARDED_BY(crit_);
+  VCMJitterEstimator jitter_estimator_ RTC_GUARDED_BY(mutex_);
+  VCMTiming* const timing_ RTC_GUARDED_BY(mutex_);
+  VCMInterFrameDelay inter_frame_delay_ RTC_GUARDED_BY(mutex_);
   absl::optional<VideoLayerFrameId> last_continuous_frame_
-      RTC_GUARDED_BY(crit_);
-  std::vector<FrameMap::iterator> frames_to_decode_ RTC_GUARDED_BY(crit_);
-  bool stopped_ RTC_GUARDED_BY(crit_);
-  VCMVideoProtection protection_mode_ RTC_GUARDED_BY(crit_);
+      RTC_GUARDED_BY(mutex_);
+  std::vector<FrameMap::iterator> frames_to_decode_ RTC_GUARDED_BY(mutex_);
+  bool stopped_ RTC_GUARDED_BY(mutex_);
+  VCMVideoProtection protection_mode_ RTC_GUARDED_BY(mutex_);
   VCMReceiveStatisticsCallback* const stats_callback_;
-  int64_t last_log_non_decoded_ms_ RTC_GUARDED_BY(crit_);
+  int64_t last_log_non_decoded_ms_ RTC_GUARDED_BY(mutex_);
 
   const bool add_rtt_to_playout_delay_;