Switch CriticalSectionWrapper->rtc::CriticalSection in modules/audio_coding.
This is a part of cleaning up CriticalSectionWrapper in general. BUG= R=henrik.lundin@webrtc.org Review URL: https://codereview.webrtc.org/1610073003 . Cr-Commit-Position: refs/heads/master@{#11319}
This commit is contained in:
@ -25,7 +25,6 @@
|
||||
#include "webrtc/modules/audio_coding/acm2/call_statistics.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/include/neteq.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/system_wrappers/include/trace.h"
|
||||
|
||||
@ -119,8 +118,7 @@ bool IsCng(int codec_id) {
|
||||
} // namespace
|
||||
|
||||
AcmReceiver::AcmReceiver(const AudioCodingModule::Config& config)
|
||||
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
id_(config.id),
|
||||
: id_(config.id),
|
||||
last_audio_decoder_(nullptr),
|
||||
previous_audio_activity_(AudioFrame::kVadPassive),
|
||||
audio_buffer_(new int16_t[AudioFrame::kMaxDataSizeSamples]),
|
||||
@ -157,7 +155,7 @@ int AcmReceiver::LeastRequiredDelayMs() const {
|
||||
}
|
||||
|
||||
rtc::Optional<int> AcmReceiver::last_packet_sample_rate_hz() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return last_packet_sample_rate_hz_;
|
||||
}
|
||||
|
||||
@ -171,7 +169,7 @@ int AcmReceiver::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||
const RTPHeader* header = &rtp_header.header; // Just a shorthand.
|
||||
|
||||
{
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
|
||||
const Decoder* decoder = RtpHeaderToDecoder(*header, incoming_payload[0]);
|
||||
if (!decoder) {
|
||||
@ -216,7 +214,7 @@ int AcmReceiver::GetAudio(int desired_freq_hz, AudioFrame* audio_frame) {
|
||||
size_t num_channels;
|
||||
|
||||
// Accessing members, take the lock.
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
|
||||
// Always write the output to |audio_buffer_| first.
|
||||
if (neteq_->GetAudio(AudioFrame::kMaxDataSizeSamples,
|
||||
@ -317,7 +315,7 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id,
|
||||
return *ned;
|
||||
}();
|
||||
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
|
||||
// The corresponding NetEq decoder ID.
|
||||
// If this codec has been registered before.
|
||||
@ -366,13 +364,13 @@ int32_t AcmReceiver::AddCodec(int acm_codec_id,
|
||||
|
||||
void AcmReceiver::EnableVad() {
|
||||
neteq_->EnableVad();
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
vad_enabled_ = true;
|
||||
}
|
||||
|
||||
void AcmReceiver::DisableVad() {
|
||||
neteq_->DisableVad();
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
vad_enabled_ = false;
|
||||
}
|
||||
|
||||
@ -384,7 +382,7 @@ void AcmReceiver::FlushBuffers() {
|
||||
// many as it can.
|
||||
int AcmReceiver::RemoveAllCodecs() {
|
||||
int ret_val = 0;
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
for (auto it = decoders_.begin(); it != decoders_.end(); ) {
|
||||
auto cur = it;
|
||||
++it; // it will be valid even if we erase cur
|
||||
@ -404,7 +402,7 @@ int AcmReceiver::RemoveAllCodecs() {
|
||||
}
|
||||
|
||||
int AcmReceiver::RemoveCodec(uint8_t payload_type) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
auto it = decoders_.find(payload_type);
|
||||
if (it == decoders_.end()) { // Such a payload-type is not registered.
|
||||
return 0;
|
||||
@ -422,7 +420,7 @@ int AcmReceiver::RemoveCodec(uint8_t payload_type) {
|
||||
}
|
||||
|
||||
void AcmReceiver::set_id(int id) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
id_ = id;
|
||||
}
|
||||
|
||||
@ -431,7 +429,7 @@ bool AcmReceiver::GetPlayoutTimestamp(uint32_t* timestamp) {
|
||||
}
|
||||
|
||||
int AcmReceiver::LastAudioCodec(CodecInst* codec) const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (!last_audio_decoder_) {
|
||||
return -1;
|
||||
}
|
||||
@ -468,7 +466,7 @@ void AcmReceiver::GetNetworkStatistics(NetworkStatistics* acm_stat) {
|
||||
|
||||
int AcmReceiver::DecoderByPayloadType(uint8_t payload_type,
|
||||
CodecInst* codec) const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
auto it = decoders_.find(payload_type);
|
||||
if (it == decoders_.end()) {
|
||||
LOG(LERROR) << "AcmReceiver::DecoderByPayloadType "
|
||||
@ -532,7 +530,7 @@ uint32_t AcmReceiver::NowInTimestamp(int decoder_sampling_rate) const {
|
||||
|
||||
void AcmReceiver::GetDecodingCallStatistics(
|
||||
AudioDecodingCallStats* stats) const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
*stats = call_stats_.GetDecodingStatistics();
|
||||
}
|
||||
|
||||
|
||||
@ -16,15 +16,16 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/array_view.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/optional.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/common_audio/vad/include/webrtc_vad.h"
|
||||
#include "webrtc/engine_configurations.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/acm_resampler.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/call_statistics.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/initial_delay_manager.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
@ -32,7 +33,6 @@
|
||||
namespace webrtc {
|
||||
|
||||
struct CodecInst;
|
||||
class CriticalSectionWrapper;
|
||||
class NetEq;
|
||||
|
||||
namespace acm2 {
|
||||
@ -281,7 +281,7 @@ class AcmReceiver {
|
||||
|
||||
uint32_t NowInTimestamp(int decoder_sampling_rate) const;
|
||||
|
||||
rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
||||
mutable rtc::CriticalSection crit_sect_;
|
||||
int id_; // TODO(henrik.lundin) Make const.
|
||||
const Decoder* last_audio_decoder_ GUARDED_BY(crit_sect_);
|
||||
AudioFrame::VADActivity previous_audio_activity_ GUARDED_BY(crit_sect_);
|
||||
|
||||
@ -21,7 +21,6 @@
|
||||
#include "webrtc/modules/audio_coding/acm2/acm_common_defs.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/acm_resampler.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/call_statistics.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/logging.h"
|
||||
#include "webrtc/system_wrappers/include/metrics.h"
|
||||
#include "webrtc/system_wrappers/include/rw_lock_wrapper.h"
|
||||
@ -103,8 +102,7 @@ void AudioCodingModuleImpl::ChangeLogger::MaybeLog(int value) {
|
||||
|
||||
AudioCodingModuleImpl::AudioCodingModuleImpl(
|
||||
const AudioCodingModule::Config& config)
|
||||
: acm_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
id_(config.id),
|
||||
: id_(config.id),
|
||||
expected_codec_ts_(0xD87F3F9F),
|
||||
expected_in_ts_(0xD87F3F9F),
|
||||
receiver_(config),
|
||||
@ -113,7 +111,6 @@ AudioCodingModuleImpl::AudioCodingModuleImpl(
|
||||
receiver_initialized_(false),
|
||||
first_10ms_data_(false),
|
||||
first_frame_(true),
|
||||
callback_crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
packetization_callback_(NULL),
|
||||
vad_callback_(NULL) {
|
||||
if (InitializeReceiverSafe() < 0) {
|
||||
@ -173,7 +170,7 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
|
||||
}
|
||||
|
||||
{
|
||||
CriticalSectionScoped lock(callback_crit_sect_.get());
|
||||
rtc::CritScope lock(&callback_crit_sect_);
|
||||
if (packetization_callback_) {
|
||||
packetization_callback_->SendData(
|
||||
frame_type, encoded_info.payload_type, encoded_info.encoded_timestamp,
|
||||
@ -197,7 +194,7 @@ int32_t AudioCodingModuleImpl::Encode(const InputData& input_data) {
|
||||
|
||||
// Can be called multiple times for Codec, CNG, RED.
|
||||
int AudioCodingModuleImpl::RegisterSendCodec(const CodecInst& send_codec) {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (!codec_manager_.RegisterEncoder(send_codec)) {
|
||||
return -1;
|
||||
}
|
||||
@ -217,7 +214,7 @@ int AudioCodingModuleImpl::RegisterSendCodec(const CodecInst& send_codec) {
|
||||
|
||||
void AudioCodingModuleImpl::RegisterExternalSendCodec(
|
||||
AudioEncoder* external_speech_encoder) {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
auto* sp = codec_manager_.GetStackParams();
|
||||
sp->speech_encoder = external_speech_encoder;
|
||||
rent_a_codec_.RentEncoderStack(sp);
|
||||
@ -225,7 +222,7 @@ void AudioCodingModuleImpl::RegisterExternalSendCodec(
|
||||
|
||||
// Get current send codec.
|
||||
rtc::Optional<CodecInst> AudioCodingModuleImpl::SendCodec() const {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
auto* ci = codec_manager_.GetCodecInst();
|
||||
if (ci) {
|
||||
return rtc::Optional<CodecInst>(*ci);
|
||||
@ -241,7 +238,7 @@ rtc::Optional<CodecInst> AudioCodingModuleImpl::SendCodec() const {
|
||||
int AudioCodingModuleImpl::SendFrequency() const {
|
||||
WEBRTC_TRACE(webrtc::kTraceStream, webrtc::kTraceAudioCoding, id_,
|
||||
"SendFrequency()");
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
|
||||
const auto* enc = rent_a_codec_.GetEncoderStack();
|
||||
if (!enc) {
|
||||
@ -254,7 +251,7 @@ int AudioCodingModuleImpl::SendFrequency() const {
|
||||
}
|
||||
|
||||
void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
auto* enc = rent_a_codec_.GetEncoderStack();
|
||||
if (enc) {
|
||||
enc->SetTargetBitrate(bitrate_bps);
|
||||
@ -265,7 +262,7 @@ void AudioCodingModuleImpl::SetBitRate(int bitrate_bps) {
|
||||
// the encoded buffers.
|
||||
int AudioCodingModuleImpl::RegisterTransportCallback(
|
||||
AudioPacketizationCallback* transport) {
|
||||
CriticalSectionScoped lock(callback_crit_sect_.get());
|
||||
rtc::CritScope lock(&callback_crit_sect_);
|
||||
packetization_callback_ = transport;
|
||||
return 0;
|
||||
}
|
||||
@ -273,7 +270,7 @@ int AudioCodingModuleImpl::RegisterTransportCallback(
|
||||
// Add 10MS of raw (PCM) audio data to the encoder.
|
||||
int AudioCodingModuleImpl::Add10MsData(const AudioFrame& audio_frame) {
|
||||
InputData input_data;
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
int r = Add10MsDataInternal(audio_frame, &input_data);
|
||||
return r < 0 ? r : Encode(input_data);
|
||||
}
|
||||
@ -445,14 +442,14 @@ int AudioCodingModuleImpl::PreprocessToAddData(const AudioFrame& in_frame,
|
||||
//
|
||||
|
||||
bool AudioCodingModuleImpl::REDStatus() const {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
return codec_manager_.GetStackParams()->use_red;
|
||||
}
|
||||
|
||||
// Configure RED status i.e on/off.
|
||||
int AudioCodingModuleImpl::SetREDStatus(bool enable_red) {
|
||||
#ifdef WEBRTC_CODEC_RED
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (!codec_manager_.SetCopyRed(enable_red)) {
|
||||
return -1;
|
||||
}
|
||||
@ -472,12 +469,12 @@ int AudioCodingModuleImpl::SetREDStatus(bool enable_red) {
|
||||
//
|
||||
|
||||
bool AudioCodingModuleImpl::CodecFEC() const {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
return codec_manager_.GetStackParams()->use_codec_fec;
|
||||
}
|
||||
|
||||
int AudioCodingModuleImpl::SetCodecFEC(bool enable_codec_fec) {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (!codec_manager_.SetCodecFEC(enable_codec_fec)) {
|
||||
return -1;
|
||||
}
|
||||
@ -493,7 +490,7 @@ int AudioCodingModuleImpl::SetCodecFEC(bool enable_codec_fec) {
|
||||
}
|
||||
|
||||
int AudioCodingModuleImpl::SetPacketLossRate(int loss_rate) {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (HaveValidEncoder("SetPacketLossRate")) {
|
||||
rent_a_codec_.GetEncoderStack()->SetProjectedPacketLossRate(loss_rate /
|
||||
100.0);
|
||||
@ -509,7 +506,7 @@ int AudioCodingModuleImpl::SetVAD(bool enable_dtx,
|
||||
ACMVADMode mode) {
|
||||
// Note: |enable_vad| is not used; VAD is enabled based on the DTX setting.
|
||||
RTC_DCHECK_EQ(enable_dtx, enable_vad);
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (!codec_manager_.SetVAD(enable_dtx, mode)) {
|
||||
return -1;
|
||||
}
|
||||
@ -522,7 +519,7 @@ int AudioCodingModuleImpl::SetVAD(bool enable_dtx,
|
||||
// Get VAD/DTX settings.
|
||||
int AudioCodingModuleImpl::VAD(bool* dtx_enabled, bool* vad_enabled,
|
||||
ACMVADMode* mode) const {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
const auto* sp = codec_manager_.GetStackParams();
|
||||
*dtx_enabled = *vad_enabled = sp->use_cng;
|
||||
*mode = sp->vad_mode;
|
||||
@ -534,7 +531,7 @@ int AudioCodingModuleImpl::VAD(bool* dtx_enabled, bool* vad_enabled,
|
||||
//
|
||||
|
||||
int AudioCodingModuleImpl::InitializeReceiver() {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
return InitializeReceiverSafe();
|
||||
}
|
||||
|
||||
@ -587,7 +584,7 @@ int AudioCodingModuleImpl::PlayoutFrequency() const {
|
||||
// Register possible receive codecs, can be called multiple times,
|
||||
// for codecs, CNG (NB, WB and SWB), DTMF, RED.
|
||||
int AudioCodingModuleImpl::RegisterReceiveCodec(const CodecInst& codec) {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
RTC_DCHECK(receiver_initialized_);
|
||||
if (codec.channels > 2) {
|
||||
LOG_F(LS_ERROR) << "Unsupported number of channels: " << codec.channels;
|
||||
@ -625,7 +622,7 @@ int AudioCodingModuleImpl::RegisterExternalReceiveCodec(
|
||||
int sample_rate_hz,
|
||||
int num_channels,
|
||||
const std::string& name) {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
RTC_DCHECK(receiver_initialized_);
|
||||
if (num_channels > 2 || num_channels < 0) {
|
||||
LOG_F(LS_ERROR) << "Unsupported number of channels: " << num_channels;
|
||||
@ -645,7 +642,7 @@ int AudioCodingModuleImpl::RegisterExternalReceiveCodec(
|
||||
|
||||
// Get current received codec.
|
||||
int AudioCodingModuleImpl::ReceiveCodec(CodecInst* current_codec) const {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
return receiver_.LastAudioCodec(current_codec);
|
||||
}
|
||||
|
||||
@ -705,7 +702,7 @@ int AudioCodingModuleImpl::GetNetworkStatistics(NetworkStatistics* statistics) {
|
||||
int AudioCodingModuleImpl::RegisterVADCallback(ACMVADCallback* vad_callback) {
|
||||
WEBRTC_TRACE(webrtc::kTraceDebug, webrtc::kTraceAudioCoding, id_,
|
||||
"RegisterVADCallback()");
|
||||
CriticalSectionScoped lock(callback_crit_sect_.get());
|
||||
rtc::CritScope lock(&callback_crit_sect_);
|
||||
vad_callback_ = vad_callback;
|
||||
return 0;
|
||||
}
|
||||
@ -740,7 +737,7 @@ int AudioCodingModuleImpl::IncomingPayload(const uint8_t* incoming_payload,
|
||||
}
|
||||
|
||||
int AudioCodingModuleImpl::SetOpusApplication(OpusApplicationMode application) {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (!HaveValidEncoder("SetOpusApplication")) {
|
||||
return -1;
|
||||
}
|
||||
@ -761,7 +758,7 @@ int AudioCodingModuleImpl::SetOpusApplication(OpusApplicationMode application) {
|
||||
|
||||
// Informs Opus encoder of the maximum playback rate the receiver will render.
|
||||
int AudioCodingModuleImpl::SetOpusMaxPlaybackRate(int frequency_hz) {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (!HaveValidEncoder("SetOpusMaxPlaybackRate")) {
|
||||
return -1;
|
||||
}
|
||||
@ -770,7 +767,7 @@ int AudioCodingModuleImpl::SetOpusMaxPlaybackRate(int frequency_hz) {
|
||||
}
|
||||
|
||||
int AudioCodingModuleImpl::EnableOpusDtx() {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (!HaveValidEncoder("EnableOpusDtx")) {
|
||||
return -1;
|
||||
}
|
||||
@ -778,7 +775,7 @@ int AudioCodingModuleImpl::EnableOpusDtx() {
|
||||
}
|
||||
|
||||
int AudioCodingModuleImpl::DisableOpusDtx() {
|
||||
CriticalSectionScoped lock(acm_crit_sect_.get());
|
||||
rtc::CritScope lock(&acm_crit_sect_);
|
||||
if (!HaveValidEncoder("DisableOpusDtx")) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
#include <vector>
|
||||
|
||||
#include "webrtc/base/buffer.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/common_types.h"
|
||||
@ -25,7 +26,6 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
class AudioCodingImpl;
|
||||
|
||||
namespace acm2 {
|
||||
@ -240,7 +240,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
|
||||
// to |index|.
|
||||
int UpdateUponReceivingCodec(int index);
|
||||
|
||||
const rtc::scoped_ptr<CriticalSectionWrapper> acm_crit_sect_;
|
||||
mutable rtc::CriticalSection acm_crit_sect_;
|
||||
rtc::Buffer encode_buffer_ GUARDED_BY(acm_crit_sect_);
|
||||
int id_; // TODO(henrik.lundin) Make const.
|
||||
uint32_t expected_codec_ts_ GUARDED_BY(acm_crit_sect_);
|
||||
@ -271,7 +271,7 @@ class AudioCodingModuleImpl final : public AudioCodingModule {
|
||||
uint32_t last_timestamp_ GUARDED_BY(acm_crit_sect_);
|
||||
uint32_t last_rtp_timestamp_ GUARDED_BY(acm_crit_sect_);
|
||||
|
||||
const rtc::scoped_ptr<CriticalSectionWrapper> callback_crit_sect_;
|
||||
mutable rtc::CriticalSection callback_crit_sect_;
|
||||
AudioPacketizationCallback* packetization_callback_
|
||||
GUARDED_BY(callback_crit_sect_);
|
||||
ACMVADCallback* vad_callback_ GUARDED_BY(callback_crit_sect_);
|
||||
|
||||
@ -13,17 +13,18 @@
|
||||
#include <vector>
|
||||
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/md5digest.h"
|
||||
#include "webrtc/base/platform_thread.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/acm_send_test_oldapi.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h"
|
||||
#include "webrtc/modules/audio_coding/acm2/acm_send_test_oldapi.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h"
|
||||
@ -37,7 +38,6 @@
|
||||
#include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/system_wrappers/include/clock.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/event_wrapper.h"
|
||||
#include "webrtc/system_wrappers/include/sleep.h"
|
||||
#include "webrtc/test/testsupport/fileutils.h"
|
||||
@ -94,8 +94,7 @@ class PacketizationCallbackStubOldApi : public AudioPacketizationCallback {
|
||||
: num_calls_(0),
|
||||
last_frame_type_(kEmptyFrame),
|
||||
last_payload_type_(-1),
|
||||
last_timestamp_(0),
|
||||
crit_sect_(CriticalSectionWrapper::CreateCriticalSection()) {}
|
||||
last_timestamp_(0) {}
|
||||
|
||||
int32_t SendData(FrameType frame_type,
|
||||
uint8_t payload_type,
|
||||
@ -103,7 +102,7 @@ class PacketizationCallbackStubOldApi : public AudioPacketizationCallback {
|
||||
const uint8_t* payload_data,
|
||||
size_t payload_len_bytes,
|
||||
const RTPFragmentationHeader* fragmentation) override {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
++num_calls_;
|
||||
last_frame_type_ = frame_type;
|
||||
last_payload_type_ = payload_type;
|
||||
@ -113,32 +112,32 @@ class PacketizationCallbackStubOldApi : public AudioPacketizationCallback {
|
||||
}
|
||||
|
||||
int num_calls() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return num_calls_;
|
||||
}
|
||||
|
||||
int last_payload_len_bytes() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return last_payload_vec_.size();
|
||||
}
|
||||
|
||||
FrameType last_frame_type() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return last_frame_type_;
|
||||
}
|
||||
|
||||
int last_payload_type() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return last_payload_type_;
|
||||
}
|
||||
|
||||
uint32_t last_timestamp() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return last_timestamp_;
|
||||
}
|
||||
|
||||
void SwapBuffers(std::vector<uint8_t>* payload) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
last_payload_vec_.swap(*payload);
|
||||
}
|
||||
|
||||
@ -148,7 +147,7 @@ class PacketizationCallbackStubOldApi : public AudioPacketizationCallback {
|
||||
int last_payload_type_ GUARDED_BY(crit_sect_);
|
||||
uint32_t last_timestamp_ GUARDED_BY(crit_sect_);
|
||||
std::vector<uint8_t> last_payload_vec_ GUARDED_BY(crit_sect_);
|
||||
const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
||||
mutable rtc::CriticalSection crit_sect_;
|
||||
};
|
||||
|
||||
class AudioCodingModuleTestOldApi : public ::testing::Test {
|
||||
@ -469,7 +468,6 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
send_count_(0),
|
||||
insert_packet_count_(0),
|
||||
pull_audio_count_(0),
|
||||
crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
next_insert_packet_time_ms_(0),
|
||||
fake_clock_(new SimulatedClock(0)) {
|
||||
clock_ = fake_clock_.get();
|
||||
@ -503,7 +501,7 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
|
||||
virtual bool TestDone() {
|
||||
if (packet_cb_.num_calls() > kNumPackets) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (pull_audio_count_ > kNumPullCalls) {
|
||||
// Both conditions for completion are met. End the test.
|
||||
return true;
|
||||
@ -541,7 +539,7 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
bool CbInsertPacketImpl() {
|
||||
SleepMs(1);
|
||||
{
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (clock_->TimeInMilliseconds() < next_insert_packet_time_ms_) {
|
||||
return true;
|
||||
}
|
||||
@ -561,7 +559,7 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
bool CbPullAudioImpl() {
|
||||
SleepMs(1);
|
||||
{
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
// Don't let the insert thread fall behind.
|
||||
if (next_insert_packet_time_ms_ < clock_->TimeInMilliseconds()) {
|
||||
return true;
|
||||
@ -581,7 +579,7 @@ class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
int send_count_;
|
||||
int insert_packet_count_;
|
||||
int pull_audio_count_ GUARDED_BY(crit_sect_);
|
||||
const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
||||
mutable rtc::CriticalSection crit_sect_;
|
||||
int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_);
|
||||
rtc::scoped_ptr<SimulatedClock> fake_clock_;
|
||||
};
|
||||
@ -681,7 +679,7 @@ class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi {
|
||||
// run).
|
||||
virtual bool TestDone() {
|
||||
if (packet_cb_.num_calls() > kNumPackets) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (pull_audio_count_ > kNumPullCalls) {
|
||||
// Both conditions for completion are met. End the test.
|
||||
return true;
|
||||
@ -720,7 +718,6 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
this,
|
||||
"codec_registration"),
|
||||
test_complete_(EventWrapper::Create()),
|
||||
crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
codec_registered_(false),
|
||||
receive_packet_count_(0),
|
||||
next_insert_packet_time_ms_(0),
|
||||
@ -781,7 +778,7 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
rtc::scoped_ptr<uint8_t[]> encoded(new uint8_t[max_encoded_bytes]);
|
||||
AudioEncoder::EncodedInfo info;
|
||||
{
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (clock_->TimeInMilliseconds() < next_insert_packet_time_ms_) {
|
||||
return true;
|
||||
}
|
||||
@ -829,7 +826,7 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
// End the test early if a fatal failure (ASSERT_*) has occurred.
|
||||
test_complete_->Set();
|
||||
}
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (!codec_registered_ &&
|
||||
receive_packet_count_ > kRegisterAfterNumPackets) {
|
||||
// Register the iSAC encoder.
|
||||
@ -845,7 +842,7 @@ class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi {
|
||||
rtc::PlatformThread receive_thread_;
|
||||
rtc::PlatformThread codec_registration_thread_;
|
||||
const rtc::scoped_ptr<EventWrapper> test_complete_;
|
||||
const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
||||
mutable rtc::CriticalSection crit_sect_;
|
||||
bool codec_registered_ GUARDED_BY(crit_sect_);
|
||||
int receive_packet_count_ GUARDED_BY(crit_sect_);
|
||||
int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_);
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isac.h"
|
||||
|
||||
#include "webrtc/base/checks.h"
|
||||
#include "webrtc/common_types.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
|
||||
@ -12,8 +12,7 @@
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
LockedIsacBandwidthInfo::LockedIsacBandwidthInfo()
|
||||
: lock_(CriticalSectionWrapper::CreateCriticalSection()) {
|
||||
LockedIsacBandwidthInfo::LockedIsacBandwidthInfo() {
|
||||
bwinfo_.in_use = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -11,10 +11,10 @@
|
||||
#ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_
|
||||
#define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_LOCKED_BANDWIDTH_INFO_H_
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/modules/audio_coding/codecs/isac/bandwidth_info.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -26,17 +26,17 @@ class LockedIsacBandwidthInfo final {
|
||||
~LockedIsacBandwidthInfo();
|
||||
|
||||
IsacBandwidthInfo Get() const {
|
||||
CriticalSectionScoped cs(lock_.get());
|
||||
rtc::CritScope lock(&lock_);
|
||||
return bwinfo_;
|
||||
}
|
||||
|
||||
void Set(const IsacBandwidthInfo& bwinfo) {
|
||||
CriticalSectionScoped cs(lock_.get());
|
||||
rtc::CritScope lock(&lock_);
|
||||
bwinfo_ = bwinfo;
|
||||
}
|
||||
|
||||
private:
|
||||
const rtc::scoped_ptr<CriticalSectionWrapper> lock_;
|
||||
mutable rtc::CriticalSection lock_;
|
||||
IsacBandwidthInfo bwinfo_ GUARDED_BY(lock_);
|
||||
};
|
||||
|
||||
|
||||
@ -44,7 +44,6 @@
|
||||
#include "webrtc/modules/audio_coding/neteq/sync_buffer.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/timestamp_scaler.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
|
||||
// Modify the code to obtain backwards bit-exactness. Once bit-exactness is no
|
||||
// longer required, this #define should be removed (and the code that it
|
||||
@ -67,8 +66,7 @@ NetEqImpl::NetEqImpl(const NetEq::Config& config,
|
||||
ExpandFactory* expand_factory,
|
||||
PreemptiveExpandFactory* preemptive_expand_factory,
|
||||
bool create_components)
|
||||
: crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
buffer_level_filter_(buffer_level_filter),
|
||||
: buffer_level_filter_(buffer_level_filter),
|
||||
decoder_database_(decoder_database),
|
||||
delay_manager_(delay_manager),
|
||||
delay_peak_detector_(delay_peak_detector),
|
||||
@ -126,7 +124,7 @@ int NetEqImpl::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||
rtc::ArrayView<const uint8_t> payload,
|
||||
uint32_t receive_timestamp) {
|
||||
TRACE_EVENT0("webrtc", "NetEqImpl::InsertPacket");
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
int error =
|
||||
InsertPacketInternal(rtp_header, payload, receive_timestamp, false);
|
||||
if (error != 0) {
|
||||
@ -138,7 +136,7 @@ int NetEqImpl::InsertPacket(const WebRtcRTPHeader& rtp_header,
|
||||
|
||||
int NetEqImpl::InsertSyncPacket(const WebRtcRTPHeader& rtp_header,
|
||||
uint32_t receive_timestamp) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
const uint8_t kSyncPayload[] = { 's', 'y', 'n', 'c' };
|
||||
int error =
|
||||
InsertPacketInternal(rtp_header, kSyncPayload, receive_timestamp, true);
|
||||
@ -154,7 +152,7 @@ int NetEqImpl::GetAudio(size_t max_length, int16_t* output_audio,
|
||||
size_t* samples_per_channel, size_t* num_channels,
|
||||
NetEqOutputType* type) {
|
||||
TRACE_EVENT0("webrtc", "NetEqImpl::GetAudio");
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
int error = GetAudioInternal(max_length, output_audio, samples_per_channel,
|
||||
num_channels);
|
||||
if (error != 0) {
|
||||
@ -177,7 +175,7 @@ int NetEqImpl::GetAudio(size_t max_length, int16_t* output_audio,
|
||||
int NetEqImpl::RegisterPayloadType(NetEqDecoder codec,
|
||||
const std::string& name,
|
||||
uint8_t rtp_payload_type) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
LOG(LS_VERBOSE) << "RegisterPayloadType "
|
||||
<< static_cast<int>(rtp_payload_type) << " "
|
||||
<< static_cast<int>(codec);
|
||||
@ -206,7 +204,7 @@ int NetEqImpl::RegisterExternalDecoder(AudioDecoder* decoder,
|
||||
const std::string& codec_name,
|
||||
uint8_t rtp_payload_type,
|
||||
int sample_rate_hz) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
LOG(LS_VERBOSE) << "RegisterExternalDecoder "
|
||||
<< static_cast<int>(rtp_payload_type) << " "
|
||||
<< static_cast<int>(codec);
|
||||
@ -243,7 +241,7 @@ int NetEqImpl::RegisterExternalDecoder(AudioDecoder* decoder,
|
||||
}
|
||||
|
||||
int NetEqImpl::RemovePayloadType(uint8_t rtp_payload_type) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
int ret = decoder_database_->Remove(rtp_payload_type);
|
||||
if (ret == DecoderDatabase::kOK) {
|
||||
return kOK;
|
||||
@ -256,7 +254,7 @@ int NetEqImpl::RemovePayloadType(uint8_t rtp_payload_type) {
|
||||
}
|
||||
|
||||
bool NetEqImpl::SetMinimumDelay(int delay_ms) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (delay_ms >= 0 && delay_ms < 10000) {
|
||||
assert(delay_manager_.get());
|
||||
return delay_manager_->SetMinimumDelay(delay_ms);
|
||||
@ -265,7 +263,7 @@ bool NetEqImpl::SetMinimumDelay(int delay_ms) {
|
||||
}
|
||||
|
||||
bool NetEqImpl::SetMaximumDelay(int delay_ms) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (delay_ms >= 0 && delay_ms < 10000) {
|
||||
assert(delay_manager_.get());
|
||||
return delay_manager_->SetMaximumDelay(delay_ms);
|
||||
@ -274,7 +272,7 @@ bool NetEqImpl::SetMaximumDelay(int delay_ms) {
|
||||
}
|
||||
|
||||
int NetEqImpl::LeastRequiredDelayMs() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
assert(delay_manager_.get());
|
||||
return delay_manager_->least_required_delay_ms();
|
||||
}
|
||||
@ -288,7 +286,7 @@ int NetEqImpl::TargetDelay() {
|
||||
}
|
||||
|
||||
int NetEqImpl::CurrentDelayMs() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (fs_hz_ == 0)
|
||||
return 0;
|
||||
// Sum up the samples in the packet buffer with the future length of the sync
|
||||
@ -306,7 +304,7 @@ int NetEqImpl::CurrentDelayMs() const {
|
||||
// Deprecated.
|
||||
// TODO(henrik.lundin) Delete.
|
||||
void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (mode != playout_mode_) {
|
||||
playout_mode_ = mode;
|
||||
CreateDecisionLogic();
|
||||
@ -316,12 +314,12 @@ void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) {
|
||||
// Deprecated.
|
||||
// TODO(henrik.lundin) Delete.
|
||||
NetEqPlayoutMode NetEqImpl::PlayoutMode() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return playout_mode_;
|
||||
}
|
||||
|
||||
int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
assert(decoder_database_.get());
|
||||
const size_t total_samples_in_buffers =
|
||||
packet_buffer_->NumSamplesInBuffer(decoder_database_.get(),
|
||||
@ -336,33 +334,33 @@ int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {
|
||||
}
|
||||
|
||||
void NetEqImpl::GetRtcpStatistics(RtcpStatistics* stats) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (stats) {
|
||||
rtcp_.GetStatistics(false, stats);
|
||||
}
|
||||
}
|
||||
|
||||
void NetEqImpl::GetRtcpStatisticsNoReset(RtcpStatistics* stats) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (stats) {
|
||||
rtcp_.GetStatistics(true, stats);
|
||||
}
|
||||
}
|
||||
|
||||
void NetEqImpl::EnableVad() {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
assert(vad_.get());
|
||||
vad_->Enable();
|
||||
}
|
||||
|
||||
void NetEqImpl::DisableVad() {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
assert(vad_.get());
|
||||
vad_->Disable();
|
||||
}
|
||||
|
||||
bool NetEqImpl::GetPlayoutTimestamp(uint32_t* timestamp) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (first_packet_) {
|
||||
// We don't have a valid RTP timestamp until we have decoded our first
|
||||
// RTP packet.
|
||||
@ -373,7 +371,7 @@ bool NetEqImpl::GetPlayoutTimestamp(uint32_t* timestamp) {
|
||||
}
|
||||
|
||||
int NetEqImpl::last_output_sample_rate_hz() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return last_output_sample_rate_hz_;
|
||||
}
|
||||
|
||||
@ -386,17 +384,17 @@ int NetEqImpl::SetTargetSampleRate() {
|
||||
}
|
||||
|
||||
int NetEqImpl::LastError() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return error_code_;
|
||||
}
|
||||
|
||||
int NetEqImpl::LastDecoderError() {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return decoder_error_code_;
|
||||
}
|
||||
|
||||
void NetEqImpl::FlushBuffers() {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
LOG(LS_VERBOSE) << "FlushBuffers";
|
||||
packet_buffer_->Flush();
|
||||
assert(sync_buffer_.get());
|
||||
@ -410,12 +408,12 @@ void NetEqImpl::FlushBuffers() {
|
||||
|
||||
void NetEqImpl::PacketBufferStatistics(int* current_num_packets,
|
||||
int* max_num_packets) const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
packet_buffer_->BufferStat(current_num_packets, max_num_packets);
|
||||
}
|
||||
|
||||
void NetEqImpl::EnableNack(size_t max_nack_list_size) {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (!nack_enabled_) {
|
||||
const int kNackThresholdPackets = 2;
|
||||
nack_.reset(Nack::Create(kNackThresholdPackets));
|
||||
@ -426,13 +424,13 @@ void NetEqImpl::EnableNack(size_t max_nack_list_size) {
|
||||
}
|
||||
|
||||
void NetEqImpl::DisableNack() {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
nack_.reset();
|
||||
nack_enabled_ = false;
|
||||
}
|
||||
|
||||
std::vector<uint16_t> NetEqImpl::GetNackList(int64_t round_trip_time_ms) const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
if (!nack_enabled_) {
|
||||
return std::vector<uint16_t>();
|
||||
}
|
||||
@ -441,7 +439,7 @@ std::vector<uint16_t> NetEqImpl::GetNackList(int64_t round_trip_time_ms) const {
|
||||
}
|
||||
|
||||
const SyncBuffer* NetEqImpl::sync_buffer_for_test() const {
|
||||
CriticalSectionScoped lock(crit_sect_.get());
|
||||
rtc::CritScope lock(&crit_sect_);
|
||||
return sync_buffer_.get();
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "webrtc/base/constructormagic.h"
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/base/scoped_ptr.h"
|
||||
#include "webrtc/base/thread_annotations.h"
|
||||
#include "webrtc/modules/audio_coding/neteq/audio_multi_vector.h"
|
||||
@ -32,7 +33,6 @@ class Accelerate;
|
||||
class BackgroundNoise;
|
||||
class BufferLevelFilter;
|
||||
class ComfortNoise;
|
||||
class CriticalSectionWrapper;
|
||||
class DecisionLogic;
|
||||
class DecoderDatabase;
|
||||
class DelayManager;
|
||||
@ -338,7 +338,7 @@ class NetEqImpl : public webrtc::NetEq {
|
||||
// Creates DecisionLogic object with the mode given by |playout_mode_|.
|
||||
virtual void CreateDecisionLogic() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
||||
|
||||
const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
||||
mutable rtc::CriticalSection crit_sect_;
|
||||
const rtc::scoped_ptr<BufferLevelFilter> buffer_level_filter_
|
||||
GUARDED_BY(crit_sect_);
|
||||
const rtc::scoped_ptr<DecoderDatabase> decoder_database_
|
||||
|
||||
@ -15,7 +15,6 @@
|
||||
|
||||
#include "webrtc/base/format_macros.h"
|
||||
#include "webrtc/system_wrappers/include/tick_util.h"
|
||||
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
@ -95,7 +94,7 @@ int32_t Channel::SendData(FrameType frameType,
|
||||
}
|
||||
}
|
||||
|
||||
_channelCritSect->Enter();
|
||||
_channelCritSect.Enter();
|
||||
if (_saveBitStream) {
|
||||
//fwrite(payloadData, sizeof(uint8_t), payloadSize, _bitStreamFile);
|
||||
}
|
||||
@ -106,7 +105,7 @@ int32_t Channel::SendData(FrameType frameType,
|
||||
_useLastFrameSize = false;
|
||||
_lastInTimestamp = timeStamp;
|
||||
_totalBytes += payloadDataSize;
|
||||
_channelCritSect->Leave();
|
||||
_channelCritSect.Leave();
|
||||
|
||||
if (_useFECTestWithPacketLoss) {
|
||||
_packetLoss += 1;
|
||||
@ -225,7 +224,6 @@ void Channel::CalcStatistics(WebRtcRTPHeader& rtpInfo, size_t payloadSize) {
|
||||
Channel::Channel(int16_t chID)
|
||||
: _receiverACM(NULL),
|
||||
_seqNo(0),
|
||||
_channelCritSect(CriticalSectionWrapper::CreateCriticalSection()),
|
||||
_bitStreamFile(NULL),
|
||||
_saveBitStream(false),
|
||||
_lastPayloadType(-1),
|
||||
@ -265,7 +263,6 @@ Channel::Channel(int16_t chID)
|
||||
}
|
||||
|
||||
Channel::~Channel() {
|
||||
delete _channelCritSect;
|
||||
}
|
||||
|
||||
void Channel::RegisterReceiverACM(AudioCodingModule* acm) {
|
||||
@ -276,7 +273,7 @@ void Channel::RegisterReceiverACM(AudioCodingModule* acm) {
|
||||
void Channel::ResetStats() {
|
||||
int n;
|
||||
int k;
|
||||
_channelCritSect->Enter();
|
||||
_channelCritSect.Enter();
|
||||
_lastPayloadType = -1;
|
||||
for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
|
||||
_payloadStats[n].payloadType = -1;
|
||||
@ -291,12 +288,12 @@ void Channel::ResetStats() {
|
||||
}
|
||||
_beginTime = TickTime::MillisecondTimestamp();
|
||||
_totalBytes = 0;
|
||||
_channelCritSect->Leave();
|
||||
_channelCritSect.Leave();
|
||||
}
|
||||
|
||||
int16_t Channel::Stats(CodecInst& codecInst,
|
||||
ACMTestPayloadStats& payloadStats) {
|
||||
_channelCritSect->Enter();
|
||||
_channelCritSect.Enter();
|
||||
int n;
|
||||
payloadStats.payloadType = -1;
|
||||
for (n = 0; n < MAX_NUM_PAYLOADS; n++) {
|
||||
@ -306,12 +303,12 @@ int16_t Channel::Stats(CodecInst& codecInst,
|
||||
}
|
||||
}
|
||||
if (payloadStats.payloadType == -1) {
|
||||
_channelCritSect->Leave();
|
||||
_channelCritSect.Leave();
|
||||
return -1;
|
||||
}
|
||||
for (n = 0; n < MAX_NUM_FRAMESIZES; n++) {
|
||||
if (payloadStats.frameSizeStats[n].frameSizeSample == 0) {
|
||||
_channelCritSect->Leave();
|
||||
_channelCritSect.Leave();
|
||||
return 0;
|
||||
}
|
||||
payloadStats.frameSizeStats[n].usageLenSec = (double) payloadStats
|
||||
@ -322,12 +319,12 @@ int16_t Channel::Stats(CodecInst& codecInst,
|
||||
/ payloadStats.frameSizeStats[n].usageLenSec;
|
||||
|
||||
}
|
||||
_channelCritSect->Leave();
|
||||
_channelCritSect.Leave();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Channel::Stats(uint32_t* numPackets) {
|
||||
_channelCritSect->Enter();
|
||||
_channelCritSect.Enter();
|
||||
int k;
|
||||
int n;
|
||||
memset(numPackets, 0, MAX_NUM_PAYLOADS * sizeof(uint32_t));
|
||||
@ -343,11 +340,11 @@ void Channel::Stats(uint32_t* numPackets) {
|
||||
numPackets[k] += _payloadStats[k].frameSizeStats[n].numPackets;
|
||||
}
|
||||
}
|
||||
_channelCritSect->Leave();
|
||||
_channelCritSect.Leave();
|
||||
}
|
||||
|
||||
void Channel::Stats(uint8_t* payloadType, uint32_t* payloadLenByte) {
|
||||
_channelCritSect->Enter();
|
||||
_channelCritSect.Enter();
|
||||
|
||||
int k;
|
||||
int n;
|
||||
@ -367,7 +364,7 @@ void Channel::Stats(uint8_t* payloadType, uint32_t* payloadLenByte) {
|
||||
}
|
||||
}
|
||||
|
||||
_channelCritSect->Leave();
|
||||
_channelCritSect.Leave();
|
||||
}
|
||||
|
||||
void Channel::PrintStats(CodecInst& codecInst) {
|
||||
@ -406,18 +403,18 @@ void Channel::PrintStats(CodecInst& codecInst) {
|
||||
|
||||
uint32_t Channel::LastInTimestamp() {
|
||||
uint32_t timestamp;
|
||||
_channelCritSect->Enter();
|
||||
_channelCritSect.Enter();
|
||||
timestamp = _lastInTimestamp;
|
||||
_channelCritSect->Leave();
|
||||
_channelCritSect.Leave();
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
double Channel::BitRate() {
|
||||
double rate;
|
||||
uint64_t currTime = TickTime::MillisecondTimestamp();
|
||||
_channelCritSect->Enter();
|
||||
_channelCritSect.Enter();
|
||||
rate = ((double) _totalBytes * 8.0) / (double) (currTime - _beginTime);
|
||||
_channelCritSect->Leave();
|
||||
_channelCritSect.Leave();
|
||||
return rate;
|
||||
}
|
||||
|
||||
|
||||
@ -13,14 +13,13 @@
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "webrtc/base/criticalsection.h"
|
||||
#include "webrtc/modules/audio_coding/include/audio_coding_module.h"
|
||||
#include "webrtc/modules/include/module_common_types.h"
|
||||
#include "webrtc/typedefs.h"
|
||||
|
||||
namespace webrtc {
|
||||
|
||||
class CriticalSectionWrapper;
|
||||
|
||||
#define MAX_NUM_PAYLOADS 50
|
||||
#define MAX_NUM_FRAMESIZES 6
|
||||
|
||||
@ -101,7 +100,7 @@ class Channel : public AudioPacketizationCallback {
|
||||
// 60msec * 32 sample(max)/msec * 2 description (maybe) * 2 bytes/sample
|
||||
uint8_t _payloadData[60 * 32 * 2 * 2];
|
||||
|
||||
CriticalSectionWrapper* _channelCritSect;
|
||||
mutable rtc::CriticalSection _channelCritSect;
|
||||
FILE* _bitStreamFile;
|
||||
bool _saveBitStream;
|
||||
int16_t _lastPayloadType;
|
||||
|
||||
Reference in New Issue
Block a user