tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_CODING_CODECS_OPUS_OPUS_INTERFACE_H_ |
| 12 | #define MODULES_AUDIO_CODING_CODECS_OPUS_OPUS_INTERFACE_H_ |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 13 | |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 14 | #include <stddef.h> |
| 15 | |
Alex Luebs | eeb2765 | 2017-11-20 11:13:56 -0800 | [diff] [blame] | 16 | #include "modules/audio_coding/codecs/opus/opus_inst.h" |
Mirko Bonadei | 7120742 | 2017-09-15 13:58:09 +0200 | [diff] [blame] | 17 | #include "typedefs.h" // NOLINT(build/include) |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 18 | |
| 19 | #ifdef __cplusplus |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | // Opaque wrapper types for the codec state. |
| 24 | typedef struct WebRtcOpusEncInst OpusEncInst; |
| 25 | typedef struct WebRtcOpusDecInst OpusDecInst; |
| 26 | |
minyue@webrtc.org | 7dba786 | 2015-01-20 16:01:50 +0000 | [diff] [blame] | 27 | /**************************************************************************** |
| 28 | * WebRtcOpus_EncoderCreate(...) |
| 29 | * |
| 30 | * This function create an Opus encoder. |
| 31 | * |
| 32 | * Input: |
| 33 | * - channels : number of channels. |
| 34 | * - application : 0 - VOIP applications. |
| 35 | * Favor speech intelligibility. |
| 36 | * 1 - Audio applications. |
| 37 | * Favor faithfulness to the original input. |
| 38 | * |
| 39 | * Output: |
| 40 | * - inst : a pointer to Encoder context that is created |
| 41 | * if success. |
| 42 | * |
| 43 | * Return value : 0 - Success |
| 44 | * -1 - Error |
| 45 | */ |
| 46 | int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst, |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 47 | size_t channels, |
minyue@webrtc.org | 7dba786 | 2015-01-20 16:01:50 +0000 | [diff] [blame] | 48 | int32_t application); |
| 49 | |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 50 | int16_t WebRtcOpus_EncoderFree(OpusEncInst* inst); |
| 51 | |
| 52 | /**************************************************************************** |
| 53 | * WebRtcOpus_Encode(...) |
| 54 | * |
| 55 | * This function encodes audio as a series of Opus frames and inserts |
| 56 | * it into a packet. Input buffer can be any length. |
| 57 | * |
| 58 | * Input: |
| 59 | * - inst : Encoder context |
| 60 | * - audio_in : Input speech data buffer |
minyue@webrtc.org | ecbe0aa | 2013-08-12 06:48:09 +0000 | [diff] [blame] | 61 | * - samples : Samples per channel in audio_in |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 62 | * - length_encoded_buffer : Output buffer size |
| 63 | * |
| 64 | * Output: |
| 65 | * - encoded : Output compressed data buffer |
| 66 | * |
minyue@webrtc.org | 0ca768b | 2014-12-11 16:09:35 +0000 | [diff] [blame] | 67 | * Return value : >=0 - Length (in bytes) of coded data |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 68 | * -1 - Error |
| 69 | */ |
Peter Kasting | bba7807 | 2015-06-11 19:02:46 -0700 | [diff] [blame] | 70 | int WebRtcOpus_Encode(OpusEncInst* inst, |
| 71 | const int16_t* audio_in, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 72 | size_t samples, |
| 73 | size_t length_encoded_buffer, |
Peter Kasting | bba7807 | 2015-06-11 19:02:46 -0700 | [diff] [blame] | 74 | uint8_t* encoded); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 75 | |
| 76 | /**************************************************************************** |
| 77 | * WebRtcOpus_SetBitRate(...) |
| 78 | * |
| 79 | * This function adjusts the target bitrate of the encoder. |
| 80 | * |
| 81 | * Input: |
| 82 | * - inst : Encoder context |
| 83 | * - rate : New target bitrate |
| 84 | * |
| 85 | * Return value : 0 - Success |
| 86 | * -1 - Error |
| 87 | */ |
| 88 | int16_t WebRtcOpus_SetBitRate(OpusEncInst* inst, int32_t rate); |
| 89 | |
minyue@webrtc.org | 0454688 | 2014-03-07 08:55:48 +0000 | [diff] [blame] | 90 | /**************************************************************************** |
minyue@webrtc.org | 46509c8 | 2014-03-07 11:49:11 +0000 | [diff] [blame] | 91 | * WebRtcOpus_SetPacketLossRate(...) |
| 92 | * |
| 93 | * This function configures the encoder's expected packet loss percentage. |
| 94 | * |
| 95 | * Input: |
| 96 | * - inst : Encoder context |
| 97 | * - loss_rate : loss percentage in the range 0-100, inclusive. |
| 98 | * Return value : 0 - Success |
| 99 | * -1 - Error |
| 100 | */ |
| 101 | int16_t WebRtcOpus_SetPacketLossRate(OpusEncInst* inst, int32_t loss_rate); |
| 102 | |
minyue@webrtc.org | 0040a6e | 2014-08-04 14:41:57 +0000 | [diff] [blame] | 103 | /**************************************************************************** |
minyue@webrtc.org | adee8f9 | 2014-09-03 12:28:06 +0000 | [diff] [blame] | 104 | * WebRtcOpus_SetMaxPlaybackRate(...) |
minyue@webrtc.org | 0040a6e | 2014-08-04 14:41:57 +0000 | [diff] [blame] | 105 | * |
minyue@webrtc.org | adee8f9 | 2014-09-03 12:28:06 +0000 | [diff] [blame] | 106 | * Configures the maximum playback rate for encoding. Due to hardware |
| 107 | * limitations, the receiver may render audio up to a playback rate. Opus |
| 108 | * encoder can use this information to optimize for network usage and encoding |
| 109 | * complexity. This will affect the audio bandwidth in the coded audio. However, |
| 110 | * the input/output sample rate is not affected. |
minyue@webrtc.org | 0040a6e | 2014-08-04 14:41:57 +0000 | [diff] [blame] | 111 | * |
| 112 | * Input: |
| 113 | * - inst : Encoder context |
minyue@webrtc.org | adee8f9 | 2014-09-03 12:28:06 +0000 | [diff] [blame] | 114 | * - frequency_hz : Maximum playback rate in Hz. |
| 115 | * This parameter can take any value. The relation |
| 116 | * between the value and the Opus internal mode is |
| 117 | * as following: |
| 118 | * frequency_hz <= 8000 narrow band |
| 119 | * 8000 < frequency_hz <= 12000 medium band |
| 120 | * 12000 < frequency_hz <= 16000 wide band |
| 121 | * 16000 < frequency_hz <= 24000 super wide band |
| 122 | * frequency_hz > 24000 full band |
minyue@webrtc.org | 0040a6e | 2014-08-04 14:41:57 +0000 | [diff] [blame] | 123 | * Return value : 0 - Success |
| 124 | * -1 - Error |
| 125 | */ |
minyue@webrtc.org | adee8f9 | 2014-09-03 12:28:06 +0000 | [diff] [blame] | 126 | int16_t WebRtcOpus_SetMaxPlaybackRate(OpusEncInst* inst, int32_t frequency_hz); |
minyue@webrtc.org | 0040a6e | 2014-08-04 14:41:57 +0000 | [diff] [blame] | 127 | |
minyue@webrtc.org | 46509c8 | 2014-03-07 11:49:11 +0000 | [diff] [blame] | 128 | /* TODO(minyue): Check whether an API to check the FEC and the packet loss rate |
| 129 | * is needed. It might not be very useful since there are not many use cases and |
| 130 | * the caller can always maintain the states. */ |
| 131 | |
| 132 | /**************************************************************************** |
| 133 | * WebRtcOpus_EnableFec() |
| 134 | * |
| 135 | * This function enables FEC for encoding. |
| 136 | * |
| 137 | * Input: |
| 138 | * - inst : Encoder context |
| 139 | * |
| 140 | * Return value : 0 - Success |
| 141 | * -1 - Error |
| 142 | */ |
| 143 | int16_t WebRtcOpus_EnableFec(OpusEncInst* inst); |
| 144 | |
| 145 | /**************************************************************************** |
| 146 | * WebRtcOpus_DisableFec() |
| 147 | * |
| 148 | * This function disables FEC for encoding. |
| 149 | * |
| 150 | * Input: |
| 151 | * - inst : Encoder context |
| 152 | * |
| 153 | * Return value : 0 - Success |
| 154 | * -1 - Error |
| 155 | */ |
| 156 | int16_t WebRtcOpus_DisableFec(OpusEncInst* inst); |
| 157 | |
minyue@webrtc.org | 0ca768b | 2014-12-11 16:09:35 +0000 | [diff] [blame] | 158 | /**************************************************************************** |
| 159 | * WebRtcOpus_EnableDtx() |
| 160 | * |
| 161 | * This function enables Opus internal DTX for encoding. |
| 162 | * |
| 163 | * Input: |
| 164 | * - inst : Encoder context |
| 165 | * |
| 166 | * Return value : 0 - Success |
| 167 | * -1 - Error |
| 168 | */ |
| 169 | int16_t WebRtcOpus_EnableDtx(OpusEncInst* inst); |
| 170 | |
| 171 | /**************************************************************************** |
| 172 | * WebRtcOpus_DisableDtx() |
| 173 | * |
| 174 | * This function disables Opus internal DTX for encoding. |
| 175 | * |
| 176 | * Input: |
| 177 | * - inst : Encoder context |
| 178 | * |
| 179 | * Return value : 0 - Success |
| 180 | * -1 - Error |
| 181 | */ |
| 182 | int16_t WebRtcOpus_DisableDtx(OpusEncInst* inst); |
| 183 | |
soren | 28dc285 | 2017-04-06 05:48:36 -0700 | [diff] [blame] | 184 | /**************************************************************************** |
| 185 | * WebRtcOpus_EnableCbr() |
| 186 | * |
| 187 | * This function enables CBR for encoding. |
| 188 | * |
| 189 | * Input: |
| 190 | * - inst : Encoder context |
| 191 | * |
| 192 | * Return value : 0 - Success |
| 193 | * -1 - Error |
| 194 | */ |
| 195 | int16_t WebRtcOpus_EnableCbr(OpusEncInst* inst); |
| 196 | |
| 197 | /**************************************************************************** |
| 198 | * WebRtcOpus_DisableCbr() |
| 199 | * |
| 200 | * This function disables CBR for encoding. |
| 201 | * |
| 202 | * Input: |
| 203 | * - inst : Encoder context |
| 204 | * |
| 205 | * Return value : 0 - Success |
| 206 | * -1 - Error |
| 207 | */ |
| 208 | int16_t WebRtcOpus_DisableCbr(OpusEncInst* inst); |
| 209 | |
minyue@webrtc.org | 46509c8 | 2014-03-07 11:49:11 +0000 | [diff] [blame] | 210 | /* |
minyue@webrtc.org | 0454688 | 2014-03-07 08:55:48 +0000 | [diff] [blame] | 211 | * WebRtcOpus_SetComplexity(...) |
| 212 | * |
| 213 | * This function adjusts the computational complexity. The effect is the same as |
| 214 | * calling the complexity setting of Opus as an Opus encoder related CTL. |
| 215 | * |
| 216 | * Input: |
| 217 | * - inst : Encoder context |
| 218 | * - complexity : New target complexity (0-10, inclusive) |
| 219 | * |
| 220 | * Return value : 0 - Success |
| 221 | * -1 - Error |
| 222 | */ |
| 223 | int16_t WebRtcOpus_SetComplexity(OpusEncInst* inst, int32_t complexity); |
| 224 | |
minyue | c8299f9 | 2016-09-27 02:08:47 -0700 | [diff] [blame] | 225 | /* |
Alex Luebs | eeb2765 | 2017-11-20 11:13:56 -0800 | [diff] [blame] | 226 | * WebRtcOpus_GetBandwidth(...) |
| 227 | * |
| 228 | * This function returns the current bandwidth. |
| 229 | * |
| 230 | * Input: |
| 231 | * - inst : Encoder context |
| 232 | * |
| 233 | * Return value : Bandwidth - Success |
| 234 | * -1 - Error |
| 235 | */ |
| 236 | int32_t WebRtcOpus_GetBandwidth(OpusEncInst* inst); |
| 237 | |
| 238 | /* |
| 239 | * WebRtcOpus_SetBandwidth(...) |
| 240 | * |
| 241 | * By default Opus decides which bandwidth to encode the signal in depending on |
| 242 | * the the bitrate. This function overrules the previous setting and forces the |
| 243 | * encoder to encode in narrowband/wideband/fullband/etc. |
| 244 | * |
| 245 | * Input: |
| 246 | * - inst : Encoder context |
| 247 | * - bandwidth : New target bandwidth. Valid values are: |
| 248 | * OPUS_BANDWIDTH_NARROWBAND |
| 249 | * OPUS_BANDWIDTH_MEDIUMBAND |
| 250 | * OPUS_BANDWIDTH_WIDEBAND |
| 251 | * OPUS_BANDWIDTH_SUPERWIDEBAND |
| 252 | * OPUS_BANDWIDTH_FULLBAND |
| 253 | * |
| 254 | * Return value : 0 - Success |
| 255 | * -1 - Error |
| 256 | */ |
| 257 | int16_t WebRtcOpus_SetBandwidth(OpusEncInst* inst, int32_t bandwidth); |
| 258 | |
| 259 | /* |
minyue | c8299f9 | 2016-09-27 02:08:47 -0700 | [diff] [blame] | 260 | * WebRtcOpus_SetForceChannels(...) |
| 261 | * |
| 262 | * If the encoder is initialized as a stereo encoder, Opus will by default |
| 263 | * decide whether to encode in mono or stereo based on the bitrate. This |
| 264 | * function overrules the previous setting, and forces the encoder to encode |
| 265 | * in auto/mono/stereo. |
| 266 | * |
| 267 | * If the Encoder is initialized as a mono encoder, and one tries to force |
| 268 | * stereo, the function will return an error. |
| 269 | * |
| 270 | * Input: |
| 271 | * - inst : Encoder context |
| 272 | * - num_channels : 0 - Not forced |
| 273 | * 1 - Mono |
| 274 | * 2 - Stereo |
| 275 | * |
| 276 | * Return value : 0 - Success |
| 277 | * -1 - Error |
| 278 | */ |
minyue | 41b9c80 | 2016-10-06 07:13:54 -0700 | [diff] [blame] | 279 | int16_t WebRtcOpus_SetForceChannels(OpusEncInst* inst, size_t num_channels); |
minyue | c8299f9 | 2016-09-27 02:08:47 -0700 | [diff] [blame] | 280 | |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 281 | int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, size_t channels); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 282 | int16_t WebRtcOpus_DecoderFree(OpusDecInst* inst); |
| 283 | |
| 284 | /**************************************************************************** |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 285 | * WebRtcOpus_DecoderChannels(...) |
| 286 | * |
| 287 | * This function returns the number of channels created for Opus decoder. |
| 288 | */ |
Peter Kasting | 6955870 | 2016-01-12 16:26:35 -0800 | [diff] [blame] | 289 | size_t WebRtcOpus_DecoderChannels(OpusDecInst* inst); |
tina.legrand@webrtc.org | c459058 | 2012-11-28 12:23:29 +0000 | [diff] [blame] | 290 | |
| 291 | /**************************************************************************** |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 292 | * WebRtcOpus_DecoderInit(...) |
| 293 | * |
| 294 | * This function resets state of the decoder. |
| 295 | * |
| 296 | * Input: |
| 297 | * - inst : Decoder context |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 298 | */ |
Karl Wiberg | 4376648 | 2015-08-27 15:22:11 +0200 | [diff] [blame] | 299 | void WebRtcOpus_DecoderInit(OpusDecInst* inst); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 300 | |
| 301 | /**************************************************************************** |
| 302 | * WebRtcOpus_Decode(...) |
| 303 | * |
| 304 | * This function decodes an Opus packet into one or more audio frames at the |
| 305 | * ACM interface's sampling rate (32 kHz). |
| 306 | * |
| 307 | * Input: |
| 308 | * - inst : Decoder context |
| 309 | * - encoded : Encoded data |
| 310 | * - encoded_bytes : Bytes in encoded vector |
| 311 | * |
| 312 | * Output: |
| 313 | * - decoded : The decoded vector |
| 314 | * - audio_type : 1 normal, 2 CNG (for Opus it should |
| 315 | * always return 1 since we're not using Opus's |
| 316 | * built-in DTX/CNG scheme) |
| 317 | * |
minyue@webrtc.org | ecbe0aa | 2013-08-12 06:48:09 +0000 | [diff] [blame] | 318 | * Return value : >0 - Samples per channel in decoded vector |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 319 | * -1 - Error |
| 320 | */ |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 321 | int WebRtcOpus_Decode(OpusDecInst* inst, |
| 322 | const uint8_t* encoded, |
| 323 | size_t encoded_bytes, |
| 324 | int16_t* decoded, |
Peter Kasting | bba7807 | 2015-06-11 19:02:46 -0700 | [diff] [blame] | 325 | int16_t* audio_type); |
minyue@webrtc.org | 46509c8 | 2014-03-07 11:49:11 +0000 | [diff] [blame] | 326 | |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 327 | /**************************************************************************** |
| 328 | * WebRtcOpus_DecodePlc(...) |
| 329 | * |
tina.legrand@webrtc.org | bd21fb5 | 2013-08-08 11:01:07 +0000 | [diff] [blame] | 330 | * This function processes PLC for opus frame(s). |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 331 | * Input: |
| 332 | * - inst : Decoder context |
| 333 | * - number_of_lost_frames : Number of PLC frames to produce |
| 334 | * |
| 335 | * Output: |
| 336 | * - decoded : The decoded vector |
| 337 | * |
| 338 | * Return value : >0 - number of samples in decoded PLC vector |
| 339 | * -1 - Error |
| 340 | */ |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 341 | int WebRtcOpus_DecodePlc(OpusDecInst* inst, |
| 342 | int16_t* decoded, |
Peter Kasting | bba7807 | 2015-06-11 19:02:46 -0700 | [diff] [blame] | 343 | int number_of_lost_frames); |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 344 | |
tina.legrand@webrtc.org | 4275ab1 | 2012-12-19 09:52:45 +0000 | [diff] [blame] | 345 | /**************************************************************************** |
minyue@webrtc.org | 46509c8 | 2014-03-07 11:49:11 +0000 | [diff] [blame] | 346 | * WebRtcOpus_DecodeFec(...) |
| 347 | * |
| 348 | * This function decodes the FEC data from an Opus packet into one or more audio |
| 349 | * frames at the ACM interface's sampling rate (32 kHz). |
| 350 | * |
| 351 | * Input: |
| 352 | * - inst : Decoder context |
| 353 | * - encoded : Encoded data |
| 354 | * - encoded_bytes : Bytes in encoded vector |
| 355 | * |
| 356 | * Output: |
| 357 | * - decoded : The decoded vector (previous frame) |
| 358 | * |
| 359 | * Return value : >0 - Samples per channel in decoded vector |
| 360 | * 0 - No FEC data in the packet |
| 361 | * -1 - Error |
| 362 | */ |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame^] | 363 | int WebRtcOpus_DecodeFec(OpusDecInst* inst, |
| 364 | const uint8_t* encoded, |
| 365 | size_t encoded_bytes, |
| 366 | int16_t* decoded, |
Peter Kasting | bba7807 | 2015-06-11 19:02:46 -0700 | [diff] [blame] | 367 | int16_t* audio_type); |
minyue@webrtc.org | 46509c8 | 2014-03-07 11:49:11 +0000 | [diff] [blame] | 368 | |
| 369 | /**************************************************************************** |
tina.legrand@webrtc.org | 4275ab1 | 2012-12-19 09:52:45 +0000 | [diff] [blame] | 370 | * WebRtcOpus_DurationEst(...) |
| 371 | * |
| 372 | * This function calculates the duration of an opus packet. |
| 373 | * Input: |
| 374 | * - inst : Decoder context |
| 375 | * - payload : Encoded data pointer |
| 376 | * - payload_length_bytes : Bytes of encoded data |
| 377 | * |
Minyue | 323b132 | 2015-05-25 13:49:37 +0200 | [diff] [blame] | 378 | * Return value : The duration of the packet, in samples per |
| 379 | * channel. |
tina.legrand@webrtc.org | 4275ab1 | 2012-12-19 09:52:45 +0000 | [diff] [blame] | 380 | */ |
| 381 | int WebRtcOpus_DurationEst(OpusDecInst* inst, |
| 382 | const uint8_t* payload, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 383 | size_t payload_length_bytes); |
tina.legrand@webrtc.org | 4275ab1 | 2012-12-19 09:52:45 +0000 | [diff] [blame] | 384 | |
minyuel | 6d92bf5 | 2015-09-23 15:20:39 +0200 | [diff] [blame] | 385 | /**************************************************************************** |
| 386 | * WebRtcOpus_PlcDuration(...) |
| 387 | * |
| 388 | * This function calculates the duration of a frame returned by packet loss |
| 389 | * concealment (PLC). |
| 390 | * |
| 391 | * Input: |
| 392 | * - inst : Decoder context |
| 393 | * |
| 394 | * Return value : The duration of a frame returned by PLC, in |
| 395 | * samples per channel. |
| 396 | */ |
| 397 | int WebRtcOpus_PlcDuration(OpusDecInst* inst); |
| 398 | |
minyue@webrtc.org | 46509c8 | 2014-03-07 11:49:11 +0000 | [diff] [blame] | 399 | /* TODO(minyue): Check whether it is needed to add a decoder context to the |
| 400 | * arguments, like WebRtcOpus_DurationEst(...). In fact, the packet itself tells |
| 401 | * the duration. The decoder context in WebRtcOpus_DurationEst(...) is not used. |
| 402 | * So it may be advisable to remove it from WebRtcOpus_DurationEst(...). */ |
| 403 | |
| 404 | /**************************************************************************** |
| 405 | * WebRtcOpus_FecDurationEst(...) |
| 406 | * |
| 407 | * This function calculates the duration of the FEC data within an opus packet. |
| 408 | * Input: |
| 409 | * - payload : Encoded data pointer |
| 410 | * - payload_length_bytes : Bytes of encoded data |
| 411 | * |
| 412 | * Return value : >0 - The duration of the FEC data in the |
Minyue | 323b132 | 2015-05-25 13:49:37 +0200 | [diff] [blame] | 413 | * packet in samples per channel. |
minyue@webrtc.org | 46509c8 | 2014-03-07 11:49:11 +0000 | [diff] [blame] | 414 | * 0 - No FEC data in the packet. |
| 415 | */ |
| 416 | int WebRtcOpus_FecDurationEst(const uint8_t* payload, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 417 | size_t payload_length_bytes); |
minyue@webrtc.org | 46509c8 | 2014-03-07 11:49:11 +0000 | [diff] [blame] | 418 | |
| 419 | /**************************************************************************** |
| 420 | * WebRtcOpus_PacketHasFec(...) |
| 421 | * |
| 422 | * This function detects if an opus packet has FEC. |
| 423 | * Input: |
| 424 | * - payload : Encoded data pointer |
| 425 | * - payload_length_bytes : Bytes of encoded data |
| 426 | * |
| 427 | * Return value : 0 - the packet does NOT contain FEC. |
| 428 | * 1 - the packet contains FEC. |
| 429 | */ |
| 430 | int WebRtcOpus_PacketHasFec(const uint8_t* payload, |
Peter Kasting | dce40cf | 2015-08-24 14:52:23 -0700 | [diff] [blame] | 431 | size_t payload_length_bytes); |
minyue@webrtc.org | 46509c8 | 2014-03-07 11:49:11 +0000 | [diff] [blame] | 432 | |
tina.legrand@webrtc.org | a7d8387 | 2012-10-18 10:00:52 +0000 | [diff] [blame] | 433 | #ifdef __cplusplus |
| 434 | } // extern "C" |
| 435 | #endif |
| 436 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 437 | #endif // MODULES_AUDIO_CODING_CODECS_OPUS_OPUS_INTERFACE_H_ |