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 14 matching lines...) Expand all Loading... |
25 | 25 |
26 /* Maximum sample count per channel is 48 kHz * maximum frame size in | 26 /* Maximum sample count per channel is 48 kHz * maximum frame size in |
27 * milliseconds. */ | 27 * milliseconds. */ |
28 kWebRtcOpusMaxFrameSizePerChannel = 48 * kWebRtcOpusMaxDecodeFrameSizeMs, | 28 kWebRtcOpusMaxFrameSizePerChannel = 48 * kWebRtcOpusMaxDecodeFrameSizeMs, |
29 | 29 |
30 /* Default frame size, 20 ms @ 48 kHz, in samples (for one channel). */ | 30 /* Default frame size, 20 ms @ 48 kHz, in samples (for one channel). */ |
31 kWebRtcOpusDefaultFrameSize = 960, | 31 kWebRtcOpusDefaultFrameSize = 960, |
32 }; | 32 }; |
33 | 33 |
34 int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst, | 34 int16_t WebRtcOpus_EncoderCreate(OpusEncInst** inst, |
35 int32_t channels, | 35 size_t channels, |
36 int32_t application) { | 36 int32_t application) { |
37 OpusEncInst* state; | 37 OpusEncInst* state; |
38 if (inst != NULL) { | 38 if (inst != NULL) { |
39 state = (OpusEncInst*) calloc(1, sizeof(OpusEncInst)); | 39 state = (OpusEncInst*) calloc(1, sizeof(OpusEncInst)); |
40 if (state) { | 40 if (state) { |
41 int opus_app; | 41 int opus_app; |
42 switch (application) { | 42 switch (application) { |
43 case 0: { | 43 case 0: { |
44 opus_app = OPUS_APPLICATION_VOIP; | 44 opus_app = OPUS_APPLICATION_VOIP; |
45 break; | 45 break; |
46 } | 46 } |
47 case 1: { | 47 case 1: { |
48 opus_app = OPUS_APPLICATION_AUDIO; | 48 opus_app = OPUS_APPLICATION_AUDIO; |
49 break; | 49 break; |
50 } | 50 } |
51 default: { | 51 default: { |
52 free(state); | 52 free(state); |
53 return -1; | 53 return -1; |
54 } | 54 } |
55 } | 55 } |
56 | 56 |
57 int error; | 57 int error; |
58 state->encoder = opus_encoder_create(48000, channels, opus_app, | 58 state->encoder = opus_encoder_create(48000, (int)channels, opus_app, |
59 &error); | 59 &error); |
60 state->in_dtx_mode = 0; | 60 state->in_dtx_mode = 0; |
61 if (error == OPUS_OK && state->encoder != NULL) { | 61 if (error == OPUS_OK && state->encoder != NULL) { |
62 *inst = state; | 62 *inst = state; |
63 return 0; | 63 return 0; |
64 } | 64 } |
65 free(state); | 65 free(state); |
66 } | 66 } |
67 } | 67 } |
68 return -1; | 68 return -1; |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 return 0; | 441 return 0; |
442 } | 442 } |
443 | 443 |
444 for (n = 0; n < channels; n++) { | 444 for (n = 0; n < channels; n++) { |
445 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) | 445 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) |
446 return 1; | 446 return 1; |
447 } | 447 } |
448 | 448 |
449 return 0; | 449 return 0; |
450 } | 450 } |
OLD | NEW |