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

Side by Side Diff: webrtc/api/audio_codecs/opus/audio_decoder_opus.cc

Issue 2944763002: Revert of Opus implementation of the AudioDecoderFactoryTemplate API (Closed)
Patch Set: Created 3 years, 6 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
(Empty)
1 /*
2 * Copyright (c) 2017 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/api/audio_codecs/opus/audio_decoder_opus.h"
12
13 #include <memory>
14 #include <utility>
15 #include <vector>
16
17 #include "webrtc/base/ptr_util.h"
18 #include "webrtc/common_types.h"
19 #include "webrtc/modules/audio_coding/codecs/opus/audio_decoder_opus.h"
20
21 namespace webrtc {
22
23 rtc::Optional<AudioDecoderOpus::Config> AudioDecoderOpus::SdpToConfig(
24 const SdpAudioFormat& format) {
25 const rtc::Optional<int> num_channels = [&] {
26 auto stereo = format.parameters.find("stereo");
27 if (stereo != format.parameters.end()) {
28 if (stereo->second == "0") {
29 return rtc::Optional<int>(1);
30 } else if (stereo->second == "1") {
31 return rtc::Optional<int>(2);
32 } else {
33 return rtc::Optional<int>(); // Bad stereo parameter.
34 }
35 }
36 return rtc::Optional<int>(1); // Default to mono.
37 }();
38 if (STR_CASE_CMP(format.name.c_str(), "opus") == 0 &&
39 format.clockrate_hz == 48000 && format.num_channels == 2 &&
40 num_channels) {
41 return rtc::Optional<Config>(Config{*num_channels});
42 } else {
43 return rtc::Optional<Config>();
44 }
45 }
46
47 void AudioDecoderOpus::AppendSupportedDecoders(
48 std::vector<AudioCodecSpec>* specs) {
49 AudioCodecInfo opus_info{48000, 1, 64000, 6000, 510000};
50 opus_info.allow_comfort_noise = false;
51 opus_info.supports_network_adaption = true;
52 SdpAudioFormat opus_format(
53 {"opus", 48000, 2, {{"minptime", "10"}, {"useinbandfec", "1"}}});
54 specs->push_back({std::move(opus_format), std::move(opus_info)});
55 }
56
57 std::unique_ptr<AudioDecoder> AudioDecoderOpus::MakeAudioDecoder(
58 Config config) {
59 return rtc::MakeUnique<AudioDecoderOpusImpl>(config.num_channels);
60 }
61
62 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/api/audio_codecs/opus/audio_decoder_opus.h ('k') | webrtc/api/audio_codecs/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698