| 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 bool SetFec(bool enable) override; | 83 bool SetFec(bool enable) override; |
| 84 | 84 |
| 85 // Set Opus DTX. Once enabled, Opus stops transmission, when it detects voice | 85 // Set Opus DTX. Once enabled, Opus stops transmission, when it detects voice |
| 86 // being inactive. During that, it still sends 2 packets (one for content, one | 86 // being inactive. During that, it still sends 2 packets (one for content, one |
| 87 // for signaling) about every 400 ms. | 87 // for signaling) about every 400 ms. |
| 88 bool SetDtx(bool enable) override; | 88 bool SetDtx(bool enable) override; |
| 89 bool GetDtx() const override; | 89 bool GetDtx() const override; |
| 90 | 90 |
| 91 bool SetApplication(Application application) override; | 91 bool SetApplication(Application application) override; |
| 92 void SetMaxPlaybackRate(int frequency_hz) override; | 92 void SetMaxPlaybackRate(int frequency_hz) override; |
| 93 void SetProjectedPacketLossRate(double fraction) override; | |
| 94 void SetTargetBitrate(int target_bps) override; | |
| 95 | |
| 96 bool EnableAudioNetworkAdaptor(const std::string& config_string, | 93 bool EnableAudioNetworkAdaptor(const std::string& config_string, |
| 97 const Clock* clock) override; | 94 const Clock* clock) override; |
| 98 void DisableAudioNetworkAdaptor() override; | 95 void DisableAudioNetworkAdaptor() override; |
| 99 void OnReceivedUplinkBandwidth(int uplink_bandwidth_bps) override; | 96 void OnReceivedUplinkBandwidth(int uplink_bandwidth_bps) override; |
| 100 void OnReceivedUplinkPacketLossFraction( | 97 void OnReceivedUplinkPacketLossFraction( |
| 101 float uplink_packet_loss_fraction) override; | 98 float uplink_packet_loss_fraction) override; |
| 102 void OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) override; | 99 void OnReceivedTargetAudioBitrate(int target_audio_bitrate_bps) override; |
| 103 void OnReceivedRtt(int rtt_ms) override; | 100 void OnReceivedRtt(int rtt_ms) override; |
| 104 void SetReceiverFrameLengthRange(int min_frame_length_ms, | 101 void SetReceiverFrameLengthRange(int min_frame_length_ms, |
| 105 int max_frame_length_ms) override; | 102 int max_frame_length_ms) override; |
| 106 rtc::ArrayView<const int> supported_frame_lengths_ms() const { | 103 rtc::ArrayView<const int> supported_frame_lengths_ms() const { |
| 107 return config_.supported_frame_lengths_ms; | 104 return config_.supported_frame_lengths_ms; |
| 108 } | 105 } |
| 109 | 106 |
| 110 // Getters for testing. | 107 // Getters for testing. |
| 111 double packet_loss_rate() const { return packet_loss_rate_; } | 108 float packet_loss_rate() const { return packet_loss_rate_; } |
| 112 ApplicationMode application() const { return config_.application; } | 109 ApplicationMode application() const { return config_.application; } |
| 113 bool fec_enabled() const { return config_.fec_enabled; } | 110 bool fec_enabled() const { return config_.fec_enabled; } |
| 114 size_t num_channels_to_encode() const { return num_channels_to_encode_; } | 111 size_t num_channels_to_encode() const { return num_channels_to_encode_; } |
| 115 int next_frame_length_ms() const { return next_frame_length_ms_; } | 112 int next_frame_length_ms() const { return next_frame_length_ms_; } |
| 116 | 113 |
| 117 protected: | 114 protected: |
| 118 EncodedInfo EncodeImpl(uint32_t rtp_timestamp, | 115 EncodedInfo EncodeImpl(uint32_t rtp_timestamp, |
| 119 rtc::ArrayView<const int16_t> audio, | 116 rtc::ArrayView<const int16_t> audio, |
| 120 rtc::Buffer* encoded) override; | 117 rtc::Buffer* encoded) override; |
| 121 | 118 |
| 122 private: | 119 private: |
| 123 class PacketLossFractionSmoother; | 120 class PacketLossFractionSmoother; |
| 124 | 121 |
| 125 size_t Num10msFramesPerPacket() const; | 122 size_t Num10msFramesPerPacket() const; |
| 126 size_t SamplesPer10msFrame() const; | 123 size_t SamplesPer10msFrame() const; |
| 127 size_t SufficientOutputBufferSize() const; | 124 size_t SufficientOutputBufferSize() const; |
| 128 bool RecreateEncoderInstance(const Config& config); | 125 bool RecreateEncoderInstance(const Config& config); |
| 129 void SetFrameLength(int frame_length_ms); | 126 void SetFrameLength(int frame_length_ms); |
| 130 void SetNumChannelsToEncode(size_t num_channels_to_encode); | 127 void SetNumChannelsToEncode(size_t num_channels_to_encode); |
| 128 void SetProjectedPacketLossRate(float fraction); |
| 129 void SetTargetBitrate(int target_bps); |
| 131 void ApplyAudioNetworkAdaptor(); | 130 void ApplyAudioNetworkAdaptor(); |
| 132 std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator( | 131 std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator( |
| 133 const std::string& config_string, | 132 const std::string& config_string, |
| 134 const Clock* clock) const; | 133 const Clock* clock) const; |
| 135 | 134 |
| 136 Config config_; | 135 Config config_; |
| 137 double packet_loss_rate_; | 136 float packet_loss_rate_; |
| 138 std::vector<int16_t> input_buffer_; | 137 std::vector<int16_t> input_buffer_; |
| 139 OpusEncInst* inst_; | 138 OpusEncInst* inst_; |
| 140 uint32_t first_timestamp_in_buffer_; | 139 uint32_t first_timestamp_in_buffer_; |
| 141 size_t num_channels_to_encode_; | 140 size_t num_channels_to_encode_; |
| 142 int next_frame_length_ms_; | 141 int next_frame_length_ms_; |
| 143 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_; | 142 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_; |
| 144 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; | 143 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; |
| 145 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; | 144 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; |
| 146 | 145 |
| 147 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); | 146 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); |
| 148 }; | 147 }; |
| 149 | 148 |
| 150 } // namespace webrtc | 149 } // namespace webrtc |
| 151 | 150 |
| 152 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ | 151 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ |
| OLD | NEW |