Set NetEq playout mode through the Config struct
This change opens up the possibility to set the playout mode when creating the NetEq object. The old methods SetPlayoutMode and PlayoutMode are still available, but are deprecated. BUG=3520 R=turaj@webrtc.org Review URL: https://webrtc-codereview.appspot.com/23869004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@7381 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
8b65d511a0
commit
7cbc4f969a
@ -74,13 +74,15 @@ class NetEq {
|
|||||||
max_packets_in_buffer(50),
|
max_packets_in_buffer(50),
|
||||||
// |max_delay_ms| has the same effect as calling SetMaximumDelay().
|
// |max_delay_ms| has the same effect as calling SetMaximumDelay().
|
||||||
max_delay_ms(2000),
|
max_delay_ms(2000),
|
||||||
background_noise_mode(kBgnOff) {}
|
background_noise_mode(kBgnOff),
|
||||||
|
playout_mode(kPlayoutOn) {}
|
||||||
|
|
||||||
int sample_rate_hz; // Initial vale. Will change with input data.
|
int sample_rate_hz; // Initial vale. Will change with input data.
|
||||||
bool enable_audio_classifier;
|
bool enable_audio_classifier;
|
||||||
int max_packets_in_buffer;
|
int max_packets_in_buffer;
|
||||||
int max_delay_ms;
|
int max_delay_ms;
|
||||||
BackgroundNoiseMode background_noise_mode;
|
BackgroundNoiseMode background_noise_mode;
|
||||||
|
NetEqPlayoutMode playout_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ReturnCodes {
|
enum ReturnCodes {
|
||||||
@ -202,9 +204,13 @@ class NetEq {
|
|||||||
virtual int CurrentDelay() = 0;
|
virtual int CurrentDelay() = 0;
|
||||||
|
|
||||||
// Sets the playout mode to |mode|.
|
// Sets the playout mode to |mode|.
|
||||||
|
// Deprecated. Set the mode in the Config struct passed to the constructor.
|
||||||
|
// TODO(henrik.lundin) Delete.
|
||||||
virtual void SetPlayoutMode(NetEqPlayoutMode mode) = 0;
|
virtual void SetPlayoutMode(NetEqPlayoutMode mode) = 0;
|
||||||
|
|
||||||
// Returns the current playout mode.
|
// Returns the current playout mode.
|
||||||
|
// Deprecated.
|
||||||
|
// TODO(henrik.lundin) Delete.
|
||||||
virtual NetEqPlayoutMode PlayoutMode() const = 0;
|
virtual NetEqPlayoutMode PlayoutMode() const = 0;
|
||||||
|
|
||||||
// Writes the current network statistics to |stats|. The statistics are reset
|
// Writes the current network statistics to |stats|. The statistics are reset
|
||||||
|
@ -91,6 +91,7 @@ NetEqImpl::NetEqImpl(const NetEq::Config& config,
|
|||||||
error_code_(0),
|
error_code_(0),
|
||||||
decoder_error_code_(0),
|
decoder_error_code_(0),
|
||||||
background_noise_mode_(config.background_noise_mode),
|
background_noise_mode_(config.background_noise_mode),
|
||||||
|
playout_mode_(config.playout_mode),
|
||||||
decoded_packet_sequence_number_(-1),
|
decoded_packet_sequence_number_(-1),
|
||||||
decoded_packet_timestamp_(0) {
|
decoded_packet_timestamp_(0) {
|
||||||
int fs = config.sample_rate_hz;
|
int fs = config.sample_rate_hz;
|
||||||
@ -278,18 +279,21 @@ int NetEqImpl::LeastRequiredDelayMs() const {
|
|||||||
return delay_manager_->least_required_delay_ms();
|
return delay_manager_->least_required_delay_ms();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated.
|
||||||
|
// TODO(henrik.lundin) Delete.
|
||||||
void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) {
|
void NetEqImpl::SetPlayoutMode(NetEqPlayoutMode mode) {
|
||||||
CriticalSectionScoped lock(crit_sect_.get());
|
CriticalSectionScoped lock(crit_sect_.get());
|
||||||
if (!decision_logic_.get() || mode != decision_logic_->playout_mode()) {
|
if (mode != playout_mode_) {
|
||||||
// The reset() method calls delete for the old object.
|
playout_mode_ = mode;
|
||||||
CreateDecisionLogic(mode);
|
CreateDecisionLogic();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deprecated.
|
||||||
|
// TODO(henrik.lundin) Delete.
|
||||||
NetEqPlayoutMode NetEqImpl::PlayoutMode() const {
|
NetEqPlayoutMode NetEqImpl::PlayoutMode() const {
|
||||||
CriticalSectionScoped lock(crit_sect_.get());
|
CriticalSectionScoped lock(crit_sect_.get());
|
||||||
assert(decision_logic_.get());
|
return playout_mode_;
|
||||||
return decision_logic_->playout_mode();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {
|
int NetEqImpl::NetworkStatistics(NetEqNetworkStatistics* stats) {
|
||||||
@ -1904,7 +1908,7 @@ void NetEqImpl::SetSampleRateAndChannels(int fs_hz, size_t channels) {
|
|||||||
// Create DecisionLogic if it is not created yet, then communicate new sample
|
// Create DecisionLogic if it is not created yet, then communicate new sample
|
||||||
// rate and output size to DecisionLogic object.
|
// rate and output size to DecisionLogic object.
|
||||||
if (!decision_logic_.get()) {
|
if (!decision_logic_.get()) {
|
||||||
CreateDecisionLogic(kPlayoutOn);
|
CreateDecisionLogic();
|
||||||
}
|
}
|
||||||
decision_logic_->SetSampleRate(fs_hz_, output_size_samples_);
|
decision_logic_->SetSampleRate(fs_hz_, output_size_samples_);
|
||||||
}
|
}
|
||||||
@ -1926,9 +1930,9 @@ NetEqOutputType NetEqImpl::LastOutputType() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetEqImpl::CreateDecisionLogic(NetEqPlayoutMode mode) {
|
void NetEqImpl::CreateDecisionLogic() {
|
||||||
decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_,
|
decision_logic_.reset(DecisionLogic::Create(fs_hz_, output_size_samples_,
|
||||||
mode,
|
playout_mode_,
|
||||||
decoder_database_.get(),
|
decoder_database_.get(),
|
||||||
*packet_buffer_.get(),
|
*packet_buffer_.get(),
|
||||||
delay_manager_.get(),
|
delay_manager_.get(),
|
||||||
|
@ -138,9 +138,13 @@ class NetEqImpl : public webrtc::NetEq {
|
|||||||
virtual int CurrentDelay() OVERRIDE { return kNotImplemented; }
|
virtual int CurrentDelay() OVERRIDE { return kNotImplemented; }
|
||||||
|
|
||||||
// Sets the playout mode to |mode|.
|
// Sets the playout mode to |mode|.
|
||||||
|
// Deprecated.
|
||||||
|
// TODO(henrik.lundin) Delete.
|
||||||
virtual void SetPlayoutMode(NetEqPlayoutMode mode) OVERRIDE;
|
virtual void SetPlayoutMode(NetEqPlayoutMode mode) OVERRIDE;
|
||||||
|
|
||||||
// Returns the current playout mode.
|
// Returns the current playout mode.
|
||||||
|
// Deprecated.
|
||||||
|
// TODO(henrik.lundin) Delete.
|
||||||
virtual NetEqPlayoutMode PlayoutMode() const OVERRIDE;
|
virtual NetEqPlayoutMode PlayoutMode() const OVERRIDE;
|
||||||
|
|
||||||
// Writes the current network statistics to |stats|. The statistics are reset
|
// Writes the current network statistics to |stats|. The statistics are reset
|
||||||
@ -327,9 +331,8 @@ class NetEqImpl : public webrtc::NetEq {
|
|||||||
virtual void UpdatePlcComponents(int fs_hz, size_t channels)
|
virtual void UpdatePlcComponents(int fs_hz, size_t channels)
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
||||||
|
|
||||||
// Creates DecisionLogic object for the given mode.
|
// Creates DecisionLogic object with the mode given by |playout_mode_|.
|
||||||
virtual void CreateDecisionLogic(NetEqPlayoutMode mode)
|
virtual void CreateDecisionLogic() EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
||||||
EXCLUSIVE_LOCKS_REQUIRED(crit_sect_);
|
|
||||||
|
|
||||||
const scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
const scoped_ptr<CriticalSectionWrapper> crit_sect_;
|
||||||
const scoped_ptr<BufferLevelFilter> buffer_level_filter_
|
const scoped_ptr<BufferLevelFilter> buffer_level_filter_
|
||||||
@ -383,6 +386,7 @@ class NetEqImpl : public webrtc::NetEq {
|
|||||||
int error_code_ GUARDED_BY(crit_sect_); // Store last error code.
|
int error_code_ GUARDED_BY(crit_sect_); // Store last error code.
|
||||||
int decoder_error_code_ GUARDED_BY(crit_sect_);
|
int decoder_error_code_ GUARDED_BY(crit_sect_);
|
||||||
const BackgroundNoiseMode background_noise_mode_ GUARDED_BY(crit_sect_);
|
const BackgroundNoiseMode background_noise_mode_ GUARDED_BY(crit_sect_);
|
||||||
|
NetEqPlayoutMode playout_mode_ GUARDED_BY(crit_sect_);
|
||||||
|
|
||||||
// These values are used by NACK module to estimate time-to-play of
|
// These values are used by NACK module to estimate time-to-play of
|
||||||
// a missing packet. Occasionally, NetEq might decide to decode more
|
// a missing packet. Occasionally, NetEq might decide to decode more
|
||||||
|
@ -442,12 +442,16 @@ TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(TestBitExactness)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(hlundin): Re-enable test once the statistics interface is up and again.
|
// Use fax mode to avoid time-scaling. This is to simplify the testing of
|
||||||
TEST_F(NetEqDecodingTest, TestFrameWaitingTimeStatistics) {
|
// packet waiting times in the packet buffer.
|
||||||
// Use fax mode to avoid time-scaling. This is to simplify the testing of
|
class NetEqDecodingTestFaxMode : public NetEqDecodingTest {
|
||||||
// packet waiting times in the packet buffer.
|
protected:
|
||||||
neteq_->SetPlayoutMode(kPlayoutFax);
|
NetEqDecodingTestFaxMode() : NetEqDecodingTest() {
|
||||||
ASSERT_EQ(kPlayoutFax, neteq_->PlayoutMode());
|
config_.playout_mode = kPlayoutFax;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) {
|
||||||
// Insert 30 dummy packets at once. Each packet contains 10 ms 16 kHz audio.
|
// Insert 30 dummy packets at once. Each packet contains 10 ms 16 kHz audio.
|
||||||
size_t num_frames = 30;
|
size_t num_frames = 30;
|
||||||
const int kSamples = 10 * 16;
|
const int kSamples = 10 * 16;
|
||||||
|
Loading…
Reference in New Issue
Block a user