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 | * Reset MCU side data. |
| 13 | */ |
| 14 | |
| 15 | #include "mcu.h" |
| 16 | |
henrik.lundin@webrtc.org | dbba1f9 | 2011-12-20 15:45:05 +0000 | [diff] [blame] | 17 | #include <assert.h> |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | #include <string.h> |
| 19 | |
| 20 | #include "automode.h" |
| 21 | |
| 22 | int WebRtcNetEQ_McuReset(MCUInst_t *inst) |
| 23 | { |
| 24 | |
| 25 | #ifdef NETEQ_ATEVENT_DECODE |
| 26 | int ok; |
| 27 | #endif |
| 28 | |
| 29 | /* MCU/DSP Communication layer */ |
| 30 | inst->pw16_readAddress = NULL; |
| 31 | inst->pw16_writeAddress = NULL; |
| 32 | inst->main_inst = NULL; |
| 33 | inst->one_desc = 0; |
| 34 | inst->BufferStat_inst.Automode_inst.extraDelayMs = 0; |
turaj@webrtc.org | e46c8d3 | 2013-05-22 20:39:43 +0000 | [diff] [blame] | 35 | inst->BufferStat_inst.Automode_inst.minimum_delay_ms = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 36 | inst->NetEqPlayoutMode = kPlayoutOn; |
turaj@webrtc.org | e46c8d3 | 2013-05-22 20:39:43 +0000 | [diff] [blame] | 37 | inst->av_sync = 0; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
| 39 | WebRtcNetEQ_DbReset(&inst->codec_DB_inst); |
| 40 | memset(&inst->PayloadSplit_inst, 0, sizeof(SplitInfo_t)); |
| 41 | |
| 42 | /* Clear the Packet buffer and the pointer to memory storage */ |
| 43 | WebRtcNetEQ_PacketBufferFlush(&inst->PacketBuffer_inst); |
| 44 | inst->PacketBuffer_inst.memorySizeW16 = 0; |
| 45 | inst->PacketBuffer_inst.maxInsertPositions = 0; |
| 46 | |
| 47 | /* Clear the decision and delay history */ |
| 48 | memset(&inst->BufferStat_inst, 0, sizeof(BufstatsInst_t)); |
| 49 | #ifdef NETEQ_ATEVENT_DECODE |
| 50 | ok = WebRtcNetEQ_DtmfDecoderInit(&inst->DTMF_inst, 8000, 560); |
| 51 | if (ok != 0) |
| 52 | { |
| 53 | return ok; |
| 54 | } |
| 55 | #endif |
| 56 | inst->NoOfExpandCalls = 0; |
| 57 | inst->current_Codec = -1; |
| 58 | inst->current_Payload = -1; |
| 59 | |
| 60 | inst->millisecondsPerCall = 10; |
| 61 | inst->timestampsPerCall = inst->millisecondsPerCall * 8; |
| 62 | inst->fs = 8000; |
| 63 | inst->first_packet = 1; |
| 64 | |
| 65 | WebRtcNetEQ_ResetMcuInCallStats(inst); |
| 66 | |
henrik.lundin@webrtc.org | dbba1f9 | 2011-12-20 15:45:05 +0000 | [diff] [blame] | 67 | WebRtcNetEQ_ResetWaitingTimeStats(inst); |
| 68 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | WebRtcNetEQ_ResetMcuJitterStat(inst); |
| 70 | |
| 71 | WebRtcNetEQ_ResetAutomode(&(inst->BufferStat_inst.Automode_inst), |
| 72 | inst->PacketBuffer_inst.maxInsertPositions); |
| 73 | |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | /* |
| 78 | * Reset MCU-side statistics variables for the in-call statistics. |
| 79 | */ |
| 80 | |
| 81 | int WebRtcNetEQ_ResetMcuInCallStats(MCUInst_t *inst) |
| 82 | { |
| 83 | inst->lostTS = 0; |
| 84 | inst->lastReportTS = 0; |
| 85 | inst->PacketBuffer_inst.discardedPackets = 0; |
| 86 | |
| 87 | return 0; |
| 88 | } |
| 89 | |
| 90 | /* |
henrik.lundin@webrtc.org | dbba1f9 | 2011-12-20 15:45:05 +0000 | [diff] [blame] | 91 | * Reset waiting-time statistics. |
| 92 | */ |
| 93 | |
| 94 | void WebRtcNetEQ_ResetWaitingTimeStats(MCUInst_t *inst) { |
| 95 | memset(inst->waiting_times, 0, |
| 96 | kLenWaitingTimes * sizeof(inst->waiting_times[0])); |
| 97 | inst->len_waiting_times = 0; |
| 98 | inst->next_waiting_time_index = 0; |
| 99 | } |
| 100 | |
| 101 | /* |
| 102 | * Store waiting-time in the statistics. |
| 103 | */ |
| 104 | |
| 105 | void WebRtcNetEQ_StoreWaitingTime(MCUInst_t *inst, int waiting_time) { |
| 106 | assert(inst->next_waiting_time_index < kLenWaitingTimes); |
| 107 | inst->waiting_times[inst->next_waiting_time_index] = waiting_time; |
| 108 | inst->next_waiting_time_index++; |
| 109 | if (inst->next_waiting_time_index >= kLenWaitingTimes) { |
| 110 | inst->next_waiting_time_index = 0; |
| 111 | } |
| 112 | if (inst->len_waiting_times < kLenWaitingTimes) { |
| 113 | inst->len_waiting_times++; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | /* |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 118 | * Reset all MCU-side statistics variables for the post-call statistics. |
| 119 | */ |
| 120 | |
| 121 | int WebRtcNetEQ_ResetMcuJitterStat(MCUInst_t *inst) |
| 122 | { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 123 | inst->BufferStat_inst.Automode_inst.countIAT500ms = 0; |
| 124 | inst->BufferStat_inst.Automode_inst.countIAT1000ms = 0; |
| 125 | inst->BufferStat_inst.Automode_inst.countIAT2000ms = 0; |
| 126 | inst->BufferStat_inst.Automode_inst.longestIATms = 0; |
| 127 | |
| 128 | return 0; |
| 129 | } |
| 130 | |