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 rtc::Maybe<RentACodec::CodecId> RentACodec::CodecIdByParams( |
| 20 const char* payload_name, |
| 21 int sampling_freq_hz, |
| 22 int channels) { |
| 23 return CodecIdFromIndex( |
| 24 ACMCodecDB::CodecId(payload_name, sampling_freq_hz, channels)); |
| 25 } |
| 26 |
| 27 rtc::Maybe<CodecInst> RentACodec::CodecInstById(CodecId codec_id) { |
| 28 rtc::Maybe<int> mi = CodecIndexFromId(codec_id); |
| 29 return mi ? rtc::Maybe<CodecInst>(Database()[*mi]) : rtc::Maybe<CodecInst>(); |
| 30 } |
| 31 |
| 32 rtc::Maybe<CodecInst> RentACodec::CodecInstByParams(const char* payload_name, |
| 33 int sampling_freq_hz, |
| 34 int channels) { |
| 35 rtc::Maybe<CodecId> codec_id = |
| 36 CodecIdByParams(payload_name, sampling_freq_hz, channels); |
| 37 if (!codec_id) |
| 38 return rtc::Maybe<CodecInst>(); |
| 39 rtc::Maybe<CodecInst> ci = CodecInstById(*codec_id); |
| 40 RTC_DCHECK(ci); |
| 41 |
| 42 // Keep the number of channels from the function call. For most codecs it |
| 43 // will be the same value as in default codec settings, but not for all. |
| 44 ci->channels = channels; |
| 45 |
| 46 return ci; |
| 47 } |
| 48 |
| 49 bool RentACodec::IsCodecValid(const CodecInst& codec_inst) { |
| 50 return ACMCodecDB::CodecNumber(codec_inst) >= 0; |
| 51 } |
| 52 |
| 53 rtc::ArrayView<const CodecInst> RentACodec::Database() { |
| 54 return rtc::ArrayView<const CodecInst>(ACMCodecDB::database_, |
| 55 NumberOfCodecs()); |
| 56 } |
| 57 |
| 58 } // namespace acm2 |
| 59 } // namespace webrtc |
OLD | NEW |