Reland 8631 "Speculative revert of 8631 "Remove lock from Bitrat..."
> Speculative revert of 8631 "Remove lock from Bitrate() and FrameRate() in Video..." > > We ran into the alignment problem on Mac 10.9 debug again. This is the only CL I see in the range that adds an rtc::CriticalSection, so I'm trying out reverting it before attempting another roll. > > > Remove lock from Bitrate() and FrameRate() in VideoSender. > > These methods are called on the VideoSender's construction thread, which is the same thread as modifies the value of _encoder. It's therefore safe to not require a lock to access _encoder on this thread. > > > > I'm making access to the rate variables from VCMGenericEncoder, thread safe, by using a lock that's not associated with the encoder. There should be little to no contention there. While modifying VCMGenericEncoder, I noticed that a couple of member variables weren't needed, so I removed them. > > > > The reason for this change is that getStats is currently contending with the encoder when Bitrate() is called. On my machine, this means that getStats can take about 25-30ms instead of ~1ms. > > > > Also adding some documentation for other methods and a suggestion for how we could avoid contention between the encoder and the network thread. > > > > BUG=2822 > > R=mflodman@webrtc.org > > > > Review URL: https://webrtc-codereview.appspot.com/43479004 > > TBR=tommi@webrtc.org > > Review URL: https://webrtc-codereview.appspot.com/45529004 TBR=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/46519004 Cr-Commit-Position: refs/heads/master@{#8645} git-svn-id: http://webrtc.googlecode.com/svn/trunk@8645 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -16,6 +16,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -74,9 +75,9 @@ class VCMGenericEncoder
|
||||
{
|
||||
friend class VCMCodecDataBase;
|
||||
public:
|
||||
VCMGenericEncoder(VideoEncoder* encoder,
|
||||
VideoEncoderRateObserver* rate_observer,
|
||||
bool internalSource);
|
||||
VCMGenericEncoder(VideoEncoder* encoder,
|
||||
VideoEncoderRateObserver* rate_observer,
|
||||
bool internalSource);
|
||||
~VCMGenericEncoder();
|
||||
/**
|
||||
* Free encoder memory
|
||||
@ -102,6 +103,9 @@ public:
|
||||
* Set new target bitrate (bits/s) and framerate.
|
||||
* Return Value: new bit rate if OK, otherwise <0s.
|
||||
*/
|
||||
// TODO(tommi): We could replace BitRate and FrameRate below with a GetRates
|
||||
// method that matches SetRates. For fetching current rates, we'd then only
|
||||
// grab the lock once instead of twice.
|
||||
int32_t SetRates(uint32_t target_bitrate, uint32_t frameRate);
|
||||
/**
|
||||
* Set a new packet loss rate and a new round-trip time in milliseconds.
|
||||
@ -132,11 +136,10 @@ public:
|
||||
private:
|
||||
VideoEncoder* const encoder_;
|
||||
VideoEncoderRateObserver* const rate_observer_;
|
||||
VideoCodecType _codecType;
|
||||
VCMEncodedFrameCallback* _VCMencodedFrameCallback;
|
||||
uint32_t _bitRate;
|
||||
uint32_t _frameRate;
|
||||
bool _internalSource;
|
||||
uint32_t bit_rate_;
|
||||
uint32_t frame_rate_;
|
||||
const bool internal_source_;
|
||||
mutable rtc::CriticalSection rates_lock_;
|
||||
}; // end of VCMGenericEncoder class
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
Reference in New Issue
Block a user