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

Side by Side Diff: webrtc/modules/audio_coding/main/acm2/rent_a_codec.h

Issue 1412683006: RentACodec: New class that takes over part of ACMCodecDB's job (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: review fixes Created 5 years, 1 month 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) 2015 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 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_
12 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_
13
14 #include <stddef.h>
15
16 #include "webrtc/base/array_view.h"
17 #include "webrtc/base/maybe.h"
18 #include "webrtc/typedefs.h"
19
20 namespace webrtc {
21
22 struct CodecInst;
23
24 namespace acm2 {
25
26 class RentACodec {
27 public:
28 enum class CodecId {
29 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
30 kISAC,
31 #endif
32 #ifdef WEBRTC_CODEC_ISAC
33 kISACSWB,
34 #endif
35 // Mono
36 kPCM16B,
37 kPCM16Bwb,
38 kPCM16Bswb32kHz,
39 // Stereo
40 kPCM16B_2ch,
41 kPCM16Bwb_2ch,
42 kPCM16Bswb32kHz_2ch,
43 // Mono
44 kPCMU,
45 kPCMA,
46 // Stereo
47 kPCMU_2ch,
48 kPCMA_2ch,
49 #ifdef WEBRTC_CODEC_ILBC
50 kILBC,
51 #endif
52 #ifdef WEBRTC_CODEC_G722
53 kG722, // Mono
54 kG722_2ch, // Stereo
55 #endif
56 #ifdef WEBRTC_CODEC_OPUS
57 kOpus, // Mono and stereo
58 #endif
59 kCNNB,
60 kCNWB,
61 kCNSWB,
62 #ifdef ENABLE_48000_HZ
63 kCNFB,
64 #endif
65 kAVT,
66 #ifdef WEBRTC_CODEC_RED
67 kRED,
68 #endif
69 kNumCodecs, // Implementation detail. Don't use.
70
71 // Set unsupported codecs to -1.
72 #if !defined(WEBRTC_CODEC_ISAC) && !defined(WEBRTC_CODEC_ISACFX)
73 kISAC = -1,
74 #endif
75 #ifndef WEBRTC_CODEC_ISAC
76 kISACSWB = -1,
77 #endif
78 // 48 kHz not supported, always set to -1.
79 kPCM16Bswb48kHz = -1,
80 #ifndef WEBRTC_CODEC_ILBC
81 kILBC = -1,
82 #endif
83 #ifndef WEBRTC_CODEC_G722
84 kG722 = -1, // Mono
85 kG722_2ch = -1, // Stereo
86 #endif
87 #ifndef WEBRTC_CODEC_OPUS
88 kOpus = -1, // Mono and stereo
89 #endif
90 #ifndef WEBRTC_CODEC_RED
91 kRED = -1,
92 #endif
93 #ifndef ENABLE_48000_HZ
94 kCNFB = -1,
95 #endif
96
97 kNone = -1
98 };
99
100 static inline size_t NumberOfCodecs() {
101 return static_cast<size_t>(CodecId::kNumCodecs);
102 }
103
104 static inline rtc::Maybe<int> CodecIndexFromId(CodecId codec_id) {
105 const int i = static_cast<int>(codec_id);
106 return i < static_cast<int>(NumberOfCodecs()) ? i : rtc::Maybe<int>();
107 }
108
109 static inline rtc::Maybe<CodecId> CodecIdFromIndex(int codec_index) {
110 return static_cast<size_t>(codec_index) < NumberOfCodecs()
111 ? static_cast<RentACodec::CodecId>(codec_index)
112 : rtc::Maybe<RentACodec::CodecId>();
113 }
114
115 static rtc::Maybe<CodecId> CodecIdByParams(const char* payload_name,
116 int sampling_freq_hz,
117 int channels);
118 static rtc::Maybe<CodecInst> CodecInstById(CodecId codec_id);
119 static rtc::Maybe<CodecInst> CodecInstByParams(const char* payload_name,
120 int sampling_freq_hz,
121 int channels);
122 static bool IsCodecValid(const CodecInst& codec_inst);
123 static rtc::ArrayView<const CodecInst> Database();
124 };
125
126 } // namespace acm2
127 } // namespace webrtc
128
129 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_
OLDNEW
« no previous file with comments | « webrtc/modules/audio_coding/main/acm2/codec_manager.cc ('k') | webrtc/modules/audio_coding/main/acm2/rent_a_codec.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698