Home | History | Annotate | Download | only in source
      1 /*
      2  *  Copyright (c) 2015 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 #ifndef WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ISAC_FIX_TYPE_H_
     12 #define WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ISAC_FIX_TYPE_H_
     13 
     14 #include "webrtc/base/checks.h"
     15 #include "webrtc/modules/audio_coding/codecs/isac/fix/include/isacfix.h"
     16 
     17 namespace webrtc {
     18 
     19 class IsacFix {
     20  public:
     21   using instance_type = ISACFIX_MainStruct;
     22   static const bool has_swb = false;
     23   static inline int16_t Control(instance_type* inst,
     24                                 int32_t rate,
     25                                 int framesize) {
     26     return WebRtcIsacfix_Control(inst, rate, framesize);
     27   }
     28   static inline int16_t ControlBwe(instance_type* inst,
     29                                    int32_t rate_bps,
     30                                    int frame_size_ms,
     31                                    int16_t enforce_frame_size) {
     32     return WebRtcIsacfix_ControlBwe(inst, rate_bps, frame_size_ms,
     33                                     enforce_frame_size);
     34   }
     35   static inline int16_t Create(instance_type** inst) {
     36     return WebRtcIsacfix_Create(inst);
     37   }
     38   static inline int DecodeInternal(instance_type* inst,
     39                                    const uint8_t* encoded,
     40                                    size_t len,
     41                                    int16_t* decoded,
     42                                    int16_t* speech_type) {
     43     return WebRtcIsacfix_Decode(inst, encoded, len, decoded, speech_type);
     44   }
     45   static inline size_t DecodePlc(instance_type* inst,
     46                                  int16_t* decoded,
     47                                  size_t num_lost_frames) {
     48     return WebRtcIsacfix_DecodePlc(inst, decoded, num_lost_frames);
     49   }
     50   static inline void DecoderInit(instance_type* inst) {
     51     WebRtcIsacfix_DecoderInit(inst);
     52   }
     53   static inline int Encode(instance_type* inst,
     54                            const int16_t* speech_in,
     55                            uint8_t* encoded) {
     56     return WebRtcIsacfix_Encode(inst, speech_in, encoded);
     57   }
     58   static inline int16_t EncoderInit(instance_type* inst, int16_t coding_mode) {
     59     return WebRtcIsacfix_EncoderInit(inst, coding_mode);
     60   }
     61   static inline uint16_t EncSampRate(instance_type* inst) {
     62     return kFixSampleRate;
     63   }
     64 
     65   static inline int16_t Free(instance_type* inst) {
     66     return WebRtcIsacfix_Free(inst);
     67   }
     68   static inline void GetBandwidthInfo(instance_type* inst,
     69                                       IsacBandwidthInfo* bwinfo) {
     70     WebRtcIsacfix_GetBandwidthInfo(inst, bwinfo);
     71   }
     72   static inline int16_t GetErrorCode(instance_type* inst) {
     73     return WebRtcIsacfix_GetErrorCode(inst);
     74   }
     75 
     76   static inline int16_t GetNewFrameLen(instance_type* inst) {
     77     return WebRtcIsacfix_GetNewFrameLen(inst);
     78   }
     79   static inline void SetBandwidthInfo(instance_type* inst,
     80                                       const IsacBandwidthInfo* bwinfo) {
     81     WebRtcIsacfix_SetBandwidthInfo(inst, bwinfo);
     82   }
     83   static inline int16_t SetDecSampRate(instance_type* inst,
     84                                        uint16_t sample_rate_hz) {
     85     RTC_DCHECK_EQ(sample_rate_hz, kFixSampleRate);
     86     return 0;
     87   }
     88   static inline int16_t SetEncSampRate(instance_type* inst,
     89                                        uint16_t sample_rate_hz) {
     90     RTC_DCHECK_EQ(sample_rate_hz, kFixSampleRate);
     91     return 0;
     92   }
     93   static inline void SetEncSampRateInDecoder(instance_type* inst,
     94                                              uint16_t sample_rate_hz) {
     95     RTC_DCHECK_EQ(sample_rate_hz, kFixSampleRate);
     96   }
     97   static inline void SetInitialBweBottleneck(instance_type* inst,
     98                                              int bottleneck_bits_per_second) {
     99     WebRtcIsacfix_SetInitialBweBottleneck(inst, bottleneck_bits_per_second);
    100   }
    101   static inline int16_t UpdateBwEstimate(instance_type* inst,
    102                                          const uint8_t* encoded,
    103                                          size_t packet_size,
    104                                          uint16_t rtp_seq_number,
    105                                          uint32_t send_ts,
    106                                          uint32_t arr_ts) {
    107     return WebRtcIsacfix_UpdateBwEstimate(inst, encoded, packet_size,
    108                                           rtp_seq_number, send_ts, arr_ts);
    109   }
    110   static inline int16_t SetMaxPayloadSize(instance_type* inst,
    111                                           int16_t max_payload_size_bytes) {
    112     return WebRtcIsacfix_SetMaxPayloadSize(inst, max_payload_size_bytes);
    113   }
    114   static inline int16_t SetMaxRate(instance_type* inst, int32_t max_bit_rate) {
    115     return WebRtcIsacfix_SetMaxRate(inst, max_bit_rate);
    116   }
    117 
    118  private:
    119   enum { kFixSampleRate = 16000 };
    120 };
    121 
    122 }  // namespace webrtc
    123 #endif  // WEBRTC_MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_ISAC_FIX_TYPE_H_
    124