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 #include <stdlib.h>
12 #include <string.h>
13
14 #include "noise_suppression_x.h"
15 #include "nsx_core.h"
16 #include "nsx_defines.h"
17
WebRtcNsx_get_version(char * versionStr,short length)18 int WebRtcNsx_get_version(char* versionStr, short length) {
19 const char version[] = "NS\t3.1.0";
20 const short versionLen = (short)strlen(version) + 1; // +1: null-termination
21
22 if (versionStr == NULL) {
23 return -1;
24 }
25
26 if (versionLen > length) {
27 return -1;
28 }
29
30 strncpy(versionStr, version, versionLen);
31
32 return 0;
33 }
34
WebRtcNsx_Create(NsxHandle ** nsxInst)35 int WebRtcNsx_Create(NsxHandle** nsxInst) {
36 *nsxInst = (NsxHandle*)malloc(sizeof(NsxInst_t));
37 if (*nsxInst != NULL) {
38 (*(NsxInst_t**)nsxInst)->initFlag = 0;
39 return 0;
40 } else {
41 return -1;
42 }
43
44 }
45
WebRtcNsx_Free(NsxHandle * nsxInst)46 int WebRtcNsx_Free(NsxHandle* nsxInst) {
47 free(nsxInst);
48 return 0;
49 }
50
WebRtcNsx_Init(NsxHandle * nsxInst,WebRtc_UWord32 fs)51 int WebRtcNsx_Init(NsxHandle* nsxInst, WebRtc_UWord32 fs) {
52 return WebRtcNsx_InitCore((NsxInst_t*)nsxInst, fs);
53 }
54
WebRtcNsx_set_policy(NsxHandle * nsxInst,int mode)55 int WebRtcNsx_set_policy(NsxHandle* nsxInst, int mode) {
56 return WebRtcNsx_set_policy_core((NsxInst_t*)nsxInst, mode);
57 }
58
WebRtcNsx_Process(NsxHandle * nsxInst,short * speechFrame,short * speechFrameHB,short * outFrame,short * outFrameHB)59 int WebRtcNsx_Process(NsxHandle* nsxInst, short* speechFrame,
60 short* speechFrameHB, short* outFrame,
61 short* outFrameHB) {
62 return WebRtcNsx_ProcessCore(
63 (NsxInst_t*)nsxInst, speechFrame, speechFrameHB, outFrame, outFrameHB);
64 }
65
66