blob: 74275a3510e22857f19b09b0a16ff73c355ba37c [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 Bonadei92ea95e2017-09-15 06:47:31 +020019#include "common_types.h"
20#include "modules/audio_coding/acm2/rent_a_codec.h"
21#include "typedefs.h"
turaj@webrtc.org7959e162013-09-12 18:30:26 +000022
23namespace webrtc {
24
turaj@webrtc.org6d5d2482013-10-06 04:47:28 +000025namespace acm2 {
26
turaj@webrtc.org7959e162013-09-12 18:30:26 +000027// TODO(tlegrand): replace class ACMCodecDB with a namespace.
28class ACMCodecDB {
kwiberg39d8bee2015-11-06 16:22:47 -080029 public:
turaj@webrtc.org7959e162013-09-12 18:30:26 +000030 // 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
34 static const int kMaxNumCodecs = 50;
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.org7959e162013-09-12 18:30:26 +000046 struct CodecSettings {
47 int num_packet_sizes;
48 int packet_sizes_samples[kMaxNumPacketSize];
49 int basic_block_samples;
Peter Kasting69558702016-01-12 16:26:35 -080050 size_t channel_support;
turaj@webrtc.org7959e162013-09-12 18:30:26 +000051 };
52
Henrik Lundin93ef1d82015-04-13 09:31:16 +020053 // Returns codec id from database, given the information received in the input
54 // [codec_inst].
turaj@webrtc.org7959e162013-09-12 18:30:26 +000055 // Input:
56 // [codec_inst] - Information about the codec for which we require the
57 // database id.
turaj@webrtc.org7959e162013-09-12 18:30:26 +000058 // Return:
59 // codec id if successful, otherwise < 0.
Henrik Lundin93ef1d82015-04-13 09:31:16 +020060 static int CodecNumber(const CodecInst& codec_inst);
turaj@webrtc.org7959e162013-09-12 18:30:26 +000061 static int CodecId(const CodecInst& codec_inst);
Peter Kasting69558702016-01-12 16:26:35 -080062 static int CodecId(const char* payload_name, int frequency, size_t channels);
Henrik Lundin93ef1d82015-04-13 09:31:16 +020063 static int ReceiverCodecNumber(const CodecInst& codec_inst);
turaj@webrtc.org7959e162013-09-12 18:30:26 +000064
turaj@webrtc.org7959e162013-09-12 18:30:26 +000065 // 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];
kwibergde94d082015-11-03 05:46:09 -080074 static const CodecSettings codec_settings_[kMaxNumCodecs];
turaj@webrtc.org7959e162013-09-12 18:30:26 +000075 static const NetEqDecoder neteq_decoders_[kMaxNumCodecs];
76};
77
turaj@webrtc.org6d5d2482013-10-06 04:47:28 +000078} // namespace acm2
79
turaj@webrtc.org7959e162013-09-12 18:30:26 +000080} // namespace webrtc
81
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020082#endif // MODULES_AUDIO_CODING_ACM2_ACM_CODEC_DATABASE_H_