Home | History | Annotate | Download | only in acm2
      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 
     16 #ifndef WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_CODEC_DATABASE_H_
     17 #define WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_CODEC_DATABASE_H_
     18 
     19 #include "webrtc/common_types.h"
     20 #include "webrtc/engine_configurations.h"
     21 #include "webrtc/modules/audio_coding/acm2/rent_a_codec.h"
     22 #include "webrtc/modules/audio_coding/neteq/include/neteq.h"
     23 
     24 namespace webrtc {
     25 
     26 namespace acm2 {
     27 
     28 // TODO(tlegrand): replace class ACMCodecDB with a namespace.
     29 class ACMCodecDB {
     30  public:
     31   // kMaxNumCodecs - Maximum number of codecs that can be activated in one
     32   //                 build.
     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
     35   static const int kMaxNumCodecs =  50;
     36   static const int kMaxNumPacketSize = 6;
     37 
     38   // Codec specific settings
     39   //
     40   // num_packet_sizes     - number of 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
     43   //                        requires to be fed with a specific number of samples
     44   //                        that can be different from packet size.
     45   // channel_support      - number of channels supported to encode;
     46   //                        1 = mono, 2 = stereo, etc.
     47   struct CodecSettings {
     48     int num_packet_sizes;
     49     int packet_sizes_samples[kMaxNumPacketSize];
     50     int basic_block_samples;
     51     size_t channel_support;
     52   };
     53 
     54   // Returns codec id from database, given the information received in the input
     55   // [codec_inst].
     56   // Input:
     57   //   [codec_inst] - Information about the codec for which we require the
     58   //                  database id.
     59   // Return:
     60   //   codec id if successful, otherwise < 0.
     61   static int CodecNumber(const CodecInst& codec_inst);
     62   static int CodecId(const CodecInst& codec_inst);
     63   static int CodecId(const char* payload_name, int frequency, size_t channels);
     64   static int ReceiverCodecNumber(const CodecInst& codec_inst);
     65 
     66   // Databases with information about the supported codecs
     67   // database_ - stored information about all codecs: payload type, name,
     68   //             sampling frequency, packet size in samples, default channel
     69   //             support, and default rate.
     70   // codec_settings_ - stored codec settings: number of allowed packet sizes,
     71   //                   a vector with the allowed packet sizes, basic block
     72   //                   samples, and max number of channels that are supported.
     73   // neteq_decoders_ - list of supported decoders in NetEQ.
     74   static const CodecInst database_[kMaxNumCodecs];
     75   static const CodecSettings codec_settings_[kMaxNumCodecs];
     76   static const NetEqDecoder neteq_decoders_[kMaxNumCodecs];
     77 };
     78 
     79 }  // namespace acm2
     80 
     81 }  // namespace webrtc
     82 
     83 #endif  // WEBRTC_MODULES_AUDIO_CODING_ACM2_ACM_CODEC_DATABASE_H_
     84