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 | * 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 | |
| 34 | typedef struct |
| 35 | { |
| 36 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 37 | int16_t position[NUM_TOTAL_CODECS]; |
| 38 | int16_t nrOfCodecs; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 40 | int16_t payloadType[NUM_CODECS]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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.org | 5ac387c | 2012-11-19 08:02:55 +0000 | [diff] [blame] | 49 | FuncDurationEst funcDurationEst[NUM_CODECS]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 50 | FuncGetErrorCode funcGetErrorCode[NUM_CODECS]; |
| 51 | void * codec_state[NUM_CODECS]; |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 52 | uint16_t codec_fs[NUM_CODECS]; |
| 53 | int16_t CNGpayloadType[NUM_CNG_CODECS]; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 54 | |
| 55 | } CodecDbInst_t; |
| 56 | |
| 57 | #define NO_SPLIT -1 /* codec payload cannot be split */ |
| 58 | |
| 59 | typedef struct |
| 60 | { |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 61 | int16_t deltaBytes; |
| 62 | int16_t deltaTime; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 63 | } SplitInfo_t; |
| 64 | |
| 65 | /* |
| 66 | * Resets the codec database. |
| 67 | */ |
| 68 | int WebRtcNetEQ_DbReset(CodecDbInst_t *inst); |
| 69 | |
| 70 | /* |
| 71 | * Adds a new codec to the database. |
| 72 | */ |
| 73 | int WebRtcNetEQ_DbAdd(CodecDbInst_t *inst, enum WebRtcNetEQDecoder codec, |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 74 | int16_t payloadType, FuncDecode funcDecode, |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 75 | FuncDecode funcDecodeRCU, FuncDecodePLC funcDecodePLC, |
| 76 | FuncDecodeInit funcDecodeInit, FuncAddLatePkt funcAddLatePkt, |
| 77 | FuncGetMDinfo funcGetMDinfo, FuncGetPitchInfo funcGetPitch, |
tina.legrand@webrtc.org | 5ac387c | 2012-11-19 08:02:55 +0000 | [diff] [blame] | 78 | FuncUpdBWEst funcUpdBWEst, FuncDurationEst funcDurationEst, |
| 79 | FuncGetErrorCode funcGetErrorCode, void* codec_state, |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 80 | uint16_t codec_fs); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 81 | |
| 82 | /* |
| 83 | * Removes a codec from the database. |
| 84 | */ |
| 85 | int WebRtcNetEQ_DbRemove(CodecDbInst_t *inst, enum WebRtcNetEQDecoder codec); |
| 86 | |
| 87 | /* |
| 88 | * Get the decoder function pointers for a codec. |
| 89 | */ |
| 90 | int WebRtcNetEQ_DbGetPtrs(CodecDbInst_t *inst, enum WebRtcNetEQDecoder, |
| 91 | CodecFuncInst_t *ptr_inst); |
| 92 | |
| 93 | /* |
| 94 | * Returns payload number given a codec identifier. |
| 95 | */ |
| 96 | |
| 97 | int WebRtcNetEQ_DbGetPayload(CodecDbInst_t *inst, enum WebRtcNetEQDecoder codecID); |
| 98 | |
| 99 | /* |
| 100 | * Returns codec identifier given a payload number. |
| 101 | */ |
| 102 | |
tina.legrand@webrtc.org | 5ac387c | 2012-11-19 08:02:55 +0000 | [diff] [blame] | 103 | int WebRtcNetEQ_DbGetCodec(const CodecDbInst_t *inst, int payloadType); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 104 | |
| 105 | /* |
| 106 | * Extracts the Payload Split information of the codec with the specified payloadType. |
| 107 | */ |
| 108 | |
| 109 | int 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 | */ |
| 115 | int 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.org | 5ac387c | 2012-11-19 08:02:55 +0000 | [diff] [blame] | 120 | int WebRtcNetEQ_DbIsCNGPayload(const CodecDbInst_t *inst, int payloadType); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 121 | |
| 122 | /* |
| 123 | * Return the sample rate for the codec with the given payload type, 0 if error. |
| 124 | */ |
pbos@webrtc.org | 0946a56 | 2013-04-09 00:28:06 +0000 | [diff] [blame] | 125 | uint16_t WebRtcNetEQ_DbGetSampleRate(CodecDbInst_t *inst, int payloadType); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 126 | |
| 127 | #endif |
| 128 | |