Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(469)

Side by Side Diff: webrtc/modules/audio_coding/neteq/decision_logic_normal.h

Issue 1903043003: WIP: Adding a centralized NetEq Clock (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@neteq-remove-type-param
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 10 matching lines...) Expand all
21 // kPlayoutStreaming. 21 // kPlayoutStreaming.
22 class DecisionLogicNormal : public DecisionLogic { 22 class DecisionLogicNormal : public DecisionLogic {
23 public: 23 public:
24 // Constructor. 24 // Constructor.
25 DecisionLogicNormal(int fs_hz, 25 DecisionLogicNormal(int fs_hz,
26 size_t output_size_samples, 26 size_t output_size_samples,
27 NetEqPlayoutMode playout_mode, 27 NetEqPlayoutMode playout_mode,
28 DecoderDatabase* decoder_database, 28 DecoderDatabase* decoder_database,
29 const PacketBuffer& packet_buffer, 29 const PacketBuffer& packet_buffer,
30 DelayManager* delay_manager, 30 DelayManager* delay_manager,
31 BufferLevelFilter* buffer_level_filter) 31 BufferLevelFilter* buffer_level_filter,
32 : DecisionLogic(fs_hz, output_size_samples, playout_mode, 32 const TickTimer& tick_timer)
33 decoder_database, packet_buffer, delay_manager, 33 : DecisionLogic(fs_hz,
34 buffer_level_filter) { 34 output_size_samples,
35 } 35 playout_mode,
36 decoder_database,
37 packet_buffer,
38 delay_manager,
39 buffer_level_filter,
40 tick_timer) {}
36 41
37 protected: 42 protected:
38 static const int kAllowMergeWithoutExpandMs = 20; // 20 ms. 43 static const int kAllowMergeWithoutExpandMs = 20; // 20 ms.
39 static const int kReinitAfterExpands = 100; 44 static const int kReinitAfterExpands = 100;
40 static const int kMaxWaitForPacket = 10; 45 static const int kMaxWaitForPacket = 10;
41 46
42 // Returns the operation that should be done next. |sync_buffer| and |expand| 47 // Returns the operation that should be done next. |sync_buffer| and |expand|
43 // are provided for reference. |decoder_frame_length| is the number of samples 48 // are provided for reference. |decoder_frame_length| is the number of samples
44 // obtained from the last decoded frame. If there is a packet available, the 49 // obtained from the last decoded frame. If there is a packet available, the
45 // packet header should be supplied in |packet_header|; otherwise it should 50 // packet header should be supplied in |packet_header|; otherwise it should
46 // be NULL. The mode resulting form the last call to NetEqImpl::GetAudio is 51 // be NULL. The mode resulting form the last call to NetEqImpl::GetAudio is
47 // supplied in |prev_mode|. If there is a DTMF event to play, |play_dtmf| 52 // supplied in |prev_mode|. If there is a DTMF event to play, |play_dtmf|
48 // should be set to true. The output variable |reset_decoder| will be set to 53 // should be set to true. The output variable |reset_decoder| will be set to
49 // true if a reset is required; otherwise it is left unchanged (i.e., it can 54 // true if a reset is required; otherwise it is left unchanged (i.e., it can
50 // remain true if it was true before the call). 55 // remain true if it was true before the call).
51 Operations GetDecisionSpecialized(const SyncBuffer& sync_buffer, 56 Operations GetDecisionSpecialized(const SyncBuffer& sync_buffer,
52 const Expand& expand, 57 const Expand& expand,
53 size_t decoder_frame_length, 58 size_t decoder_frame_length,
54 const RTPHeader* packet_header, 59 const RTPHeader* packet_header,
55 Modes prev_mode, 60 Modes prev_mode,
56 bool play_dtmf, 61 bool play_dtmf,
57 bool* reset_decoder) override; 62 bool* reset_decoder,
63 size_t noise_samples_played) override;
58 64
59 // Returns the operation to do given that the expected packet is not 65 // Returns the operation to do given that the expected packet is not
60 // available, but a packet further into the future is at hand. 66 // available, but a packet further into the future is at hand.
61 virtual Operations FuturePacketAvailable( 67 virtual Operations FuturePacketAvailable(
62 const SyncBuffer& sync_buffer, 68 const SyncBuffer& sync_buffer,
63 const Expand& expand, 69 const Expand& expand,
64 size_t decoder_frame_length, 70 size_t decoder_frame_length,
65 Modes prev_mode, 71 Modes prev_mode,
66 uint32_t target_timestamp, 72 uint32_t target_timestamp,
67 uint32_t available_timestamp, 73 uint32_t available_timestamp,
68 bool play_dtmf); 74 bool play_dtmf,
75 size_t noise_samples_played);
69 76
70 // Returns the operation to do given that the expected packet is available. 77 // Returns the operation to do given that the expected packet is available.
71 virtual Operations ExpectedPacketAvailable(Modes prev_mode, bool play_dtmf); 78 virtual Operations ExpectedPacketAvailable(Modes prev_mode, bool play_dtmf);
72 79
73 // Returns the operation given that no packets are available (except maybe 80 // Returns the operation given that no packets are available (except maybe
74 // a DTMF event, flagged by setting |play_dtmf| true). 81 // a DTMF event, flagged by setting |play_dtmf| true).
75 virtual Operations NoPacket(bool play_dtmf); 82 virtual Operations NoPacket(bool play_dtmf);
76 83
77 private: 84 private:
78 // Returns the operation given that the next available packet is a comfort 85 // Returns the operation given that the next available packet is a comfort
79 // noise payload (RFC 3389 only, not codec-internal). 86 // noise payload (RFC 3389 only, not codec-internal).
80 Operations CngOperation(Modes prev_mode, uint32_t target_timestamp, 87 Operations CngOperation(Modes prev_mode,
81 uint32_t available_timestamp); 88 uint32_t target_timestamp,
89 uint32_t available_timestamp,
90 size_t noise_samples_played);
82 91
83 // Checks if enough time has elapsed since the last successful timescale 92 // Checks if enough time has elapsed since the last successful timescale
84 // operation was done (i.e., accelerate or preemptive expand). 93 // operation was done (i.e., accelerate or preemptive expand).
85 bool TimescaleAllowed() const { return timescale_hold_off_ == 0; } 94 bool TimescaleAllowed() const {
95 return !timescale_countdown_ || timescale_countdown_->Finished();
96 }
86 97
87 // Checks if the current (filtered) buffer level is under the target level. 98 // Checks if the current (filtered) buffer level is under the target level.
88 bool UnderTargetLevel() const; 99 bool UnderTargetLevel() const;
89 100
90 // Checks if |timestamp_leap| is so long into the future that a reset due 101 // Checks if |timestamp_leap| is so long into the future that a reset due
91 // to exceeding kReinitAfterExpands will be done. 102 // to exceeding kReinitAfterExpands will be done.
92 bool ReinitAfterExpands(uint32_t timestamp_leap) const; 103 bool ReinitAfterExpands(uint32_t timestamp_leap) const;
93 104
94 // Checks if we still have not done enough expands to cover the distance from 105 // Checks if we still have not done enough expands to cover the distance from
95 // the last decoded packet to the next available packet, the distance beeing 106 // the last decoded packet to the next available packet, the distance beeing
96 // conveyed in |timestamp_leap|. 107 // conveyed in |timestamp_leap|.
97 bool PacketTooEarly(uint32_t timestamp_leap) const; 108 bool PacketTooEarly(uint32_t timestamp_leap) const;
98 109
99 // Checks if num_consecutive_expands_ >= kMaxWaitForPacket. 110 // Checks if num_consecutive_expands_ >= kMaxWaitForPacket.
100 bool MaxWaitForPacket() const; 111 bool MaxWaitForPacket() const;
101 112
102 RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogicNormal); 113 RTC_DISALLOW_COPY_AND_ASSIGN(DecisionLogicNormal);
103 }; 114 };
104 115
105 } // namespace webrtc 116 } // namespace webrtc
106 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_NORMAL_H_ 117 #endif // WEBRTC_MODULES_AUDIO_CODING_NETEQ_DECISION_LOGIC_NORMAL_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/neteq/decision_logic_fax.cc ('k') | webrtc/modules/audio_coding/neteq/decision_logic_normal.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698