| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 if (!ci) | 50 if (!ci) |
| 51 return -1; | 51 return -1; |
| 52 *codec = *ci; | 52 *codec = *ci; |
| 53 return 0; | 53 return 0; |
| 54 } | 54 } |
| 55 | 55 |
| 56 int AudioCodingModule::Codec(const char* payload_name, | 56 int AudioCodingModule::Codec(const char* payload_name, |
| 57 CodecInst* codec, | 57 CodecInst* codec, |
| 58 int sampling_freq_hz, | 58 int sampling_freq_hz, |
| 59 int channels) { | 59 int channels) { |
| 60 rtc::Maybe<CodecInst> ci = acm2::RentACodec::CodecInstByParams( | 60 rtc::Optional<CodecInst> ci = acm2::RentACodec::CodecInstByParams( |
| 61 payload_name, sampling_freq_hz, channels); | 61 payload_name, sampling_freq_hz, channels); |
| 62 if (ci) { | 62 if (ci) { |
| 63 *codec = *ci; | 63 *codec = *ci; |
| 64 return 0; | 64 return 0; |
| 65 } else { | 65 } else { |
| 66 // We couldn't find a matching codec, so set the parameters to unacceptable | 66 // We couldn't find a matching codec, so set the parameters to unacceptable |
| 67 // values and return. | 67 // values and return. |
| 68 codec->plname[0] = '\0'; | 68 codec->plname[0] = '\0'; |
| 69 codec->pltype = -1; | 69 codec->pltype = -1; |
| 70 codec->pacsize = 0; | 70 codec->pacsize = 0; |
| 71 codec->rate = 0; | 71 codec->rate = 0; |
| 72 codec->plfreq = 0; | 72 codec->plfreq = 0; |
| 73 return -1; | 73 return -1; |
| 74 } | 74 } |
| 75 } | 75 } |
| 76 | 76 |
| 77 int AudioCodingModule::Codec(const char* payload_name, | 77 int AudioCodingModule::Codec(const char* payload_name, |
| 78 int sampling_freq_hz, | 78 int sampling_freq_hz, |
| 79 int channels) { | 79 int channels) { |
| 80 rtc::Maybe<acm2::RentACodec::CodecId> ci = acm2::RentACodec::CodecIdByParams( | 80 rtc::Optional<acm2::RentACodec::CodecId> ci = |
| 81 payload_name, sampling_freq_hz, channels); | 81 acm2::RentACodec::CodecIdByParams(payload_name, sampling_freq_hz, |
| 82 channels); |
| 82 if (!ci) | 83 if (!ci) |
| 83 return -1; | 84 return -1; |
| 84 rtc::Maybe<int> i = acm2::RentACodec::CodecIndexFromId(*ci); | 85 rtc::Optional<int> i = acm2::RentACodec::CodecIndexFromId(*ci); |
| 85 return i ? *i : -1; | 86 return i ? *i : -1; |
| 86 } | 87 } |
| 87 | 88 |
| 88 // Checks the validity of the parameters of the given codec | 89 // Checks the validity of the parameters of the given codec |
| 89 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { | 90 bool AudioCodingModule::IsCodecValid(const CodecInst& codec) { |
| 90 bool valid = acm2::RentACodec::IsCodecValid(codec); | 91 bool valid = acm2::RentACodec::IsCodecValid(codec); |
| 91 if (!valid) | 92 if (!valid) |
| 92 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, | 93 WEBRTC_TRACE(webrtc::kTraceError, webrtc::kTraceAudioCoding, -1, |
| 93 "Invalid codec setting"); | 94 "Invalid codec setting"); |
| 94 return valid; | 95 return valid; |
| 95 } | 96 } |
| 96 | 97 |
| 97 } // namespace webrtc | 98 } // namespace webrtc |
| OLD | NEW |