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