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

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

Issue 2695243005: Injectable audio encoders: BuiltinAudioEncoderFactory (Closed)
Patch Set: Created 3 years, 10 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/api/audio_codecs/audio_format.h"
19 #include "webrtc/base/constructormagic.h" 20 #include "webrtc/base/constructormagic.h"
20 #include "webrtc/base/optional.h" 21 #include "webrtc/base/optional.h"
21 #include "webrtc/common_audio/smoothing_filter.h" 22 #include "webrtc/common_audio/smoothing_filter.h"
22 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ k_adaptor.h" 23 #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" 24 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h"
24 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" 25 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
25 26
26 namespace webrtc { 27 namespace webrtc {
27 28
28 class RtcEventLog; 29 class RtcEventLog;
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 private: 72 private:
72 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM) 73 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) || defined(WEBRTC_ARCH_ARM)
73 // If we are on Android, iOS and/or ARM, use a lower complexity setting as 74 // If we are on Android, iOS and/or ARM, use a lower complexity setting as
74 // default, to save encoder complexity. 75 // default, to save encoder complexity.
75 static const int kDefaultComplexity = 5; 76 static const int kDefaultComplexity = 5;
76 #else 77 #else
77 static const int kDefaultComplexity = 9; 78 static const int kDefaultComplexity = 9;
78 #endif 79 #endif
79 }; 80 };
80 81
82 static Config CreateConfig(int payload_type, const SdpAudioFormat& format);
83
81 using AudioNetworkAdaptorCreator = 84 using AudioNetworkAdaptorCreator =
82 std::function<std::unique_ptr<AudioNetworkAdaptor>(const std::string&, 85 std::function<std::unique_ptr<AudioNetworkAdaptor>(const std::string&,
83 RtcEventLog*, 86 RtcEventLog*,
84 const Clock*)>; 87 const Clock*)>;
85 AudioEncoderOpus( 88 AudioEncoderOpus(
86 const Config& config, 89 const Config& config,
87 AudioNetworkAdaptorCreator&& audio_network_adaptor_creator = nullptr, 90 AudioNetworkAdaptorCreator&& audio_network_adaptor_creator = nullptr,
88 std::unique_ptr<SmoothingFilter> bitrate_smoother = nullptr); 91 std::unique_ptr<SmoothingFilter> bitrate_smoother = nullptr);
89 92
90 explicit AudioEncoderOpus(const CodecInst& codec_inst); 93 explicit AudioEncoderOpus(const CodecInst& codec_inst);
94 AudioEncoderOpus(int payload_type, const SdpAudioFormat& format);
95 ~AudioEncoderOpus() override;
91 96
92 ~AudioEncoderOpus() override; 97 // Static interface for use by BuiltinAudioEncoderFactory.
98 static constexpr const char* GetPayloadName() { return "opus"; }
99 static rtc::Optional<AudioFormatInfo> QueryAudioFormat(
100 const SdpAudioFormat& format);
93 101
94 int SampleRateHz() const override; 102 int SampleRateHz() const override;
95 size_t NumChannels() const override; 103 size_t NumChannels() const override;
96 size_t Num10MsFramesInNextPacket() const override; 104 size_t Num10MsFramesInNextPacket() const override;
97 size_t Max10MsFramesInAPacket() const override; 105 size_t Max10MsFramesInAPacket() const override;
98 int GetTargetBitrate() const override; 106 int GetTargetBitrate() const override;
99 107
100 void Reset() override; 108 void Reset() override;
101 bool SetFec(bool enable) override; 109 bool SetFec(bool enable) override;
102 110
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 rtc::Optional<size_t> overhead_bytes_per_packet_; 183 rtc::Optional<size_t> overhead_bytes_per_packet_;
176 const std::unique_ptr<SmoothingFilter> bitrate_smoother_; 184 const std::unique_ptr<SmoothingFilter> bitrate_smoother_;
177 rtc::Optional<int64_t> bitrate_smoother_last_update_time_; 185 rtc::Optional<int64_t> bitrate_smoother_last_update_time_;
178 186
179 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus); 187 RTC_DISALLOW_COPY_AND_ASSIGN(AudioEncoderOpus);
180 }; 188 };
181 189
182 } // namespace webrtc 190 } // namespace webrtc
183 191
184 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_ 192 #endif // WEBRTC_MODULES_AUDIO_CODING_CODECS_OPUS_AUDIO_ENCODER_OPUS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698