| 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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 | 42 |
| 43 int frame_size_ms = 20; | 43 int frame_size_ms = 20; |
| 44 size_t num_channels = 1; | 44 size_t num_channels = 1; |
| 45 int payload_type = 120; | 45 int payload_type = 120; |
| 46 ApplicationMode application = kVoip; | 46 ApplicationMode application = kVoip; |
| 47 rtc::Optional<int> bitrate_bps; // Unset means to use default value. | 47 rtc::Optional<int> bitrate_bps; // Unset means to use default value. |
| 48 bool fec_enabled = false; | 48 bool fec_enabled = false; |
| 49 int max_playback_rate_hz = 48000; | 49 int max_playback_rate_hz = 48000; |
| 50 int complexity = kDefaultComplexity; | 50 int complexity = kDefaultComplexity; |
| 51 bool dtx_enabled = false; | 51 bool dtx_enabled = false; |
| 52 const Clock* clock = nullptr; |
| 52 | 53 |
| 53 private: | 54 private: |
| 54 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM) | 55 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM) |
| 55 // If we are on Android, iOS and/or ARM, use a lower complexity setting as | 56 // If we are on Android, iOS and/or ARM, use a lower complexity setting as |
| 56 // default, to save encoder complexity. | 57 // default, to save encoder complexity. |
| 57 static const int kDefaultComplexity = 5; | 58 static const int kDefaultComplexity = 5; |
| 58 #else | 59 #else |
| 59 static const int kDefaultComplexity = 9; | 60 static const int kDefaultComplexity = 9; |
| 60 #endif | 61 #endif |
| 61 }; | 62 }; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 bool fec_enabled() const { return config_.fec_enabled; } | 109 bool fec_enabled() const { return config_.fec_enabled; } |
| 109 size_t num_channels_to_encode() const { return num_channels_to_encode_; } | 110 size_t num_channels_to_encode() const { return num_channels_to_encode_; } |
| 110 int next_frame_length_ms() const { return next_frame_length_ms_; } | 111 int next_frame_length_ms() const { return next_frame_length_ms_; } |
| 111 | 112 |
| 112 protected: | 113 protected: |
| 113 EncodedInfo EncodeImpl(uint32_t rtp_timestamp, | 114 EncodedInfo EncodeImpl(uint32_t rtp_timestamp, |
| 114 rtc::ArrayView<const int16_t> audio, | 115 rtc::ArrayView<const int16_t> audio, |
| 115 rtc::Buffer* encoded) override; | 116 rtc::Buffer* encoded) override; |
| 116 | 117 |
| 117 private: | 118 private: |
| 119 class PacketLossFractionSmoother; |
| 120 |
| 118 size_t Num10msFramesPerPacket() const; | 121 size_t Num10msFramesPerPacket() const; |
| 119 size_t SamplesPer10msFrame() const; | 122 size_t SamplesPer10msFrame() const; |
| 120 size_t SufficientOutputBufferSize() const; | 123 size_t SufficientOutputBufferSize() const; |
| 121 bool RecreateEncoderInstance(const Config& config); | 124 bool RecreateEncoderInstance(const Config& config); |
| 122 void SetFrameLength(int frame_length_ms); | 125 void SetFrameLength(int frame_length_ms); |
| 123 void SetNumChannelsToEncode(size_t num_channels_to_encode); | 126 void SetNumChannelsToEncode(size_t num_channels_to_encode); |
| 124 void ApplyAudioNetworkAdaptor(); | 127 void ApplyAudioNetworkAdaptor(); |
| 125 std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator( | 128 std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator( |
| 126 const std::string& config_string, | 129 const std::string& config_string, |
| 127 const Clock* clock) const; | 130 const Clock* clock) const; |
| 128 | 131 |
| 129 Config config_; | 132 Config config_; |
| 130 double packet_loss_rate_; | 133 double packet_loss_rate_; |
| 131 std::vector<int16_t> input_buffer_; | 134 std::vector<int16_t> input_buffer_; |
| 132 OpusEncInst* inst_; | 135 OpusEncInst* inst_; |
| 133 uint32_t first_timestamp_in_buffer_; | 136 uint32_t first_timestamp_in_buffer_; |
| 134 size_t num_channels_to_encode_; | 137 size_t num_channels_to_encode_; |
| 135 int next_frame_length_ms_; | 138 int next_frame_length_ms_; |
| 139 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_; |
| 136 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; | 140 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; |
| 137 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; | 141 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; |
| 138 | 142 |
| 139 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); | 143 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); |
| 140 }; | 144 }; |
| 141 | 145 |
| 142 } // namespace webrtc | 146 } // namespace webrtc |
| 143 | 147 |
| 144 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ | 148 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ |
| OLD | NEW |