| 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 |
| 11 /* | 11 /* |
| 12 * This file generates databases with information about all supported audio | 12 * This file generates databases with information about all supported audio |
| 13 * codecs. | 13 * codecs. |
| 14 */ | 14 */ |
| 15 | 15 |
| 16 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CODEC_DATABASE_H_ | 16 #ifndef WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CODEC_DATABASE_H_ |
| 17 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CODEC_DATABASE_H_ | 17 #define WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CODEC_DATABASE_H_ |
| 18 | 18 |
| 19 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
| 20 #include "webrtc/engine_configurations.h" | 20 #include "webrtc/engine_configurations.h" |
| 21 #include "webrtc/modules/audio_coding/main/acm2/rent_a_codec.h" | 21 #include "webrtc/modules/audio_coding/main/acm2/rent_a_codec.h" |
| 22 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" | 22 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" |
| 23 | 23 |
| 24 namespace webrtc { | 24 namespace webrtc { |
| 25 | 25 |
| 26 namespace acm2 { | 26 namespace acm2 { |
| 27 | 27 |
| 28 // TODO(tlegrand): replace class ACMCodecDB with a namespace. | 28 // TODO(tlegrand): replace class ACMCodecDB with a namespace. |
| 29 class ACMCodecDB { | 29 class ACMCodecDB { |
| 30 public: | 30 private: |
| 31 // kMaxNumCodecs - Maximum number of codecs that can be activated in one | 31 // kMaxNumCodecs - Maximum number of codecs that can be activated in one |
| 32 // build. | 32 // build. |
| 33 // kMaxNumPacketSize - Maximum number of allowed packet sizes for one codec. | 33 // kMaxNumPacketSize - Maximum number of allowed packet sizes for one codec. |
| 34 // These might need to be increased if adding a new codec to the database | 34 // These might need to be increased if adding a new codec to the database |
| 35 static const int kMaxNumCodecs = 50; | 35 static const int kMaxNumCodecs = 50; |
| 36 static const int kMaxNumPacketSize = 6; | 36 static const int kMaxNumPacketSize = 6; |
| 37 | 37 |
| 38 // Codec specific settings | 38 // Codec specific settings |
| 39 // | 39 // |
| 40 // num_packet_sizes - number of allowed packet sizes. | 40 // num_packet_sizes - number of allowed packet sizes. |
| 41 // packet_sizes_samples - list of the allowed packet sizes. | 41 // packet_sizes_samples - list of the allowed packet sizes. |
| 42 // basic_block_samples - assigned a value different from 0 if the codec | 42 // basic_block_samples - assigned a value different from 0 if the codec |
| 43 // requires to be fed with a specific number of samples | 43 // requires to be fed with a specific number of samples |
| 44 // that can be different from packet size. | 44 // that can be different from packet size. |
| 45 // channel_support - number of channels supported to encode; | 45 // channel_support - number of channels supported to encode; |
| 46 // 1 = mono, 2 = stereo, etc. | 46 // 1 = mono, 2 = stereo, etc. |
| 47 struct CodecSettings { | 47 struct CodecSettings { |
| 48 int num_packet_sizes; | 48 int num_packet_sizes; |
| 49 int packet_sizes_samples[kMaxNumPacketSize]; | 49 int packet_sizes_samples[kMaxNumPacketSize]; |
| 50 int basic_block_samples; | 50 int basic_block_samples; |
| 51 int channel_support; | 51 int channel_support; |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 // Gets codec information from database at the position in database given by | |
| 55 // [codec_id]. | |
| 56 // Input: | |
| 57 // [codec_id] - number that specifies at what position in the database to | |
| 58 // get the information. | |
| 59 // Output: | |
| 60 // [codec_inst] - filled with information about the codec. | |
| 61 // Return: | |
| 62 // 0 if successful, otherwise -1. | |
| 63 static int Codec(int codec_id, CodecInst* codec_inst); | |
| 64 | |
| 65 // Returns codec id from database, given the information received in the input | 54 // Returns codec id from database, given the information received in the input |
| 66 // [codec_inst]. | 55 // [codec_inst]. |
| 67 // Input: | 56 // Input: |
| 68 // [codec_inst] - Information about the codec for which we require the | 57 // [codec_inst] - Information about the codec for which we require the |
| 69 // database id. | 58 // database id. |
| 70 // Return: | 59 // Return: |
| 71 // codec id if successful, otherwise < 0. | 60 // codec id if successful, otherwise < 0. |
| 72 static int CodecNumber(const CodecInst& codec_inst); | 61 static int CodecNumber(const CodecInst& codec_inst); |
| 73 static int CodecId(const CodecInst& codec_inst); | 62 static int CodecId(const CodecInst& codec_inst); |
| 74 static int CodecId(const char* payload_name, int frequency, int channels); | 63 static int CodecId(const char* payload_name, int frequency, int channels); |
| 75 static int ReceiverCodecNumber(const CodecInst& codec_inst); | 64 static int ReceiverCodecNumber(const CodecInst& codec_inst); |
| 76 | 65 |
| 77 private: | |
| 78 // Databases with information about the supported codecs | 66 // Databases with information about the supported codecs |
| 79 // database_ - stored information about all codecs: payload type, name, | 67 // database_ - stored information about all codecs: payload type, name, |
| 80 // sampling frequency, packet size in samples, default channel | 68 // sampling frequency, packet size in samples, default channel |
| 81 // support, and default rate. | 69 // support, and default rate. |
| 82 // codec_settings_ - stored codec settings: number of allowed packet sizes, | 70 // codec_settings_ - stored codec settings: number of allowed packet sizes, |
| 83 // a vector with the allowed packet sizes, basic block | 71 // a vector with the allowed packet sizes, basic block |
| 84 // samples, and max number of channels that are supported. | 72 // samples, and max number of channels that are supported. |
| 85 // neteq_decoders_ - list of supported decoders in NetEQ. | 73 // neteq_decoders_ - list of supported decoders in NetEQ. |
| 86 static const CodecInst database_[kMaxNumCodecs]; | 74 static const CodecInst database_[kMaxNumCodecs]; |
| 87 static const CodecSettings codec_settings_[kMaxNumCodecs]; | 75 static const CodecSettings codec_settings_[kMaxNumCodecs]; |
| 88 static const NetEqDecoder neteq_decoders_[kMaxNumCodecs]; | 76 static const NetEqDecoder neteq_decoders_[kMaxNumCodecs]; |
| 89 | 77 |
| 90 friend class RentACodec; | 78 friend class RentACodec; |
| 91 }; | 79 }; |
| 92 | 80 |
| 93 } // namespace acm2 | 81 } // namespace acm2 |
| 94 | 82 |
| 95 } // namespace webrtc | 83 } // namespace webrtc |
| 96 | 84 |
| 97 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CODEC_DATABASE_H_ | 85 #endif // WEBRTC_MODULES_AUDIO_CODING_MAIN_ACM2_ACM_CODEC_DATABASE_H_ |
| OLD | NEW |