blob: 3aae4ce614a83fca8f0100588b33c36e20210644 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
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.orgdbba1f92011-12-20 15:45:05 +000017#include <assert.h>
niklase@google.com470e71d2011-07-07 08:21:25 +000018#include <string.h>
19
20#include "automode.h"
21
22int 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;
35 inst->NetEqPlayoutMode = kPlayoutOn;
36
37 WebRtcNetEQ_DbReset(&inst->codec_DB_inst);
38 memset(&inst->PayloadSplit_inst, 0, sizeof(SplitInfo_t));
39
40 /* Clear the Packet buffer and the pointer to memory storage */
41 WebRtcNetEQ_PacketBufferFlush(&inst->PacketBuffer_inst);
42 inst->PacketBuffer_inst.memorySizeW16 = 0;
43 inst->PacketBuffer_inst.maxInsertPositions = 0;
44
45 /* Clear the decision and delay history */
46 memset(&inst->BufferStat_inst, 0, sizeof(BufstatsInst_t));
47#ifdef NETEQ_ATEVENT_DECODE
48 ok = WebRtcNetEQ_DtmfDecoderInit(&inst->DTMF_inst, 8000, 560);
49 if (ok != 0)
50 {
51 return ok;
52 }
53#endif
54 inst->NoOfExpandCalls = 0;
55 inst->current_Codec = -1;
56 inst->current_Payload = -1;
57
58 inst->millisecondsPerCall = 10;
59 inst->timestampsPerCall = inst->millisecondsPerCall * 8;
60 inst->fs = 8000;
61 inst->first_packet = 1;
62
63 WebRtcNetEQ_ResetMcuInCallStats(inst);
64
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05 +000065 WebRtcNetEQ_ResetWaitingTimeStats(inst);
66
niklase@google.com470e71d2011-07-07 08:21:25 +000067 WebRtcNetEQ_ResetMcuJitterStat(inst);
68
69 WebRtcNetEQ_ResetAutomode(&(inst->BufferStat_inst.Automode_inst),
70 inst->PacketBuffer_inst.maxInsertPositions);
71
72 return 0;
73}
74
75/*
76 * Reset MCU-side statistics variables for the in-call statistics.
77 */
78
79int WebRtcNetEQ_ResetMcuInCallStats(MCUInst_t *inst)
80{
81 inst->lostTS = 0;
82 inst->lastReportTS = 0;
83 inst->PacketBuffer_inst.discardedPackets = 0;
84
85 return 0;
86}
87
88/*
henrik.lundin@webrtc.orgdbba1f92011-12-20 15:45:05 +000089 * Reset waiting-time statistics.
90 */
91
92void WebRtcNetEQ_ResetWaitingTimeStats(MCUInst_t *inst) {
93 memset(inst->waiting_times, 0,
94 kLenWaitingTimes * sizeof(inst->waiting_times[0]));
95 inst->len_waiting_times = 0;
96 inst->next_waiting_time_index = 0;
97}
98
99/*
100 * Store waiting-time in the statistics.
101 */
102
103void WebRtcNetEQ_StoreWaitingTime(MCUInst_t *inst, int waiting_time) {
104 assert(inst->next_waiting_time_index < kLenWaitingTimes);
105 inst->waiting_times[inst->next_waiting_time_index] = waiting_time;
106 inst->next_waiting_time_index++;
107 if (inst->next_waiting_time_index >= kLenWaitingTimes) {
108 inst->next_waiting_time_index = 0;
109 }
110 if (inst->len_waiting_times < kLenWaitingTimes) {
111 inst->len_waiting_times++;
112 }
113}
114
115/*
niklase@google.com470e71d2011-07-07 08:21:25 +0000116 * Reset all MCU-side statistics variables for the post-call statistics.
117 */
118
119int WebRtcNetEQ_ResetMcuJitterStat(MCUInst_t *inst)
120{
niklase@google.com470e71d2011-07-07 08:21:25 +0000121 inst->BufferStat_inst.Automode_inst.countIAT500ms = 0;
122 inst->BufferStat_inst.Automode_inst.countIAT1000ms = 0;
123 inst->BufferStat_inst.Automode_inst.countIAT2000ms = 0;
124 inst->BufferStat_inst.Automode_inst.longestIATms = 0;
125
126 return 0;
127}
128