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

Side by Side Diff: webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.h

Issue 2538493006: Reland "Renaming AudioEncoder::SetTargetBitrate and SetProjectedPacketLossRate." (Closed)
Patch Set: fixing Created 4 years 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 bool SetFec(bool enable) override; 95 bool SetFec(bool enable) override;
96 96
97 // Set Opus DTX. Once enabled, Opus stops transmission, when it detects voice 97 // Set Opus DTX. Once enabled, Opus stops transmission, when it detects voice
98 // being inactive. During that, it still sends 2 packets (one for content, one 98 // being inactive. During that, it still sends 2 packets (one for content, one
99 // for signaling) about every 400 ms. 99 // for signaling) about every 400 ms.
100 bool SetDtx(bool enable) override; 100 bool SetDtx(bool enable) override;
101 bool GetDtx() const override; 101 bool GetDtx() const override;
102 102
103 bool SetApplication(Application application) override; 103 bool SetApplication(Application application) override;
104 void SetMaxPlaybackRate(int frequency_hz) override; 104 void SetMaxPlaybackRate(int frequency_hz) override;
105 void SetProjectedPacketLossRate(double fraction) override;
106 void SetTargetBitrate(int target_bps) override;
107
108 bool EnableAudioNetworkAdaptor(const std::string& config_string, 105 bool EnableAudioNetworkAdaptor(const std::string& config_string,
109 const Clock* clock) override; 106 const Clock* clock) override;
110 void DisableAudioNetworkAdaptor() override; 107 void DisableAudioNetworkAdaptor() override;
111 void OnReceivedUplinkBandwidth(int uplink_bandwidth_bps) override; 108 void OnReceivedUplinkBandwidth(int uplink_bandwidth_bps) override;
112 void OnReceivedUplinkPacketLossFraction( 109 void OnReceivedUplinkPacketLossFraction(
113 float uplink_packet_loss_fraction) override; 110 float uplink_packet_loss_fraction) override;
114 void OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) override; 111 void OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) override;
115 void OnReceivedRtt(int rtt_ms) override; 112 void OnReceivedRtt(int rtt_ms) override;
116 void SetReceiverFrameLengthRange(int min_frame_length_ms, 113 void SetReceiverFrameLengthRange(int min_frame_length_ms,
117 int max_frame_length_ms) override; 114 int max_frame_length_ms) override;
118 rtc::ArrayView<const int> supported_frame_lengths_ms() const { 115 rtc::ArrayView<const int> supported_frame_lengths_ms() const {
119 return config_.supported_frame_lengths_ms; 116 return config_.supported_frame_lengths_ms;
120 } 117 }
121 118
122 // Getters for testing. 119 // Getters for testing.
123 double packet_loss_rate() const { return packet_loss_rate_; } 120 float packet_loss_rate() const { return packet_loss_rate_; }
124 ApplicationMode application() const { return config_.application; } 121 ApplicationMode application() const { return config_.application; }
125 bool fec_enabled() const { return config_.fec_enabled; } 122 bool fec_enabled() const { return config_.fec_enabled; }
126 size_t num_channels_to_encode() const { return num_channels_to_encode_; } 123 size_t num_channels_to_encode() const { return num_channels_to_encode_; }
127 int next_frame_length_ms() const { return next_frame_length_ms_; } 124 int next_frame_length_ms() const { return next_frame_length_ms_; }
128 125
129 protected: 126 protected:
130 EncodedInfo EncodeImpl(uint32_t rtp_timestamp, 127 EncodedInfo EncodeImpl(uint32_t rtp_timestamp,
131 rtc::ArrayView<const int16_t> audio, 128 rtc::ArrayView<const int16_t> audio,
132 rtc::Buffer* encoded) override; 129 rtc::Buffer* encoded) override;
133 130
134 private: 131 private:
135 class PacketLossFractionSmoother; 132 class PacketLossFractionSmoother;
136 133
137 size_t Num10msFramesPerPacket() const; 134 size_t Num10msFramesPerPacket() const;
138 size_t SamplesPer10msFrame() const; 135 size_t SamplesPer10msFrame() const;
139 size_t SufficientOutputBufferSize() const; 136 size_t SufficientOutputBufferSize() const;
140 bool RecreateEncoderInstance(const Config& config); 137 bool RecreateEncoderInstance(const Config& config);
141 void SetFrameLength(int frame_length_ms); 138 void SetFrameLength(int frame_length_ms);
142 void SetNumChannelsToEncode(size_t num_channels_to_encode); 139 void SetNumChannelsToEncode(size_t num_channels_to_encode);
140 void SetProjectedPacketLossRate(float fraction);
141
142 // TODO(minyue): remove "override" when we can deprecate
143 // |AudioEncoder::SetTargetBitrate|.
144 void SetTargetBitrate(int target_bps) override;
145
143 void ApplyAudioNetworkAdaptor(); 146 void ApplyAudioNetworkAdaptor();
144 std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator( 147 std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator(
145 const std::string& config_string, 148 const std::string& config_string,
146 const Clock* clock) const; 149 const Clock* clock) const;
147 150
148 Config config_; 151 Config config_;
149 double packet_loss_rate_; 152 float packet_loss_rate_;
150 std::vector<int16_t> input_buffer_; 153 std::vector<int16_t> input_buffer_;
151 OpusEncInst* inst_; 154 OpusEncInst* inst_;
152 uint32_t first_timestamp_in_buffer_; 155 uint32_t first_timestamp_in_buffer_;
153 size_t num_channels_to_encode_; 156 size_t num_channels_to_encode_;
154 int next_frame_length_ms_; 157 int next_frame_length_ms_;
155 int complexity_; 158 int complexity_;
156 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_; 159 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_;
157 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; 160 AudioNetworkAdaptorCreator audio_network_adaptor_creator_;
158 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; 161 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_;
159 162
160 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); 163 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus);
161 }; 164 };
162 165
163 } // namespace webrtc 166 } // namespace webrtc
164 167
165 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ 168 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698