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

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

Issue 2390883004: Hooking up audio network adaptor to VoE. (Closed)
Patch Set: moving packet loss rate smoothing to AudioEncoderOpus. Created 4 years, 2 months 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
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 <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/constructormagic.h" 17 #include "webrtc/base/constructormagic.h"
18 #include "webrtc/base/optional.h" 18 #include "webrtc/base/optional.h"
19 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h" 19 #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" 20 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h"
21 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" 21 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
22 22
23 namespace webrtc { 23 namespace webrtc {
24 24
25 namespace {
26 class PacketLossFractionSmoother;
27 }
kwiberg-webrtc 2016/10/11 14:56:19 Style guide says "Don't use unnamed namespaces in
minyue-webrtc 2016/10/11 15:31:09 Thanks! It reads better.
28
25 struct CodecInst; 29 struct CodecInst;
26 30
27 class AudioEncoderOpus final : public AudioEncoder { 31 class AudioEncoderOpus final : public AudioEncoder {
28 public: 32 public:
29 enum ApplicationMode { 33 enum ApplicationMode {
30 kVoip = 0, 34 kVoip = 0,
31 kAudio = 1, 35 kAudio = 1,
32 }; 36 };
33 37
34 struct Config { 38 struct Config {
35 Config(); 39 Config();
36 Config(const Config&); 40 Config(const Config&);
37 ~Config(); 41 ~Config();
38 Config& operator=(const Config&); 42 Config& operator=(const Config&);
39 43
40 bool IsOk() const; 44 bool IsOk() const;
41 int GetBitrateBps() const; 45 int GetBitrateBps() const;
42 46
43 int frame_size_ms = 20; 47 int frame_size_ms = 20;
44 size_t num_channels = 1; 48 size_t num_channels = 1;
45 int payload_type = 120; 49 int payload_type = 120;
46 ApplicationMode application = kVoip; 50 ApplicationMode application = kVoip;
47 rtc::Optional<int> bitrate_bps; // Unset means to use default value. 51 rtc::Optional<int> bitrate_bps; // Unset means to use default value.
48 bool fec_enabled = false; 52 bool fec_enabled = false;
49 int max_playback_rate_hz = 48000; 53 int max_playback_rate_hz = 48000;
50 int complexity = kDefaultComplexity; 54 int complexity = kDefaultComplexity;
51 bool dtx_enabled = false; 55 bool dtx_enabled = false;
56 const Clock* clock = nullptr;
52 57
53 private: 58 private:
54 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM) 59 #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 60 // If we are on Android, iOS and/or ARM, use a lower complexity setting as
56 // default, to save encoder complexity. 61 // default, to save encoder complexity.
57 static const int kDefaultComplexity = 5; 62 static const int kDefaultComplexity = 5;
58 #else 63 #else
59 static const int kDefaultComplexity = 9; 64 static const int kDefaultComplexity = 9;
60 #endif 65 #endif
61 }; 66 };
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 const std::string& config_string, 131 const std::string& config_string,
127 const Clock* clock) const; 132 const Clock* clock) const;
128 133
129 Config config_; 134 Config config_;
130 double packet_loss_rate_; 135 double packet_loss_rate_;
131 std::vector<int16_t> input_buffer_; 136 std::vector<int16_t> input_buffer_;
132 OpusEncInst* inst_; 137 OpusEncInst* inst_;
133 uint32_t first_timestamp_in_buffer_; 138 uint32_t first_timestamp_in_buffer_;
134 size_t num_channels_to_encode_; 139 size_t num_channels_to_encode_;
135 int next_frame_length_ms_; 140 int next_frame_length_ms_;
141 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_;
136 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; 142 AudioNetworkAdaptorCreator audio_network_adaptor_creator_;
137 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; 143 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_;
138 144
139 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); 145 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus);
140 }; 146 };
141 147
142 } // namespace webrtc 148 } // namespace webrtc
143 149
144 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ 150 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698