1 /* 2 * Copyright (c) 2011 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 * bandwidth_estimator.h 13 * 14 * This header file contains the API for the Bandwidth Estimator 15 * designed for iSAC. 16 * 17 */ 18 19 #ifndef MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ 20 #define MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ 21 22 #include "modules/audio_coding/codecs/isac/fix/source/structs.h" 23 24 /**************************************************************************** 25 * WebRtcIsacfix_InitBandwidthEstimator(...) 26 * 27 * This function initializes the struct for the bandwidth estimator 28 * 29 * Input/Output: 30 * - bwest_str : Struct containing bandwidth information. 31 * 32 * Return value : 0 33 */ 34 35 int32_t WebRtcIsacfix_InitBandwidthEstimator(BwEstimatorstr* bwest_str); 36 37 /**************************************************************************** 38 * WebRtcIsacfix_UpdateUplinkBwImpl(...) 39 * 40 * This function updates bottle neck rate received from other side in payload 41 * and calculates a new bottle neck to send to the other side. 42 * 43 * Input/Output: 44 * - bweStr : struct containing bandwidth information. 45 * - rtpNumber : value from RTP packet, from NetEq 46 * - frameSize : length of signal frame in ms, from iSAC decoder 47 * - sendTime : value in RTP header giving send time in samples 48 * - arrivalTime : value given by timeGetTime() time of arrival in 49 * samples of packet from NetEq 50 * - pksize : size of packet in bytes, from NetEq 51 * - Index : integer (range 0...23) indicating bottle neck & 52 * jitter as estimated by other side 53 * 54 * Return value : 0 if everything went fine, 55 * -1 otherwise 56 */ 57 58 int32_t WebRtcIsacfix_UpdateUplinkBwImpl(BwEstimatorstr* bwest_str, 59 const uint16_t rtp_number, 60 const int16_t frameSize, 61 const uint32_t send_ts, 62 const uint32_t arr_ts, 63 const size_t pksize, 64 const uint16_t Index); 65 66 /* Update receiving estimates. Used when we only receive BWE index, no iSAC data 67 * packet. */ 68 int16_t WebRtcIsacfix_UpdateUplinkBwRec(BwEstimatorstr* bwest_str, 69 const int16_t Index); 70 71 /**************************************************************************** 72 * WebRtcIsacfix_GetDownlinkBwIndexImpl(...) 73 * 74 * This function calculates and returns the bandwidth/jitter estimation code 75 * (integer 0...23) to put in the sending iSAC payload. 76 * 77 * Input: 78 * - bweStr : BWE struct 79 * 80 * Return: 81 * bandwith and jitter index (0..23) 82 */ 83 uint16_t WebRtcIsacfix_GetDownlinkBwIndexImpl(BwEstimatorstr* bwest_str); 84 85 /* Returns the bandwidth estimation (in bps) */ 86 uint16_t WebRtcIsacfix_GetDownlinkBandwidth(const BwEstimatorstr* bwest_str); 87 88 /* Returns the bandwidth that iSAC should send with in bps */ 89 int16_t WebRtcIsacfix_GetUplinkBandwidth(const BwEstimatorstr* bwest_str); 90 91 /* Returns the max delay (in ms) */ 92 int16_t WebRtcIsacfix_GetDownlinkMaxDelay(const BwEstimatorstr* bwest_str); 93 94 /* Returns the max delay value from the other side in ms */ 95 int16_t WebRtcIsacfix_GetUplinkMaxDelay(const BwEstimatorstr* bwest_str); 96 97 /* 98 * update amount of data in bottle neck buffer and burst handling 99 * returns minimum payload size (bytes) 100 */ 101 uint16_t WebRtcIsacfix_GetMinBytes( 102 RateModel* State, 103 int16_t StreamSize, /* bytes in bitstream */ 104 const int16_t FrameLen, /* ms per frame */ 105 const int16_t BottleNeck, /* bottle neck rate; excl headers (bps) */ 106 const int16_t DelayBuildUp); /* max delay from bottle neck buffering (ms) */ 107 108 /* 109 * update long-term average bitrate and amount of data in buffer 110 */ 111 void WebRtcIsacfix_UpdateRateModel( 112 RateModel* State, 113 int16_t StreamSize, /* bytes in bitstream */ 114 const int16_t FrameSamples, /* samples per frame */ 115 const int16_t BottleNeck); /* bottle neck rate; excl headers (bps) */ 116 117 void WebRtcIsacfix_InitRateModel(RateModel* State); 118 119 /* Returns the new framelength value (input argument: bottle_neck) */ 120 int16_t WebRtcIsacfix_GetNewFrameLength(int16_t bottle_neck, 121 int16_t current_framelength); 122 123 /* Returns the new SNR value (input argument: bottle_neck) */ 124 // returns snr in Q10 125 int16_t WebRtcIsacfix_GetSnr(int16_t bottle_neck, int16_t framesamples); 126 127 #endif /* MODULES_AUDIO_CODING_CODECS_ISAC_FIX_SOURCE_BANDWIDTH_ESTIMATOR_H_ \ 128 */ 129