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  * decode_bwe.c
13  *
14  * This C file contains the internal decode bandwidth estimate function.
15  *
16  */
17 
18 
19 #include "bandwidth_estimator.h"
20 #include "codec.h"
21 #include "entropy_coding.h"
22 #include "structs.h"
23 
24 
25 
26 
WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr * bwest_str,Bitstr_dec * streamdata,size_t packet_size,uint16_t rtp_seq_number,uint32_t send_ts,uint32_t arr_ts)27 int WebRtcIsacfix_EstimateBandwidth(BwEstimatorstr *bwest_str,
28                                     Bitstr_dec  *streamdata,
29                                     size_t packet_size,
30                                     uint16_t rtp_seq_number,
31                                     uint32_t send_ts,
32                                     uint32_t arr_ts)
33 {
34   int16_t index;
35   size_t frame_samples;
36   int err;
37 
38   /* decode framelength */
39   err = WebRtcIsacfix_DecodeFrameLen(streamdata, &frame_samples);
40   /* error check */
41   if (err<0) {
42     return err;
43   }
44 
45   /* decode BW estimation */
46   err = WebRtcIsacfix_DecodeSendBandwidth(streamdata, &index);
47   /* error check */
48   if (err<0) {
49     return err;
50   }
51 
52   /* Update BWE with received data */
53   err = WebRtcIsacfix_UpdateUplinkBwImpl(
54       bwest_str,
55       rtp_seq_number,
56       (int16_t)(frame_samples * 1000 / FS),
57       send_ts,
58       arr_ts,
59       packet_size,  /* in bytes */
60       index);
61 
62   /* error check */
63   if (err<0) {
64     return err;
65   }
66 
67   /* Succesful */
68   return 0;
69 }
70