turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 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 | /* |
| 12 | * This file generates databases with information about all supported audio |
| 13 | * codecs. |
| 14 | */ |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #ifndef MODULES_AUDIO_CODING_ACM2_ACM_CODEC_DATABASE_H_ |
| 17 | #define MODULES_AUDIO_CODING_ACM2_ACM_CODEC_DATABASE_H_ |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 18 | |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 19 | #include "common_types.h" // NOLINT(build/include) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "modules/audio_coding/acm2/rent_a_codec.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 21 | #include "typedefs.h" // NOLINT(build/include) |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 22 | |
| 23 | namespace webrtc { |
| 24 | |
turaj@webrtc.org | 6d5d248 | 2013-10-06 04:47:28 +0000 | [diff] [blame] | 25 | namespace acm2 { |
| 26 | |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 27 | // TODO(tlegrand): replace class ACMCodecDB with a namespace. |
| 28 | class ACMCodecDB { |
kwiberg | 39d8bee | 2015-11-06 16:22:47 -0800 | [diff] [blame] | 29 | public: |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 30 | // kMaxNumCodecs - Maximum number of codecs that can be activated in one |
| 31 | // build. |
| 32 | // kMaxNumPacketSize - Maximum number of allowed packet sizes for one codec. |
| 33 | // These might need to be increased if adding a new codec to the database |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 34 | static const int kMaxNumCodecs = 50; |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 35 | static const int kMaxNumPacketSize = 6; |
| 36 | |
| 37 | // Codec specific settings |
| 38 | // |
| 39 | // num_packet_sizes - number of allowed packet sizes. |
| 40 | // packet_sizes_samples - list of the allowed packet sizes. |
| 41 | // basic_block_samples - assigned a value different from 0 if the codec |
| 42 | // requires to be fed with a specific number of samples |
| 43 | // that can be different from packet size. |
| 44 | // channel_support - number of channels supported to encode; |
| 45 | // 1 = mono, 2 = stereo, etc. |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 46 | struct CodecSettings { |
| 47 | int num_packet_sizes; |
| 48 | int packet_sizes_samples[kMaxNumPacketSize]; |
| 49 | int basic_block_samples; |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 50 | size_t channel_support; |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
Henrik Lundin | 93ef1d8 | 2015-04-13 09:31:16 +0200 | [diff] [blame] | 53 | // Returns codec id from database, given the information received in the input |
| 54 | // [codec_inst]. |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 55 | // Input: |
| 56 | // [codec_inst] - Information about the codec for which we require the |
| 57 | // database id. |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 58 | // Return: |
| 59 | // codec id if successful, otherwise < 0. |
Henrik Lundin | 93ef1d8 | 2015-04-13 09:31:16 +0200 | [diff] [blame] | 60 | static int CodecNumber(const CodecInst& codec_inst); |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 61 | static int CodecId(const CodecInst& codec_inst); |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 62 | static int CodecId(const char* payload_name, int frequency, size_t channels); |
Henrik Lundin | 93ef1d8 | 2015-04-13 09:31:16 +0200 | [diff] [blame] | 63 | static int ReceiverCodecNumber(const CodecInst& codec_inst); |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 64 | |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 65 | // Databases with information about the supported codecs |
| 66 | // database_ - stored information about all codecs: payload type, name, |
| 67 | // sampling frequency, packet size in samples, default channel |
| 68 | // support, and default rate. |
| 69 | // codec_settings_ - stored codec settings: number of allowed packet sizes, |
| 70 | // a vector with the allowed packet sizes, basic block |
| 71 | // samples, and max number of channels that are supported. |
| 72 | // neteq_decoders_ - list of supported decoders in NetEQ. |
| 73 | static const CodecInst database_[kMaxNumCodecs]; |
kwiberg | de94d08 | 2015-11-03 05:46:09 -0800 | [diff] [blame] | 74 | static const CodecSettings codec_settings_[kMaxNumCodecs]; |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 75 | static const NetEqDecoder neteq_decoders_[kMaxNumCodecs]; |
| 76 | }; |
| 77 | |
turaj@webrtc.org | 6d5d248 | 2013-10-06 04:47:28 +0000 | [diff] [blame] | 78 | } // namespace acm2 |
| 79 | |
turaj@webrtc.org | 7959e16 | 2013-09-12 18:30:26 +0000 | [diff] [blame] | 80 | } // namespace webrtc |
| 81 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 82 | #endif // MODULES_AUDIO_CODING_ACM2_ACM_CODEC_DATABASE_H_ |