OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 } | 201 } |
202 | 202 |
203 int16_t WebRtcOpus_SetComplexity(OpusEncInst* inst, int32_t complexity) { | 203 int16_t WebRtcOpus_SetComplexity(OpusEncInst* inst, int32_t complexity) { |
204 if (inst) { | 204 if (inst) { |
205 return opus_encoder_ctl(inst->encoder, OPUS_SET_COMPLEXITY(complexity)); | 205 return opus_encoder_ctl(inst->encoder, OPUS_SET_COMPLEXITY(complexity)); |
206 } else { | 206 } else { |
207 return -1; | 207 return -1; |
208 } | 208 } |
209 } | 209 } |
210 | 210 |
| 211 int16_t WebRtcOpus_SetForceChannels(OpusEncInst* inst, int32_t num_channels) { |
| 212 if (!inst) |
| 213 return -1; |
| 214 if (num_channels == 0) { |
| 215 return opus_encoder_ctl(inst->encoder, |
| 216 OPUS_SET_FORCE_CHANNELS(OPUS_AUTO)); |
| 217 } else if (num_channels == 1 || num_channels == 2) { |
| 218 return opus_encoder_ctl(inst->encoder, |
| 219 OPUS_SET_FORCE_CHANNELS(num_channels)); |
| 220 } else { |
| 221 return -1; |
| 222 } |
| 223 } |
| 224 |
211 int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, size_t channels) { | 225 int16_t WebRtcOpus_DecoderCreate(OpusDecInst** inst, size_t channels) { |
212 int error; | 226 int error; |
213 OpusDecInst* state; | 227 OpusDecInst* state; |
214 | 228 |
215 if (inst != NULL) { | 229 if (inst != NULL) { |
216 /* Create Opus decoder state. */ | 230 /* Create Opus decoder state. */ |
217 state = (OpusDecInst*) calloc(1, sizeof(OpusDecInst)); | 231 state = (OpusDecInst*) calloc(1, sizeof(OpusDecInst)); |
218 if (state == NULL) { | 232 if (state == NULL) { |
219 return -1; | 233 return -1; |
220 } | 234 } |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 return 0; | 469 return 0; |
456 } | 470 } |
457 | 471 |
458 for (n = 0; n < channels; n++) { | 472 for (n = 0; n < channels; n++) { |
459 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) | 473 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) |
460 return 1; | 474 return 1; |
461 } | 475 } |
462 | 476 |
463 return 0; | 477 return 0; |
464 } | 478 } |
OLD | NEW |