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

Side by Side Diff: webrtc/modules/audio_coding/acm2/audio_coding_module_impl.h

Issue 1673213002: AudioCodingModule: Add methods for injecting external encoder stacks (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Total rebase of the heart Created 4 years, 9 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) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 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
42 ///////////////////////////////////////// 42 /////////////////////////////////////////
43 // Sender 43 // Sender
44 // 44 //
45 45
46 // Can be called multiple times for Codec, CNG, RED. 46 // Can be called multiple times for Codec, CNG, RED.
47 int RegisterSendCodec(const CodecInst& send_codec) override; 47 int RegisterSendCodec(const CodecInst& send_codec) override;
48 48
49 void RegisterExternalSendCodec( 49 void RegisterExternalSendCodec(
50 AudioEncoder* external_speech_encoder) override; 50 AudioEncoder* external_speech_encoder) override;
51 51
52 void ModifyEncoder(
53 FunctionView<void(std::unique_ptr<AudioEncoder>*)> modifier) override;
54
52 // Get current send codec. 55 // Get current send codec.
53 rtc::Optional<CodecInst> SendCodec() const override; 56 rtc::Optional<CodecInst> SendCodec() const override;
54 57
55 // Get current send frequency. 58 // Get current send frequency.
56 int SendFrequency() const override; 59 int SendFrequency() const override;
57 60
58 // Sets the bitrate to the specified value in bits/sec. In case the codec does 61 // Sets the bitrate to the specified value in bits/sec. In case the codec does
59 // not support the requested value it will choose an appropriate value 62 // not support the requested value it will choose an appropriate value
60 // instead. 63 // instead.
61 void SetBitRate(int bitrate_bps) override; 64 void SetBitRate(int bitrate_bps) override;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 115
113 // Initialize receiver, resets codec database etc. 116 // Initialize receiver, resets codec database etc.
114 int InitializeReceiver() override; 117 int InitializeReceiver() override;
115 118
116 // Get current receive frequency. 119 // Get current receive frequency.
117 int ReceiveFrequency() const override; 120 int ReceiveFrequency() const override;
118 121
119 // Get current playout frequency. 122 // Get current playout frequency.
120 int PlayoutFrequency() const override; 123 int PlayoutFrequency() const override;
121 124
122 // Register possible receive codecs, can be called multiple times,
123 // for codecs, CNG, DTMF, RED.
124 int RegisterReceiveCodec(const CodecInst& receive_codec) override; 125 int RegisterReceiveCodec(const CodecInst& receive_codec) override;
126 int RegisterReceiveCodec(
127 const CodecInst& receive_codec,
128 FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory) override;
125 129
126 int RegisterExternalReceiveCodec(int rtp_payload_type, 130 int RegisterExternalReceiveCodec(int rtp_payload_type,
127 AudioDecoder* external_decoder, 131 AudioDecoder* external_decoder,
128 int sample_rate_hz, 132 int sample_rate_hz,
129 int num_channels, 133 int num_channels,
130 const std::string& name) override; 134 const std::string& name) override;
131 135
132 // Get current received codec. 136 // Get current received codec.
133 int ReceiveCodec(CodecInst* current_codec) const override; 137 int ReceiveCodec(CodecInst* current_codec) const override;
134 138
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 // Logs the new value if it is different from the last logged value, or if 210 // Logs the new value if it is different from the last logged value, or if
207 // this is the first call. 211 // this is the first call.
208 void MaybeLog(int value); 212 void MaybeLog(int value);
209 213
210 private: 214 private:
211 int last_value_ = 0; 215 int last_value_ = 0;
212 int first_time_ = true; 216 int first_time_ = true;
213 const std::string histogram_name_; 217 const std::string histogram_name_;
214 }; 218 };
215 219
220 int RegisterReceiveCodecUnlocked(
221 const CodecInst& codec,
222 FunctionView<std::unique_ptr<AudioDecoder>()> isac_factory)
223 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
224
216 int Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data) 225 int Add10MsDataInternal(const AudioFrame& audio_frame, InputData* input_data)
217 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 226 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
218 int Encode(const InputData& input_data) 227 int Encode(const InputData& input_data)
219 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 228 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
220 229
221 int InitializeReceiverSafe() EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 230 int InitializeReceiverSafe() EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
222 231
223 bool HaveValidEncoder(const char* caller_name) const 232 bool HaveValidEncoder(const char* caller_name) const
224 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_); 233 EXCLUSIVE_LOCKS_REQUIRED(acm_crit_sect_);
225 234
(...skipping 25 matching lines...) Expand all
251 AcmReceiver receiver_; // AcmReceiver has it's own internal lock. 260 AcmReceiver receiver_; // AcmReceiver has it's own internal lock.
252 ChangeLogger bitrate_logger_ GUARDED_BY(acm_crit_sect_); 261 ChangeLogger bitrate_logger_ GUARDED_BY(acm_crit_sect_);
253 262
254 std::unique_ptr<EncoderFactory> encoder_factory_ GUARDED_BY(acm_crit_sect_); 263 std::unique_ptr<EncoderFactory> encoder_factory_ GUARDED_BY(acm_crit_sect_);
255 264
256 // Current encoder stack, either obtained from 265 // Current encoder stack, either obtained from
257 // encoder_factory_->rent_a_codec.RentEncoderStack or provided by a call to 266 // encoder_factory_->rent_a_codec.RentEncoderStack or provided by a call to
258 // RegisterEncoder. 267 // RegisterEncoder.
259 std::unique_ptr<AudioEncoder> encoder_stack_ GUARDED_BY(acm_crit_sect_); 268 std::unique_ptr<AudioEncoder> encoder_stack_ GUARDED_BY(acm_crit_sect_);
260 269
270 std::unique_ptr<AudioDecoder> isac_decoder_ GUARDED_BY(acm_crit_sect_);
271
261 // This is to keep track of CN instances where we can send DTMFs. 272 // This is to keep track of CN instances where we can send DTMFs.
262 uint8_t previous_pltype_ GUARDED_BY(acm_crit_sect_); 273 uint8_t previous_pltype_ GUARDED_BY(acm_crit_sect_);
263 274
264 // Used when payloads are pushed into ACM without any RTP info 275 // Used when payloads are pushed into ACM without any RTP info
265 // One example is when pre-encoded bit-stream is pushed from 276 // One example is when pre-encoded bit-stream is pushed from
266 // a file. 277 // a file.
267 // IMPORTANT: this variable is only used in IncomingPayload(), therefore, 278 // IMPORTANT: this variable is only used in IncomingPayload(), therefore,
268 // no lock acquired when interacting with this variable. If it is going to 279 // no lock acquired when interacting with this variable. If it is going to
269 // be used in other methods, locks need to be taken. 280 // be used in other methods, locks need to be taken.
270 std::unique_ptr<WebRtcRTPHeader> aux_rtp_header_; 281 std::unique_ptr<WebRtcRTPHeader> aux_rtp_header_;
(...skipping 10 matching lines...) Expand all
281 rtc::CriticalSection callback_crit_sect_; 292 rtc::CriticalSection callback_crit_sect_;
282 AudioPacketizationCallback* packetization_callback_ 293 AudioPacketizationCallback* packetization_callback_
283 GUARDED_BY(callback_crit_sect_); 294 GUARDED_BY(callback_crit_sect_);
284 ACMVADCallback* vad_callback_ GUARDED_BY(callback_crit_sect_); 295 ACMVADCallback* vad_callback_ GUARDED_BY(callback_crit_sect_);
285 }; 296 };
286 297
287 } // namespace acm2 298 } // namespace acm2
288 } // namespace webrtc 299 } // namespace webrtc
289 300
290 #endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_AUDIO_CODING_MODULE_IMPL_H_ 301 #endif // WEBRTC_MODULES_AUDIO_CODING_ACM2_AUDIO_CODING_MODULE_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698