blob: 102dec847d0fb98dbc7a07217dc515fcbe8caaff [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 * Interface for the codec database.
13 */
14
15#ifndef CODEC_DB_H
16#define CODEC_DB_H
17
18#include "typedefs.h"
19
20#include "webrtc_neteq.h"
21#include "codec_db_defines.h"
22#include "neteq_defines.h"
23
24#if defined(NETEQ_48KHZ_WIDEBAND)
25 #define NUM_CNG_CODECS 4
26#elif defined(NETEQ_32KHZ_WIDEBAND)
27 #define NUM_CNG_CODECS 3
28#elif defined(NETEQ_WIDEBAND)
29 #define NUM_CNG_CODECS 2
30#else
31 #define NUM_CNG_CODECS 1
32#endif
33
34typedef struct
35{
36
37 WebRtc_Word16 position[NUM_TOTAL_CODECS];
38 WebRtc_Word16 nrOfCodecs;
39
40 WebRtc_Word16 payloadType[NUM_CODECS];
41 FuncDecode funcDecode[NUM_CODECS];
42 FuncDecode funcDecodeRCU[NUM_CODECS];
43 FuncDecodePLC funcDecodePLC[NUM_CODECS];
44 FuncDecodeInit funcDecodeInit[NUM_CODECS];
45 FuncAddLatePkt funcAddLatePkt[NUM_CODECS];
46 FuncGetMDinfo funcGetMDinfo[NUM_CODECS];
47 FuncGetPitchInfo funcGetPitch[NUM_CODECS];
48 FuncUpdBWEst funcUpdBWEst[NUM_CODECS];
tina.legrand@webrtc.org5ac387c2012-11-19 08:02:55 +000049 FuncDurationEst funcDurationEst[NUM_CODECS];
niklase@google.com470e71d2011-07-07 08:21:25 +000050 FuncGetErrorCode funcGetErrorCode[NUM_CODECS];
51 void * codec_state[NUM_CODECS];
52 WebRtc_UWord16 codec_fs[NUM_CODECS];
53 WebRtc_Word16 CNGpayloadType[NUM_CNG_CODECS];
54
55} CodecDbInst_t;
56
57#define NO_SPLIT -1 /* codec payload cannot be split */
58
59typedef struct
60{
61 WebRtc_Word16 deltaBytes;
62 WebRtc_Word16 deltaTime;
63} SplitInfo_t;
64
65/*
66 * Resets the codec database.
67 */
68int WebRtcNetEQ_DbReset(CodecDbInst_t *inst);
69
70/*
71 * Adds a new codec to the database.
72 */
73int WebRtcNetEQ_DbAdd(CodecDbInst_t *inst, enum WebRtcNetEQDecoder codec,
74 WebRtc_Word16 payloadType, FuncDecode funcDecode,
75 FuncDecode funcDecodeRCU, FuncDecodePLC funcDecodePLC,
76 FuncDecodeInit funcDecodeInit, FuncAddLatePkt funcAddLatePkt,
77 FuncGetMDinfo funcGetMDinfo, FuncGetPitchInfo funcGetPitch,
tina.legrand@webrtc.org5ac387c2012-11-19 08:02:55 +000078 FuncUpdBWEst funcUpdBWEst, FuncDurationEst funcDurationEst,
79 FuncGetErrorCode funcGetErrorCode, void* codec_state,
80 WebRtc_UWord16 codec_fs);
niklase@google.com470e71d2011-07-07 08:21:25 +000081
82/*
83 * Removes a codec from the database.
84 */
85int WebRtcNetEQ_DbRemove(CodecDbInst_t *inst, enum WebRtcNetEQDecoder codec);
86
87/*
88 * Get the decoder function pointers for a codec.
89 */
90int WebRtcNetEQ_DbGetPtrs(CodecDbInst_t *inst, enum WebRtcNetEQDecoder,
91 CodecFuncInst_t *ptr_inst);
92
93/*
94 * Returns payload number given a codec identifier.
95 */
96
97int WebRtcNetEQ_DbGetPayload(CodecDbInst_t *inst, enum WebRtcNetEQDecoder codecID);
98
99/*
100 * Returns codec identifier given a payload number.
101 */
102
tina.legrand@webrtc.org5ac387c2012-11-19 08:02:55 +0000103int WebRtcNetEQ_DbGetCodec(const CodecDbInst_t *inst, int payloadType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000104
105/*
106 * Extracts the Payload Split information of the codec with the specified payloadType.
107 */
108
109int WebRtcNetEQ_DbGetSplitInfo(SplitInfo_t *inst, enum WebRtcNetEQDecoder codecID,
110 int codedsize);
111
112/*
113 * Returns 1 if codec is multiple description type, 0 otherwise.
114 */
115int WebRtcNetEQ_DbIsMDCodec(enum WebRtcNetEQDecoder codecID);
116
117/*
118 * Returns 1 if payload type is registered as a CNG codec, 0 otherwise.
119 */
tina.legrand@webrtc.org5ac387c2012-11-19 08:02:55 +0000120int WebRtcNetEQ_DbIsCNGPayload(const CodecDbInst_t *inst, int payloadType);
niklase@google.com470e71d2011-07-07 08:21:25 +0000121
122/*
123 * Return the sample rate for the codec with the given payload type, 0 if error.
124 */
125WebRtc_UWord16 WebRtcNetEQ_DbGetSampleRate(CodecDbInst_t *inst, int payloadType);
126
127#endif
128