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.h" 15 #include "ns_core.h" 16 #include "defines.h" 17 18 int WebRtcNs_get_version(char* versionStr, short length) { 19 const char version[] = "NS 2.2.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 35 int WebRtcNs_Create(NsHandle** NS_inst) { 36 *NS_inst = (NsHandle*) malloc(sizeof(NSinst_t)); 37 if (*NS_inst != NULL) { 38 (*(NSinst_t**)NS_inst)->initFlag = 0; 39 return 0; 40 } else { 41 return -1; 42 } 43 44 } 45 46 int WebRtcNs_Free(NsHandle* NS_inst) { 47 free(NS_inst); 48 return 0; 49 } 50 51 52 int WebRtcNs_Init(NsHandle* NS_inst, WebRtc_UWord32 fs) { 53 return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs); 54 } 55 56 int WebRtcNs_set_policy(NsHandle* NS_inst, int mode) { 57 return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode); 58 } 59 60 61 int WebRtcNs_Process(NsHandle* NS_inst, short* spframe, short* spframe_H, 62 short* outframe, short* outframe_H) { 63 return WebRtcNs_ProcessCore( 64 (NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H); 65 } 66