blob: e185411e29e4fbde0f5095179a721d15489be4f5 [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 * Packet buffer for DTMF messages.
13 */
14
15#ifndef DTMF_BUFFER_H
16#define DTMF_BUFFER_H
17
18#include "typedefs.h"
19
20#include "neteq_defines.h"
21
22/* Include this code only if ATEVENT (DTMF) is defined in */
23#ifdef NETEQ_ATEVENT_DECODE
24
25#define MAX_DTMF_QUEUE_SIZE 4
26
27typedef struct dtmf_inst_t_
28{
29 WebRtc_Word16 MaxPLCtime;
30 WebRtc_Word16 CurrentPLCtime;
31 WebRtc_Word16 EventQueue[MAX_DTMF_QUEUE_SIZE];
32 WebRtc_Word16 EventQueueVolume[MAX_DTMF_QUEUE_SIZE];
33 WebRtc_Word16 EventQueueEnded[MAX_DTMF_QUEUE_SIZE];
34 WebRtc_UWord32 EventQueueStartTime[MAX_DTMF_QUEUE_SIZE];
35 WebRtc_UWord32 EventQueueEndTime[MAX_DTMF_QUEUE_SIZE];
36 WebRtc_Word16 EventBufferSize;
37 WebRtc_Word16 framelen;
38} dtmf_inst_t;
39
40/****************************************************************************
41 * WebRtcNetEQ_DtmfDecoderInit(...)
42 *
43 * This function initializes a DTMF instance.
44 *
45 * Input:
46 * - DTMF_decinst_t : DTMF instance
47 * - fs : The sample rate used for the DTMF
48 * - MaxPLCtime : Maximum length for a PLC before zeros should be inserted
49 *
50 * Return value : 0 - Ok
51 * -1 - Error
52 */
53
54WebRtc_Word16 WebRtcNetEQ_DtmfDecoderInit(dtmf_inst_t *DTMFdec_inst, WebRtc_UWord16 fs,
55 WebRtc_Word16 MaxPLCtime);
56
57/****************************************************************************
58 * WebRtcNetEQ_DtmfInsertEvent(...)
59 *
60 * This function decodes a packet with DTMF frames.
61 *
62 * Input:
63 * - DTMFdec_inst : DTMF instance
64 * - encoded : Encoded DTMF frame(s)
65 * - len : Bytes in encoded vector
66 *
67 *
68 * Return value : 0 - Ok
69 * -1 - Error
70 */
71
72WebRtc_Word16 WebRtcNetEQ_DtmfInsertEvent(dtmf_inst_t *DTMFdec_inst,
73 const WebRtc_Word16 *encoded, WebRtc_Word16 len,
74 WebRtc_UWord32 timeStamp);
75
76/****************************************************************************
77 * WebRtcNetEQ_DtmfDecode(...)
78 *
79 * This function decodes a packet with DTMF frame(s). Output will be the
80 * event that should be played for next 10 ms.
81 *
82 * Input:
83 * - DTMFdec_inst : DTMF instance
84 * - currTimeStamp : The current playout timestamp
85 *
86 * Output:
87 * - event : Event number to be played
88 * - volume : Event volume to be played
89 *
90 * Return value : >0 - There is a event to be played
91 * 0 - No event to be played
92 * -1 - Error
93 */
94
95WebRtc_Word16 WebRtcNetEQ_DtmfDecode(dtmf_inst_t *DTMFdec_inst, WebRtc_Word16 *event,
96 WebRtc_Word16 *volume, WebRtc_UWord32 currTimeStamp);
97
98#endif /* NETEQ_ATEVENT_DECODE */
99
100#endif /* DTMF_BUFFER_H */
101