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

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

Issue 2553413002: Pass event log to ANA. (Closed)
Patch Set: Rebased Created 3 years, 11 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 <memory> 15 #include <memory>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "webrtc/base/constructormagic.h" 19 #include "webrtc/base/constructormagic.h"
20 #include "webrtc/base/optional.h" 20 #include "webrtc/base/optional.h"
21 #include "webrtc/common_audio/smoothing_filter.h" 21 #include "webrtc/common_audio/smoothing_filter.h"
22 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h" 22 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h"
23 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" 23 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h"
24 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" 24 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
25 25
26 namespace webrtc { 26 namespace webrtc {
27 27
28 class RtcEventLog;
29
28 struct CodecInst; 30 struct CodecInst;
29 31
30 class AudioEncoderOpus final : public AudioEncoder { 32 class AudioEncoderOpus final : public AudioEncoder {
31 public: 33 public:
32 enum ApplicationMode { 34 enum ApplicationMode {
33 kVoip = 0, 35 kVoip = 0,
34 kAudio = 1, 36 kAudio = 1,
35 }; 37 };
36 38
37 struct Config { 39 struct Config {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 // If we are on Android, iOS and/or ARM, use a lower complexity setting as 73 // If we are on Android, iOS and/or ARM, use a lower complexity setting as
72 // default, to save encoder complexity. 74 // default, to save encoder complexity.
73 static const int kDefaultComplexity = 5; 75 static const int kDefaultComplexity = 5;
74 #else 76 #else
75 static const int kDefaultComplexity = 9; 77 static const int kDefaultComplexity = 9;
76 #endif 78 #endif
77 }; 79 };
78 80
79 using AudioNetworkAdaptorCreator = 81 using AudioNetworkAdaptorCreator =
80 std::function<std::unique_ptr<AudioNetworkAdaptor>(const std::string&, 82 std::function<std::unique_ptr<AudioNetworkAdaptor>(const std::string&,
83 RtcEventLog*,
81 const Clock*)>; 84 const Clock*)>;
82 AudioEncoderOpus( 85 AudioEncoderOpus(
83 const Config& config, 86 const Config& config,
84 AudioNetworkAdaptorCreator&& audio_network_adaptor_creator = nullptr, 87 AudioNetworkAdaptorCreator&& audio_network_adaptor_creator = nullptr,
85 std::unique_ptr<SmoothingFilter> bitrate_smoother = nullptr); 88 std::unique_ptr<SmoothingFilter> bitrate_smoother = nullptr);
86 89
87 explicit AudioEncoderOpus(const CodecInst& codec_inst); 90 explicit AudioEncoderOpus(const CodecInst& codec_inst);
88 91
89 ~AudioEncoderOpus() override; 92 ~AudioEncoderOpus() override;
90 93
91 int SampleRateHz() const override; 94 int SampleRateHz() const override;
92 size_t NumChannels() const override; 95 size_t NumChannels() const override;
93 size_t Num10MsFramesInNextPacket() const override; 96 size_t Num10MsFramesInNextPacket() const override;
94 size_t Max10MsFramesInAPacket() const override; 97 size_t Max10MsFramesInAPacket() const override;
95 int GetTargetBitrate() const override; 98 int GetTargetBitrate() const override;
96 99
97 void Reset() override; 100 void Reset() override;
98 bool SetFec(bool enable) override; 101 bool SetFec(bool enable) override;
99 102
100 // Set Opus DTX. Once enabled, Opus stops transmission, when it detects voice 103 // Set Opus DTX. Once enabled, Opus stops transmission, when it detects voice
101 // being inactive. During that, it still sends 2 packets (one for content, one 104 // being inactive. During that, it still sends 2 packets (one for content, one
102 // for signaling) about every 400 ms. 105 // for signaling) about every 400 ms.
103 bool SetDtx(bool enable) override; 106 bool SetDtx(bool enable) override;
104 bool GetDtx() const override; 107 bool GetDtx() const override;
105 108
106 bool SetApplication(Application application) override; 109 bool SetApplication(Application application) override;
107 void SetMaxPlaybackRate(int frequency_hz) override; 110 void SetMaxPlaybackRate(int frequency_hz) override;
108 bool EnableAudioNetworkAdaptor(const std::string& config_string, 111 bool EnableAudioNetworkAdaptor(const std::string& config_string,
112 RtcEventLog* event_log,
109 const Clock* clock) override; 113 const Clock* clock) override;
110 void DisableAudioNetworkAdaptor() override; 114 void DisableAudioNetworkAdaptor() override;
111 void OnReceivedUplinkPacketLossFraction( 115 void OnReceivedUplinkPacketLossFraction(
112 float uplink_packet_loss_fraction) override; 116 float uplink_packet_loss_fraction) override;
113 void OnReceivedUplinkBandwidth( 117 void OnReceivedUplinkBandwidth(
114 int target_audio_bitrate_bps, 118 int target_audio_bitrate_bps,
115 rtc::Optional<int64_t> probing_interval_ms) override; 119 rtc::Optional<int64_t> probing_interval_ms) override;
116 void OnReceivedRtt(int rtt_ms) override; 120 void OnReceivedRtt(int rtt_ms) override;
117 void OnReceivedOverhead(size_t overhead_bytes_per_packet) override; 121 void OnReceivedOverhead(size_t overhead_bytes_per_packet) override;
118 void SetReceiverFrameLengthRange(int min_frame_length_ms, 122 void SetReceiverFrameLengthRange(int min_frame_length_ms,
(...skipping 25 matching lines...) Expand all
144 void SetNumChannelsToEncode(size_t num_channels_to_encode); 148 void SetNumChannelsToEncode(size_t num_channels_to_encode);
145 void SetProjectedPacketLossRate(float fraction); 149 void SetProjectedPacketLossRate(float fraction);
146 150
147 // TODO(minyue): remove "override" when we can deprecate 151 // TODO(minyue): remove "override" when we can deprecate
148 // |AudioEncoder::SetTargetBitrate|. 152 // |AudioEncoder::SetTargetBitrate|.
149 void SetTargetBitrate(int target_bps) override; 153 void SetTargetBitrate(int target_bps) override;
150 154
151 void ApplyAudioNetworkAdaptor(); 155 void ApplyAudioNetworkAdaptor();
152 std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator( 156 std::unique_ptr<AudioNetworkAdaptor> DefaultAudioNetworkAdaptorCreator(
153 const std::string& config_string, 157 const std::string& config_string,
158 RtcEventLog* event_log,
154 const Clock* clock) const; 159 const Clock* clock) const;
155 160
156 void MaybeUpdateUplinkBandwidth(); 161 void MaybeUpdateUplinkBandwidth();
157 162
158 Config config_; 163 Config config_;
159 float packet_loss_rate_; 164 float packet_loss_rate_;
160 std::vector<int16_t> input_buffer_; 165 std::vector<int16_t> input_buffer_;
161 OpusEncInst* inst_; 166 OpusEncInst* inst_;
162 uint32_t first_timestamp_in_buffer_; 167 uint32_t first_timestamp_in_buffer_;
163 size_t num_channels_to_encode_; 168 size_t num_channels_to_encode_;
164 int next_frame_length_ms_; 169 int next_frame_length_ms_;
165 int complexity_; 170 int complexity_;
166 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_; 171 std::unique_ptr<PacketLossFractionSmoother> packet_loss_fraction_smoother_;
167 AudioNetworkAdaptorCreator audio_network_adaptor_creator_; 172 AudioNetworkAdaptorCreator audio_network_adaptor_creator_;
168 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_; 173 std::unique_ptr<AudioNetworkAdaptor> audio_network_adaptor_;
169 rtc::Optional<size_t> overhead_bytes_per_packet_; 174 rtc::Optional<size_t> overhead_bytes_per_packet_;
170 const std::unique_ptr<SmoothingFilter> bitrate_smoother_; 175 const std::unique_ptr<SmoothingFilter> bitrate_smoother_;
171 rtc::Optional<int64_t> bitrate_smoother_last_update_time_; 176 rtc::Optional<int64_t> bitrate_smoother_last_update_time_;
172 177
173 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); 178 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus);
174 }; 179 };
175 180
176 } // namespace webrtc 181 } // namespace webrtc
177 182
178 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ 183 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/codecs/audio_encoder.cc ('k') | webrtc/modules/audio_coding/codecs/opus/audio_encoder_opus.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698