niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | * Calculates and stores the packet buffer statistics. |
| 13 | */ |
| 14 | |
| 15 | #ifndef BUFFER_STATS_H |
| 16 | #define BUFFER_STATS_H |
| 17 | |
| 18 | #include "automode.h" |
| 19 | #include "webrtc_neteq.h" /* to define enum WebRtcNetEQPlayoutMode */ |
| 20 | |
| 21 | /* NetEQ related decisions */ |
| 22 | #define BUFSTATS_DO_NORMAL 0 |
| 23 | #define BUFSTATS_DO_ACCELERATE 1 |
| 24 | #define BUFSTATS_DO_MERGE 2 |
| 25 | #define BUFSTATS_DO_EXPAND 3 |
| 26 | #define BUFSTAT_REINIT 4 |
| 27 | #define BUFSTATS_DO_RFC3389CNG_PACKET 5 |
| 28 | #define BUFSTATS_DO_RFC3389CNG_NOPACKET 6 |
| 29 | #define BUFSTATS_DO_INTERNAL_CNG_NOPACKET 7 |
| 30 | #define BUFSTATS_DO_PREEMPTIVE_EXPAND 8 |
| 31 | #define BUFSTAT_REINIT_DECODER 9 |
| 32 | #define BUFSTATS_DO_DTMF_ONLY 10 |
| 33 | /* Decisions related to when NetEQ is switched off (or in FAX mode) */ |
| 34 | #define BUFSTATS_DO_ALTERNATIVE_PLC 11 |
| 35 | #define BUFSTATS_DO_ALTERNATIVE_PLC_INC_TS 12 |
| 36 | #define BUFSTATS_DO_AUDIO_REPETITION 13 |
| 37 | #define BUFSTATS_DO_AUDIO_REPETITION_INC_TS 14 |
| 38 | |
| 39 | /* Reinit decoder states after this number of expands (upon arrival of new packet) */ |
| 40 | #define REINIT_AFTER_EXPANDS 100 |
| 41 | |
| 42 | /* Wait no longer than this number of RecOut calls before using an "early" packet */ |
| 43 | #define MAX_WAIT_FOR_PACKET 10 |
| 44 | |
| 45 | /* CNG modes */ |
| 46 | #define CNG_OFF 0 |
| 47 | #define CNG_RFC3389_ON 1 |
| 48 | #define CNG_INTERNAL_ON 2 |
| 49 | |
| 50 | typedef struct |
| 51 | { |
| 52 | |
| 53 | /* store statistical data here */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 54 | int16_t w16_cngOn; /* remember if CNG is interrupted by other event (e.g. DTMF) */ |
| 55 | int16_t w16_noExpand; |
| 56 | int32_t uw32_CNGplayedTS; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 57 | |
| 58 | /* VQmon data */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 59 | uint16_t avgDelayMsQ8; |
| 60 | int16_t maxDelayMs; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 61 | |
| 62 | AutomodeInst_t Automode_inst; |
| 63 | |
| 64 | } BufstatsInst_t; |
| 65 | |
| 66 | /**************************************************************************** |
| 67 | * WebRtcNetEQ_BufstatsDecision() |
| 68 | * |
| 69 | * Gives a decision about what action that is currently desired |
| 70 | * |
| 71 | * |
| 72 | * Input: |
| 73 | * inst: The bufstat instance |
| 74 | * cur_size: Current buffer size in ms in Q3 domain |
| 75 | * targetTS: The desired timestamp to start playout from |
| 76 | * availableTS: The closest future value available in buffer |
| 77 | * noPacket 1 if no packet is available, makes availableTS undefined |
| 78 | * prevPlayMode mode of last NetEq playout |
| 79 | * timestampsPerCall number of timestamp for 10ms |
| 80 | * |
| 81 | * Output: |
| 82 | * Returns: A decision, as defined above (see top of file) |
| 83 | * |
| 84 | */ |
| 85 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 86 | uint16_t WebRtcNetEQ_BufstatsDecision(BufstatsInst_t *inst, int16_t frameSize, |
| 87 | int32_t cur_size, uint32_t targetTS, |
| 88 | uint32_t availableTS, int noPacket, |
| 89 | int cngPacket, int prevPlayMode, |
| 90 | enum WebRtcNetEQPlayoutMode playoutMode, |
| 91 | int timestampsPerCall, int NoOfExpandCalls, |
| 92 | int16_t fs_mult, |
| 93 | int16_t lastModeBGNonly, int playDtmf); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 94 | |
| 95 | #endif |