Migrate video/ except video/end_to_end_tests and video/adaptation to webrtc::Mutex.

Also migrates test/ partly.

Bug: webrtc:11567
Change-Id: If5b2eae65c5f297f364b6e3c67f94946a09b4a96
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/178862
Commit-Queue: Markus Handell <handellm@webrtc.org>
Reviewed-by: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#31672}
diff --git a/video/receive_statistics_proxy.cc b/video/receive_statistics_proxy.cc
index 82951c8..7aec685 100644
--- a/video/receive_statistics_proxy.cc
+++ b/video/receive_statistics_proxy.cc
@@ -133,7 +133,7 @@
   // earlier.
   RTC_DCHECK_RUN_ON(&decode_thread_);
 
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
 
   char log_stream_buf[8 * 1024];
   rtc::SimpleStringBuilder log_stream(log_stream_buf);
@@ -623,7 +623,7 @@
 }
 
 VideoReceiveStream::Stats ReceiveStatisticsProxy::GetStats() const {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   // Get current frame rates here, as only updating them on new frames prevents
   // us from ever correctly displaying frame rate of 0.
   int64_t now_ms = clock_->TimeInMilliseconds();
@@ -654,13 +654,13 @@
 }
 
 void ReceiveStatisticsProxy::OnIncomingPayloadType(int payload_type) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   stats_.current_payload_type = payload_type;
 }
 
 void ReceiveStatisticsProxy::OnDecoderImplementationName(
     const char* implementation_name) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   stats_.decoder_implementation_name = implementation_name;
 }
 
@@ -671,7 +671,7 @@
     int jitter_buffer_ms,
     int min_playout_delay_ms,
     int render_delay_ms) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   stats_.max_decode_ms = max_decode_ms;
   stats_.current_delay_ms = current_delay_ms;
   stats_.target_delay_ms = target_delay_ms;
@@ -687,13 +687,13 @@
 }
 
 void ReceiveStatisticsProxy::OnUniqueFramesCounted(int num_unique_frames) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   num_unique_frames_.emplace(num_unique_frames);
 }
 
 void ReceiveStatisticsProxy::OnTimingFrameInfoUpdated(
     const TimingFrameInfo& info) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   if (info.flags != VideoSendTiming::kInvalid) {
     int64_t now_ms = clock_->TimeInMilliseconds();
     timing_frame_info_counter_.Add(info, now_ms);
@@ -714,14 +714,14 @@
 void ReceiveStatisticsProxy::RtcpPacketTypesCounterUpdated(
     uint32_t ssrc,
     const RtcpPacketTypeCounter& packet_counter) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   if (stats_.ssrc != ssrc)
     return;
   stats_.rtcp_packet_type_counts = packet_counter;
 }
 
 void ReceiveStatisticsProxy::OnCname(uint32_t ssrc, absl::string_view cname) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   // TODO(pbos): Handle both local and remote ssrcs here and RTC_DCHECK that we
   // receive stats from one of them.
   if (stats_.ssrc != ssrc)
@@ -733,7 +733,7 @@
                                             absl::optional<uint8_t> qp,
                                             int32_t decode_time_ms,
                                             VideoContentType content_type) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
 
   uint64_t now_ms = clock_->TimeInMilliseconds();
 
@@ -799,7 +799,7 @@
   RTC_DCHECK_GT(width, 0);
   RTC_DCHECK_GT(height, 0);
   int64_t now_ms = clock_->TimeInMilliseconds();
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
 
   video_quality_observer_->OnRenderedFrame(frame, now_ms);
 
@@ -833,7 +833,7 @@
 void ReceiveStatisticsProxy::OnSyncOffsetUpdated(int64_t video_playout_ntp_ms,
                                                  int64_t sync_offset_ms,
                                                  double estimated_freq_khz) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   sync_offset_counter_.Add(std::abs(sync_offset_ms));
   stats_.sync_offset_ms = sync_offset_ms;
   last_estimated_playout_ntp_timestamp_ms_ = video_playout_ntp_ms;
@@ -851,7 +851,7 @@
 void ReceiveStatisticsProxy::OnCompleteFrame(bool is_keyframe,
                                              size_t size_bytes,
                                              VideoContentType content_type) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   if (is_keyframe) {
     ++stats_.frame_counts.key_frames;
   } else {
@@ -881,13 +881,13 @@
 }
 
 void ReceiveStatisticsProxy::OnDroppedFrames(uint32_t frames_dropped) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   stats_.frames_dropped += frames_dropped;
 }
 
 void ReceiveStatisticsProxy::OnPreDecode(VideoCodecType codec_type, int qp) {
   RTC_DCHECK_RUN_ON(&decode_thread_);
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   last_codec_type_ = codec_type;
   if (last_codec_type_ == kVideoCodecVP8 && qp != -1) {
     qp_counters_.vp8.Add(qp);
@@ -898,7 +898,7 @@
 void ReceiveStatisticsProxy::OnStreamInactive() {
   // TODO(sprang): Figure out any other state that should be reset.
 
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   // Don't report inter-frame delay if stream was paused.
   last_decoded_frame_time_ms_.reset();
   video_quality_observer_->OnStreamInactive();
@@ -906,7 +906,7 @@
 
 void ReceiveStatisticsProxy::OnRttUpdate(int64_t avg_rtt_ms,
                                          int64_t max_rtt_ms) {
-  rtc::CritScope lock(&crit_);
+  MutexLock lock(&mutex_);
   avg_rtt_ms_ = avg_rtt_ms;
 }