1/* 2 * Copyright (c) 2013 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 11package org.webrtc.webrtcdemo; 12 13public class VoiceEngine { 14 private final long nativeVoiceEngine; 15 16 // Keep in sync (including this comment) with 17 // webrtc/common_types.h:NsModes 18 public enum NsModes { 19 UNCHANGED, DEFAULT, CONFERENCE, LOW_SUPPRESSION, 20 MODERATE_SUPPRESSION, HIGH_SUPPRESSION, VERY_HIGH_SUPPRESSION 21 } 22 23 // Keep in sync (including this comment) with 24 // webrtc/common_types.h:AgcModes 25 public enum AgcModes { 26 UNCHANGED, DEFAULT, ADAPTIVE_ANALOG, ADAPTIVE_DIGITAL, 27 FIXED_DIGITAL 28 } 29 30 // Keep in sync (including this comment) with 31 // webrtc/common_types.h:AecmModes 32 public enum AecmModes { 33 QUIET_EARPIECE_OR_HEADSET, EARPIECE, LOUD_EARPIECE, 34 SPEAKERPHONE, LOUD_SPEAKERPHONE 35 } 36 37 // Keep in sync (including this comment) with 38 // webrtc/common_types.h:EcModes 39 public enum EcModes { UNCHANGED, DEFAULT, CONFERENCE, AEC, AECM } 40 41 // Keep in sync (including this comment) with 42 // webrtc/common_types.h:RtpDirections 43 public enum RtpDirections { INCOMING, OUTGOING } 44 45 public static class AgcConfig { 46 AgcConfig(int targetLevelDbOv, int digitalCompressionGaindB, 47 boolean limiterEnable) { 48 this.targetLevelDbOv = targetLevelDbOv; 49 this.digitalCompressionGaindB = digitalCompressionGaindB; 50 this.limiterEnable = limiterEnable; 51 } 52 private final int targetLevelDbOv; 53 private final int digitalCompressionGaindB; 54 private final boolean limiterEnable; 55 } 56 57 public VoiceEngine() { 58 nativeVoiceEngine = create(); 59 } 60 private static native long create(); 61 public native int init(); 62 public native void dispose(); 63 public native int createChannel(); 64 public native int deleteChannel(int channel); 65 public native int setLocalReceiver(int channel, int port); 66 public native int setSendDestination(int channel, int port, String ipaddr); 67 public native int startListen(int channel); 68 public native int startPlayout(int channel); 69 public native int startSend(int channel); 70 public native int stopListen(int channel); 71 public native int stopPlayout(int channel); 72 public native int stopSend(int channel); 73 public native int setSpeakerVolume(int volume); 74 public native int setLoudspeakerStatus(boolean enable); 75 public native int startPlayingFileLocally( 76 int channel, 77 String fileName, 78 boolean loop); 79 public native int stopPlayingFileLocally(int channel); 80 public native int startPlayingFileAsMicrophone( 81 int channel, 82 String fileName, 83 boolean loop); 84 public native int stopPlayingFileAsMicrophone(int channel); 85 public native int numOfCodecs(); 86 public native CodecInst getCodec(int index); 87 public native int setSendCodec(int channel, CodecInst codec); 88 public int setEcStatus(boolean enable, EcModes mode) { 89 return setEcStatus(enable, mode.ordinal()); 90 } 91 private native int setEcStatus(boolean enable, int ec_mode); 92 public int setAecmMode(AecmModes aecm_mode, boolean cng) { 93 return setAecmMode(aecm_mode.ordinal(), cng); 94 } 95 private native int setAecmMode(int aecm_mode, boolean cng); 96 public int setAgcStatus(boolean enable, AgcModes agc_mode) { 97 return setAgcStatus(enable, agc_mode.ordinal()); 98 } 99 private native int setAgcStatus(boolean enable, int agc_mode); 100 public native int setAgcConfig(AgcConfig agc_config); 101 public int setNsStatus(boolean enable, NsModes ns_mode) { 102 return setNsStatus(enable, ns_mode.ordinal()); 103 } 104 private native int setNsStatus(boolean enable, int ns_mode); 105 public native int startDebugRecording(String file); 106 public native int stopDebugRecording(); 107 public int startRtpDump(int channel, String file, 108 RtpDirections direction) { 109 return startRtpDump(channel, file, direction.ordinal()); 110 } 111 private native int startRtpDump(int channel, String file, 112 int direction); 113 public int stopRtpDump(int channel, RtpDirections direction) { 114 return stopRtpDump(channel, direction.ordinal()); 115 } 116 private native int stopRtpDump(int channel, int direction); 117}