Swap use of CriticalSectionWrapper for rtc::CriticalSection in webrtc/video.
While doing this, I made a couple of minor changes: * Removed unused variables (one lock and one video frame variable) * Switched over to a scoped lock in remb.cc and removed an if() in a function where we can just return the expression being checked. BUG= R=mflodman@webrtc.org Review URL: https://codereview.webrtc.org/1613053003 . Cr-Commit-Position: refs/heads/master@{#11349}
This commit is contained in:
parent
7ac8babbc6
commit
97888bd95a
@ -15,7 +15,6 @@
|
||||
#include <algorithm>
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/tick_util.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -93,7 +92,6 @@ class RtcpObserver : public RtcpRttStats {
|
||||
|
||||
CallStats::CallStats(Clock* clock)
|
||||
: clock_(clock),
|
||||
crit_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
rtcp_rtt_stats_(new RtcpObserver(this)),
|
||||
last_process_time_(clock_->TimeInMilliseconds()),
|
||||
max_rtt_ms_(0),
|
||||
@ -108,7 +106,7 @@ int64_t CallStats::TimeUntilNextProcess() {
|
||||
}
|
||||
|
||||
int32_t CallStats::Process() {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope cs(&crit_);
|
||||
int64_t now = clock_->TimeInMilliseconds();
|
||||
if (now < last_process_time_ + kUpdateIntervalMs)
|
||||
return 0;
|
||||
@ -131,7 +129,7 @@ int32_t CallStats::Process() {
|
||||
}
|
||||
|
||||
int64_t CallStats::avg_rtt_ms() const {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope cs(&crit_);
|
||||
return avg_rtt_ms_;
|
||||
}
|
||||
|
||||
@ -140,7 +138,7 @@ RtcpRttStats* CallStats::rtcp_rtt_stats() const {
|
||||
}
|
||||
|
||||
void CallStats::RegisterStatsObserver(CallStatsObserver* observer) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope cs(&crit_);
|
||||
for (std::list<CallStatsObserver*>::iterator it = observers_.begin();
|
||||
it != observers_.end(); ++it) {
|
||||
if (*it == observer)
|
||||
@ -150,7 +148,7 @@ void CallStats::RegisterStatsObserver(CallStatsObserver* observer) {
|
||||
}
|
||||
|
||||
void CallStats::DeregisterStatsObserver(CallStatsObserver* observer) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope cs(&crit_);
|
||||
for (std::list<CallStatsObserver*>::iterator it = observers_.begin();
|
||||
it != observers_.end(); ++it) {
|
||||
if (*it == observer) {
|
||||
@ -161,7 +159,7 @@ void CallStats::DeregisterStatsObserver(CallStatsObserver* observer) {
|
||||
}
|
||||
|
||||
void CallStats::OnRttUpdate(int64_t rtt) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope cs(&crit_);
|
||||
reports_.push_back(RttTime(rtt, clock_->TimeInMilliseconds()));
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <list>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/include/module.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
@ -21,7 +22,6 @@
|
||||
namespace webrtc {
|
||||
|
||||
class CallStatsObserver;
|
||||
class CriticalSectionWrapper;
|
||||
class RtcpRttStats;
|
||||
|
||||
// CallStats keeps track of statistics for a call.
|
||||
@ -60,7 +60,7 @@ class CallStats : public Module {
|
||||
private:
|
||||
Clock* const clock_;
|
||||
// Protecting all members.
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> crit_;
|
||||
mutable rtc::CriticalSection crit_;
|
||||
// Observer receiving statistics updates.
|
||||
rtc::scoped_ptr<RtcpRttStats> rtcp_rtt_stats_;
|
||||
// The last time 'Process' resulted in statistic update.
|
||||
|
||||
@ -14,7 +14,6 @@
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/video/vie_encoder.h"
|
||||
|
||||
namespace webrtc {
|
||||
@ -47,8 +46,7 @@ class EncoderStateFeedbackObserver : public RtcpIntraFrameObserver {
|
||||
};
|
||||
|
||||
EncoderStateFeedback::EncoderStateFeedback()
|
||||
: crit_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
observer_(new EncoderStateFeedbackObserver(this)) {}
|
||||
: observer_(new EncoderStateFeedbackObserver(this)) {}
|
||||
|
||||
EncoderStateFeedback::~EncoderStateFeedback() {
|
||||
assert(encoders_.empty());
|
||||
@ -57,7 +55,7 @@ EncoderStateFeedback::~EncoderStateFeedback() {
|
||||
void EncoderStateFeedback::AddEncoder(const std::vector<uint32_t>& ssrcs,
|
||||
ViEEncoder* encoder) {
|
||||
RTC_DCHECK(!ssrcs.empty());
|
||||
CriticalSectionScoped lock(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
for (uint32_t ssrc : ssrcs) {
|
||||
RTC_DCHECK(encoders_.find(ssrc) == encoders_.end());
|
||||
encoders_[ssrc] = encoder;
|
||||
@ -65,7 +63,7 @@ void EncoderStateFeedback::AddEncoder(const std::vector<uint32_t>& ssrcs,
|
||||
}
|
||||
|
||||
void EncoderStateFeedback::RemoveEncoder(const ViEEncoder* encoder) {
|
||||
CriticalSectionScoped lock(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
SsrcEncoderMap::iterator it = encoders_.begin();
|
||||
while (it != encoders_.end()) {
|
||||
if (it->second == encoder) {
|
||||
@ -81,7 +79,7 @@ RtcpIntraFrameObserver* EncoderStateFeedback::GetRtcpIntraFrameObserver() {
|
||||
}
|
||||
|
||||
void EncoderStateFeedback::OnReceivedIntraFrameRequest(uint32_t ssrc) {
|
||||
CriticalSectionScoped lock(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
SsrcEncoderMap::iterator it = encoders_.find(ssrc);
|
||||
if (it == encoders_.end())
|
||||
return;
|
||||
@ -90,7 +88,7 @@ void EncoderStateFeedback::OnReceivedIntraFrameRequest(uint32_t ssrc) {
|
||||
}
|
||||
|
||||
void EncoderStateFeedback::OnReceivedSLI(uint32_t ssrc, uint8_t picture_id) {
|
||||
CriticalSectionScoped lock(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
SsrcEncoderMap::iterator it = encoders_.find(ssrc);
|
||||
if (it == encoders_.end())
|
||||
return;
|
||||
@ -99,7 +97,7 @@ void EncoderStateFeedback::OnReceivedSLI(uint32_t ssrc, uint8_t picture_id) {
|
||||
}
|
||||
|
||||
void EncoderStateFeedback::OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id) {
|
||||
CriticalSectionScoped lock(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
SsrcEncoderMap::iterator it = encoders_.find(ssrc);
|
||||
if (it == encoders_.end())
|
||||
return;
|
||||
@ -109,7 +107,7 @@ void EncoderStateFeedback::OnReceivedRPSI(uint32_t ssrc, uint64_t picture_id) {
|
||||
|
||||
void EncoderStateFeedback::OnLocalSsrcChanged(uint32_t old_ssrc,
|
||||
uint32_t new_ssrc) {
|
||||
CriticalSectionScoped lock(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
SsrcEncoderMap::iterator it = encoders_.find(old_ssrc);
|
||||
if (it == encoders_.end() || encoders_.find(new_ssrc) != encoders_.end()) {
|
||||
return;
|
||||
|
||||
@ -18,12 +18,12 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
class EncoderStateFeedbackObserver;
|
||||
class RtcpIntraFrameObserver;
|
||||
class ViEEncoder;
|
||||
@ -55,7 +55,7 @@ class EncoderStateFeedback {
|
||||
private:
|
||||
typedef std::map<uint32_t, ViEEncoder*> SsrcEncoderMap;
|
||||
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> crit_;
|
||||
mutable rtc::CriticalSection crit_;
|
||||
|
||||
// Instance registered at the class requesting new key frames.
|
||||
rtc::scoped_ptr<EncoderStateFeedbackObserver> observer_;
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
#include "webrtc/modules/video_coding/codecs/vp8/include/vp8.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
|
||||
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
#include "webrtc/test/call_test.h"
|
||||
|
||||
@ -13,13 +13,11 @@
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
PayloadRouter::PayloadRouter()
|
||||
: crit_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
active_(false) {}
|
||||
: active_(false) {}
|
||||
|
||||
PayloadRouter::~PayloadRouter() {}
|
||||
|
||||
@ -30,7 +28,7 @@ size_t PayloadRouter::DefaultMaxPayloadLength() {
|
||||
|
||||
void PayloadRouter::SetSendingRtpModules(
|
||||
const std::list<RtpRtcp*>& rtp_modules) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
rtp_modules_.clear();
|
||||
rtp_modules_.reserve(rtp_modules.size());
|
||||
for (auto* rtp_module : rtp_modules) {
|
||||
@ -39,12 +37,12 @@ void PayloadRouter::SetSendingRtpModules(
|
||||
}
|
||||
|
||||
void PayloadRouter::set_active(bool active) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
active_ = active;
|
||||
}
|
||||
|
||||
bool PayloadRouter::active() {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
return active_ && !rtp_modules_.empty();
|
||||
}
|
||||
|
||||
@ -56,7 +54,7 @@ bool PayloadRouter::RoutePayload(FrameType frame_type,
|
||||
size_t payload_length,
|
||||
const RTPFragmentationHeader* fragmentation,
|
||||
const RTPVideoHeader* rtp_video_hdr) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (!active_ || rtp_modules_.empty())
|
||||
return false;
|
||||
|
||||
@ -76,7 +74,7 @@ bool PayloadRouter::RoutePayload(FrameType frame_type,
|
||||
|
||||
void PayloadRouter::SetTargetSendBitrates(
|
||||
const std::vector<uint32_t>& stream_bitrates) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (stream_bitrates.size() < rtp_modules_.size()) {
|
||||
// There can be a size mis-match during codec reconfiguration.
|
||||
return;
|
||||
@ -89,7 +87,7 @@ void PayloadRouter::SetTargetSendBitrates(
|
||||
|
||||
size_t PayloadRouter::MaxPayloadLength() const {
|
||||
size_t min_payload_length = DefaultMaxPayloadLength();
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
for (auto* rtp_module : rtp_modules_) {
|
||||
size_t module_payload_length = rtp_module->MaxDataPayloadLength();
|
||||
if (module_payload_length < min_payload_length)
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/common_types.h"
|
||||
@ -22,7 +23,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
class RTPFragmentationHeader;
|
||||
class RtpRtcp;
|
||||
struct RTPVideoHeader;
|
||||
@ -69,11 +69,11 @@ class PayloadRouter {
|
||||
private:
|
||||
// TODO(mflodman): When the new video API has launched, remove crit_ and
|
||||
// assume rtp_modules_ will never change during a call.
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> crit_;
|
||||
mutable rtc::CriticalSection crit_;
|
||||
|
||||
// Active sending RTP modules, in layer order.
|
||||
std::vector<RtpRtcp*> rtp_modules_ GUARDED_BY(crit_.get());
|
||||
bool active_ GUARDED_BY(crit_.get());
|
||||
std::vector<RtpRtcp*> rtp_modules_ GUARDED_BY(crit_);
|
||||
bool active_ GUARDED_BY(crit_);
|
||||
|
||||
Atomic32 ref_count_;
|
||||
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/base/logging.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -19,7 +19,6 @@
|
||||
#include "webrtc/modules/video_processing/include/video_processing.h"
|
||||
#include "webrtc/modules/video_render/video_render_defines.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/tick_util.h"
|
||||
#include "webrtc/video/overuse_frame_detector.h"
|
||||
#include "webrtc/video/send_statistics_proxy.h"
|
||||
@ -35,12 +34,10 @@ VideoCaptureInput::VideoCaptureInput(
|
||||
SendStatisticsProxy* stats_proxy,
|
||||
CpuOveruseObserver* overuse_observer,
|
||||
EncodingTimeObserver* encoding_time_observer)
|
||||
: capture_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
module_process_thread_(module_process_thread),
|
||||
: module_process_thread_(module_process_thread),
|
||||
frame_callback_(frame_callback),
|
||||
local_renderer_(local_renderer),
|
||||
stats_proxy_(stats_proxy),
|
||||
incoming_frame_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
encoder_thread_(EncoderThreadFunction, this, "EncoderThread"),
|
||||
capture_event_(false, false),
|
||||
stop_(0),
|
||||
@ -95,7 +92,7 @@ void VideoCaptureInput::IncomingCapturedFrame(const VideoFrame& video_frame) {
|
||||
incoming_frame.set_timestamp(
|
||||
kMsToRtpTimestamp * static_cast<uint32_t>(incoming_frame.ntp_time_ms()));
|
||||
|
||||
CriticalSectionScoped cs(capture_cs_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (incoming_frame.ntp_time_ms() <= last_captured_timestamp_) {
|
||||
// We don't allow the same capture time for two frames, drop this one.
|
||||
LOG(LS_WARNING) << "Same/old NTP timestamp ("
|
||||
@ -132,7 +129,7 @@ bool VideoCaptureInput::EncoderProcess() {
|
||||
int64_t encode_start_time = -1;
|
||||
VideoFrame deliver_frame;
|
||||
{
|
||||
CriticalSectionScoped cs(capture_cs_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (!captured_frame_.IsZeroSize()) {
|
||||
deliver_frame = captured_frame_;
|
||||
captured_frame_.Reset();
|
||||
|
||||
@ -24,7 +24,6 @@
|
||||
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
|
||||
#include "webrtc/modules/video_coding/include/video_coding.h"
|
||||
#include "webrtc/modules/video_processing/include/video_processing.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video_send_stream.h"
|
||||
|
||||
@ -33,7 +32,6 @@ namespace webrtc {
|
||||
class Config;
|
||||
class CpuOveruseMetricsObserver;
|
||||
class CpuOveruseObserver;
|
||||
class CriticalSectionWrapper;
|
||||
class OveruseFrameDetector;
|
||||
class ProcessThread;
|
||||
class RegistrableCpuOveruseMetricsObserver;
|
||||
@ -65,23 +63,19 @@ class VideoCaptureInput : public webrtc::VideoCaptureInput {
|
||||
static bool EncoderThreadFunction(void* obj);
|
||||
bool EncoderProcess();
|
||||
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> capture_cs_;
|
||||
mutable rtc::CriticalSection crit_;
|
||||
ProcessThread* const module_process_thread_;
|
||||
|
||||
VideoCaptureCallback* const frame_callback_;
|
||||
VideoRenderer* const local_renderer_;
|
||||
SendStatisticsProxy* const stats_proxy_;
|
||||
|
||||
// Frame used in IncomingFrameI420.
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> incoming_frame_cs_;
|
||||
VideoFrame incoming_frame_;
|
||||
|
||||
rtc::PlatformThread encoder_thread_;
|
||||
rtc::Event capture_event_;
|
||||
|
||||
volatile int stop_;
|
||||
|
||||
VideoFrame captured_frame_ GUARDED_BY(capture_cs_.get());
|
||||
VideoFrame captured_frame_ GUARDED_BY(crit_);
|
||||
// Used to make sure incoming time stamp is increasing for every frame.
|
||||
int64_t last_captured_timestamp_;
|
||||
// Delta used for translating between NTP and internal timestamps.
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
#include "webrtc/base/event.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/utility/include/mock/mock_process_thread.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/ref_count.h"
|
||||
#include "webrtc/system_wrappers/include/scoped_vector.h"
|
||||
#include "webrtc/test/fake_texture_frame.h"
|
||||
|
||||
@ -18,7 +18,6 @@
|
||||
#include "webrtc/call/transport_adapter.h"
|
||||
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/video/encoded_frame_callback_adapter.h"
|
||||
#include "webrtc/video/send_statistics_proxy.h"
|
||||
#include "webrtc/video/video_capture_input.h"
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h"
|
||||
#include "webrtc/modules/rtp_rtcp/source/rtp_format_vp9.h"
|
||||
#include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/ref_count.h"
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
#include "webrtc/test/call_test.h"
|
||||
|
||||
@ -28,7 +28,6 @@
|
||||
#include "webrtc/modules/video_coding/include/video_coding.h"
|
||||
#include "webrtc/modules/video_processing/include/video_processing.h"
|
||||
#include "webrtc/modules/video_render/video_render_defines.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
#include "webrtc/video/call_stats.h"
|
||||
#include "webrtc/video/payload_router.h"
|
||||
@ -93,7 +92,6 @@ ViEChannel::ViEChannel(uint32_t number_of_cores,
|
||||
: number_of_cores_(number_of_cores),
|
||||
sender_(sender),
|
||||
module_process_thread_(module_process_thread),
|
||||
crit_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
send_payload_router_(new PayloadRouter()),
|
||||
vcm_protection_callback_(new ViEChannelProtectionCallback(this)),
|
||||
vcm_(VideoCodingModule::Create(Clock::GetRealTimeClock(),
|
||||
@ -196,7 +194,7 @@ void ViEChannel::UpdateHistograms() {
|
||||
int64_t now = Clock::GetRealTimeClock()->TimeInMilliseconds();
|
||||
|
||||
{
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
int64_t elapsed_sec = (now - time_of_first_rtt_ms_) / 1000;
|
||||
if (time_of_first_rtt_ms_ != -1 && num_rtts_ > 0 &&
|
||||
elapsed_sec > metrics::kMinRunTimeInSeconds) {
|
||||
@ -367,7 +365,7 @@ int32_t ViEChannel::SetSendCodec(const VideoCodec& video_codec,
|
||||
size_t num_prev_active_modules;
|
||||
{
|
||||
// Cache which modules are active so StartSend can know which ones to start.
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
num_prev_active_modules = num_active_rtp_rtcp_modules_;
|
||||
num_active_rtp_rtcp_modules_ = num_active_modules;
|
||||
}
|
||||
@ -446,7 +444,7 @@ void ViEChannel::RegisterExternalDecoder(const uint8_t pl_type,
|
||||
|
||||
int32_t ViEChannel::ReceiveCodecStatistics(uint32_t* num_key_frames,
|
||||
uint32_t* num_delta_frames) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
*num_key_frames = receive_frame_counts_.key_frames;
|
||||
*num_delta_frames = receive_frame_counts_.delta_frames;
|
||||
return 0;
|
||||
@ -884,7 +882,7 @@ void ViEChannel::RegisterSendBitrateObserver(
|
||||
}
|
||||
|
||||
int32_t ViEChannel::StartSend() {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
|
||||
if (rtp_rtcp_modules_[0]->Sending())
|
||||
return -1;
|
||||
@ -970,7 +968,7 @@ CallStatsObserver* ViEChannel::GetStatsObserver() {
|
||||
// held the lock when calling VideoDecoder::Decode, Reset, or Release. Acquiring
|
||||
// the same lock in the path of decode callback can deadlock.
|
||||
int32_t ViEChannel::FrameToRender(VideoFrame& video_frame) { // NOLINT
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
|
||||
if (pre_render_callback_ != NULL)
|
||||
pre_render_callback_->FrameCallback(&video_frame);
|
||||
@ -986,31 +984,31 @@ int32_t ViEChannel::ReceivedDecodedReferenceFrame(
|
||||
}
|
||||
|
||||
void ViEChannel::OnIncomingPayloadType(int payload_type) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (receive_stats_callback_)
|
||||
receive_stats_callback_->OnIncomingPayloadType(payload_type);
|
||||
}
|
||||
|
||||
void ViEChannel::OnDecoderImplementationName(const char* implementation_name) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (receive_stats_callback_)
|
||||
receive_stats_callback_->OnDecoderImplementationName(implementation_name);
|
||||
}
|
||||
|
||||
void ViEChannel::OnReceiveRatesUpdated(uint32_t bit_rate, uint32_t frame_rate) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (receive_stats_callback_)
|
||||
receive_stats_callback_->OnIncomingRate(frame_rate, bit_rate);
|
||||
}
|
||||
|
||||
void ViEChannel::OnDiscardedPacketsUpdated(int discarded_packets) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (receive_stats_callback_)
|
||||
receive_stats_callback_->OnDiscardedPacketsUpdated(discarded_packets);
|
||||
}
|
||||
|
||||
void ViEChannel::OnFrameCountsUpdated(const FrameCounts& frame_counts) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
receive_frame_counts_ = frame_counts;
|
||||
if (receive_stats_callback_)
|
||||
receive_stats_callback_->OnFrameCountsUpdated(frame_counts);
|
||||
@ -1023,7 +1021,7 @@ void ViEChannel::OnDecoderTiming(int decode_ms,
|
||||
int jitter_buffer_ms,
|
||||
int min_playout_delay_ms,
|
||||
int render_delay_ms) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (!receive_stats_callback_)
|
||||
return;
|
||||
receive_stats_callback_->OnDecoderTiming(
|
||||
@ -1058,7 +1056,7 @@ bool ViEChannel::ChannelDecodeProcess() {
|
||||
void ViEChannel::OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
|
||||
vcm_->SetReceiveChannelParameters(max_rtt_ms);
|
||||
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
if (time_of_first_rtt_ms_ == -1)
|
||||
time_of_first_rtt_ms_ = Clock::GetRealTimeClock()->TimeInMilliseconds();
|
||||
rtt_sum_ms_ += avg_rtt_ms;
|
||||
@ -1168,7 +1166,7 @@ int32_t ViEChannel::VoiceChannel() {
|
||||
|
||||
void ViEChannel::RegisterPreRenderCallback(
|
||||
I420FrameCallback* pre_render_callback) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
pre_render_callback_ = pre_render_callback;
|
||||
}
|
||||
|
||||
@ -1205,13 +1203,13 @@ void ViEChannel::RegisterSendFrameCountObserver(
|
||||
|
||||
void ViEChannel::RegisterReceiveStatisticsProxy(
|
||||
ReceiveStatisticsProxy* receive_statistics_proxy) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
receive_stats_callback_ = receive_statistics_proxy;
|
||||
}
|
||||
|
||||
void ViEChannel::SetIncomingVideoStream(
|
||||
IncomingVideoStream* incoming_video_stream) {
|
||||
CriticalSectionScoped cs(crit_.get());
|
||||
rtc::CritScope lock(&crit_);
|
||||
incoming_video_stream_ = incoming_video_stream;
|
||||
}
|
||||
} // namespace webrtc
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
@ -22,7 +23,6 @@
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/tick_util.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
#include "webrtc/video/vie_receiver.h"
|
||||
@ -33,7 +33,6 @@ namespace webrtc {
|
||||
class CallStatsObserver;
|
||||
class ChannelStatsObserver;
|
||||
class Config;
|
||||
class CriticalSectionWrapper;
|
||||
class EncodedImageCallback;
|
||||
class I420FrameCallback;
|
||||
class IncomingVideoStream;
|
||||
@ -322,12 +321,10 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
template <class T>
|
||||
class RegisterableCallback : public T {
|
||||
public:
|
||||
RegisterableCallback()
|
||||
: critsect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
callback_(NULL) {}
|
||||
RegisterableCallback() : callback_(NULL) {}
|
||||
|
||||
void Set(T* callback) {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
rtc::CritScope lock(&critsect_);
|
||||
callback_ = callback;
|
||||
}
|
||||
|
||||
@ -335,7 +332,7 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
// Note: this should be implemented with a RW-lock to allow simultaneous
|
||||
// calls into the callback. However that doesn't seem to be needed for the
|
||||
// current type of callbacks covered by this class.
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> critsect_;
|
||||
mutable rtc::CriticalSection critsect_;
|
||||
T* callback_ GUARDED_BY(critsect_);
|
||||
|
||||
private:
|
||||
@ -347,7 +344,7 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
virtual void Notify(const BitrateStatistics& total_stats,
|
||||
const BitrateStatistics& retransmit_stats,
|
||||
uint32_t ssrc) {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
rtc::CritScope lock(&critsect_);
|
||||
if (callback_)
|
||||
callback_->Notify(total_stats, retransmit_stats, ssrc);
|
||||
}
|
||||
@ -358,7 +355,7 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
public:
|
||||
virtual void FrameCountUpdated(const FrameCounts& frame_counts,
|
||||
uint32_t ssrc) {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
rtc::CritScope lock(&critsect_);
|
||||
if (callback_)
|
||||
callback_->FrameCountUpdated(frame_counts, ssrc);
|
||||
}
|
||||
@ -371,7 +368,7 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
void SendSideDelayUpdated(int avg_delay_ms,
|
||||
int max_delay_ms,
|
||||
uint32_t ssrc) override {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
rtc::CritScope lock(&critsect_);
|
||||
if (callback_)
|
||||
callback_->SendSideDelayUpdated(avg_delay_ms, max_delay_ms, ssrc);
|
||||
}
|
||||
@ -383,7 +380,7 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
void RtcpPacketTypesCounterUpdated(
|
||||
uint32_t ssrc,
|
||||
const RtcpPacketTypeCounter& packet_counter) override {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
rtc::CritScope lock(&critsect_);
|
||||
if (callback_)
|
||||
callback_->RtcpPacketTypesCounterUpdated(ssrc, packet_counter);
|
||||
counter_map_[ssrc] = packet_counter;
|
||||
@ -391,7 +388,7 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
|
||||
virtual std::map<uint32_t, RtcpPacketTypeCounter> GetPacketTypeCounterMap()
|
||||
const {
|
||||
CriticalSectionScoped cs(critsect_.get());
|
||||
rtc::CritScope lock(&critsect_);
|
||||
return counter_map_;
|
||||
}
|
||||
|
||||
@ -406,7 +403,7 @@ class ViEChannel : public VCMFrameTypeCallback,
|
||||
ProcessThread* const module_process_thread_;
|
||||
|
||||
// Used for all registered callbacks except rendering.
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> crit_;
|
||||
mutable rtc::CriticalSection crit_;
|
||||
|
||||
// Owned modules/classes.
|
||||
rtc::scoped_refptr<PayloadRouter> send_payload_router_;
|
||||
|
||||
@ -29,7 +29,6 @@
|
||||
#include "webrtc/modules/video_coding/include/video_coding_defines.h"
|
||||
#include "webrtc/modules/video_coding/encoded_frame.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
#include "webrtc/system_wrappers/include/tick_util.h"
|
||||
#include "webrtc/video/payload_router.h"
|
||||
@ -117,7 +116,6 @@ ViEEncoder::ViEEncoder(uint32_t number_of_cores,
|
||||
this,
|
||||
qm_callback_.get())),
|
||||
send_payload_router_(NULL),
|
||||
data_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
stats_proxy_(stats_proxy),
|
||||
pre_encode_callback_(pre_encode_callback),
|
||||
pacer_(pacer),
|
||||
@ -175,18 +173,18 @@ ViEEncoder::~ViEEncoder() {
|
||||
|
||||
void ViEEncoder::SetNetworkTransmissionState(bool is_transmitting) {
|
||||
{
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
network_is_transmitting_ = is_transmitting;
|
||||
}
|
||||
}
|
||||
|
||||
void ViEEncoder::Pause() {
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
encoder_paused_ = true;
|
||||
}
|
||||
|
||||
void ViEEncoder::Restart() {
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
encoder_paused_ = false;
|
||||
}
|
||||
|
||||
@ -218,7 +216,7 @@ int32_t ViEEncoder::SetEncoder(const webrtc::VideoCodec& video_codec) {
|
||||
// Cache codec before calling AddBitrateObserver (which calls OnNetworkChanged
|
||||
// that makes use of the number of simulcast streams configured).
|
||||
{
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
encoder_config_ = video_codec;
|
||||
}
|
||||
|
||||
@ -246,7 +244,7 @@ int ViEEncoder::GetPaddingNeededBps() const {
|
||||
int bitrate_bps;
|
||||
VideoCodec send_codec;
|
||||
{
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
bool send_padding = encoder_config_.numberOfSimulcastStreams > 1 ||
|
||||
video_suspended_ || min_transmit_bitrate_kbps_ > 0;
|
||||
if (!send_padding)
|
||||
@ -345,7 +343,7 @@ void ViEEncoder::DeliverFrame(VideoFrame video_frame) {
|
||||
}
|
||||
VideoCodecType codec_type;
|
||||
{
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp();
|
||||
if (EncoderPaused()) {
|
||||
TraceFrameDropStart();
|
||||
@ -381,7 +379,7 @@ void ViEEncoder::DeliverFrame(VideoFrame video_frame) {
|
||||
webrtc::CodecSpecificInfo codec_specific_info;
|
||||
codec_specific_info.codecType = webrtc::kVideoCodecVP8;
|
||||
{
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
codec_specific_info.codecSpecific.VP8.hasReceivedRPSI =
|
||||
has_received_rpsi_;
|
||||
codec_specific_info.codecSpecific.VP8.hasReceivedSLI =
|
||||
@ -406,7 +404,7 @@ void ViEEncoder::SendKeyFrame() {
|
||||
}
|
||||
|
||||
uint32_t ViEEncoder::LastObservedBitrateBps() const {
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
return last_observed_bitrate_bps_;
|
||||
}
|
||||
|
||||
@ -430,7 +428,7 @@ void ViEEncoder::SetProtectionMethod(bool nack, bool fec) {
|
||||
|
||||
void ViEEncoder::SetSenderBufferingMode(int target_delay_ms) {
|
||||
{
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
target_delay_ms_ = target_delay_ms;
|
||||
}
|
||||
if (target_delay_ms > 0) {
|
||||
@ -457,7 +455,7 @@ int32_t ViEEncoder::SendData(
|
||||
RTC_DCHECK(send_payload_router_ != NULL);
|
||||
|
||||
{
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
time_of_last_frame_activity_ms_ = TickTime::MillisecondTimestamp();
|
||||
}
|
||||
|
||||
@ -487,14 +485,14 @@ int32_t ViEEncoder::SendStatistics(const uint32_t bit_rate,
|
||||
|
||||
void ViEEncoder::OnReceivedSLI(uint32_t /*ssrc*/,
|
||||
uint8_t picture_id) {
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
picture_id_sli_ = picture_id;
|
||||
has_received_sli_ = true;
|
||||
}
|
||||
|
||||
void ViEEncoder::OnReceivedRPSI(uint32_t /*ssrc*/,
|
||||
uint64_t picture_id) {
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
picture_id_rpsi_ = picture_id;
|
||||
has_received_rpsi_ = true;
|
||||
}
|
||||
@ -505,7 +503,7 @@ void ViEEncoder::OnReceivedIntraFrameRequest(uint32_t ssrc) {
|
||||
|
||||
int idx = 0;
|
||||
{
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
auto stream_it = ssrc_streams_.find(ssrc);
|
||||
if (stream_it == ssrc_streams_.end()) {
|
||||
LOG_F(LS_WARNING) << "ssrc not found: " << ssrc << ", map size "
|
||||
@ -531,7 +529,7 @@ void ViEEncoder::OnReceivedIntraFrameRequest(uint32_t ssrc) {
|
||||
}
|
||||
|
||||
void ViEEncoder::OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) {
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
std::map<unsigned int, int>::iterator it = ssrc_streams_.find(old_ssrc);
|
||||
if (it == ssrc_streams_.end()) {
|
||||
return;
|
||||
@ -551,7 +549,7 @@ void ViEEncoder::OnLocalSsrcChanged(uint32_t old_ssrc, uint32_t new_ssrc) {
|
||||
}
|
||||
|
||||
void ViEEncoder::SetSsrcs(const std::vector<uint32_t>& ssrcs) {
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
ssrc_streams_.clear();
|
||||
time_last_intra_request_ms_.clear();
|
||||
int idx = 0;
|
||||
@ -562,7 +560,7 @@ void ViEEncoder::SetSsrcs(const std::vector<uint32_t>& ssrcs) {
|
||||
|
||||
void ViEEncoder::SetMinTransmitBitrate(int min_transmit_bitrate_kbps) {
|
||||
assert(min_transmit_bitrate_kbps >= 0);
|
||||
CriticalSectionScoped crit(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
min_transmit_bitrate_kbps_ = min_transmit_bitrate_kbps;
|
||||
}
|
||||
|
||||
@ -580,7 +578,7 @@ void ViEEncoder::OnNetworkChanged(uint32_t bitrate_bps,
|
||||
VideoCodec send_codec;
|
||||
uint32_t first_ssrc;
|
||||
{
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
last_observed_bitrate_bps_ = bitrate_bps;
|
||||
video_suspension_changed = video_suspended_ != video_is_suspended;
|
||||
video_suspended_ = video_is_suspended;
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/scoped_ref_ptr.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
@ -31,7 +32,6 @@ namespace webrtc {
|
||||
class BitrateAllocator;
|
||||
class BitrateObserver;
|
||||
class Config;
|
||||
class CriticalSectionWrapper;
|
||||
class EncodedImageCallback;
|
||||
class PacedSender;
|
||||
class PayloadRouter;
|
||||
@ -158,7 +158,7 @@ class ViEEncoder : public RtcpIntraFrameObserver,
|
||||
const rtc::scoped_ptr<VideoCodingModule> vcm_;
|
||||
rtc::scoped_refptr<PayloadRouter> send_payload_router_;
|
||||
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> data_cs_;
|
||||
mutable rtc::CriticalSection data_cs_;
|
||||
rtc::scoped_ptr<BitrateObserver> bitrate_observer_;
|
||||
|
||||
SendStatisticsProxy* const stats_proxy_;
|
||||
|
||||
@ -23,7 +23,6 @@
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
#include "webrtc/modules/video_coding/include/video_coding.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
#include "webrtc/system_wrappers/include/tick_util.h"
|
||||
#include "webrtc/system_wrappers/include/timestamp_extrapolator.h"
|
||||
@ -36,8 +35,7 @@ static const int kPacketLogIntervalMs = 10000;
|
||||
ViEReceiver::ViEReceiver(VideoCodingModule* module_vcm,
|
||||
RemoteBitrateEstimator* remote_bitrate_estimator,
|
||||
RtpFeedback* rtp_feedback)
|
||||
: receive_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
clock_(Clock::GetRealTimeClock()),
|
||||
: clock_(Clock::GetRealTimeClock()),
|
||||
rtp_header_parser_(RtpHeaderParser::Create()),
|
||||
rtp_payload_registry_(
|
||||
new RTPPayloadRegistry(RTPPayloadStrategy::CreateStrategy(false))),
|
||||
@ -153,7 +151,7 @@ RtpReceiver* ViEReceiver::GetRtpReceiver() const {
|
||||
|
||||
void ViEReceiver::RegisterRtpRtcpModules(
|
||||
const std::vector<RtpRtcp*>& rtp_modules) {
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
rtc::CritScope lock(&receive_cs_);
|
||||
// Only change the "simulcast" modules, the base module can be accessed
|
||||
// without a lock whereas the simulcast modules require locking as they can be
|
||||
// changed in runtime.
|
||||
@ -262,7 +260,7 @@ int ViEReceiver::InsertRTPPacket(const uint8_t* rtp_packet,
|
||||
size_t rtp_packet_length,
|
||||
const PacketTime& packet_time) {
|
||||
{
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
rtc::CritScope lock(&receive_cs_);
|
||||
if (!receiving_) {
|
||||
return -1;
|
||||
}
|
||||
@ -283,7 +281,7 @@ int ViEReceiver::InsertRTPPacket(const uint8_t* rtp_packet,
|
||||
|
||||
{
|
||||
// Periodically log the RTP header of incoming packets.
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
rtc::CritScope lock(&receive_cs_);
|
||||
if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) {
|
||||
std::stringstream ss;
|
||||
ss << "Packet received on SSRC: " << header.ssrc << " with payload type: "
|
||||
@ -361,7 +359,7 @@ bool ViEReceiver::ParseAndHandleEncapsulatingHeader(const uint8_t* packet,
|
||||
return false;
|
||||
if (packet_length > sizeof(restored_packet_))
|
||||
return false;
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
rtc::CritScope lock(&receive_cs_);
|
||||
if (restored_packet_in_use_) {
|
||||
LOG(LS_WARNING) << "Multiple RTX headers detected, dropping packet.";
|
||||
return false;
|
||||
@ -410,7 +408,7 @@ void ViEReceiver::NotifyReceiverOfFecPacket(const RTPHeader& header) {
|
||||
int ViEReceiver::InsertRTCPPacket(const uint8_t* rtcp_packet,
|
||||
size_t rtcp_packet_length) {
|
||||
{
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
rtc::CritScope lock(&receive_cs_);
|
||||
if (!receiving_) {
|
||||
return -1;
|
||||
}
|
||||
@ -444,12 +442,12 @@ int ViEReceiver::InsertRTCPPacket(const uint8_t* rtcp_packet,
|
||||
}
|
||||
|
||||
void ViEReceiver::StartReceive() {
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
rtc::CritScope lock(&receive_cs_);
|
||||
receiving_ = true;
|
||||
}
|
||||
|
||||
void ViEReceiver::StopReceive() {
|
||||
CriticalSectionScoped cs(receive_cs_.get());
|
||||
rtc::CritScope lock(&receive_cs_);
|
||||
receiving_ = false;
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/receive_statistics.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
|
||||
@ -22,7 +23,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
class FecReceiver;
|
||||
class RemoteNtpTimeEstimator;
|
||||
class ReceiveStatistics;
|
||||
@ -104,7 +104,7 @@ class ViEReceiver : public RtpData {
|
||||
bool IsPacketRetransmitted(const RTPHeader& header, bool in_order) const;
|
||||
void UpdateHistograms();
|
||||
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> receive_cs_;
|
||||
rtc::CriticalSection receive_cs_;
|
||||
Clock* clock_;
|
||||
rtc::scoped_ptr<RtpHeaderParser> rtp_header_parser_;
|
||||
rtc::scoped_ptr<RTPPayloadRegistry> rtp_payload_registry_;
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
#include "webrtc/modules/utility/include/process_thread.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/tick_util.h"
|
||||
#include "webrtc/system_wrappers/include/trace.h"
|
||||
|
||||
@ -29,7 +28,6 @@ const unsigned int kSendThresholdPercent = 97;
|
||||
|
||||
VieRemb::VieRemb(Clock* clock)
|
||||
: clock_(clock),
|
||||
list_crit_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
last_remb_time_(clock_->TimeInMilliseconds()),
|
||||
last_send_bitrate_(0),
|
||||
bitrate_(0) {}
|
||||
@ -39,7 +37,7 @@ VieRemb::~VieRemb() {}
|
||||
void VieRemb::AddReceiveChannel(RtpRtcp* rtp_rtcp) {
|
||||
assert(rtp_rtcp);
|
||||
|
||||
CriticalSectionScoped cs(list_crit_.get());
|
||||
rtc::CritScope lock(&list_crit_);
|
||||
if (std::find(receive_modules_.begin(), receive_modules_.end(), rtp_rtcp) !=
|
||||
receive_modules_.end())
|
||||
return;
|
||||
@ -52,7 +50,7 @@ void VieRemb::AddReceiveChannel(RtpRtcp* rtp_rtcp) {
|
||||
void VieRemb::RemoveReceiveChannel(RtpRtcp* rtp_rtcp) {
|
||||
assert(rtp_rtcp);
|
||||
|
||||
CriticalSectionScoped cs(list_crit_.get());
|
||||
rtc::CritScope lock(&list_crit_);
|
||||
for (RtpModules::iterator it = receive_modules_.begin();
|
||||
it != receive_modules_.end(); ++it) {
|
||||
if ((*it) == rtp_rtcp) {
|
||||
@ -65,7 +63,7 @@ void VieRemb::RemoveReceiveChannel(RtpRtcp* rtp_rtcp) {
|
||||
void VieRemb::AddRembSender(RtpRtcp* rtp_rtcp) {
|
||||
assert(rtp_rtcp);
|
||||
|
||||
CriticalSectionScoped cs(list_crit_.get());
|
||||
rtc::CritScope lock(&list_crit_);
|
||||
|
||||
// Verify this module hasn't been added earlier.
|
||||
if (std::find(rtcp_sender_.begin(), rtcp_sender_.end(), rtp_rtcp) !=
|
||||
@ -77,7 +75,7 @@ void VieRemb::AddRembSender(RtpRtcp* rtp_rtcp) {
|
||||
void VieRemb::RemoveRembSender(RtpRtcp* rtp_rtcp) {
|
||||
assert(rtp_rtcp);
|
||||
|
||||
CriticalSectionScoped cs(list_crit_.get());
|
||||
rtc::CritScope lock(&list_crit_);
|
||||
for (RtpModules::iterator it = rtcp_sender_.begin();
|
||||
it != rtcp_sender_.end(); ++it) {
|
||||
if ((*it) == rtp_rtcp) {
|
||||
@ -88,53 +86,48 @@ void VieRemb::RemoveRembSender(RtpRtcp* rtp_rtcp) {
|
||||
}
|
||||
|
||||
bool VieRemb::InUse() const {
|
||||
CriticalSectionScoped cs(list_crit_.get());
|
||||
if (receive_modules_.empty() && rtcp_sender_.empty())
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
rtc::CritScope lock(&list_crit_);
|
||||
return !receive_modules_.empty() || !rtcp_sender_.empty();
|
||||
}
|
||||
|
||||
void VieRemb::OnReceiveBitrateChanged(const std::vector<unsigned int>& ssrcs,
|
||||
unsigned int bitrate) {
|
||||
list_crit_->Enter();
|
||||
// If we already have an estimate, check if the new total estimate is below
|
||||
// kSendThresholdPercent of the previous estimate.
|
||||
if (last_send_bitrate_ > 0) {
|
||||
unsigned int new_remb_bitrate = last_send_bitrate_ - bitrate_ + bitrate;
|
||||
|
||||
if (new_remb_bitrate < kSendThresholdPercent * last_send_bitrate_ / 100) {
|
||||
// The new bitrate estimate is less than kSendThresholdPercent % of the
|
||||
// last report. Send a REMB asap.
|
||||
last_remb_time_ = clock_->TimeInMilliseconds() - kRembSendIntervalMs;
|
||||
}
|
||||
}
|
||||
bitrate_ = bitrate;
|
||||
|
||||
// Calculate total receive bitrate estimate.
|
||||
int64_t now = clock_->TimeInMilliseconds();
|
||||
|
||||
if (now - last_remb_time_ < kRembSendIntervalMs) {
|
||||
list_crit_->Leave();
|
||||
return;
|
||||
}
|
||||
last_remb_time_ = now;
|
||||
|
||||
if (ssrcs.empty() || receive_modules_.empty()) {
|
||||
list_crit_->Leave();
|
||||
return;
|
||||
}
|
||||
|
||||
// Send a REMB packet.
|
||||
RtpRtcp* sender = NULL;
|
||||
if (!rtcp_sender_.empty()) {
|
||||
sender = rtcp_sender_.front();
|
||||
} else {
|
||||
sender = receive_modules_.front();
|
||||
}
|
||||
last_send_bitrate_ = bitrate_;
|
||||
{
|
||||
rtc::CritScope lock(&list_crit_);
|
||||
// If we already have an estimate, check if the new total estimate is below
|
||||
// kSendThresholdPercent of the previous estimate.
|
||||
if (last_send_bitrate_ > 0) {
|
||||
unsigned int new_remb_bitrate = last_send_bitrate_ - bitrate_ + bitrate;
|
||||
|
||||
list_crit_->Leave();
|
||||
if (new_remb_bitrate < kSendThresholdPercent * last_send_bitrate_ / 100) {
|
||||
// The new bitrate estimate is less than kSendThresholdPercent % of the
|
||||
// last report. Send a REMB asap.
|
||||
last_remb_time_ = clock_->TimeInMilliseconds() - kRembSendIntervalMs;
|
||||
}
|
||||
}
|
||||
bitrate_ = bitrate;
|
||||
|
||||
// Calculate total receive bitrate estimate.
|
||||
int64_t now = clock_->TimeInMilliseconds();
|
||||
|
||||
if (now - last_remb_time_ < kRembSendIntervalMs) {
|
||||
return;
|
||||
}
|
||||
last_remb_time_ = now;
|
||||
|
||||
if (ssrcs.empty() || receive_modules_.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Send a REMB packet.
|
||||
if (!rtcp_sender_.empty()) {
|
||||
sender = rtcp_sender_.front();
|
||||
} else {
|
||||
sender = receive_modules_.front();
|
||||
}
|
||||
last_send_bitrate_ = bitrate_;
|
||||
}
|
||||
|
||||
if (sender) {
|
||||
sender->SetREMBData(bitrate_, ssrcs);
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/include/module.h"
|
||||
#include "webrtc/modules/remote_bitrate_estimator/include/remote_bitrate_estimator.h"
|
||||
@ -22,7 +23,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
class ProcessThread;
|
||||
class RtpRtcp;
|
||||
|
||||
@ -58,7 +58,7 @@ class VieRemb : public RemoteBitrateObserver {
|
||||
typedef std::list<RtpRtcp*> RtpModules;
|
||||
|
||||
Clock* const clock_;
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> list_crit_;
|
||||
mutable rtc::CriticalSection list_crit_;
|
||||
|
||||
// The last time a REMB was sent.
|
||||
int64_t last_remb_time_;
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
|
||||
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
|
||||
#include "webrtc/modules/video_coding/include/video_coding.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/video/stream_synchronization.h"
|
||||
#include "webrtc/voice_engine/include/voe_video_sync.h"
|
||||
|
||||
@ -49,8 +48,7 @@ int UpdateMeasurements(StreamSynchronization::Measurements* stream,
|
||||
}
|
||||
|
||||
ViESyncModule::ViESyncModule(VideoCodingModule* vcm)
|
||||
: data_cs_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
vcm_(vcm),
|
||||
: vcm_(vcm),
|
||||
video_receiver_(NULL),
|
||||
video_rtp_rtcp_(NULL),
|
||||
voe_channel_id_(-1),
|
||||
@ -66,7 +64,7 @@ int ViESyncModule::ConfigureSync(int voe_channel_id,
|
||||
VoEVideoSync* voe_sync_interface,
|
||||
RtpRtcp* video_rtcp_module,
|
||||
RtpReceiver* video_receiver) {
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
// Prevent expensive no-ops.
|
||||
if (voe_channel_id_ == voe_channel_id &&
|
||||
voe_sync_interface_ == voe_sync_interface &&
|
||||
@ -102,7 +100,7 @@ int64_t ViESyncModule::TimeUntilNextProcess() {
|
||||
}
|
||||
|
||||
int32_t ViESyncModule::Process() {
|
||||
CriticalSectionScoped cs(data_cs_.get());
|
||||
rtc::CritScope lock(&data_cs_);
|
||||
last_sync_time_ = TickTime::Now();
|
||||
|
||||
const int current_video_delay_ms = vcm_->Delay();
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#ifndef WEBRTC_VIDEO_VIE_SYNC_MODULE_H_
|
||||
#define WEBRTC_VIDEO_VIE_SYNC_MODULE_H_
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/modules/include/module.h"
|
||||
#include "webrtc/system_wrappers/include/tick_util.h"
|
||||
@ -22,7 +23,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
class RtpRtcp;
|
||||
class VideoCodingModule;
|
||||
class ViEChannel;
|
||||
@ -45,7 +45,7 @@ class ViESyncModule : public Module {
|
||||
int32_t Process() override;
|
||||
|
||||
private:
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> data_cs_;
|
||||
rtc::CriticalSection data_cs_;
|
||||
VideoCodingModule* const vcm_;
|
||||
RtpReceiver* video_receiver_;
|
||||
RtpRtcp* video_rtp_rtcp_;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user