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 #include "webrtc/modules/audio_coding/main/acm2/rent_a_codec.h" | |
12 | |
13 #include "webrtc/modules/audio_coding/main/acm2/acm_codec_database.h" | |
14 #include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" | |
15 | |
16 namespace webrtc { | |
17 namespace acm2 { | |
18 | |
19 namespace {} // namespace | |
hlundin-webrtc
2015/10/27 13:52:02
WAT?
kwiberg-webrtc
2015/10/27 14:43:23
What, have you never seen an empty anonymous names
hlundin-webrtc
2015/10/27 15:31:27
Yes, but very time you enter this file, you will l
| |
20 | |
21 rtc::Maybe<RentACodec::CodecId> RentACodec::CodecIdByParams( | |
22 const char* payload_name, | |
23 int sampling_freq_hz, | |
24 int channels) { | |
25 return CodecIdFromIndex( | |
26 ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels)); | |
27 } | |
28 | |
29 rtc::Maybe<CodecInst> RentACodec::CodecInstById(CodecId codec_id) { | |
30 rtc::Maybe<int> mi = CodecIndexFromId(codec_id); | |
31 return mi ? rtc::Maybe<CodecInst>(Database()[*mi]) : rtc::Maybe<CodecInst>(); | |
32 } | |
33 | |
34 rtc::Maybe<CodecInst> RentACodec::CodecInstByParams(const char* payload_name, | |
35 int sampling_freq_hz, | |
36 int channels) { | |
37 rtc::Maybe<CodecId> codec_id = | |
38 CodecIdByParams(payload_name, sampling_freq_hz, channels); | |
39 if (!codec_id) | |
40 return rtc::Maybe<CodecInst>(); | |
41 rtc::Maybe<CodecInst> ci = CodecInstById(*codec_id); | |
42 RTC_DCHECK(ci); | |
43 | |
44 // Keep the number of channels from the function call. For most codecs it | |
45 // will be the same value as in default codec settings, but not for all. | |
46 ci->channels = channels; | |
47 | |
48 return ci; | |
49 } | |
50 | |
51 bool RentACodec::IsCodecValid(const CodecInst& codec_inst) { | |
52 return ACMCodecDB::CodecNumber(codec_inst) >= 0; | |
53 } | |
54 | |
55 rtc::ArrayView<const CodecInst> RentACodec::Database() { | |
56 return rtc::ArrayView<const CodecInst>(ACMCodecDB::database_, | |
57 NumberOfCodecs()); | |
58 } | |
59 | |
60 } // namespace acm2 | |
61 } // namespace webrtc | |
OLD | NEW |