blob: ee6bb46faa3ac8ffd380fb8f8ebd6e27c9712fd7 [file] [log] [blame]
turaj@webrtc.org7959e162013-09-12 18:30:26 +00001/*
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 Bonadei92ea95e2017-09-15 06:47:31 +020016#ifndef MODULES_AUDIO_CODING_ACM2_ACM_CODEC_DATABASE_H_
17#define MODULES_AUDIO_CODING_ACM2_ACM_CODEC_DATABASE_H_
turaj@webrtc.org7959e162013-09-12 18:30:26 +000018
Mirko Bonadei71207422017-09-15 13:58:09 +020019#include "common_types.h" // NOLINT(build/include)
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020020#include "modules/audio_coding/acm2/rent_a_codec.h"
turaj@webrtc.org7959e162013-09-12 18:30:26 +000021
22namespace webrtc {
23
turaj@webrtc.org6d5d2482013-10-06 04:47:28 +000024namespace acm2 {
25
turaj@webrtc.org7959e162013-09-12 18:30:26 +000026// TODO(tlegrand): replace class ACMCodecDB with a namespace.
27class ACMCodecDB {
kwiberg39d8bee2015-11-06 16:22:47 -080028 public:
turaj@webrtc.org7959e162013-09-12 18:30:26 +000029 // kMaxNumCodecs - Maximum number of codecs that can be activated in one
30 // build.
31 // kMaxNumPacketSize - Maximum number of allowed packet sizes for one codec.
32 // These might need to be increased if adding a new codec to the database
Yves Gerey665174f2018-06-19 15:03:05 +020033 static const int kMaxNumCodecs = 50;
turaj@webrtc.org7959e162013-09-12 18:30:26 +000034 static const int kMaxNumPacketSize = 6;
35
36 // Codec specific settings
37 //
38 // num_packet_sizes - number of allowed packet sizes.
39 // packet_sizes_samples - list of the allowed packet sizes.
40 // basic_block_samples - assigned a value different from 0 if the codec
41 // requires to be fed with a specific number of samples
42 // that can be different from packet size.
43 // channel_support - number of channels supported to encode;
44 // 1 = mono, 2 = stereo, etc.
turaj@webrtc.org7959e162013-09-12 18:30:26 +000045 struct CodecSettings {
46 int num_packet_sizes;
47 int packet_sizes_samples[kMaxNumPacketSize];
48 int basic_block_samples;
Peter Kasting69558702016-01-12 16:26:35 -080049 size_t channel_support;
turaj@webrtc.org7959e162013-09-12 18:30:26 +000050 };
51
Henrik Lundin93ef1d82015-04-13 09:31:16 +020052 // Returns codec id from database, given the information received in the input
53 // [codec_inst].
turaj@webrtc.org7959e162013-09-12 18:30:26 +000054 // Input:
55 // [codec_inst] - Information about the codec for which we require the
56 // database id.
turaj@webrtc.org7959e162013-09-12 18:30:26 +000057 // Return:
58 // codec id if successful, otherwise < 0.
Henrik Lundin93ef1d82015-04-13 09:31:16 +020059 static int CodecNumber(const CodecInst& codec_inst);
turaj@webrtc.org7959e162013-09-12 18:30:26 +000060 static int CodecId(const CodecInst& codec_inst);
Peter Kasting69558702016-01-12 16:26:35 -080061 static int CodecId(const char* payload_name, int frequency, size_t channels);
Henrik Lundin93ef1d82015-04-13 09:31:16 +020062 static int ReceiverCodecNumber(const CodecInst& codec_inst);
turaj@webrtc.org7959e162013-09-12 18:30:26 +000063
turaj@webrtc.org7959e162013-09-12 18:30:26 +000064 // Databases with information about the supported codecs
65 // database_ - stored information about all codecs: payload type, name,
66 // sampling frequency, packet size in samples, default channel
67 // support, and default rate.
68 // codec_settings_ - stored codec settings: number of allowed packet sizes,
69 // a vector with the allowed packet sizes, basic block
70 // samples, and max number of channels that are supported.
71 // neteq_decoders_ - list of supported decoders in NetEQ.
72 static const CodecInst database_[kMaxNumCodecs];
kwibergde94d082015-11-03 05:46:09 -080073 static const CodecSettings codec_settings_[kMaxNumCodecs];
turaj@webrtc.org7959e162013-09-12 18:30:26 +000074 static const NetEqDecoder neteq_decoders_[kMaxNumCodecs];
75};
76
turaj@webrtc.org6d5d2482013-10-06 04:47:28 +000077} // namespace acm2
78
turaj@webrtc.org7959e162013-09-12 18:30:26 +000079} // namespace webrtc
80
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020081#endif // MODULES_AUDIO_CODING_ACM2_ACM_CODEC_DATABASE_H_