Removed usage of the deprecated critical section constructor in rtp_rtcp.
Review URL: http://webrtc-codereview.appspot.com/315004

git-svn-id: http://webrtc.googlecode.com/svn/trunk@1173 4adac7df-926f-26a2-2b94-8c16560cd09d
diff --git a/src/modules/rtp_rtcp/source/bandwidth_management.cc b/src/modules/rtp_rtcp/source/bandwidth_management.cc
index aa279e9..9d5cf68 100644
--- a/src/modules/rtp_rtcp/source/bandwidth_management.cc
+++ b/src/modules/rtp_rtcp/source/bandwidth_management.cc
@@ -19,7 +19,7 @@
 
 BandwidthManagement::BandwidthManagement(const WebRtc_Word32 id) :
     _id(id),
-    _critsect(*CriticalSectionWrapper::CreateCriticalSection()),
+    _critsect(CriticalSectionWrapper::CreateCriticalSection()),
     _lastPacketLossExtendedHighSeqNum(0),
     _lastReportAllLost(false),
     _lastLoss(0),
@@ -39,7 +39,7 @@
 
 BandwidthManagement::~BandwidthManagement()
 {
-    delete &_critsect;
+    delete _critsect;
 }
 
 WebRtc_Word32
diff --git a/src/modules/rtp_rtcp/source/bandwidth_management.h b/src/modules/rtp_rtcp/source/bandwidth_management.h
index aeb32b6..6761820 100644
--- a/src/modules/rtp_rtcp/source/bandwidth_management.h
+++ b/src/modules/rtp_rtcp/source/bandwidth_management.h
@@ -64,7 +64,7 @@
 
     WebRtc_Word32         _id;
 
-    CriticalSectionWrapper& _critsect;
+    CriticalSectionWrapper* _critsect;
 
     // incoming filters
     WebRtc_UWord32        _lastPacketLossExtendedHighSeqNum;
diff --git a/src/modules/rtp_rtcp/source/dtmf_queue.cc b/src/modules/rtp_rtcp/source/dtmf_queue.cc
index 72cd735..749309b 100644
--- a/src/modules/rtp_rtcp/source/dtmf_queue.cc
+++ b/src/modules/rtp_rtcp/source/dtmf_queue.cc
@@ -14,7 +14,7 @@
 
 namespace webrtc {
 DTMFqueue::DTMFqueue():
-    _DTMFCritsect(*CriticalSectionWrapper::CreateCriticalSection()),
+    _DTMFCritsect(CriticalSectionWrapper::CreateCriticalSection()),
     _nextEmptyIndex(0)
 {
     memset(_DTMFKey,0, sizeof(_DTMFKey));
@@ -24,7 +24,7 @@
 
 DTMFqueue::~DTMFqueue()
 {
-    delete &_DTMFCritsect;
+    delete _DTMFCritsect;
 }
 
 WebRtc_Word32
diff --git a/src/modules/rtp_rtcp/source/dtmf_queue.h b/src/modules/rtp_rtcp/source/dtmf_queue.h
index 67c47d0..8451a21 100644
--- a/src/modules/rtp_rtcp/source/dtmf_queue.h
+++ b/src/modules/rtp_rtcp/source/dtmf_queue.h
@@ -29,7 +29,7 @@
     void ResetDTMF();
 
 private:
-    CriticalSectionWrapper& _DTMFCritsect;
+    CriticalSectionWrapper* _DTMFCritsect;
     WebRtc_UWord8        _nextEmptyIndex;
     WebRtc_UWord8        _DTMFKey[DTMF_OUTBAND_MAX];
     WebRtc_UWord16       _DTMFLen[DTMF_OUTBAND_MAX];
diff --git a/src/modules/rtp_rtcp/source/rtcp_receiver.cc b/src/modules/rtp_rtcp/source/rtcp_receiver.cc
index dabfe71..9b76e46 100644
--- a/src/modules/rtp_rtcp/source/rtcp_receiver.cc
+++ b/src/modules/rtp_rtcp/source/rtcp_receiver.cc
@@ -35,10 +35,11 @@
     _method(kRtcpOff),
     _lastReceived(0),
     _rtpRtcp(*owner),
-    _criticalSectionFeedbacks(*CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSectionFeedbacks(CriticalSectionWrapper::CreateCriticalSection()),
     _cbRtcpFeedback(NULL),
     _cbVideoFeedback(NULL),
-    _criticalSectionRTCPReceiver(*CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSectionRTCPReceiver(
+        CriticalSectionWrapper::CreateCriticalSection()),
     _SSRC(0),
     _remoteSSRC(0),
     _remoteSenderInfo(),
@@ -53,8 +54,8 @@
 
 RTCPReceiver::~RTCPReceiver()
 {
-    delete &_criticalSectionRTCPReceiver;
-    delete &_criticalSectionFeedbacks;
+    delete _criticalSectionRTCPReceiver;
+    delete _criticalSectionFeedbacks;
 
     bool loop = true;
     do
@@ -481,13 +482,13 @@
         }
     }
 
-    _criticalSectionRTCPReceiver.Leave();
+    _criticalSectionRTCPReceiver->Leave();
      // to avoid problem with accuireing _criticalSectionRTCPSender while holding _criticalSectionRTCPReceiver
 
     WebRtc_UWord32 sendTimeMS = 
         _rtpRtcp.SendTimeOfSendReport(rtcpPacket.ReportBlockItem.LastSR);
 
-    _criticalSectionRTCPReceiver.Enter();
+    _criticalSectionRTCPReceiver->Enter();
 
     // ReportBlockItem.SSRC is who it's to
     // we store all incoming reports, used in conference relay
diff --git a/src/modules/rtp_rtcp/source/rtcp_receiver.h b/src/modules/rtp_rtcp/source/rtcp_receiver.h
index cac5a69..5d8f143 100644
--- a/src/modules/rtp_rtcp/source/rtcp_receiver.h
+++ b/src/modules/rtp_rtcp/source/rtcp_receiver.h
@@ -187,11 +187,11 @@
     WebRtc_UWord32          _lastReceived;
     ModuleRtpRtcpImpl&      _rtpRtcp;
 
-    CriticalSectionWrapper& _criticalSectionFeedbacks;
+    CriticalSectionWrapper* _criticalSectionFeedbacks;
     RtcpFeedback*           _cbRtcpFeedback;
     RtpVideoFeedback*       _cbVideoFeedback;
 
-    CriticalSectionWrapper& _criticalSectionRTCPReceiver;
+    CriticalSectionWrapper* _criticalSectionRTCPReceiver;
     WebRtc_UWord32          _SSRC;
     WebRtc_UWord32          _remoteSSRC;
 
diff --git a/src/modules/rtp_rtcp/source/rtcp_sender.cc b/src/modules/rtp_rtcp/source/rtcp_sender.cc
index cf9885c..2ae88fc 100644
--- a/src/modules/rtp_rtcp/source/rtcp_sender.cc
+++ b/src/modules/rtp_rtcp/source/rtcp_sender.cc
@@ -31,10 +31,10 @@
     _clock(*clock),
     _method(kRtcpOff),
     _rtpRtcp(*owner),
-    _criticalSectionTransport(*CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSectionTransport(CriticalSectionWrapper::CreateCriticalSection()),
     _cbTransport(NULL),
 
-    _criticalSectionRTCPSender(*CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSectionRTCPSender(CriticalSectionWrapper::CreateCriticalSection()),
     _usingNack(false),
     _sending(false),
     _sendTMMBN(false),
@@ -112,8 +112,8 @@
         _csrcCNAMEs.Erase(item);
         item = _csrcCNAMEs.First();
     }
-    delete &_criticalSectionTransport;
-    delete &_criticalSectionRTCPSender;
+    delete _criticalSectionTransport;
+    delete _criticalSectionRTCPSender;
 
     WEBRTC_TRACE(kTraceMemory, kTraceRtpRtcp, _id, "%s deleted", __FUNCTION__);
 }
diff --git a/src/modules/rtp_rtcp/source/rtcp_sender.h b/src/modules/rtp_rtcp/source/rtcp_sender.h
index e744afd..109d4b5 100644
--- a/src/modules/rtp_rtcp/source/rtcp_sender.h
+++ b/src/modules/rtp_rtcp/source/rtcp_sender.h
@@ -178,10 +178,10 @@
 
     ModuleRtpRtcpImpl&      _rtpRtcp;
 
-    CriticalSectionWrapper& _criticalSectionTransport;
+    CriticalSectionWrapper* _criticalSectionTransport;
     Transport*              _cbTransport;
 
-    CriticalSectionWrapper& _criticalSectionRTCPSender;
+    CriticalSectionWrapper* _criticalSectionRTCPSender;
     bool                    _usingNack;
     bool                    _sending;
     bool                    _sendTMMBN;
diff --git a/src/modules/rtp_rtcp/source/rtp_receiver.cc b/src/modules/rtp_rtcp/source/rtp_receiver.cc
index 26fdb9b..570fa7e 100644
--- a/src/modules/rtp_rtcp/source/rtp_receiver.cc
+++ b/src/modules/rtp_rtcp/source/rtp_receiver.cc
@@ -31,11 +31,12 @@
     _id(id),
     _audio(audio),
     _rtpRtcp(*owner),
-    _criticalSectionCbs(*CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSectionCbs(CriticalSectionWrapper::CreateCriticalSection()),
     _cbRtpFeedback(NULL),
     _cbRtpData(NULL),
 
-    _criticalSectionRTPReceiver(*CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSectionRTPReceiver(
+        CriticalSectionWrapper::CreateCriticalSection()),
     _lastReceiveTime(0),
     _lastReceivedPayloadLength(0),
     _lastReceivedPayloadType(-1),
@@ -101,8 +102,8 @@
             _cbRtpFeedback->OnIncomingCSRCChanged(_id,_currentRemoteCSRC[i], false);
         }
     }
-    delete &_criticalSectionCbs;
-    delete &_criticalSectionRTPReceiver;
+    delete _criticalSectionCbs;
+    delete _criticalSectionRTPReceiver;
 
     // empty map
     bool loop = true;
diff --git a/src/modules/rtp_rtcp/source/rtp_receiver.h b/src/modules/rtp_rtcp/source/rtp_receiver.h
index 03a3b0d..a289fbf 100644
--- a/src/modules/rtp_rtcp/source/rtp_receiver.h
+++ b/src/modules/rtp_rtcp/source/rtp_receiver.h
@@ -174,11 +174,11 @@
     const bool              _audio;
     ModuleRtpRtcpImpl&      _rtpRtcp;
 
-    CriticalSectionWrapper&    _criticalSectionCbs;
+    CriticalSectionWrapper*    _criticalSectionCbs;
     RtpFeedback*        _cbRtpFeedback;
     RtpData*            _cbRtpData;
 
-    CriticalSectionWrapper&    _criticalSectionRTPReceiver;
+    CriticalSectionWrapper*    _criticalSectionRTPReceiver;
     mutable WebRtc_UWord32    _lastReceiveTime;
     WebRtc_UWord16            _lastReceivedPayloadLength;
     WebRtc_Word8              _lastReceivedPayloadType;
diff --git a/src/modules/rtp_rtcp/source/rtp_receiver_audio.cc b/src/modules/rtp_rtcp/source/rtp_receiver_audio.cc
index 2458725..cb75c9e 100644
--- a/src/modules/rtp_rtcp/source/rtp_receiver_audio.cc
+++ b/src/modules/rtp_rtcp/source/rtp_receiver_audio.cc
@@ -31,14 +31,14 @@
     _cngPayloadType(-1),
     _G722PayloadType(-1),
     _lastReceivedG722(false),
-    _criticalSectionFeedback(*CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSectionFeedback(CriticalSectionWrapper::CreateCriticalSection()),
     _cbAudioFeedback(NULL)
 {
 }
 
 RTPReceiverAudio::~RTPReceiverAudio()
 {
-    delete &_criticalSectionFeedback;
+    delete _criticalSectionFeedback;
 }
 
 WebRtc_Word32
diff --git a/src/modules/rtp_rtcp/source/rtp_receiver_audio.h b/src/modules/rtp_rtcp/source/rtp_receiver_audio.h
index 6fe9bf5..8a7172a 100644
--- a/src/modules/rtp_rtcp/source/rtp_receiver_audio.h
+++ b/src/modules/rtp_rtcp/source/rtp_receiver_audio.h
@@ -89,7 +89,7 @@
     WebRtc_Word8              _G722PayloadType;
     bool                    _lastReceivedG722;
 
-    CriticalSectionWrapper&    _criticalSectionFeedback;
+    CriticalSectionWrapper* _criticalSectionFeedback;
     RtpAudioFeedback*   _cbAudioFeedback;
 };
 } // namespace webrtc
diff --git a/src/modules/rtp_rtcp/source/rtp_receiver_video.cc b/src/modules/rtp_rtcp/source/rtp_receiver_video.cc
index a681760..051f752 100644
--- a/src/modules/rtp_rtcp/source/rtp_receiver_video.cc
+++ b/src/modules/rtp_rtcp/source/rtp_receiver_video.cc
@@ -28,10 +28,10 @@
                                    ModuleRtpRtcpImpl* owner):
     _id(id),
     _rtpRtcp(*owner),
-    _criticalSectionFeedback(*CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSectionFeedback(CriticalSectionWrapper::CreateCriticalSection()),
     _cbVideoFeedback(NULL),
-    _criticalSectionReceiverVideo(*CriticalSectionWrapper::CreateCriticalSection()),
-
+    _criticalSectionReceiverVideo(
+        CriticalSectionWrapper::CreateCriticalSection()),
     _completeFrame(false),
     _packetStartTimeMs(0),
     _receivedBW(),
@@ -49,8 +49,8 @@
 
 RTPReceiverVideo::~RTPReceiverVideo()
 {
-    delete &_criticalSectionFeedback;
-    delete &_criticalSectionReceiverVideo;
+    delete _criticalSectionFeedback;
+    delete _criticalSectionReceiverVideo;
     delete _receiveFEC;
 }
 
@@ -228,7 +228,7 @@
 {
     WebRtc_Word32 retVal = 0;
 
-    _criticalSectionReceiverVideo.Enter();
+    _criticalSectionReceiverVideo->Enter();
 
     _videoBitRate.Update(payloadDataLength, nowMS);
 
@@ -242,7 +242,7 @@
     {
         if(_receiveFEC == NULL)
         {
-            _criticalSectionReceiverVideo.Leave();
+            _criticalSectionReceiverVideo->Leave();
             return -1;
         }
         if (rtpHeader->header.timestamp != TimeStamp())
@@ -269,7 +269,7 @@
                 _receiveFEC->AddReceivedFECInfo(rtpHeader,incomingRtpPacket, FECpacket);
             }
         }
-        _criticalSectionReceiverVideo.Leave();
+        _criticalSectionReceiverVideo->Leave();
 
         if(retVal == 0 && FECpacket )
         {
@@ -296,18 +296,18 @@
 
     // Update the remote rate control object and update the overuse
     // detector with the current rate control region.
-    _criticalSectionReceiverVideo.Enter();
+    _criticalSectionReceiverVideo->Enter();
     const RateControlInput input(_overUseDetector.State(),
                                  _videoBitRate.BitRate(nowMS),
                                  _overUseDetector.NoiseVar());
-    _criticalSectionReceiverVideo.Leave();
+    _criticalSectionReceiverVideo->Leave();
 
     // Call the callback outside critical section
     const RateControlRegion region = _rtpRtcp.OnOverUseStateUpdate(input);
 
-    _criticalSectionReceiverVideo.Enter();
+    _criticalSectionReceiverVideo->Enter();
     _overUseDetector.SetRateControlRegion(region);
-    _criticalSectionReceiverVideo.Leave();
+    _criticalSectionReceiverVideo->Leave();
 
     return retVal;
 }
@@ -356,7 +356,7 @@
                                                  const WebRtc_UWord8* payloadData,
                                                  const WebRtc_UWord16 payloadDataLength)
 {
-     _criticalSectionReceiverVideo.Enter();
+     _criticalSectionReceiverVideo->Enter();
 
     _currentFecFrameDecoded = true;
 
@@ -450,7 +450,7 @@
         retVal = ReceiveMPEG4Codec(rtpHeader,payloadData, payloadDataLength);
         break;
     default:
-        _criticalSectionReceiverVideo.Leave();
+        _criticalSectionReceiverVideo->Leave();
         assert(((void)"ParseCodecSpecific videoType can not be unknown here!", false));
         return -1;
     }
@@ -470,7 +470,7 @@
     const bool success = rtpPayloadParser.Parse(parsedPacket);
 
     // from here down we only work on local data
-    _criticalSectionReceiverVideo.Leave();
+    _criticalSectionReceiverVideo->Leave();
 
     if (!success)
     {
@@ -498,17 +498,17 @@
     const bool success = rtpPayloadParser.Parse(parsedPacket);
     if (!success)
     {
-        _criticalSectionReceiverVideo.Leave();
+        _criticalSectionReceiverVideo->Leave();
         return -1;
     }
     if (IP_PACKET_SIZE < parsedPacket.info.H263.dataLength +
         (parsedPacket.info.H263.insert2byteStartCode ? 2 : 0))
     {
-        _criticalSectionReceiverVideo.Leave();
+        _criticalSectionReceiverVideo->Leave();
         return -1;
     }
     // from here down we only work on local data
-    _criticalSectionReceiverVideo.Leave();
+    _criticalSectionReceiverVideo->Leave();
 
     return ReceiveH263CodecCommon(parsedPacket, rtpHeader);
 }
@@ -590,11 +590,11 @@
     const bool success = rtpPayloadParser.Parse(parsedPacket);
     if (!success)
     {
-        _criticalSectionReceiverVideo.Leave();
+        _criticalSectionReceiverVideo->Leave();
         return -1;
     }
     // from here down we only work on local data
-    _criticalSectionReceiverVideo.Leave();
+    _criticalSectionReceiverVideo->Leave();
 
     rtpHeader->frameType = (parsedPacket.frameType == ModuleRTPUtility::kIFrame) ? kVideoFrameKey : kVideoFrameDelta;
     rtpHeader->type.Video.isFirstPacket = parsedPacket.info.MPEG4.isFirstPacket;
@@ -622,7 +622,7 @@
     const bool success = rtpPayloadParser.Parse(parsedPacket);
 
     // from here down we only work on local data
-    _criticalSectionReceiverVideo.Leave();
+    _criticalSectionReceiverVideo->Leave();
 
     if (!success)
     {
@@ -681,7 +681,7 @@
     {
         rtpHeader->type.Video.isFirstPacket = true;
     }
-    _criticalSectionReceiverVideo.Leave();
+    _criticalSectionReceiverVideo->Leave();
 
     if(CallbackOfReceivedPayloadData(payloadData, payloadDataLength, rtpHeader) != 0)
     {
diff --git a/src/modules/rtp_rtcp/source/rtp_receiver_video.h b/src/modules/rtp_rtcp/source/rtp_receiver_video.h
index 737699a..7893426 100644
--- a/src/modules/rtp_rtcp/source/rtp_receiver_video.h
+++ b/src/modules/rtp_rtcp/source/rtp_receiver_video.h
@@ -132,10 +132,10 @@
     WebRtc_Word32             _id;
     ModuleRtpRtcpImpl&        _rtpRtcp;
 
-    CriticalSectionWrapper&   _criticalSectionFeedback;
+    CriticalSectionWrapper*   _criticalSectionFeedback;
     RtpVideoFeedback*         _cbVideoFeedback;
 
-    CriticalSectionWrapper&   _criticalSectionReceiverVideo;
+    CriticalSectionWrapper*   _criticalSectionReceiverVideo;
 
     // bandwidth
     bool                      _completeFrame;
diff --git a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
index a18f690..23d55b2 100644
--- a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
+++ b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.cc
@@ -89,8 +89,9 @@
     _lastProcessTime(clock->GetTimeInMS()),
 
     _packetOverHead(28), // IPV4 UDP
-    _criticalSectionModulePtrs(*CriticalSectionWrapper::CreateCriticalSection()),
-    _criticalSectionModulePtrsFeedback(*CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSectionModulePtrs(CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSectionModulePtrsFeedback(
+        CriticalSectionWrapper::CreateCriticalSection()),
     _defaultModule(NULL),
     _audioModule(NULL),
     _videoModule(NULL),
@@ -165,8 +166,8 @@
     }
 #endif
 
-    delete &_criticalSectionModulePtrs;
-    delete &_criticalSectionModulePtrsFeedback;
+    delete _criticalSectionModulePtrs;
+    delete _criticalSectionModulePtrsFeedback;
 }
 
 WebRtc_Word32
diff --git a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h
index c0269cf..5da611a 100644
--- a/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h
+++ b/src/modules/rtp_rtcp/source/rtp_rtcp_impl.h
@@ -544,8 +544,8 @@
     WebRtc_UWord32            _lastProcessTime;
     WebRtc_UWord16            _packetOverHead;
 
-    CriticalSectionWrapper&       _criticalSectionModulePtrs;
-    CriticalSectionWrapper&       _criticalSectionModulePtrsFeedback;
+    CriticalSectionWrapper*       _criticalSectionModulePtrs;
+    CriticalSectionWrapper*       _criticalSectionModulePtrsFeedback;
     ModuleRtpRtcpImpl*            _defaultModule;
     ModuleRtpRtcpImpl*            _audioModule;
     ModuleRtpRtcpImpl*            _videoModule;
diff --git a/src/modules/rtp_rtcp/source/rtp_sender.cc b/src/modules/rtp_rtcp/source/rtp_sender.cc
index 617faf7..2af0dbf 100644
--- a/src/modules/rtp_rtcp/source/rtp_sender.cc
+++ b/src/modules/rtp_rtcp/source/rtp_sender.cc
@@ -27,8 +27,8 @@
     _audioConfigured(audio),
     _audio(NULL),
     _video(NULL),
-    _sendCritsect(*CriticalSectionWrapper::CreateCriticalSection()),
-    _transportCritsect(*CriticalSectionWrapper::CreateCriticalSection()),
+    _sendCritsect(CriticalSectionWrapper::CreateCriticalSection()),
+    _transportCritsect(CriticalSectionWrapper::CreateCriticalSection()),
 
     _transport(NULL),
 
@@ -48,7 +48,7 @@
 
     _storeSentPackets(false),
     _storeSentPacketsNumber(0),
-    _prevSentPacketsCritsect(*CriticalSectionWrapper::CreateCriticalSection()),
+    _prevSentPacketsCritsect(CriticalSectionWrapper::CreateCriticalSection()),
     _prevSentPacketsIndex(0),
     _ptrPrevSentPackets(NULL),
     _prevSentPacketsSeqNum(NULL),
@@ -107,9 +107,9 @@
     _ssrcDB.ReturnSSRC(_ssrc);
 
     SSRCDatabase::ReturnSSRCDatabase();
-    delete &_prevSentPacketsCritsect;
-    delete &_sendCritsect;
-    delete &_transportCritsect;
+    delete _prevSentPacketsCritsect;
+    delete _sendCritsect;
+    delete _transportCritsect;
 
     // empty map
     bool loop = true;
diff --git a/src/modules/rtp_rtcp/source/rtp_sender.h b/src/modules/rtp_rtcp/source/rtp_sender.h
index b4d17a3..0d47926 100644
--- a/src/modules/rtp_rtcp/source/rtp_sender.h
+++ b/src/modules/rtp_rtcp/source/rtp_sender.h
@@ -267,9 +267,9 @@
     RTPSenderAudio*         _audio;
     RTPSenderVideo*         _video;
 
-    CriticalSectionWrapper&    _sendCritsect;
+    CriticalSectionWrapper*    _sendCritsect;
 
-    CriticalSectionWrapper&    _transportCritsect;
+    CriticalSectionWrapper*    _transportCritsect;
     Transport*         _transport;
 
     bool                      _sendingMedia;
@@ -288,7 +288,7 @@
 
     bool                      _storeSentPackets;
     WebRtc_UWord16            _storeSentPacketsNumber;
-    CriticalSectionWrapper&    _prevSentPacketsCritsect;
+    CriticalSectionWrapper*    _prevSentPacketsCritsect;
     WebRtc_Word32             _prevSentPacketsIndex;
     WebRtc_Word8**            _ptrPrevSentPackets;
     WebRtc_UWord16*           _prevSentPacketsSeqNum;
diff --git a/src/modules/rtp_rtcp/source/rtp_sender_audio.cc b/src/modules/rtp_rtcp/source/rtp_sender_audio.cc
index 5d690c1..854f394 100644
--- a/src/modules/rtp_rtcp/source/rtp_sender_audio.cc
+++ b/src/modules/rtp_rtcp/source/rtp_sender_audio.cc
@@ -19,9 +19,9 @@
     _id(id),
     _clock(*clock),
     _rtpSender(rtpSender),
-    _audioFeedbackCritsect(*CriticalSectionWrapper::CreateCriticalSection()),
+    _audioFeedbackCritsect(CriticalSectionWrapper::CreateCriticalSection()),
     _audioFeedback(NULL),
-    _sendAudioCritsect(*CriticalSectionWrapper::CreateCriticalSection()),
+    _sendAudioCritsect(CriticalSectionWrapper::CreateCriticalSection()),
     _frequency(8000),
     _packetSizeSamples(160),
     _dtmfEventIsOn(false),
@@ -46,8 +46,8 @@
 
 RTPSenderAudio::~RTPSenderAudio()
 {
-    delete &_sendAudioCritsect;
-    delete &_audioFeedbackCritsect;
+    delete _sendAudioCritsect;
+    delete _audioFeedbackCritsect;
 }
 
 WebRtc_Word32
@@ -296,7 +296,7 @@
     // A source MAY send events and coded audio packets for the same time
     // but we don't support it
     {
-        _sendAudioCritsect.Enter();
+        _sendAudioCritsect->Enter();
 
         if (_dtmfEventIsOn)
         {
@@ -307,7 +307,7 @@
                 if(_packetSizeSamples > (captureTimeStamp - _dtmfTimestampLastSent) )
                 {
                     // not time to send yet
-                    _sendAudioCritsect.Leave();
+                    _sendAudioCritsect->Leave();
                     return 0;
                 }
             }
@@ -333,7 +333,7 @@
                 _dtmfTimeLastSent = _clock.GetTimeInMS();
             }
             // don't hold the critsect while calling SendTelephoneEventPacket
-            _sendAudioCritsect.Leave();
+            _sendAudioCritsect->Leave();
             if(send)
             {
                 if(dtmfDurationSamples > 0xffff)
@@ -357,7 +357,7 @@
             }
             return(0);
         }
-        _sendAudioCritsect.Leave();
+        _sendAudioCritsect->Leave();
     }
     if(payloadSize == 0 || payloadData == NULL)
     {
@@ -627,7 +627,7 @@
     }
     do
     {
-        _sendAudioCritsect.Enter();
+        _sendAudioCritsect->Enter();
 
         //Send DTMF data
         _rtpSender->BuildRTPheader(dtmfbuffer, _dtmfPayloadType, markerBit, dtmfTimeStamp);
@@ -661,7 +661,7 @@
         dtmfbuffer[13] = E|R|volume;
         ModuleRTPUtility::AssignUWord16ToBuffer(dtmfbuffer+14, duration);
 
-        _sendAudioCritsect.Leave();
+        _sendAudioCritsect->Leave();
         retVal = _rtpSender->SendToNetwork(dtmfbuffer, 4, 12);
         sendCount--;
 
diff --git a/src/modules/rtp_rtcp/source/rtp_sender_audio.h b/src/modules/rtp_rtcp/source/rtp_sender_audio.h
index 0e0b20b..d51a473 100644
--- a/src/modules/rtp_rtcp/source/rtp_sender_audio.h
+++ b/src/modules/rtp_rtcp/source/rtp_sender_audio.h
@@ -95,10 +95,10 @@
     WebRtc_Word32             _id;
     RtpRtcpClock&             _clock;
     RTPSenderInterface*     _rtpSender;
-    CriticalSectionWrapper&    _audioFeedbackCritsect;
+    CriticalSectionWrapper* _audioFeedbackCritsect;
     RtpAudioFeedback*   _audioFeedback;
 
-    CriticalSectionWrapper&    _sendAudioCritsect;
+    CriticalSectionWrapper*   _sendAudioCritsect;
 
     WebRtc_UWord32            _frequency;
     WebRtc_UWord16            _packetSizeSamples;
diff --git a/src/modules/rtp_rtcp/source/rtp_sender_video.cc b/src/modules/rtp_rtcp/source/rtp_sender_video.cc
index ecd9e8d..a8a78d0 100644
--- a/src/modules/rtp_rtcp/source/rtp_sender_video.cc
+++ b/src/modules/rtp_rtcp/source/rtp_sender_video.cc
@@ -30,7 +30,7 @@
                                RTPSenderInterface* rtpSender) :
     _id(id),
     _rtpSender(*rtpSender),
-    _sendVideoCritsect(*CriticalSectionWrapper::CreateCriticalSection()),
+    _sendVideoCritsect(CriticalSectionWrapper::CreateCriticalSection()),
 
     _videoType(kRtpNoVideo),
     _videoCodecInformation(NULL),
@@ -63,7 +63,7 @@
     {
         delete _videoCodecInformation;
     }
-    delete &_sendVideoCritsect;
+    delete _sendVideoCritsect;
 }
 
 WebRtc_Word32
diff --git a/src/modules/rtp_rtcp/source/rtp_sender_video.h b/src/modules/rtp_rtcp/source/rtp_sender_video.h
index 47f5ec7..989205f 100644
--- a/src/modules/rtp_rtcp/source/rtp_sender_video.h
+++ b/src/modules/rtp_rtcp/source/rtp_sender_video.h
@@ -150,7 +150,7 @@
     WebRtc_Word32             _id;
     RTPSenderInterface&        _rtpSender;
 
-    CriticalSectionWrapper&    _sendVideoCritsect;
+    CriticalSectionWrapper*   _sendVideoCritsect;
     RtpVideoCodecTypes  _videoType;
     VideoCodecInformation*  _videoCodecInformation;
     WebRtc_UWord32            _maxBitrate;
diff --git a/src/modules/rtp_rtcp/source/ssrc_database.cc b/src/modules/rtp_rtcp/source/ssrc_database.cc
index befc5ee..b3e9ab0 100644
--- a/src/modules/rtp_rtcp/source/ssrc_database.cc
+++ b/src/modules/rtp_rtcp/source/ssrc_database.cc
@@ -54,7 +54,7 @@
 WebRtc_UWord32
 SSRCDatabase::CreateSSRC()
 {
-    CriticalSectionScoped lock(*_critSect);
+    CriticalSectionScoped lock(_critSect);
 
     WebRtc_UWord32 ssrc = GenerateRandom();
 
@@ -103,7 +103,7 @@
 WebRtc_Word32
 SSRCDatabase::RegisterSSRC(const WebRtc_UWord32 ssrc)
 {
-    CriticalSectionScoped lock(*_critSect);
+    CriticalSectionScoped lock(_critSect);
 
 #ifndef WEBRTC_NO_STL
 
@@ -143,7 +143,7 @@
 WebRtc_Word32
 SSRCDatabase::ReturnSSRC(const WebRtc_UWord32 ssrc)
 {
-    CriticalSectionScoped lock(*_critSect);
+    CriticalSectionScoped lock(_critSect);
 
 #ifndef WEBRTC_NO_STL
     _ssrcMap.erase(ssrc);
diff --git a/src/modules/rtp_rtcp/source/tmmbr_help.cc b/src/modules/rtp_rtcp/source/tmmbr_help.cc
index 43537f8..cf34e08 100644
--- a/src/modules/rtp_rtcp/source/tmmbr_help.cc
+++ b/src/modules/rtp_rtcp/source/tmmbr_help.cc
@@ -62,7 +62,7 @@
 }
 
 TMMBRHelp::TMMBRHelp(const bool audio) :
-    _criticalSection(*CriticalSectionWrapper::CreateCriticalSection()),
+    _criticalSection(CriticalSectionWrapper::CreateCriticalSection()),
     _audio(audio),
     _candidateSet(),
     _boundingSet(),
@@ -78,7 +78,7 @@
     delete [] _ptrMaxPRBoundingSet;
     _ptrIntersectionBoundingSet = 0;
     _ptrMaxPRBoundingSet = 0;
-    delete &_criticalSection;
+    delete _criticalSection;
 }
 
 TMMBRSet*
diff --git a/src/modules/rtp_rtcp/source/tmmbr_help.h b/src/modules/rtp_rtcp/source/tmmbr_help.h
index 0575f1d..35704fe 100644
--- a/src/modules/rtp_rtcp/source/tmmbr_help.h
+++ b/src/modules/rtp_rtcp/source/tmmbr_help.h
@@ -65,7 +65,7 @@
     WebRtc_Word32 FindTMMBRBoundingSet(WebRtc_Word32 numCandidates, TMMBRSet& candidateSet);
 
 private:
-    CriticalSectionWrapper& _criticalSection;
+    CriticalSectionWrapper* _criticalSection;
     const bool              _audio;
     TMMBRSet                _candidateSet;
     TMMBRSet                _boundingSet;
diff --git a/src/modules/rtp_rtcp/test/BWEStandAlone/BWETestBase.cpp b/src/modules/rtp_rtcp/test/BWEStandAlone/BWETestBase.cpp
index edc26c8..2940abd 100644
--- a/src/modules/rtp_rtcp/test/BWEStandAlone/BWETestBase.cpp
+++ b/src/modules/rtp_rtcp/test/BWEStandAlone/BWETestBase.cpp
@@ -199,7 +199,7 @@
 _procThread(NULL),
 _startTimeMs(-1),
 _stopTimeMs(-1),
-_statCritSect(*CriticalSectionWrapper::CreateCriticalSection())
+_statCritSect(CriticalSectionWrapper::CreateCriticalSection())
 {
     _sendrec = new TestSenderReceiver();
 }
@@ -212,7 +212,7 @@
         Stop();
     }
 
-    _statCritSect.Enter();
+    _statCritSect->Enter();
     delete &_statCritSect;
 
     if (_sendrec)
diff --git a/src/modules/rtp_rtcp/test/BWEStandAlone/BWETestBase.h b/src/modules/rtp_rtcp/test/BWEStandAlone/BWETestBase.h
index 2dccdb0..bab1b94 100644
--- a/src/modules/rtp_rtcp/test/BWEStandAlone/BWETestBase.h
+++ b/src/modules/rtp_rtcp/test/BWEStandAlone/BWETestBase.h
@@ -76,7 +76,7 @@
     WebRtc_Word64 _stopTimeMs;
 
     // Statistics, protected by separate CritSect
-    CriticalSectionWrapper& _statCritSect;
+    CriticalSectionWrapper* _statCritSect;
     StatVec _rateVecKbps;
     StatVec _rttVecMs;
     StatVec _lossVec;
diff --git a/src/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.cc b/src/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.cc
index e708b0f..9c81fd0 100644
--- a/src/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.cc
+++ b/src/modules/rtp_rtcp/test/BWEStandAlone/MatlabPlot.cc
@@ -386,7 +386,7 @@
 _legendEnabled(true),
 _donePlottingEvent(EventWrapper::Create())
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     _xlim[0] = 0;
     _xlim[1] = 0;
@@ -419,7 +419,7 @@
 
 int MatlabPlot::AddLine(int maxLen /*= -1*/, const char *plotAttrib /*= NULL*/, const char *name /*= NULL*/)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
     if (!_enabled)
     {
         return -1;
@@ -435,7 +435,7 @@
 int MatlabPlot::AddTimeLine(int maxLen /*= -1*/, const char *plotAttrib /*= NULL*/, const char *name /*= NULL*/,
                             WebRtc_Word64 refTimeMs /*= -1*/)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     if (!_enabled)
     {
@@ -451,7 +451,7 @@
 
 int MatlabPlot::GetLineIx(const char *name)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     if (!_enabled)
     {
@@ -485,7 +485,7 @@
 
 void MatlabPlot::Append(int lineIndex, double x, double y)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     if (!_enabled)
     {
@@ -505,7 +505,7 @@
 
 void MatlabPlot::Append(int lineIndex, double y)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     if (!_enabled)
     {
@@ -525,7 +525,7 @@
 
 int MatlabPlot::Append(const char *name, double x, double y)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     if (!_enabled)
     {
@@ -548,7 +548,7 @@
 
 int MatlabPlot::Append(const char *name, double y)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     if (!_enabled)
     {
@@ -571,7 +571,7 @@
 
 int MatlabPlot::Length(char *name)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     if (!_enabled)
     {
@@ -592,7 +592,7 @@
 
 void MatlabPlot::SetPlotAttribute(char *name, char *plotAttrib)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     if (!_enabled)
     {
@@ -789,7 +789,7 @@
 
 void MatlabPlot::Plot()
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     _timeToPlot = true;
 
@@ -801,7 +801,7 @@
 
 void MatlabPlot::Reset()
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     _enabled = true;
 
@@ -814,7 +814,7 @@
 
 void MatlabPlot::SetFigHandle(int handle)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     if (handle > 0)
         _figHandle = handle;
@@ -823,21 +823,21 @@
 bool
 MatlabPlot::TimeToPlot()
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
     return _enabled && _timeToPlot;
 }
 
 void
 MatlabPlot::Plotting()
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
     _plotting = true;
 }
 
 void
 MatlabPlot::DonePlotting()
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
     _timeToPlot = false;
     _plotting = false;
     _donePlottingEvent->Set();
@@ -858,7 +858,7 @@
 
 int MatlabPlot::MakeTrend(const char *sourceName, const char *trendName, double slope, double offset, const char *plotAttrib)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     int sourceIx;
     int trendIx;
@@ -941,7 +941,7 @@
 
 MatlabPlot * MatlabEngine::NewPlot(MatlabPlot *newPlot)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     //MatlabPlot *newPlot = new MatlabPlot();
 
@@ -958,7 +958,7 @@
 
 void MatlabEngine::DeletePlot(MatlabPlot *plot)
 {
-    CriticalSectionScoped cs(*_critSect);
+    CriticalSectionScoped cs(_critSect);
 
     if (plot == NULL)
     {
diff --git a/src/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc b/src/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc
index 20ffe60..d322242 100644
--- a/src/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc
+++ b/src/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.cc
@@ -33,7 +33,7 @@
 
 TestLoadGenerator::TestLoadGenerator(TestSenderReceiver *sender, WebRtc_Word32 rtpSampleRate)
 :
-_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
+_critSect(CriticalSectionWrapper::CreateCriticalSection()),
 _eventPtr(NULL),
 _genThread(NULL),
 _bitrateKbps(0),
@@ -50,7 +50,7 @@
         Stop();
     }
 
-    delete &_critSect;
+    delete _critSect;
 }
 
 WebRtc_Word32 TestLoadGenerator::SetBitrate (WebRtc_Word32 newBitrateKbps)
diff --git a/src/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h b/src/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h
index 4ab7519..c22591c 100644
--- a/src/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h
+++ b/src/modules/rtp_rtcp/test/BWEStandAlone/TestLoadGenerator.h
@@ -42,7 +42,7 @@
         const WebRtc_UWord32 payloadSize,
         const webrtc::FrameType frameType = webrtc::kVideoFrameDelta);
 
-    webrtc::CriticalSectionWrapper& _critSect;
+    webrtc::CriticalSectionWrapper* _critSect;
     webrtc::EventWrapper *_eventPtr;
     webrtc::ThreadWrapper* _genThread;
     WebRtc_Word32 _bitrateKbps;
diff --git a/src/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc b/src/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc
index 2e8270a..1fc0fd3 100644
--- a/src/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc
+++ b/src/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.cc
@@ -37,7 +37,7 @@
 
 TestSenderReceiver::TestSenderReceiver (void)
 :
-_critSect(*CriticalSectionWrapper::CreateCriticalSection()),
+_critSect(CriticalSectionWrapper::CreateCriticalSection()),
 _eventPtr(NULL),
 _procThread(NULL),
 _running(false),
@@ -85,7 +85,7 @@
 
     Stop(); // N.B. without critSect
 
-    _critSect.Enter();
+    _critSect->Enter();
 
     if (_rtp)
     {
@@ -99,7 +99,7 @@
         _transport = NULL;
     }
 
-    delete &_critSect;
+    delete _critSect;
 
 }
 
@@ -440,5 +440,3 @@
             bwEstimateKbitMax);
     }
 }
-
-
diff --git a/src/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h b/src/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h
index cc9ccdd..7f7f2f0 100644
--- a/src/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h
+++ b/src/modules/rtp_rtcp/test/BWEStandAlone/TestSenderReceiver.h
@@ -148,7 +148,7 @@
 private:
     RtpRtcp* _rtp;
     UdpTransport* _transport;
-    webrtc::CriticalSectionWrapper& _critSect;
+    webrtc::CriticalSectionWrapper* _critSect;
     webrtc::EventWrapper *_eventPtr;
     webrtc::ThreadWrapper* _procThread;
     bool _running;