OLD | NEW |
---|---|
(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 static inline rtc::Maybe<int> CodecIndexFromId(CodecId codec_id) { | |
hlundin-webrtc
2015/10/27 13:52:02
I wouldn't mind an empty line between each method
kwiberg-webrtc
2015/10/27 14:43:23
Done.
| |
104 const int i = static_cast<int>(codec_id); | |
105 return i < static_cast<int>(NumberOfCodecs()) ? i : rtc::Maybe<int>(); | |
106 } | |
107 static inline rtc::Maybe<CodecId> CodecIdFromIndex(int codec_index) { | |
108 return static_cast<size_t>(codec_index) < NumberOfCodecs() | |
109 ? static_cast<RentACodec::CodecId>(codec_index) | |
110 : rtc::Maybe<RentACodec::CodecId>(); | |
111 } | |
112 static rtc::Maybe<CodecId> CodecIdByParams(const char* payload_name, | |
113 int sampling_freq_hz, | |
114 int channels); | |
115 static rtc::Maybe<CodecInst> CodecInstById(CodecId codec_id); | |
116 static rtc::Maybe<CodecInst> CodecInstByParams(const char* payload_name, | |
the sun
2015/10/27 14:07:07
Sorry for the naïve question, but... Isn't this th
kwiberg-webrtc
2015/10/27 14:43:23
They're all needed at the moment, because old call
| |
117 int sampling_freq_hz, | |
118 int channels); | |
119 static bool IsCodecValid(const CodecInst& codec_inst); | |
120 | |
121 static rtc::ArrayView<const CodecInst> Database(); | |
122 }; | |
123 | |
124 } // namespace acm2 | |
125 } // namespace webrtc | |
126 | |
127 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_RENT_A_CODEC_H_ | |
OLD | NEW |