1/*
2 *  Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 *
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
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#include "webrtc/modules/audio_coding/neteq/include/neteq.h"
12
13#include <sstream>
14
15#include "webrtc/modules/audio_coding/neteq/accelerate.h"
16#include "webrtc/modules/audio_coding/neteq/buffer_level_filter.h"
17#include "webrtc/modules/audio_coding/neteq/decoder_database.h"
18#include "webrtc/modules/audio_coding/neteq/delay_manager.h"
19#include "webrtc/modules/audio_coding/neteq/delay_peak_detector.h"
20#include "webrtc/modules/audio_coding/neteq/dtmf_buffer.h"
21#include "webrtc/modules/audio_coding/neteq/dtmf_tone_generator.h"
22#include "webrtc/modules/audio_coding/neteq/expand.h"
23#include "webrtc/modules/audio_coding/neteq/neteq_impl.h"
24#include "webrtc/modules/audio_coding/neteq/packet_buffer.h"
25#include "webrtc/modules/audio_coding/neteq/payload_splitter.h"
26#include "webrtc/modules/audio_coding/neteq/preemptive_expand.h"
27#include "webrtc/modules/audio_coding/neteq/timestamp_scaler.h"
28
29namespace webrtc {
30
31std::string NetEq::Config::ToString() const {
32  std::stringstream ss;
33  ss << "sample_rate_hz=" << sample_rate_hz << ", enable_audio_classifier="
34     << (enable_audio_classifier ? "true" : "false")
35     << ", enable_post_decode_vad="
36     << (enable_post_decode_vad ? "true" : "false")
37     << ", max_packets_in_buffer=" << max_packets_in_buffer
38     << ", background_noise_mode=" << background_noise_mode
39     << ", playout_mode=" << playout_mode
40     << ", enable_fast_accelerate=" << enable_fast_accelerate;
41  return ss.str();
42}
43
44// Creates all classes needed and inject them into a new NetEqImpl object.
45// Return the new object.
46NetEq* NetEq::Create(const NetEq::Config& config) {
47  BufferLevelFilter* buffer_level_filter = new BufferLevelFilter;
48  DecoderDatabase* decoder_database = new DecoderDatabase;
49  DelayPeakDetector* delay_peak_detector = new DelayPeakDetector;
50  DelayManager* delay_manager =
51      new DelayManager(config.max_packets_in_buffer, delay_peak_detector);
52  delay_manager->SetMaximumDelay(config.max_delay_ms);
53  DtmfBuffer* dtmf_buffer = new DtmfBuffer(config.sample_rate_hz);
54  DtmfToneGenerator* dtmf_tone_generator = new DtmfToneGenerator;
55  PacketBuffer* packet_buffer = new PacketBuffer(config.max_packets_in_buffer);
56  PayloadSplitter* payload_splitter = new PayloadSplitter;
57  TimestampScaler* timestamp_scaler = new TimestampScaler(*decoder_database);
58  AccelerateFactory* accelerate_factory = new AccelerateFactory;
59  ExpandFactory* expand_factory = new ExpandFactory;
60  PreemptiveExpandFactory* preemptive_expand_factory =
61      new PreemptiveExpandFactory;
62  return new NetEqImpl(config,
63                       buffer_level_filter,
64                       decoder_database,
65                       delay_manager,
66                       delay_peak_detector,
67                       dtmf_buffer,
68                       dtmf_tone_generator,
69                       packet_buffer,
70                       payload_splitter,
71                       timestamp_scaler,
72                       accelerate_factory,
73                       expand_factory,
74                       preemptive_expand_factory);
75}
76
77}  // namespace webrtc
78