| 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 |
| 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ |
| 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ | 12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ |
| 13 | 13 |
| 14 #include <functional> | 14 #include <functional> |
| 15 #include <memory> |
| 16 #include <string> |
| 15 #include <vector> | 17 #include <vector> |
| 16 | 18 |
| 17 #include "webrtc/base/constructormagic.h" | 19 #include "webrtc/base/constructormagic.h" |
| 18 #include "webrtc/base/optional.h" | 20 #include "webrtc/base/optional.h" |
| 19 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ
k_adaptor.h" | 21 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ
k_adaptor.h" |
| 20 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" | 22 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" |
| 21 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" | 23 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" |
| 22 | 24 |
| 23 namespace webrtc { | 25 namespace webrtc { |
| 24 | 26 |
| 25 struct CodecInst; | 27 struct CodecInst; |
| 26 | 28 |
| 27 class AudioEncoderOpus final : public AudioEncoder { | 29 class AudioEncoderOpus final : public AudioEncoder { |
| 28 public: | 30 public: |
| 29 enum ApplicationMode { | 31 enum ApplicationMode { |
| 30 kVoip = 0, | 32 kVoip = 0, |
| 31 kAudio = 1, | 33 kAudio = 1, |
| 32 }; | 34 }; |
| 33 | 35 |
| 34 struct Config { | 36 struct Config { |
| 35 Config(); | 37 Config(); |
| 36 Config(const Config&); | 38 Config(const Config&); |
| 37 ~Config(); | 39 ~Config(); |
| 38 Config& operator=(const Config&); | 40 Config& operator=(const Config&); |
| 39 | 41 |
| 40 bool IsOk() const; | 42 bool IsOk() const; |
| 41 int GetBitrateBps() const; | 43 int GetBitrateBps() const; |
| 44 int GetComplexity() const; |
| 42 | 45 |
| 43 int frame_size_ms = 20; | 46 int frame_size_ms = 20; |
| 44 size_t num_channels = 1; | 47 size_t num_channels = 1; |
| 45 int payload_type = 120; | 48 int payload_type = 120; |
| 46 ApplicationMode application = kVoip; | 49 ApplicationMode application = kVoip; |
| 47 rtc::Optional<int> bitrate_bps; // Unset means to use default value. | 50 rtc::Optional<int> bitrate_bps; // Unset means to use default value. |
| 48 bool fec_enabled = false; | 51 bool fec_enabled = false; |
| 49 int max_playback_rate_hz = 48000; | 52 int max_playback_rate_hz = 48000; |
| 50 int complexity = kDefaultComplexity; | 53 int complexity = kDefaultComplexity; |
| 54 // This value may change in the struct's constructor. |
| 55 int low_rate_complexity = kDefaultComplexity; |
| 56 // low_rate_complexity is used when the bitrate is below this threshold. |
| 57 int complexity_threshold_bps = 12500; |
| 51 bool dtx_enabled = false; | 58 bool dtx_enabled = false; |
| 52 std::vector<int> supported_frame_lengths_ms; | 59 std::vector<int> supported_frame_lengths_ms; |
| 53 const Clock* clock = nullptr; | 60 const Clock* clock = nullptr; |
| 54 | 61 |
| 55 private: | 62 private: |
| 56 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM) | 63 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM) |
| 57 // If we are on Android, iOS and/or ARM, use a lower complexity setting as | 64 // If we are on Android, iOS and/or ARM, use a lower complexity setting as |
| 58 // default, to save encoder complexity. | 65 // default, to save encoder complexity. |
| 59 static const int kDefaultComplexity = 5; | 66 static const int kDefaultComplexity = 5; |
| 60 #else | 67 #else |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 const std::string& config_string, | 140 const std::string& config_string, |
| 134 const Clock* clock) const; | 141 const Clock* clock) const; |
| 135 | 142 |
| 136 Config config_; | 143 Config config_; |
| 137 double packet_loss_rate_; | 144 double packet_loss_rate_; |
| 138 std::vector<int16_t> input_buffer_; | 145 std::vector<int16_t> input_buffer_; |
| 139 OpusEncInst* inst_; | 146 OpusEncInst* inst_; |
| 140 uint32_t first_timestamp_in_buffer_; | 147 uint32_t first_timestamp_in_buffer_; |
| 141 size_t num_channels_to_encode_; | 148 size_t num_channels_to_encode_; |
| 142 int next_frame_length_ms_; | 149 int next_frame_length_ms_; |
| 150 int complexity_; |
| 143 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_; | 151 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_; |
| 144 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; | 152 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; |
| 145 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; | 153 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; |
| 146 | 154 |
| 147 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); | 155 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); |
| 148 }; | 156 }; |
| 149 | 157 |
| 150 } // namespace webrtc | 158 } // namespace webrtc |
| 151 | 159 |
| 152 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ | 160 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ |
| OLD | NEW |