2013-01-29 12:09:21 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_NORMAL_H_
|
|
|
|
|
#define MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_NORMAL_H_
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "modules/audio_coding/neteq/decision_logic.h"
|
|
|
|
|
#include "rtc_base/constructormagic.h"
|
2017-09-15 13:58:09 +02:00
|
|
|
#include "typedefs.h" // NOLINT(build/include)
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// Implementation of the DecisionLogic class for playout modes kPlayoutOn and
|
|
|
|
|
// kPlayoutStreaming.
|
|
|
|
|
class DecisionLogicNormal : public DecisionLogic {
|
|
|
|
|
public:
|
|
|
|
|
// Constructor.
|
|
|
|
|
DecisionLogicNormal(int fs_hz,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t output_size_samples,
|
2013-01-29 12:09:21 +00:00
|
|
|
NetEqPlayoutMode playout_mode,
|
|
|
|
|
DecoderDatabase* decoder_database,
|
|
|
|
|
const PacketBuffer& packet_buffer,
|
|
|
|
|
DelayManager* delay_manager,
|
2016-05-10 10:20:59 +02:00
|
|
|
BufferLevelFilter* buffer_level_filter,
|
|
|
|
|
const TickTimer* tick_timer)
|
|
|
|
|
: DecisionLogic(fs_hz,
|
|
|
|
|
output_size_samples,
|
|
|
|
|
playout_mode,
|
|
|
|
|
decoder_database,
|
|
|
|
|
packet_buffer,
|
|
|
|
|
delay_manager,
|
|
|
|
|
buffer_level_filter,
|
|
|
|
|
tick_timer) {}
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
protected:
|
2014-04-11 18:47:55 +00:00
|
|
|
static const int kReinitAfterExpands = 100;
|
|
|
|
|
static const int kMaxWaitForPacket = 10;
|
|
|
|
|
|
2015-04-09 15:44:22 +02:00
|
|
|
Operations GetDecisionSpecialized(const SyncBuffer& sync_buffer,
|
|
|
|
|
const Expand& expand,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t decoder_frame_length,
|
2016-10-18 04:06:13 -07:00
|
|
|
const Packet* next_packet,
|
2015-04-09 15:44:22 +02:00
|
|
|
Modes prev_mode,
|
|
|
|
|
bool play_dtmf,
|
2016-05-03 08:18:47 -07:00
|
|
|
bool* reset_decoder,
|
|
|
|
|
size_t generated_noise_samples) override;
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2014-04-11 18:47:55 +00:00
|
|
|
// Returns the operation to do given that the expected packet is not
|
|
|
|
|
// available, but a packet further into the future is at hand.
|
|
|
|
|
virtual Operations FuturePacketAvailable(
|
|
|
|
|
const SyncBuffer& sync_buffer,
|
|
|
|
|
const Expand& expand,
|
Update a ton of audio code to use size_t more correctly and in general reduce
use of int16_t/uint16_t.
This is the upshot of a recommendation by henrik.lundin and kwiberg on an original small change ( https://webrtc-codereview.appspot.com/42569004/#ps1 ) to stop using int16_t just because values could fit in it, and is similar in nature to a previous "mass change to use size_t more" ( https://webrtc-codereview.appspot.com/23129004/ ) which also needed to be split up for review but to land all at once, since, like adding "const", such changes tend to cause a lot of transitive effects.
This was be reviewed and approved in pieces:
https://codereview.webrtc.org/1224093003
https://codereview.webrtc.org/1224123002
https://codereview.webrtc.org/1224163002
https://codereview.webrtc.org/1225133003
https://codereview.webrtc.org/1225173002
https://codereview.webrtc.org/1227163003
https://codereview.webrtc.org/1227203003
https://codereview.webrtc.org/1227213002
https://codereview.webrtc.org/1227893002
https://codereview.webrtc.org/1228793004
https://codereview.webrtc.org/1228803003
https://codereview.webrtc.org/1228823002
https://codereview.webrtc.org/1228823003
https://codereview.webrtc.org/1228843002
https://codereview.webrtc.org/1230693002
https://codereview.webrtc.org/1231713002
The change is being landed as TBR to all the folks who reviewed the above.
BUG=chromium:81439
TEST=none
R=andrew@webrtc.org, pbos@webrtc.org
TBR=aluebs, andrew, asapersson, henrika, hlundin, jan.skoglund, kwiberg, minyue, pbos, pthatcher
Review URL: https://codereview.webrtc.org/1230503003 .
Cr-Commit-Position: refs/heads/master@{#9768}
2015-08-24 14:52:23 -07:00
|
|
|
size_t decoder_frame_length,
|
Reformat existing code. There should be no functional effects.
This includes changes like:
* Attempt to break lines at better positions
* Use "override" in more places, don't use "virtual" with it
* Use {} where the body is more than one line
* Make declaration and definition arg names match
* Eliminate unused code
* EXPECT_EQ(expected, actual) (but use (actual, expected) for e.g. _GT)
* Correct #include order
* Use anonymous namespaces in preference to "static" for file-scoping
* Eliminate unnecessary casts
* Update reference code in comments of ARM assembly sources to match actual current C code
* Fix indenting to be more style-guide compliant
* Use arraysize() in more places
* Use bool instead of int for "boolean" values (0/1)
* Shorten and simplify code
* Spaces around operators
* 80 column limit
* Use const more consistently
* Space goes after '*' in type name, not before
* Remove unnecessary return values
* Use "(var == const)", not "(const == var)"
* Spelling
* Prefer true, typed constants to "enum hack" constants
* Avoid "virtual" on non-overridden functions
* ASSERT(x == y) -> ASSERT_EQ(y, x)
BUG=none
R=andrew@webrtc.org, asapersson@webrtc.org, henrika@webrtc.org, juberti@webrtc.org, kjellander@webrtc.org, kwiberg@webrtc.org
Review URL: https://codereview.webrtc.org/1172163004
Cr-Commit-Position: refs/heads/master@{#9420}
2015-06-11 14:31:38 -07:00
|
|
|
Modes prev_mode,
|
2014-04-11 18:47:55 +00:00
|
|
|
uint32_t target_timestamp,
|
|
|
|
|
uint32_t available_timestamp,
|
2016-05-03 08:18:47 -07:00
|
|
|
bool play_dtmf,
|
|
|
|
|
size_t generated_noise_samples);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2014-04-11 18:47:55 +00:00
|
|
|
// Returns the operation to do given that the expected packet is available.
|
|
|
|
|
virtual Operations ExpectedPacketAvailable(Modes prev_mode, bool play_dtmf);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Returns the operation given that no packets are available (except maybe
|
|
|
|
|
// a DTMF event, flagged by setting |play_dtmf| true).
|
2014-04-11 18:47:55 +00:00
|
|
|
virtual Operations NoPacket(bool play_dtmf);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
2014-04-11 18:47:55 +00:00
|
|
|
private:
|
|
|
|
|
// Returns the operation given that the next available packet is a comfort
|
|
|
|
|
// noise payload (RFC 3389 only, not codec-internal).
|
2016-05-03 08:18:47 -07:00
|
|
|
Operations CngOperation(Modes prev_mode,
|
|
|
|
|
uint32_t target_timestamp,
|
|
|
|
|
uint32_t available_timestamp,
|
|
|
|
|
size_t generated_noise_samples);
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// Checks if enough time has elapsed since the last successful timescale
|
|
|
|
|
// operation was done (i.e., accelerate or preemptive expand).
|
2016-05-10 10:20:59 +02:00
|
|
|
bool TimescaleAllowed() const {
|
|
|
|
|
return !timescale_countdown_ || timescale_countdown_->Finished();
|
|
|
|
|
}
|
2013-01-29 12:09:21 +00:00
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
2015-09-16 05:37:44 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogicNormal);
|
2013-01-29 12:09:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_NORMAL_H_
|