Home | History | Annotate | Download | only in source
      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 {
     20     const char version[] = "NS 2.2.0";
     21     const short versionLen = (short)strlen(version) + 1; // +1 for null-termination
     22 
     23     if (versionStr == NULL) {
     24         return -1;
     25     }
     26 
     27     if (versionLen > length) {
     28         return -1;
     29     }
     30 
     31     strncpy(versionStr, version, versionLen);
     32 
     33     return 0;
     34 }
     35 
     36 int WebRtcNs_Create(NsHandle **NS_inst)
     37 {
     38     *NS_inst = (NsHandle*) malloc(sizeof(NSinst_t));
     39     if (*NS_inst!=NULL) {
     40         (*(NSinst_t**)NS_inst)->initFlag=0;
     41         return 0;
     42     } else {
     43         return -1;
     44     }
     45 
     46 }
     47 
     48 int WebRtcNs_Free(NsHandle *NS_inst)
     49 {
     50     free(NS_inst);
     51     return 0;
     52 }
     53 
     54 
     55 int WebRtcNs_Init(NsHandle *NS_inst, WebRtc_UWord32 fs)
     56 {
     57     return WebRtcNs_InitCore((NSinst_t*) NS_inst, fs);
     58 }
     59 
     60 int WebRtcNs_set_policy(NsHandle *NS_inst, int mode)
     61 {
     62     return WebRtcNs_set_policy_core((NSinst_t*) NS_inst, mode);
     63 }
     64 
     65 
     66 int WebRtcNs_Process(NsHandle *NS_inst, short *spframe, short *spframe_H, short *outframe, short *outframe_H)
     67 {
     68     return WebRtcNs_ProcessCore((NSinst_t*) NS_inst, spframe, spframe_H, outframe, outframe_H);
     69 }
     70