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 11 matching lines...) Expand all Loading... |
22 #include "webrtc/base/checks.h" | 22 #include "webrtc/base/checks.h" |
23 #include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" | 23 #include "webrtc/modules/audio_coding/main/acm2/acm_common_defs.h" |
24 #include "webrtc/system_wrappers/include/trace.h" | 24 #include "webrtc/system_wrappers/include/trace.h" |
25 | 25 |
26 namespace webrtc { | 26 namespace webrtc { |
27 | 27 |
28 namespace acm2 { | 28 namespace acm2 { |
29 | 29 |
30 namespace { | 30 namespace { |
31 | 31 |
32 // Checks if the bitrate is valid for the codec. | |
33 bool IsRateValid(int codec_id, int rate) { | |
34 return ACMCodecDB::database_[codec_id].rate == rate; | |
35 } | |
36 | |
37 // Checks if the bitrate is valid for iSAC. | 32 // Checks if the bitrate is valid for iSAC. |
38 bool IsISACRateValid(int rate) { | 33 bool IsISACRateValid(int rate) { |
39 return (rate == -1) || ((rate <= 56000) && (rate >= 10000)); | 34 return (rate == -1) || ((rate <= 56000) && (rate >= 10000)); |
40 } | 35 } |
41 | 36 |
42 // Checks if the bitrate is valid for iLBC. | 37 // Checks if the bitrate is valid for iLBC. |
43 bool IsILBCRateValid(int rate, int frame_size_samples) { | 38 bool IsILBCRateValid(int rate, int frame_size_samples) { |
44 if (((frame_size_samples == 240) || (frame_size_samples == 480)) && | 39 if (((frame_size_samples == 240) || (frame_size_samples == 480)) && |
45 (rate == 13300)) { | 40 (rate == 13300)) { |
46 return true; | 41 return true; |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 if (STR_CASE_CMP("isac", codec_inst.plname) == 0) { | 286 if (STR_CASE_CMP("isac", codec_inst.plname) == 0) { |
292 return IsISACRateValid(codec_inst.rate) ? codec_id : kInvalidRate; | 287 return IsISACRateValid(codec_inst.rate) ? codec_id : kInvalidRate; |
293 } else if (STR_CASE_CMP("ilbc", codec_inst.plname) == 0) { | 288 } else if (STR_CASE_CMP("ilbc", codec_inst.plname) == 0) { |
294 return IsILBCRateValid(codec_inst.rate, codec_inst.pacsize) | 289 return IsILBCRateValid(codec_inst.rate, codec_inst.pacsize) |
295 ? codec_id : kInvalidRate; | 290 ? codec_id : kInvalidRate; |
296 } else if (STR_CASE_CMP("opus", codec_inst.plname) == 0) { | 291 } else if (STR_CASE_CMP("opus", codec_inst.plname) == 0) { |
297 return IsOpusRateValid(codec_inst.rate) | 292 return IsOpusRateValid(codec_inst.rate) |
298 ? codec_id : kInvalidRate; | 293 ? codec_id : kInvalidRate; |
299 } | 294 } |
300 | 295 |
301 return IsRateValid(codec_id, codec_inst.rate) ? | 296 return database_[codec_id].rate == codec_inst.rate ? codec_id : kInvalidRate; |
302 codec_id : kInvalidRate; | |
303 } | 297 } |
304 | 298 |
305 // Looks for a matching payload name, frequency, and channels in the | 299 // Looks for a matching payload name, frequency, and channels in the |
306 // codec list. Need to check all three since some codecs have several codec | 300 // codec list. Need to check all three since some codecs have several codec |
307 // entries with different frequencies and/or channels. | 301 // entries with different frequencies and/or channels. |
308 // Does not check other codec settings, such as payload type and packet size. | 302 // Does not check other codec settings, such as payload type and packet size. |
309 // Returns the id of the codec, or -1 if no match is found. | 303 // Returns the id of the codec, or -1 if no match is found. |
310 int ACMCodecDB::CodecId(const CodecInst& codec_inst) { | 304 int ACMCodecDB::CodecId(const CodecInst& codec_inst) { |
311 return (CodecId(codec_inst.plname, codec_inst.plfreq, | 305 return (CodecId(codec_inst.plname, codec_inst.plfreq, |
312 codec_inst.channels)); | 306 codec_inst.channels)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 } | 349 } |
356 | 350 |
357 // Checks if the payload type is in the valid range. | 351 // Checks if the payload type is in the valid range. |
358 bool ACMCodecDB::ValidPayloadType(int payload_type) { | 352 bool ACMCodecDB::ValidPayloadType(int payload_type) { |
359 return (payload_type >= 0) && (payload_type <= 127); | 353 return (payload_type >= 0) && (payload_type <= 127); |
360 } | 354 } |
361 | 355 |
362 } // namespace acm2 | 356 } // namespace acm2 |
363 | 357 |
364 } // namespace webrtc | 358 } // namespace webrtc |
OLD | NEW |