OLD | NEW |
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 Loading... |
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 void SetTargetBitrate(int target_bps); |
143 void ApplyAudioNetworkAdaptor(); | 142 void ApplyAudioNetworkAdaptor(); |
144 std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator( | 143 std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator( |
145 const std::string& config_string, | 144 const std::string& config_string, |
146 const Clock* clock) const; | 145 const Clock* clock) const; |
147 | 146 |
148 Config config_; | 147 Config config_; |
149 double packet_loss_rate_; | 148 float packet_loss_rate_; |
150 std::vector<int16_t> input_buffer_; | 149 std::vector<int16_t> input_buffer_; |
151 OpusEncInst* inst_; | 150 OpusEncInst* inst_; |
152 uint32_t first_timestamp_in_buffer_; | 151 uint32_t first_timestamp_in_buffer_; |
153 size_t num_channels_to_encode_; | 152 size_t num_channels_to_encode_; |
154 int next_frame_length_ms_; | 153 int next_frame_length_ms_; |
155 int complexity_; | 154 int complexity_; |
156 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_; | 155 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_; |
157 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; | 156 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; |
158 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; | 157 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; |
159 | 158 |
160 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); | 159 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); |
161 }; | 160 }; |
162 | 161 |
163 } // namespace webrtc | 162 } // namespace webrtc |
164 | 163 |
165 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ | 164 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ |
OLD | NEW |