Reland "NetEq: Deprecate playout modes Fax, Off and Streaming"
This is a reland of 80c4cca4915dbc6094a5bfae749f85f7371eadd1 Original change's description: > NetEq: Deprecate playout modes Fax, Off and Streaming > > The playout modes other than Normal have not been reachable for a long > time, other than through tests. It is time to deprecate them. > > The only meaningful use was that Fax mode was sometimes set from > tests, in order to avoid time-stretching operations (accelerate and > pre-emptive expand) from messing with the test results. With this CL, > a new config is added instead, which lets the user specify exactly > this: don't do time-stretching. > > As a result of Fax and Off modes being removed, the following code > clean-up was done: > - Fold DecisionLogicNormal into DecisionLogic. > - Remove AudioRepetition and AlternativePlc operations, since they can > no longer be reached. > > Bug: webrtc:9421 > Change-Id: I651458e9c1931a99f3b07e242817d303bac119df > Reviewed-on: https://webrtc-review.googlesource.com/84123 > Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org> > Reviewed-by: Ivo Creusen <ivoc@webrtc.org> > Reviewed-by: Minyue Li <minyue@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#23704} Bug: webrtc:9421 Change-Id: Ice351b635788167f2971b26470f73a5e5fa1a240 Reviewed-on: https://webrtc-review.googlesource.com/86543 Reviewed-by: Ivo Creusen <ivoc@webrtc.org> Commit-Queue: Henrik Lundin <henrik.lundin@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23799}
This commit is contained in:
committed by
Commit Bot
parent
04b18cb365
commit
7687ad58b2
@ -28,32 +28,34 @@ class PacketBuffer;
|
||||
class SyncBuffer;
|
||||
struct Packet;
|
||||
|
||||
// This is the base class for the decision tree implementations. Derived classes
|
||||
// must implement the method GetDecisionSpecialized().
|
||||
// This is the class for the decision tree implementation.
|
||||
class DecisionLogic {
|
||||
public:
|
||||
// Static factory function which creates different types of objects depending
|
||||
// on the |playout_mode|.
|
||||
static DecisionLogic* Create(int fs_hz,
|
||||
size_t output_size_samples,
|
||||
NetEqPlayoutMode playout_mode,
|
||||
bool disallow_time_stretching,
|
||||
DecoderDatabase* decoder_database,
|
||||
const PacketBuffer& packet_buffer,
|
||||
DelayManager* delay_manager,
|
||||
BufferLevelFilter* buffer_level_filter,
|
||||
const TickTimer* tick_timer);
|
||||
|
||||
static const int kReinitAfterExpands = 100;
|
||||
static const int kMaxWaitForPacket = 10;
|
||||
|
||||
// Constructor.
|
||||
DecisionLogic(int fs_hz,
|
||||
size_t output_size_samples,
|
||||
NetEqPlayoutMode playout_mode,
|
||||
bool disallow_time_stretching,
|
||||
DecoderDatabase* decoder_database,
|
||||
const PacketBuffer& packet_buffer,
|
||||
DelayManager* delay_manager,
|
||||
BufferLevelFilter* buffer_level_filter,
|
||||
const TickTimer* tick_timer);
|
||||
|
||||
virtual ~DecisionLogic();
|
||||
~DecisionLogic();
|
||||
|
||||
// Resets object to a clean state.
|
||||
void Reset();
|
||||
@ -94,7 +96,7 @@ class DecisionLogic {
|
||||
// not. Note that this is necessary, since an expand decision can be changed
|
||||
// to kNormal in NetEqImpl::GetDecision if there is still enough data in the
|
||||
// sync buffer.
|
||||
virtual void ExpandDecision(Operations operation);
|
||||
void ExpandDecision(Operations operation);
|
||||
|
||||
// Adds |value| to |sample_memory_|.
|
||||
void AddSampleMemory(int32_t value) { sample_memory_ += value; }
|
||||
@ -107,14 +109,17 @@ class DecisionLogic {
|
||||
packet_length_samples_ = value;
|
||||
}
|
||||
void set_prev_time_scale(bool value) { prev_time_scale_ = value; }
|
||||
NetEqPlayoutMode playout_mode() const { return playout_mode_; }
|
||||
|
||||
protected:
|
||||
private:
|
||||
// The value 5 sets maximum time-stretch rate to about 100 ms/s.
|
||||
static const int kMinTimescaleInterval = 5;
|
||||
|
||||
enum CngState { kCngOff, kCngRfc3389On, kCngInternalOn };
|
||||
|
||||
// Updates the |buffer_level_filter_| with the current buffer level
|
||||
// |buffer_size_packets|.
|
||||
void FilterBufferLevel(size_t buffer_size_packets, Modes prev_mode);
|
||||
|
||||
// Returns the operation that should be done next. |sync_buffer| and |expand|
|
||||
// are provided for reference. |decoder_frame_length| is the number of samples
|
||||
// obtained from the last decoded frame. If there is a packet available, it
|
||||
@ -123,20 +128,63 @@ class DecisionLogic {
|
||||
// |prev_mode|. If there is a DTMF event to play, |play_dtmf| should be set to
|
||||
// true. The output variable |reset_decoder| will be set to true if a reset is
|
||||
// required; otherwise it is left unchanged (i.e., it can remain true if it
|
||||
// was true before the call). Should be implemented by derived classes.
|
||||
virtual Operations GetDecisionSpecialized(const SyncBuffer& sync_buffer,
|
||||
const Expand& expand,
|
||||
size_t decoder_frame_length,
|
||||
const Packet* next_packet,
|
||||
Modes prev_mode,
|
||||
bool play_dtmf,
|
||||
bool* reset_decoder,
|
||||
size_t generated_noise_samples,
|
||||
size_t cur_size_samples) = 0;
|
||||
// was true before the call).
|
||||
// TODO(henrik.lundin) Fold this method into GetDecision.
|
||||
Operations GetDecisionSpecialized(const SyncBuffer& sync_buffer,
|
||||
const Expand& expand,
|
||||
size_t decoder_frame_length,
|
||||
const Packet* next_packet,
|
||||
Modes prev_mode,
|
||||
bool play_dtmf,
|
||||
bool* reset_decoder,
|
||||
size_t generated_noise_samples,
|
||||
size_t cur_size_samples);
|
||||
|
||||
// Updates the |buffer_level_filter_| with the current buffer level
|
||||
// |buffer_size_packets|.
|
||||
void FilterBufferLevel(size_t buffer_size_packets, Modes prev_mode);
|
||||
// Returns the operation given that the next available packet is a comfort
|
||||
// noise payload (RFC 3389 only, not codec-internal).
|
||||
Operations CngOperation(Modes prev_mode,
|
||||
uint32_t target_timestamp,
|
||||
uint32_t available_timestamp,
|
||||
size_t generated_noise_samples);
|
||||
|
||||
// Returns the operation given that no packets are available (except maybe
|
||||
// a DTMF event, flagged by setting |play_dtmf| true).
|
||||
Operations NoPacket(bool play_dtmf);
|
||||
|
||||
// Returns the operation to do given that the expected packet is available.
|
||||
Operations ExpectedPacketAvailable(Modes prev_mode, bool play_dtmf);
|
||||
|
||||
// Returns the operation to do given that the expected packet is not
|
||||
// available, but a packet further into the future is at hand.
|
||||
Operations FuturePacketAvailable(const SyncBuffer& sync_buffer,
|
||||
const Expand& expand,
|
||||
size_t decoder_frame_length,
|
||||
Modes prev_mode,
|
||||
uint32_t target_timestamp,
|
||||
uint32_t available_timestamp,
|
||||
bool play_dtmf,
|
||||
size_t generated_noise_samples);
|
||||
|
||||
// Checks if enough time has elapsed since the last successful timescale
|
||||
// operation was done (i.e., accelerate or preemptive expand).
|
||||
bool TimescaleAllowed() const {
|
||||
return !timescale_countdown_ || timescale_countdown_->Finished();
|
||||
}
|
||||
|
||||
// Checks if the current (filtered) buffer level is under the target level.
|
||||
bool UnderTargetLevel() const;
|
||||
|
||||
// Checks if |timestamp_leap| is so long into the future that a reset due
|
||||
// to exceeding kReinitAfterExpands will be done.
|
||||
bool ReinitAfterExpands(uint32_t timestamp_leap) const;
|
||||
|
||||
// Checks if we still have not done enough expands to cover the distance from
|
||||
// the last decoded packet to the next available packet, the distance beeing
|
||||
// conveyed in |timestamp_leap|.
|
||||
bool PacketTooEarly(uint32_t timestamp_leap) const;
|
||||
|
||||
// Checks if num_consecutive_expands_ >= kMaxWaitForPacket.
|
||||
bool MaxWaitForPacket() const;
|
||||
|
||||
DecoderDatabase* decoder_database_;
|
||||
const PacketBuffer& packet_buffer_;
|
||||
@ -151,11 +199,11 @@ class DecisionLogic {
|
||||
size_t packet_length_samples_;
|
||||
int sample_memory_;
|
||||
bool prev_time_scale_;
|
||||
bool disallow_time_stretching_;
|
||||
std::unique_ptr<TickTimer::Countdown> timescale_countdown_;
|
||||
int num_consecutive_expands_;
|
||||
const NetEqPlayoutMode playout_mode_;
|
||||
const bool postpone_decoding_after_expand_;
|
||||
|
||||
private:
|
||||
RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogic);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user