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 |
11 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" | 11 #include "webrtc/modules/audio_coding/codecs/opus/opus_interface.h" |
| 12 |
| 13 #include "webrtc/base/checks.h" |
12 #include "webrtc/modules/audio_coding/codecs/opus/opus_inst.h" | 14 #include "webrtc/modules/audio_coding/codecs/opus/opus_inst.h" |
13 | 15 |
14 #include <assert.h> | |
15 #include <stdlib.h> | 16 #include <stdlib.h> |
16 #include <string.h> | 17 #include <string.h> |
17 | 18 |
18 enum { | 19 enum { |
19 /* Maximum supported frame size in WebRTC is 60 ms. */ | 20 /* Maximum supported frame size in WebRTC is 60 ms. */ |
20 kWebRtcOpusMaxEncodeFrameSizeMs = 60, | 21 kWebRtcOpusMaxEncodeFrameSizeMs = 60, |
21 | 22 |
22 /* The format allows up to 120 ms frames. Since we don't control the other | 23 /* The format allows up to 120 ms frames. Since we don't control the other |
23 * side, we must allow for packets of that size. NetEq is currently limited | 24 * side, we must allow for packets of that size. NetEq is currently limited |
24 * to 60 ms on the receive side. */ | 25 * to 60 ms on the receive side. */ |
(...skipping 19 matching lines...) Expand all Loading... |
44 opus_app = OPUS_APPLICATION_VOIP; | 45 opus_app = OPUS_APPLICATION_VOIP; |
45 break; | 46 break; |
46 case 1: | 47 case 1: |
47 opus_app = OPUS_APPLICATION_AUDIO; | 48 opus_app = OPUS_APPLICATION_AUDIO; |
48 break; | 49 break; |
49 default: | 50 default: |
50 return -1; | 51 return -1; |
51 } | 52 } |
52 | 53 |
53 OpusEncInst* state = calloc(1, sizeof(OpusEncInst)); | 54 OpusEncInst* state = calloc(1, sizeof(OpusEncInst)); |
54 assert(state); | 55 RTC_DCHECK(state); |
55 | 56 |
56 int error; | 57 int error; |
57 state->encoder = opus_encoder_create(48000, (int)channels, opus_app, | 58 state->encoder = opus_encoder_create(48000, (int)channels, opus_app, |
58 &error); | 59 &error); |
59 if (error != OPUS_OK || !state->encoder) { | 60 if (error != OPUS_OK || !state->encoder) { |
60 WebRtcOpus_EncoderFree(state); | 61 WebRtcOpus_EncoderFree(state); |
61 return -1; | 62 return -1; |
62 } | 63 } |
63 | 64 |
64 state->in_dtx_mode = 0; | 65 state->in_dtx_mode = 0; |
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 return 0; | 455 return 0; |
455 } | 456 } |
456 | 457 |
457 for (n = 0; n < channels; n++) { | 458 for (n = 0; n < channels; n++) { |
458 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) | 459 if (frame_data[0][0] & (0x80 >> ((n + 1) * (frames + 1) - 1))) |
459 return 1; | 460 return 1; |
460 } | 461 } |
461 | 462 |
462 return 0; | 463 return 0; |
463 } | 464 } |
OLD | NEW |