├── ic_launcher-web.png ├── README.md ├── src ├── jay │ ├── media │ │ ├── LanVedioPlay.java │ │ ├── LanVedioRecord.java │ │ ├── LanAudioPlay.java │ │ ├── MediaService.java │ │ ├── LanAudioRecord.java │ │ └── MediaManager.java │ ├── dencode │ │ ├── Decoder.java │ │ └── Encoder.java │ ├── codec │ │ ├── alaw.java │ │ ├── ulaw.java │ │ ├── Speex.java │ │ ├── G722.java │ │ ├── Codec.java │ │ ├── EchoCancellation.java │ │ └── G711.java │ └── func │ │ └── func.java ├── org │ └── sipdroid │ │ └── net │ │ ├── RtpPacket.java │ │ ├── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ └── text-base │ │ │ ├── SipdroidSocket.java.svn-base │ │ │ ├── KeepAliveSip.java.svn-base │ │ │ ├── RtpSocket.java.svn-base │ │ │ ├── KeepAliveUdp.java.svn-base │ │ │ └── RtpPacket.java.svn-base │ │ ├── Random.java │ │ └── RtpSocket.java └── com │ └── shawn │ └── demo │ └── voip │ ├── MainActivity.java │ └── .svn │ ├── text-base │ ├── Static.java.svn-base │ ├── AudioReader.java.svn-base │ ├── AudioWriter.java.svn-base │ └── MainActivity.java.svn-base │ └── entries ├── libs ├── android-support-v4.jar ├── armeabi │ ├── libg722_jni.so │ └── libspeex_jni.so └── armeabi-v7a │ ├── libg722_jni.so │ └── libspeex_jni.so ├── bin ├── classes │ ├── jay │ │ ├── func │ │ │ └── func.class │ │ ├── codec │ │ │ ├── Codec.class │ │ │ ├── G711.class │ │ │ ├── G722.class │ │ │ ├── Speex.class │ │ │ ├── alaw.class │ │ │ ├── ulaw.class │ │ │ └── EchoCancellation.class │ │ ├── dencode │ │ │ ├── Decoder.class │ │ │ └── Encoder.class │ │ └── media │ │ │ ├── LanAudioPlay.class │ │ │ ├── LanVedioPlay.class │ │ │ ├── MediaManager.class │ │ │ ├── MediaService.class │ │ │ ├── LanAudioRecord.class │ │ │ ├── LanVedioRecord.class │ │ │ ├── MediaManager$1.class │ │ │ └── MediaService$JayBinder.class │ ├── com │ │ └── shawn │ │ │ └── demo │ │ │ └── voip │ │ │ ├── R.class │ │ │ ├── rtp.class │ │ │ ├── R$attr.class │ │ │ ├── R$id.class │ │ │ ├── R$menu.class │ │ │ ├── R$dimen.class │ │ │ ├── R$layout.class │ │ │ ├── R$string.class │ │ │ ├── R$style.class │ │ │ ├── BuildConfig.class │ │ │ ├── R$drawable.class │ │ │ ├── MainActivity.class │ │ │ ├── MainActivity$1.class │ │ │ ├── MainActivity$2.class │ │ │ ├── MainActivity$3.class │ │ │ └── .svn │ │ │ ├── text-base │ │ │ ├── Static.java.svn-base │ │ │ ├── AudioReader.java.svn-base │ │ │ ├── AudioWriter.java.svn-base │ │ │ └── MainActivity.java.svn-base │ │ │ └── entries │ └── org │ │ └── sipdroid │ │ └── net │ │ ├── Random.class │ │ ├── RtpPacket.class │ │ ├── RtpSocket.class │ │ └── .svn │ │ ├── all-wcprops │ │ ├── entries │ │ └── text-base │ │ ├── SipdroidSocket.java.svn-base │ │ ├── KeepAliveSip.java.svn-base │ │ ├── RtpSocket.java.svn-base │ │ ├── KeepAliveUdp.java.svn-base │ │ └── RtpPacket.java.svn-base └── AndroidManifest.xml ├── res ├── drawable-hdpi │ └── ic_launcher.png ├── drawable-mdpi │ └── ic_launcher.png ├── drawable-xhdpi │ └── ic_launcher.png ├── drawable-xxhdpi │ └── ic_launcher.png ├── values-sw600dp │ └── dimens.xml ├── values │ ├── dimens.xml │ ├── strings.xml │ └── styles.xml ├── menu │ └── main.xml ├── values-sw720dp-land │ └── dimens.xml └── layout │ └── main.xml ├── gen └── com │ └── shawn │ └── demo │ └── voip │ ├── BuildConfig.java │ └── R.java ├── .settings └── org.eclipse.jdt.core.prefs ├── .classpath ├── project.properties ├── proguard-project.txt ├── .project └── AndroidManifest.xml /ic_launcher-web.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/ic_launcher-web.png -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | lan-voice-chat 2 | ============== 3 | 4 | an android lan voice chat,refer to sipdroid. 5 | -------------------------------------------------------------------------------- /src/jay/media/LanVedioPlay.java: -------------------------------------------------------------------------------- 1 | package jay.media; 2 | 3 | public class LanVedioPlay 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /src/jay/media/LanVedioRecord.java: -------------------------------------------------------------------------------- 1 | package jay.media; 2 | 3 | public class LanVedioRecord 4 | { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /libs/android-support-v4.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/libs/android-support-v4.jar -------------------------------------------------------------------------------- /libs/armeabi/libg722_jni.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/libs/armeabi/libg722_jni.so -------------------------------------------------------------------------------- /libs/armeabi/libspeex_jni.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/libs/armeabi/libspeex_jni.so -------------------------------------------------------------------------------- /src/jay/dencode/Decoder.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/src/jay/dencode/Decoder.java -------------------------------------------------------------------------------- /bin/classes/jay/func/func.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/func/func.class -------------------------------------------------------------------------------- /libs/armeabi-v7a/libg722_jni.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/libs/armeabi-v7a/libg722_jni.so -------------------------------------------------------------------------------- /src/jay/media/LanAudioPlay.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/src/jay/media/LanAudioPlay.java -------------------------------------------------------------------------------- /src/jay/media/MediaService.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/src/jay/media/MediaService.java -------------------------------------------------------------------------------- /bin/classes/jay/codec/Codec.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/codec/Codec.class -------------------------------------------------------------------------------- /bin/classes/jay/codec/G711.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/codec/G711.class -------------------------------------------------------------------------------- /bin/classes/jay/codec/G722.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/codec/G722.class -------------------------------------------------------------------------------- /bin/classes/jay/codec/Speex.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/codec/Speex.class -------------------------------------------------------------------------------- /bin/classes/jay/codec/alaw.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/codec/alaw.class -------------------------------------------------------------------------------- /bin/classes/jay/codec/ulaw.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/codec/ulaw.class -------------------------------------------------------------------------------- /libs/armeabi-v7a/libspeex_jni.so: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/libs/armeabi-v7a/libspeex_jni.so -------------------------------------------------------------------------------- /res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/jay/media/LanAudioRecord.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/src/jay/media/LanAudioRecord.java -------------------------------------------------------------------------------- /res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/org/sipdroid/net/RtpPacket.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/src/org/sipdroid/net/RtpPacket.java -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/R.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/R.class -------------------------------------------------------------------------------- /bin/classes/jay/dencode/Decoder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/dencode/Decoder.class -------------------------------------------------------------------------------- /bin/classes/jay/dencode/Encoder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/dencode/Encoder.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/rtp.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/rtp.class -------------------------------------------------------------------------------- /bin/classes/jay/media/LanAudioPlay.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/media/LanAudioPlay.class -------------------------------------------------------------------------------- /bin/classes/jay/media/LanVedioPlay.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/media/LanVedioPlay.class -------------------------------------------------------------------------------- /bin/classes/jay/media/MediaManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/media/MediaManager.class -------------------------------------------------------------------------------- /bin/classes/jay/media/MediaService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/media/MediaService.class -------------------------------------------------------------------------------- /bin/classes/org/sipdroid/net/Random.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/org/sipdroid/net/Random.class -------------------------------------------------------------------------------- /src/com/shawn/demo/voip/MainActivity.java: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/src/com/shawn/demo/voip/MainActivity.java -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/R$attr.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/R$attr.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/R$id.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/R$id.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/R$menu.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/R$menu.class -------------------------------------------------------------------------------- /bin/classes/jay/codec/EchoCancellation.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/codec/EchoCancellation.class -------------------------------------------------------------------------------- /bin/classes/jay/media/LanAudioRecord.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/media/LanAudioRecord.class -------------------------------------------------------------------------------- /bin/classes/jay/media/LanVedioRecord.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/media/LanVedioRecord.class -------------------------------------------------------------------------------- /bin/classes/jay/media/MediaManager$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/media/MediaManager$1.class -------------------------------------------------------------------------------- /bin/classes/org/sipdroid/net/RtpPacket.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/org/sipdroid/net/RtpPacket.class -------------------------------------------------------------------------------- /bin/classes/org/sipdroid/net/RtpSocket.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/org/sipdroid/net/RtpSocket.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/R$dimen.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/R$dimen.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/R$layout.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/R$layout.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/R$string.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/R$string.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/R$style.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/R$style.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/BuildConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/BuildConfig.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/R$drawable.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/R$drawable.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/MainActivity.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/MainActivity.class -------------------------------------------------------------------------------- /bin/classes/jay/media/MediaService$JayBinder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/jay/media/MediaService$JayBinder.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/MainActivity$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/MainActivity$1.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/MainActivity$2.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/MainActivity$2.class -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/MainActivity$3.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shawn7com/lan-voice-chat/HEAD/bin/classes/com/shawn/demo/voip/MainActivity$3.class -------------------------------------------------------------------------------- /src/com/shawn/demo/voip/.svn/text-base/Static.java.svn-base: -------------------------------------------------------------------------------- 1 | package com.sea.chapter6_5; 2 | 3 | public class Static { 4 | public final static int SAMPLERATEINHZ = 8000; 5 | } 6 | -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/.svn/text-base/Static.java.svn-base: -------------------------------------------------------------------------------- 1 | package com.sea.chapter6_5; 2 | 3 | public class Static { 4 | public final static int SAMPLERATEINHZ = 8000; 5 | } 6 | -------------------------------------------------------------------------------- /gen/com/shawn/demo/voip/BuildConfig.java: -------------------------------------------------------------------------------- 1 | /** Automatically generated file. DO NOT MODIFY */ 2 | package com.shawn.demo.voip; 3 | 4 | public final class BuildConfig { 5 | public final static boolean DEBUG = true; 6 | } -------------------------------------------------------------------------------- /.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /res/values-sw600dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16dp 5 | 16dp 6 | 7 | -------------------------------------------------------------------------------- /res/menu/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | -------------------------------------------------------------------------------- /res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | LAN_Voice_Chat 5 | Settings 6 | Hello world! 7 | 8 | -------------------------------------------------------------------------------- /res/values-sw720dp-land/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 128dp 8 | 9 | -------------------------------------------------------------------------------- /.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system edit 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | # 10 | # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): 11 | #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt 12 | 13 | # Project target. 14 | target=android-8 15 | -------------------------------------------------------------------------------- /res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 14 | 15 | 16 | 19 | 20 | -------------------------------------------------------------------------------- /src/org/sipdroid/net/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 44 4 | /svn/!svn/ver/437/trunk/src/org/sipdroid/net 5 | END 6 | KeepAliveSip.java 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 61 10 | /svn/!svn/ver/50/trunk/src/org/sipdroid/net/KeepAliveSip.java 11 | END 12 | SipdroidSocket.java 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 64 16 | /svn/!svn/ver/156/trunk/src/org/sipdroid/net/SipdroidSocket.java 17 | END 18 | RtpPacket.java 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 59 22 | /svn/!svn/ver/437/trunk/src/org/sipdroid/net/RtpPacket.java 23 | END 24 | KeepAliveUdp.java 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 62 28 | /svn/!svn/ver/182/trunk/src/org/sipdroid/net/KeepAliveUdp.java 29 | END 30 | RtpSocket.java 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 59 34 | /svn/!svn/ver/156/trunk/src/org/sipdroid/net/RtpSocket.java 35 | END 36 | -------------------------------------------------------------------------------- /bin/classes/org/sipdroid/net/.svn/all-wcprops: -------------------------------------------------------------------------------- 1 | K 25 2 | svn:wc:ra_dav:version-url 3 | V 44 4 | /svn/!svn/ver/437/trunk/src/org/sipdroid/net 5 | END 6 | KeepAliveSip.java 7 | K 25 8 | svn:wc:ra_dav:version-url 9 | V 61 10 | /svn/!svn/ver/50/trunk/src/org/sipdroid/net/KeepAliveSip.java 11 | END 12 | SipdroidSocket.java 13 | K 25 14 | svn:wc:ra_dav:version-url 15 | V 64 16 | /svn/!svn/ver/156/trunk/src/org/sipdroid/net/SipdroidSocket.java 17 | END 18 | RtpPacket.java 19 | K 25 20 | svn:wc:ra_dav:version-url 21 | V 59 22 | /svn/!svn/ver/437/trunk/src/org/sipdroid/net/RtpPacket.java 23 | END 24 | KeepAliveUdp.java 25 | K 25 26 | svn:wc:ra_dav:version-url 27 | V 62 28 | /svn/!svn/ver/182/trunk/src/org/sipdroid/net/KeepAliveUdp.java 29 | END 30 | RtpSocket.java 31 | K 25 32 | svn:wc:ra_dav:version-url 33 | V 59 34 | /svn/!svn/ver/156/trunk/src/org/sipdroid/net/RtpSocket.java 35 | END 36 | -------------------------------------------------------------------------------- /proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | LAN_Voice_Chat 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | 30 | com.android.ide.eclipse.adt.AndroidNature 31 | org.eclipse.jdt.core.javanature 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/jay/codec/alaw.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Sipdroid Open Source Project 3 | * 4 | * This file is part of Sipdroid (http://www.sipdroid.org) 5 | * 6 | * Sipdroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | package jay.codec; 21 | 22 | 23 | class alaw { 24 | alaw() { 25 | //load(); 26 | } 27 | 28 | public void init() { 29 | G711.init(); 30 | } 31 | 32 | public int decode(byte enc[], short lin[], int frames) { 33 | G711.alaw2linear(enc, lin, frames); 34 | 35 | return frames; 36 | } 37 | 38 | public int encode(short lin[], int offset, byte enc[], int frames) { 39 | G711.linear2alaw(lin, offset, enc, frames); 40 | return frames; 41 | } 42 | 43 | public void close() { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/jay/codec/ulaw.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Sipdroid Open Source Project 3 | * 4 | * This file is part of Sipdroid (http://www.sipdroid.org) 5 | * 6 | * Sipdroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | package jay.codec; 21 | 22 | 23 | class ulaw { 24 | ulaw() { 25 | //load(); 26 | } 27 | 28 | public void init() { 29 | G711.init(); 30 | } 31 | 32 | public int decode(byte enc[], short lin[], int frames) { 33 | G711.ulaw2linear(enc, lin, frames); 34 | 35 | return frames; 36 | } 37 | 38 | public int encode(short lin[], int offset, byte enc[], int frames) { 39 | G711.linear2ulaw(lin, offset, enc, frames); 40 | return frames; 41 | } 42 | 43 | public void close() { 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/jay/codec/Speex.java: -------------------------------------------------------------------------------- 1 | package jay.codec; 2 | 3 | import android.util.Log; 4 | 5 | 6 | public class Speex { 7 | private final static String TAG = "Speex"; 8 | 9 | /* quality 10 | * 1 : 4kbps (very noticeable artifacts, usually intelligible) 11 | * 2 : 6kbps (very noticeable artifacts, good intelligibility) 12 | * 4 : 8kbps (noticeable artifacts sometimes) 13 | * 6 : 11kpbs (artifacts usually only noticeable with headphones) 14 | * 8 : 15kbps (artifacts not usually noticeable) 15 | */ 16 | private static final int DEFAULT_COMPRESSION = 2; 17 | 18 | public Speex() { 19 | load(); 20 | } 21 | 22 | public void init() { 23 | Log.i(TAG, "Speex open with "+DEFAULT_COMPRESSION+" compression"); 24 | open(DEFAULT_COMPRESSION); 25 | } 26 | 27 | public void load() { 28 | try { 29 | System.loadLibrary("speex_jni"); 30 | } catch (Throwable e) { 31 | e.printStackTrace(); 32 | } 33 | 34 | } 35 | 36 | public native int open(int compression); 37 | public native int getFrameSize(); 38 | public native int decode(byte encoded[], short lin[], int size); 39 | public native int encode(short lin[], int offset, byte encoded[], int size); 40 | public native void close(); 41 | 42 | /*echo cancellation*/ 43 | public native int echoinit(int framesize,int filterlength); 44 | public native int echoplayback(short[] play); 45 | public native int echocapture(short[] rec ,short[] out); 46 | public native void echoclose(); 47 | 48 | } -------------------------------------------------------------------------------- /src/jay/func/func.java: -------------------------------------------------------------------------------- 1 | package jay.func; 2 | 3 | import java.nio.ByteBuffer; 4 | import java.nio.ByteOrder; 5 | 6 | public class func { 7 | 8 | static public short[] byteArray2ShortArray(byte[] data) { 9 | // short[] retVal = new short[data.length]; 10 | // for (int i = 0; i < retVal.length; i++) 11 | // retVal[i] = (short) ((data[i * 2]&0xff) | (data[i * 2+1]&0xff) << 8); 12 | // return retVal; 13 | short[] shorts = new short[data.length/2]; 14 | // to turn bytes to shorts as either big endian or little endian. 15 | ByteBuffer.wrap(data).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().get(shorts); 16 | return shorts; 17 | } 18 | 19 | public static byte[] shortArray2ByteArray(short shorts[]) { 20 | // to turn shorts back to bytes. 21 | byte[] bytes = new byte[shorts.length * 2]; 22 | ByteBuffer.wrap(bytes).order(ByteOrder.LITTLE_ENDIAN).asShortBuffer().put(shorts); 23 | return bytes; 24 | } 25 | /* 26 | * static public short[] byteArray2ShortArray(byte[] data) { 27 | short[] retVal = new short[data.length/2]; 28 | for (int i = 0; i < retVal.length; i++) 29 | retVal[i] = (short) ((data[i * 2]&0xff) | (data[i * 2+1]&0xff) << 8); 30 | return retVal; 31 | } 32 | 33 | public static byte[] shortArray2ByteArray(short shorts[]) { 34 | byte[] bytes = new byte[shorts.length*2]; 35 | for (int i = 0; i < shorts.length; i++){ 36 | bytes[i*2]=(byte)((shorts[i]&0xff00)>>8); 37 | bytes[i*2+1]=(byte)(shorts[i]&0x00ff); 38 | } 39 | return bytes; 40 | } 41 | */ 42 | 43 | } -------------------------------------------------------------------------------- /AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /bin/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 25 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /src/jay/media/MediaManager.java: -------------------------------------------------------------------------------- 1 | package jay.media; 2 | 3 | import android.content.ComponentName; 4 | import android.content.Context; 5 | import android.content.Intent; 6 | import android.content.ServiceConnection; 7 | import android.os.IBinder; 8 | 9 | public class MediaManager 10 | { 11 | 12 | private MediaService mMediaService; 13 | private Context context; 14 | boolean mIsBound; 15 | 16 | private ServiceConnection mConnection = new ServiceConnection() 17 | { 18 | public void onServiceConnected(ComponentName className, IBinder service) 19 | { 20 | mMediaService = ((MediaService.JayBinder) service).getService(); 21 | } 22 | 23 | public void onServiceDisconnected(ComponentName className) 24 | { 25 | mMediaService = null; 26 | } 27 | }; 28 | 29 | void doBindService(Intent intent) 30 | { 31 | context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); 32 | mIsBound = true; 33 | } 34 | 35 | void doUnbindService() 36 | { 37 | if (mIsBound) { 38 | context.unbindService(mConnection); 39 | mIsBound = false; 40 | } 41 | } 42 | 43 | public MediaManager(Context context) 44 | { 45 | this.context = context; 46 | initService(); 47 | } 48 | 49 | public void initService() 50 | { 51 | // we want to start our service (for handling our time-consuming 52 | // operation) 53 | Intent serviceIntent = new Intent(context, MediaService.class); 54 | // used to bind sipservice ,it could be destroyed when app was destroyed 55 | doBindService(serviceIntent); 56 | } 57 | 58 | public void test() 59 | { 60 | mMediaService.test(); 61 | } 62 | 63 | public void startAudio() 64 | { 65 | mMediaService.startAudio("192.168.1.4", 8, 8000, 8000, 8000, 5); 66 | } 67 | 68 | public void stopAudio() 69 | { 70 | mMediaService.stopAudio(); 71 | } 72 | } -------------------------------------------------------------------------------- /src/jay/codec/G722.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Sipdroid Open Source Project 3 | * 4 | * This file is part of Sipdroid (http://www.sipdroid.org) 5 | * 6 | * Sipdroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | package jay.codec; 21 | 22 | import android.util.Log; 23 | 24 | 25 | 26 | class G722 { 27 | private final static String TAG = "G722"; 28 | 29 | /* 30 | Acceptable values for bitrate are 31 | 48000, 56000 or 64000 32 | */ 33 | private static final int DEFAULT_BITRATE = 64000; 34 | 35 | G722() { 36 | load(); 37 | } 38 | 39 | 40 | void load() { 41 | try { 42 | System.loadLibrary("g722_jni"); 43 | } catch (Throwable e) { 44 | Log.e("g722", "load error"); 45 | } 46 | 47 | } 48 | 49 | public native int open(int brate); 50 | public native int decode(byte encoded[], short lin[], int size); 51 | public native int encode(short lin[], int offset, byte encoded[], int size); 52 | public native void close(); 53 | 54 | public void init() { 55 | open(DEFAULT_BITRATE); 56 | Log.i(TAG, "open with "+DEFAULT_BITRATE+" brate"); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/com/shawn/demo/voip/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 2386 5 | svn://192.168.0.10/examples/basic/chapter6_5_w_client/src/com/sea/chapter6_5 6 | svn://192.168.0.10 7 | 8 | 9 | 10 | 2011-09-16T03:52:08.669818Z 11 | 2195 12 | pirate 13 | 14 | 15 | svn:special svn:externals svn:needs-lock 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 47cacf33-6897-42b0-b24f-9d493718c6c9 28 | 29 | AudioReader.java 30 | file 31 | 32 | 33 | 34 | 35 | 2011-09-29T00:46:44.000000Z 36 | 1c997c6f33d3fb78eefeb33e2fab67eb 37 | 2011-09-16T03:04:01.973665Z 38 | 2191 39 | pirate 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 1670 62 | 63 | AudioWriter.java 64 | file 65 | 66 | 67 | 68 | 69 | 2011-09-29T00:46:44.000000Z 70 | 1c9f574125212229a9a34cfc35a24873 71 | 2011-09-16T03:04:01.973665Z 72 | 2191 73 | pirate 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 1728 96 | 97 | MainActivity.java 98 | file 99 | 100 | 101 | 102 | 103 | 2011-09-29T00:46:44.000000Z 104 | 9dd4e67d617d9eee986c04d1decba443 105 | 2011-09-16T03:52:08.669818Z 106 | 2195 107 | pirate 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 1779 130 | 131 | Static.java 132 | file 133 | 134 | 135 | 136 | 137 | 2011-09-29T00:46:44.000000Z 138 | 01e7f631b08c14a12564b3658c7a9fb4 139 | 2011-09-16T03:04:01.973665Z 140 | 2191 141 | pirate 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 101 164 | 165 | -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 2386 5 | svn://192.168.0.10/examples/basic/chapter6_5_w_client/src/com/sea/chapter6_5 6 | svn://192.168.0.10 7 | 8 | 9 | 10 | 2011-09-16T03:52:08.669818Z 11 | 2195 12 | pirate 13 | 14 | 15 | svn:special svn:externals svn:needs-lock 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 47cacf33-6897-42b0-b24f-9d493718c6c9 28 | 29 | AudioReader.java 30 | file 31 | 32 | 33 | 34 | 35 | 2011-09-29T00:46:44.000000Z 36 | 1c997c6f33d3fb78eefeb33e2fab67eb 37 | 2011-09-16T03:04:01.973665Z 38 | 2191 39 | pirate 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 1670 62 | 63 | AudioWriter.java 64 | file 65 | 66 | 67 | 68 | 69 | 2011-09-29T00:46:44.000000Z 70 | 1c9f574125212229a9a34cfc35a24873 71 | 2011-09-16T03:04:01.973665Z 72 | 2191 73 | pirate 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 1728 96 | 97 | MainActivity.java 98 | file 99 | 100 | 101 | 102 | 103 | 2011-09-29T00:46:44.000000Z 104 | 9dd4e67d617d9eee986c04d1decba443 105 | 2011-09-16T03:52:08.669818Z 106 | 2195 107 | pirate 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 1779 130 | 131 | Static.java 132 | file 133 | 134 | 135 | 136 | 137 | 2011-09-29T00:46:44.000000Z 138 | 01e7f631b08c14a12564b3658c7a9fb4 139 | 2011-09-16T03:04:01.973665Z 140 | 2191 141 | pirate 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 101 164 | 165 | -------------------------------------------------------------------------------- /src/com/shawn/demo/voip/.svn/text-base/AudioReader.java.svn-base: -------------------------------------------------------------------------------- 1 | package com.sea.chapter6_5; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.IOException; 5 | import java.net.Socket; 6 | 7 | import android.media.AudioFormat; 8 | import android.media.AudioManager; 9 | import android.media.AudioTrack; 10 | import android.util.Log; 11 | 12 | public class AudioReader extends Thread { 13 | protected AudioTrack audioTrack; 14 | protected int bufferSize; 15 | protected byte[] buffer; 16 | protected boolean isRunning; 17 | private Socket socket; 18 | private DataInputStream dataInputStream; 19 | 20 | public void init(Socket socket) { 21 | try { 22 | this.socket = socket; 23 | dataInputStream = new DataInputStream(socket.getInputStream()); 24 | 25 | isRunning = true; 26 | 27 | bufferSize = AudioTrack.getMinBufferSize(Static.SAMPLERATEINHZ, 28 | AudioFormat.CHANNEL_CONFIGURATION_MONO, 29 | AudioFormat.ENCODING_PCM_16BIT); 30 | Log.i("chapter6_5_w", "AudioTrack bufferSize=" + bufferSize); 31 | audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, Static.SAMPLERATEINHZ, 32 | AudioFormat.CHANNEL_CONFIGURATION_MONO, 33 | AudioFormat.ENCODING_PCM_16BIT, bufferSize, 34 | AudioTrack.MODE_STREAM); 35 | 36 | buffer = new byte[bufferSize]; 37 | 38 | } catch (Exception e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | 43 | public void free() { 44 | isRunning = false; 45 | try { 46 | Thread.sleep(1000); 47 | } catch (Exception e) { 48 | Log.d("sleep exceptions...\n", ""); 49 | } 50 | } 51 | 52 | public void run() { 53 | audioTrack.play(); 54 | while (isRunning) { 55 | try { 56 | dataInputStream.read(buffer); 57 | audioTrack.write(buffer, 0, buffer.length); 58 | audioTrack.flush(); 59 | } catch (Exception e) { 60 | e.printStackTrace(); 61 | } 62 | 63 | } 64 | 65 | audioTrack.stop(); 66 | audioTrack = null; 67 | try { 68 | dataInputStream.close(); 69 | } catch (IOException e) { 70 | e.printStackTrace(); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/.svn/text-base/AudioReader.java.svn-base: -------------------------------------------------------------------------------- 1 | package com.sea.chapter6_5; 2 | 3 | import java.io.DataInputStream; 4 | import java.io.IOException; 5 | import java.net.Socket; 6 | 7 | import android.media.AudioFormat; 8 | import android.media.AudioManager; 9 | import android.media.AudioTrack; 10 | import android.util.Log; 11 | 12 | public class AudioReader extends Thread { 13 | protected AudioTrack audioTrack; 14 | protected int bufferSize; 15 | protected byte[] buffer; 16 | protected boolean isRunning; 17 | private Socket socket; 18 | private DataInputStream dataInputStream; 19 | 20 | public void init(Socket socket) { 21 | try { 22 | this.socket = socket; 23 | dataInputStream = new DataInputStream(socket.getInputStream()); 24 | 25 | isRunning = true; 26 | 27 | bufferSize = AudioTrack.getMinBufferSize(Static.SAMPLERATEINHZ, 28 | AudioFormat.CHANNEL_CONFIGURATION_MONO, 29 | AudioFormat.ENCODING_PCM_16BIT); 30 | Log.i("chapter6_5_w", "AudioTrack bufferSize=" + bufferSize); 31 | audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, Static.SAMPLERATEINHZ, 32 | AudioFormat.CHANNEL_CONFIGURATION_MONO, 33 | AudioFormat.ENCODING_PCM_16BIT, bufferSize, 34 | AudioTrack.MODE_STREAM); 35 | 36 | buffer = new byte[bufferSize]; 37 | 38 | } catch (Exception e) { 39 | e.printStackTrace(); 40 | } 41 | } 42 | 43 | public void free() { 44 | isRunning = false; 45 | try { 46 | Thread.sleep(1000); 47 | } catch (Exception e) { 48 | Log.d("sleep exceptions...\n", ""); 49 | } 50 | } 51 | 52 | public void run() { 53 | audioTrack.play(); 54 | while (isRunning) { 55 | try { 56 | dataInputStream.read(buffer); 57 | audioTrack.write(buffer, 0, buffer.length); 58 | audioTrack.flush(); 59 | } catch (Exception e) { 60 | e.printStackTrace(); 61 | } 62 | 63 | } 64 | 65 | audioTrack.stop(); 66 | audioTrack = null; 67 | try { 68 | dataInputStream.close(); 69 | } catch (IOException e) { 70 | e.printStackTrace(); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /src/com/shawn/demo/voip/.svn/text-base/AudioWriter.java.svn-base: -------------------------------------------------------------------------------- 1 | package com.sea.chapter6_5; 2 | 3 | import java.io.DataOutputStream; 4 | import java.io.IOException; 5 | import java.net.Socket; 6 | import java.net.UnknownHostException; 7 | import java.util.LinkedList; 8 | 9 | import android.media.AudioFormat; 10 | import android.media.AudioRecord; 11 | import android.media.MediaRecorder; 12 | import android.util.Log; 13 | 14 | public class AudioWriter extends Thread { 15 | 16 | protected AudioRecord audioRecord; 17 | protected int bufferSize; 18 | protected byte[] buffer; 19 | protected boolean isRunning; 20 | protected Socket socket; 21 | protected DataOutputStream dataOutputStream; 22 | 23 | public void run() { 24 | try { 25 | audioRecord.startRecording(); 26 | while (isRunning) { 27 | audioRecord.read(buffer, 0, bufferSize); 28 | dataOutputStream.write(buffer); 29 | } 30 | 31 | audioRecord.stop(); 32 | audioRecord = null; 33 | buffer = null; 34 | dataOutputStream.close(); 35 | 36 | } catch (Exception e) { 37 | e.printStackTrace(); 38 | } 39 | } 40 | 41 | public void init(Socket socket) { 42 | bufferSize = AudioRecord.getMinBufferSize(Static.SAMPLERATEINHZ, 43 | AudioFormat.CHANNEL_CONFIGURATION_MONO, 44 | AudioFormat.ENCODING_PCM_16BIT); 45 | Log.i("chapter6_5_w", "AudioRecord bufferSize=" + bufferSize); 46 | 47 | audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, Static.SAMPLERATEINHZ, 48 | AudioFormat.CHANNEL_CONFIGURATION_MONO, 49 | AudioFormat.ENCODING_PCM_16BIT, bufferSize); 50 | 51 | buffer = new byte[bufferSize]; 52 | 53 | isRunning = true; 54 | 55 | try { 56 | this.socket = socket; 57 | dataOutputStream = new DataOutputStream(socket.getOutputStream()); 58 | } catch (UnknownHostException e) { 59 | e.printStackTrace(); 60 | } catch (IOException e) { 61 | e.printStackTrace(); 62 | } 63 | 64 | } 65 | 66 | public void free() { 67 | isRunning = false; 68 | try { 69 | Thread.sleep(1000); 70 | } catch (Exception e) { 71 | Log.d("sleep exceptions...\n", ""); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/.svn/text-base/AudioWriter.java.svn-base: -------------------------------------------------------------------------------- 1 | package com.sea.chapter6_5; 2 | 3 | import java.io.DataOutputStream; 4 | import java.io.IOException; 5 | import java.net.Socket; 6 | import java.net.UnknownHostException; 7 | import java.util.LinkedList; 8 | 9 | import android.media.AudioFormat; 10 | import android.media.AudioRecord; 11 | import android.media.MediaRecorder; 12 | import android.util.Log; 13 | 14 | public class AudioWriter extends Thread { 15 | 16 | protected AudioRecord audioRecord; 17 | protected int bufferSize; 18 | protected byte[] buffer; 19 | protected boolean isRunning; 20 | protected Socket socket; 21 | protected DataOutputStream dataOutputStream; 22 | 23 | public void run() { 24 | try { 25 | audioRecord.startRecording(); 26 | while (isRunning) { 27 | audioRecord.read(buffer, 0, bufferSize); 28 | dataOutputStream.write(buffer); 29 | } 30 | 31 | audioRecord.stop(); 32 | audioRecord = null; 33 | buffer = null; 34 | dataOutputStream.close(); 35 | 36 | } catch (Exception e) { 37 | e.printStackTrace(); 38 | } 39 | } 40 | 41 | public void init(Socket socket) { 42 | bufferSize = AudioRecord.getMinBufferSize(Static.SAMPLERATEINHZ, 43 | AudioFormat.CHANNEL_CONFIGURATION_MONO, 44 | AudioFormat.ENCODING_PCM_16BIT); 45 | Log.i("chapter6_5_w", "AudioRecord bufferSize=" + bufferSize); 46 | 47 | audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, Static.SAMPLERATEINHZ, 48 | AudioFormat.CHANNEL_CONFIGURATION_MONO, 49 | AudioFormat.ENCODING_PCM_16BIT, bufferSize); 50 | 51 | buffer = new byte[bufferSize]; 52 | 53 | isRunning = true; 54 | 55 | try { 56 | this.socket = socket; 57 | dataOutputStream = new DataOutputStream(socket.getOutputStream()); 58 | } catch (UnknownHostException e) { 59 | e.printStackTrace(); 60 | } catch (IOException e) { 61 | e.printStackTrace(); 62 | } 63 | 64 | } 65 | 66 | public void free() { 67 | isRunning = false; 68 | try { 69 | Thread.sleep(1000); 70 | } catch (Exception e) { 71 | Log.d("sleep exceptions...\n", ""); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/com/shawn/demo/voip/.svn/text-base/MainActivity.java.svn-base: -------------------------------------------------------------------------------- 1 | package com.sea.chapter6_5; 2 | 3 | import java.io.IOException; 4 | import java.net.InetAddress; 5 | import java.net.Socket; 6 | import java.net.UnknownHostException; 7 | 8 | import android.app.Activity; 9 | import android.os.Bundle; 10 | import android.view.Menu; 11 | import android.view.MenuItem; 12 | 13 | public class MainActivity extends Activity { 14 | 15 | public static final int MENU_START_ID = Menu.FIRST; 16 | public static final int MENU_STOP_ID = Menu.FIRST + 1; 17 | public static final int MENU_EXIT_ID = Menu.FIRST + 2; 18 | 19 | private AudioWriter audioWriter; 20 | private AudioReader AudioReader; 21 | private Socket socket; 22 | 23 | @Override 24 | public void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.main); 27 | } 28 | 29 | public boolean onCreateOptionsMenu(Menu aMenu) { 30 | boolean res = super.onCreateOptionsMenu(aMenu); 31 | 32 | aMenu.add(0, MENU_START_ID, 0, "START"); 33 | aMenu.add(0, MENU_STOP_ID, 0, "STOP"); 34 | aMenu.add(0, MENU_EXIT_ID, 0, "EXIT"); 35 | 36 | return res; 37 | } 38 | 39 | public boolean onOptionsItemSelected(MenuItem aMenuItem) { 40 | switch (aMenuItem.getItemId()) { 41 | case MENU_START_ID: { 42 | try { 43 | if (socket == null) { 44 | socket = new Socket(InetAddress.getByName("192.168.0.116"), 45 | 54321); 46 | audioWriter = new AudioWriter(); 47 | AudioReader = new AudioReader(); 48 | 49 | audioWriter.init(socket); 50 | AudioReader.init(socket); 51 | 52 | audioWriter.start(); 53 | AudioReader.start(); 54 | } 55 | } catch (Exception e) { 56 | e.printStackTrace(); 57 | } 58 | 59 | } 60 | break; 61 | case MENU_STOP_ID: { 62 | audioWriter.free(); 63 | AudioReader.free(); 64 | 65 | audioWriter = null; 66 | AudioReader = null; 67 | } 68 | break; 69 | case MENU_EXIT_ID: { 70 | int pid = android.os.Process.myPid(); 71 | android.os.Process.killProcess(pid); 72 | } 73 | break; 74 | default: 75 | break; 76 | } 77 | 78 | return super.onOptionsItemSelected(aMenuItem); 79 | } 80 | } -------------------------------------------------------------------------------- /bin/classes/com/shawn/demo/voip/.svn/text-base/MainActivity.java.svn-base: -------------------------------------------------------------------------------- 1 | package com.sea.chapter6_5; 2 | 3 | import java.io.IOException; 4 | import java.net.InetAddress; 5 | import java.net.Socket; 6 | import java.net.UnknownHostException; 7 | 8 | import android.app.Activity; 9 | import android.os.Bundle; 10 | import android.view.Menu; 11 | import android.view.MenuItem; 12 | 13 | public class MainActivity extends Activity { 14 | 15 | public static final int MENU_START_ID = Menu.FIRST; 16 | public static final int MENU_STOP_ID = Menu.FIRST + 1; 17 | public static final int MENU_EXIT_ID = Menu.FIRST + 2; 18 | 19 | private AudioWriter audioWriter; 20 | private AudioReader AudioReader; 21 | private Socket socket; 22 | 23 | @Override 24 | public void onCreate(Bundle savedInstanceState) { 25 | super.onCreate(savedInstanceState); 26 | setContentView(R.layout.main); 27 | } 28 | 29 | public boolean onCreateOptionsMenu(Menu aMenu) { 30 | boolean res = super.onCreateOptionsMenu(aMenu); 31 | 32 | aMenu.add(0, MENU_START_ID, 0, "START"); 33 | aMenu.add(0, MENU_STOP_ID, 0, "STOP"); 34 | aMenu.add(0, MENU_EXIT_ID, 0, "EXIT"); 35 | 36 | return res; 37 | } 38 | 39 | public boolean onOptionsItemSelected(MenuItem aMenuItem) { 40 | switch (aMenuItem.getItemId()) { 41 | case MENU_START_ID: { 42 | try { 43 | if (socket == null) { 44 | socket = new Socket(InetAddress.getByName("192.168.0.116"), 45 | 54321); 46 | audioWriter = new AudioWriter(); 47 | AudioReader = new AudioReader(); 48 | 49 | audioWriter.init(socket); 50 | AudioReader.init(socket); 51 | 52 | audioWriter.start(); 53 | AudioReader.start(); 54 | } 55 | } catch (Exception e) { 56 | e.printStackTrace(); 57 | } 58 | 59 | } 60 | break; 61 | case MENU_STOP_ID: { 62 | audioWriter.free(); 63 | AudioReader.free(); 64 | 65 | audioWriter = null; 66 | AudioReader = null; 67 | } 68 | break; 69 | case MENU_EXIT_ID: { 70 | int pid = android.os.Process.myPid(); 71 | android.os.Process.killProcess(pid); 72 | } 73 | break; 74 | default: 75 | break; 76 | } 77 | 78 | return super.onOptionsItemSelected(aMenuItem); 79 | } 80 | } -------------------------------------------------------------------------------- /src/org/sipdroid/net/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 618 5 | http://sipdroid.googlecode.com/svn/trunk/src/org/sipdroid/net 6 | http://sipdroid.googlecode.com/svn 7 | 8 | 9 | 10 | 2010-01-31T09:31:30.597620Z 11 | 437 12 | tm.inoue@gmail.com 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 8b64e154-0f13-11de-9106-f38757f67524 28 | 29 | impl 30 | dir 31 | 32 | KeepAliveSip.java 33 | file 34 | 35 | 36 | 37 | 38 | 2011-12-28T05:33:26.749278Z 39 | 3b0071b722edd390c3df853d32265a00 40 | 2009-04-28T00:22:15.939425Z 41 | 50 42 | pmerle71 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 2688 65 | 66 | SipdroidSocket.java 67 | file 68 | 69 | 70 | 71 | 72 | 2011-12-28T05:33:26.925296Z 73 | adb2ea7bed2d9130d8b9d7af1dfe77b3 74 | 2009-07-05T22:39:04.228246Z 75 | 156 76 | pmerle71 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 2617 99 | 100 | RtpPacket.java 101 | file 102 | 103 | 104 | 105 | 106 | 2011-12-28T05:33:27.087312Z 107 | e3752360c20429e361a9b182d02083b0 108 | 2010-01-31T09:31:30.597620Z 109 | 437 110 | tm.inoue@gmail.com 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 7853 133 | 134 | KeepAliveUdp.java 135 | file 136 | 137 | 138 | 139 | 140 | 2011-12-28T05:33:27.274331Z 141 | cc8fc7996c8444d170e6ad59f3ab115b 142 | 2009-07-17T20:44:36.326783Z 143 | 182 144 | pmerle71 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 4742 167 | 168 | RtpSocket.java 169 | file 170 | 171 | 172 | 173 | 174 | 2011-12-28T05:33:27.420345Z 175 | 107e7e96f1318d4ab42047918843eaff 176 | 2009-07-05T22:39:04.228246Z 177 | 156 178 | pmerle71 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 2769 201 | 202 | -------------------------------------------------------------------------------- /bin/classes/org/sipdroid/net/.svn/entries: -------------------------------------------------------------------------------- 1 | 10 2 | 3 | dir 4 | 618 5 | http://sipdroid.googlecode.com/svn/trunk/src/org/sipdroid/net 6 | http://sipdroid.googlecode.com/svn 7 | 8 | 9 | 10 | 2010-01-31T09:31:30.597620Z 11 | 437 12 | tm.inoue@gmail.com 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 8b64e154-0f13-11de-9106-f38757f67524 28 | 29 | impl 30 | dir 31 | 32 | KeepAliveSip.java 33 | file 34 | 35 | 36 | 37 | 38 | 2011-12-28T05:33:26.749278Z 39 | 3b0071b722edd390c3df853d32265a00 40 | 2009-04-28T00:22:15.939425Z 41 | 50 42 | pmerle71 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 2688 65 | 66 | SipdroidSocket.java 67 | file 68 | 69 | 70 | 71 | 72 | 2011-12-28T05:33:26.925296Z 73 | adb2ea7bed2d9130d8b9d7af1dfe77b3 74 | 2009-07-05T22:39:04.228246Z 75 | 156 76 | pmerle71 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 2617 99 | 100 | RtpPacket.java 101 | file 102 | 103 | 104 | 105 | 106 | 2011-12-28T05:33:27.087312Z 107 | e3752360c20429e361a9b182d02083b0 108 | 2010-01-31T09:31:30.597620Z 109 | 437 110 | tm.inoue@gmail.com 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 7853 133 | 134 | KeepAliveUdp.java 135 | file 136 | 137 | 138 | 139 | 140 | 2011-12-28T05:33:27.274331Z 141 | cc8fc7996c8444d170e6ad59f3ab115b 142 | 2009-07-17T20:44:36.326783Z 143 | 182 144 | pmerle71 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 4742 167 | 168 | RtpSocket.java 169 | file 170 | 171 | 172 | 173 | 174 | 2011-12-28T05:33:27.420345Z 175 | 107e7e96f1318d4ab42047918843eaff 176 | 2009-07-05T22:39:04.228246Z 177 | 156 178 | pmerle71 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 2769 201 | 202 | -------------------------------------------------------------------------------- /src/org/sipdroid/net/.svn/text-base/SipdroidSocket.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Sipdroid Open Source Project 3 | * 4 | * This file is part of Sipdroid (http://www.sipdroid.org) 5 | * 6 | * Sipdroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package org.sipdroid.net; 22 | 23 | import java.io.IOException; 24 | import java.net.DatagramPacket; 25 | import java.net.DatagramSocket; 26 | import java.net.InetAddress; 27 | import java.net.SocketException; 28 | import java.net.SocketOptions; 29 | import java.net.UnknownHostException; 30 | 31 | import org.sipdroid.net.impl.OSNetworkSystem; 32 | import org.sipdroid.net.impl.PlainDatagramSocketImpl; 33 | 34 | public class SipdroidSocket extends DatagramSocket { 35 | 36 | PlainDatagramSocketImpl impl; 37 | public static boolean loaded = false; 38 | 39 | public SipdroidSocket(int port) throws SocketException, UnknownHostException { 40 | super(!loaded?port:0); 41 | if (loaded) { 42 | impl = new PlainDatagramSocketImpl(); 43 | impl.create(); 44 | impl.bind(port,InetAddress.getByName("0")); 45 | } 46 | } 47 | 48 | public void close() { 49 | super.close(); 50 | if (loaded) impl.close(); 51 | } 52 | 53 | public void setSoTimeout(int val) throws SocketException { 54 | if (loaded) impl.setOption(SocketOptions.SO_TIMEOUT, val); 55 | else super.setSoTimeout(val); 56 | } 57 | 58 | public void receive(DatagramPacket pack) throws IOException { 59 | if (loaded) impl.receive(pack); 60 | else super.receive(pack); 61 | } 62 | 63 | public void send(DatagramPacket pack) throws IOException { 64 | if (loaded) impl.send(pack); 65 | else super.send(pack); 66 | } 67 | 68 | public boolean isConnected() { 69 | if (loaded) return true; 70 | else return super.isConnected(); 71 | } 72 | 73 | public void disconnect() { 74 | if (!loaded) super.disconnect(); 75 | } 76 | 77 | public void connect(InetAddress addr,int port) { 78 | if (!loaded) super.connect(addr,port); 79 | } 80 | 81 | static { 82 | try { 83 | System.loadLibrary("OSNetworkSystem"); 84 | OSNetworkSystem.getOSNetworkSystem().oneTimeInitialization(true); 85 | SipdroidSocket.loaded = true; 86 | } catch (Throwable e) { 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /bin/classes/org/sipdroid/net/.svn/text-base/SipdroidSocket.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Sipdroid Open Source Project 3 | * 4 | * This file is part of Sipdroid (http://www.sipdroid.org) 5 | * 6 | * Sipdroid is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 3 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * This source code is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with this source code; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | */ 20 | 21 | package org.sipdroid.net; 22 | 23 | import java.io.IOException; 24 | import java.net.DatagramPacket; 25 | import java.net.DatagramSocket; 26 | import java.net.InetAddress; 27 | import java.net.SocketException; 28 | import java.net.SocketOptions; 29 | import java.net.UnknownHostException; 30 | 31 | import org.sipdroid.net.impl.OSNetworkSystem; 32 | import org.sipdroid.net.impl.PlainDatagramSocketImpl; 33 | 34 | public class SipdroidSocket extends DatagramSocket { 35 | 36 | PlainDatagramSocketImpl impl; 37 | public static boolean loaded = false; 38 | 39 | public SipdroidSocket(int port) throws SocketException, UnknownHostException { 40 | super(!loaded?port:0); 41 | if (loaded) { 42 | impl = new PlainDatagramSocketImpl(); 43 | impl.create(); 44 | impl.bind(port,InetAddress.getByName("0")); 45 | } 46 | } 47 | 48 | public void close() { 49 | super.close(); 50 | if (loaded) impl.close(); 51 | } 52 | 53 | public void setSoTimeout(int val) throws SocketException { 54 | if (loaded) impl.setOption(SocketOptions.SO_TIMEOUT, val); 55 | else super.setSoTimeout(val); 56 | } 57 | 58 | public void receive(DatagramPacket pack) throws IOException { 59 | if (loaded) impl.receive(pack); 60 | else super.receive(pack); 61 | } 62 | 63 | public void send(DatagramPacket pack) throws IOException { 64 | if (loaded) impl.send(pack); 65 | else super.send(pack); 66 | } 67 | 68 | public boolean isConnected() { 69 | if (loaded) return true; 70 | else return super.isConnected(); 71 | } 72 | 73 | public void disconnect() { 74 | if (!loaded) super.disconnect(); 75 | } 76 | 77 | public void connect(InetAddress addr,int port) { 78 | if (!loaded) super.connect(addr,port); 79 | } 80 | 81 | static { 82 | try { 83 | System.loadLibrary("OSNetworkSystem"); 84 | OSNetworkSystem.getOSNetworkSystem().oneTimeInitialization(true); 85 | SipdroidSocket.loaded = true; 86 | } catch (Throwable e) { 87 | } 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /src/jay/codec/Codec.java: -------------------------------------------------------------------------------- 1 | package jay.codec; 2 | 3 | import android.util.Log; 4 | 5 | public class Codec { 6 | private final String TAG ="Codec"; 7 | 8 | protected Speex speex; 9 | protected ulaw g711u; 10 | protected alaw g711a; 11 | protected G722 g722; 12 | protected int codeccode; 13 | protected final int speex_pt=101; //Dynamic 14 | protected final int framesize=160; 15 | protected final int DEFAULT_BITRATE = 64000; 16 | //choose what codec to use 17 | public Codec(int codeccode) { 18 | this.codeccode = codeccode; 19 | } 20 | 21 | public void init() { 22 | switch(this.codeccode){ 23 | case speex_pt: 24 | Log.d(TAG, "Codec speex selected"); 25 | speex=new Speex(); 26 | speex.init(); 27 | break; 28 | case 0: 29 | Log.d(TAG, "Codec g711u selected"); 30 | g711u = new ulaw(); 31 | g711u.init(); 32 | break; 33 | case 8: 34 | Log.d(TAG, "Codec g711a selected"); 35 | g711a = new alaw(); 36 | g711a.init(); 37 | break; 38 | case 9: 39 | Log.d(TAG, "Codec g722 selected"); 40 | g722 = new G722(); 41 | g722.init(); 42 | break; 43 | } 44 | } 45 | //I put load() in related codec class 46 | public int open(int compression){ 47 | switch(this.codeccode){ 48 | case 0: 49 | return 0; 50 | case speex_pt: 51 | return speex.open(compression); 52 | case 8: 53 | return 0; 54 | case 9: 55 | return g722.open(DEFAULT_BITRATE); 56 | default: 57 | return 0; 58 | } 59 | } 60 | public int getFrameSize() 61 | { 62 | switch(this.codeccode){ 63 | case 0: 64 | return 0; 65 | case speex_pt: 66 | return speex.getFrameSize(); 67 | case 8: 68 | return 0; 69 | case 9: 70 | return 0; 71 | default: 72 | return 0; 73 | } 74 | } 75 | public int decode(byte[] encoded, short[] lin, int size) 76 | { 77 | switch(this.codeccode){ 78 | case speex_pt: 79 | return speex.decode(encoded, lin, size); 80 | case 0: 81 | return g711u.decode(encoded, lin, size); 82 | case 8: 83 | return g711a.decode(encoded, lin, size); 84 | case 9: 85 | return g722.decode(encoded, lin, size); 86 | default: 87 | return 0; 88 | } 89 | } 90 | public int encode(short[] lin, int offset, byte[] encoded, int size){ 91 | switch(this.codeccode){ 92 | case speex_pt: 93 | return speex.encode(lin, offset, encoded, size); 94 | case 0: 95 | return g711u.encode(lin, offset, encoded, size); 96 | case 8: 97 | return g711a.encode(lin, offset, encoded, size); 98 | case 9: 99 | return g722.encode(lin, offset, encoded, size); 100 | default: 101 | return 0; 102 | } 103 | } 104 | public void close(){ 105 | switch(this.codeccode){ 106 | case 0: 107 | break; 108 | case speex_pt: 109 | speex.close(); 110 | break; 111 | case 8: 112 | break; 113 | case 9: 114 | g722.close(); 115 | default: 116 | break; 117 | } 118 | } 119 | 120 | } 121 | -------------------------------------------------------------------------------- /gen/com/shawn/demo/voip/R.java: -------------------------------------------------------------------------------- 1 | /* AUTO-GENERATED FILE. DO NOT MODIFY. 2 | * 3 | * This class was automatically generated by the 4 | * aapt tool from the resource data it found. It 5 | * should not be modified by hand. 6 | */ 7 | 8 | package com.shawn.demo.voip; 9 | 10 | public final class R { 11 | public static final class attr { 12 | } 13 | public static final class dimen { 14 | /** Default screen margins, per the Android Design guidelines. 15 | 16 | Customize dimensions originally defined in res/values/dimens.xml (such as 17 | screen margins) for sw720dp devices (e.g. 10" tablets) in landscape here. 18 | 19 | */ 20 | public static final int activity_horizontal_margin=0x7f040000; 21 | public static final int activity_vertical_margin=0x7f040001; 22 | } 23 | public static final class drawable { 24 | public static final int ic_launcher=0x7f020000; 25 | } 26 | public static final class id { 27 | public static final int TextView01=0x7f080007; 28 | public static final int action_settings=0x7f08000d; 29 | public static final int btn_connect=0x7f080009; 30 | public static final int btn_exit=0x7f08000b; 31 | public static final int btn_stop=0x7f08000a; 32 | public static final int et_Send_ip=0x7f080001; 33 | public static final int et_compression=0x7f080008; 34 | public static final int et_ec_buffer=0x7f080006; 35 | public static final int et_recv_port=0x7f080005; 36 | public static final int et_send_port=0x7f080003; 37 | public static final int textView1=0x7f080000; 38 | public static final int tv_info=0x7f08000c; 39 | public static final int tx=0x7f080004; 40 | public static final int tx1=0x7f080002; 41 | } 42 | public static final class layout { 43 | public static final int main=0x7f030000; 44 | } 45 | public static final class menu { 46 | public static final int main=0x7f070000; 47 | } 48 | public static final class string { 49 | public static final int action_settings=0x7f050001; 50 | public static final int app_name=0x7f050000; 51 | public static final int hello_world=0x7f050002; 52 | } 53 | public static final class style { 54 | /** 55 | Base application theme, dependent on API level. This theme is replaced 56 | by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 57 | 58 | 59 | Theme customizations available in newer API levels can go in 60 | res/values-vXX/styles.xml, while customizations related to 61 | backward-compatibility can go here. 62 | 63 | */ 64 | public static final int AppBaseTheme=0x7f060000; 65 | /** Application theme. 66 | All customizations that are NOT specific to a particular API-level can go here. 67 | */ 68 | public static final int AppTheme=0x7f060001; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /src/org/sipdroid/net/.svn/text-base/KeepAliveSip.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Sipdroid Open Source Project 3 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 4 | * 5 | * This file is part of Sipdroid (http://www.sipdroid.org) 6 | * 7 | * Sipdroid is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This source code is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this source code; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | package org.sipdroid.net; 23 | 24 | import org.zoolu.sip.provider.SipProvider; 25 | import org.zoolu.sip.message.Message; 26 | 27 | /** 28 | * KeepAliveSip thread, for keeping the connection up toward a target SIP node 29 | * (e.g. toward the serving proxy/gw or a remote UA). It periodically sends 30 | * keep-alive tokens in order to refresh TCP connection timeouts and/or NAT 31 | * TCP/UDP session timeouts. 32 | */ 33 | public class KeepAliveSip extends KeepAliveUdp { 34 | /** SipProvider */ 35 | SipProvider sip_provider; 36 | 37 | /** Sip message */ 38 | Message message = null; 39 | 40 | /** Creates a new SIP KeepAliveSip daemon */ 41 | public KeepAliveSip(SipProvider sip_provider, 42 | long delta_time) { 43 | super(null, delta_time); 44 | init(sip_provider, null); 45 | start(); 46 | } 47 | 48 | /** Creates a new SIP KeepAliveSip daemon */ 49 | public KeepAliveSip(SipProvider sip_provider, 50 | Message message, long delta_time) { 51 | super(null, delta_time); 52 | init(sip_provider, message); 53 | start(); 54 | } 55 | 56 | /** Inits the KeepAliveSip in SIP mode */ 57 | private void init(SipProvider sip_provider, Message message) { 58 | this.sip_provider = sip_provider; 59 | if (message == null) { 60 | message = new Message("\r\n"); 61 | } 62 | this.message = message; 63 | } 64 | 65 | /** Sends the kepp-alive packet now. */ 66 | public void sendToken() throws java.io.IOException { // do send? 67 | if (!stop && sip_provider != null) { 68 | sip_provider.sendMessage(message); 69 | } 70 | } 71 | 72 | /** Main thread. */ 73 | public void run() { 74 | super.run(); 75 | sip_provider = null; 76 | } 77 | 78 | /** Gets a String representation of the Object */ 79 | public String toString() { 80 | String str = null; 81 | if (sip_provider != null) { 82 | str = "sip:" + sip_provider.getViaAddress() + ":" 83 | + sip_provider.getPort(); 84 | } 85 | return str + " (" + delta_time + "ms)"; 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /bin/classes/org/sipdroid/net/.svn/text-base/KeepAliveSip.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Sipdroid Open Source Project 3 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 4 | * 5 | * This file is part of Sipdroid (http://www.sipdroid.org) 6 | * 7 | * Sipdroid is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This source code is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this source code; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | package org.sipdroid.net; 23 | 24 | import org.zoolu.sip.provider.SipProvider; 25 | import org.zoolu.sip.message.Message; 26 | 27 | /** 28 | * KeepAliveSip thread, for keeping the connection up toward a target SIP node 29 | * (e.g. toward the serving proxy/gw or a remote UA). It periodically sends 30 | * keep-alive tokens in order to refresh TCP connection timeouts and/or NAT 31 | * TCP/UDP session timeouts. 32 | */ 33 | public class KeepAliveSip extends KeepAliveUdp { 34 | /** SipProvider */ 35 | SipProvider sip_provider; 36 | 37 | /** Sip message */ 38 | Message message = null; 39 | 40 | /** Creates a new SIP KeepAliveSip daemon */ 41 | public KeepAliveSip(SipProvider sip_provider, 42 | long delta_time) { 43 | super(null, delta_time); 44 | init(sip_provider, null); 45 | start(); 46 | } 47 | 48 | /** Creates a new SIP KeepAliveSip daemon */ 49 | public KeepAliveSip(SipProvider sip_provider, 50 | Message message, long delta_time) { 51 | super(null, delta_time); 52 | init(sip_provider, message); 53 | start(); 54 | } 55 | 56 | /** Inits the KeepAliveSip in SIP mode */ 57 | private void init(SipProvider sip_provider, Message message) { 58 | this.sip_provider = sip_provider; 59 | if (message == null) { 60 | message = new Message("\r\n"); 61 | } 62 | this.message = message; 63 | } 64 | 65 | /** Sends the kepp-alive packet now. */ 66 | public void sendToken() throws java.io.IOException { // do send? 67 | if (!stop && sip_provider != null) { 68 | sip_provider.sendMessage(message); 69 | } 70 | } 71 | 72 | /** Main thread. */ 73 | public void run() { 74 | super.run(); 75 | sip_provider = null; 76 | } 77 | 78 | /** Gets a String representation of the Object */ 79 | public String toString() { 80 | String str = null; 81 | if (sip_provider != null) { 82 | str = "sip:" + sip_provider.getViaAddress() + ":" 83 | + sip_provider.getPort(); 84 | } 85 | return str + " (" + delta_time + "ms)"; 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/org/sipdroid/net/.svn/text-base/RtpSocket.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Sipdroid Open Source Project 3 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 4 | * 5 | * This file is part of Sipdroid (http://www.sipdroid.org) 6 | * 7 | * Sipdroid is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This source code is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this source code; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | package org.sipdroid.net; 23 | 24 | import java.net.InetAddress; 25 | import java.net.DatagramPacket; 26 | import java.io.IOException; 27 | 28 | 29 | 30 | /** 31 | * RtpSocket implements a RTP socket for receiving and sending RTP packets. 32 | *

33 | * RtpSocket is associated to a DatagramSocket that is used to send and/or 34 | * receive RtpPackets. 35 | */ 36 | public class RtpSocket { 37 | /** UDP socket */ 38 | SipdroidSocket socket; 39 | DatagramPacket datagram; 40 | 41 | /** Remote address */ 42 | InetAddress r_addr; 43 | 44 | /** Remote port */ 45 | int r_port; 46 | 47 | /** Creates a new RTP socket (only receiver) */ 48 | public RtpSocket(SipdroidSocket datagram_socket) { 49 | socket = datagram_socket; 50 | r_addr = null; 51 | r_port = 0; 52 | datagram = new DatagramPacket(new byte[1],1); 53 | } 54 | 55 | /** Creates a new RTP socket (sender and receiver) */ 56 | public RtpSocket(SipdroidSocket datagram_socket, 57 | InetAddress remote_address, int remote_port) { 58 | socket = datagram_socket; 59 | r_addr = remote_address; 60 | r_port = remote_port; 61 | datagram = new DatagramPacket(new byte[1],1); 62 | } 63 | 64 | /** Returns the RTP SipdroidSocket */ 65 | public SipdroidSocket getDatagramSocket() { 66 | return socket; 67 | } 68 | 69 | /** Receives a RTP packet from this socket */ 70 | public void receive(RtpPacket rtpp) throws IOException { 71 | datagram.setData(rtpp.packet); 72 | datagram.setLength(rtpp.packet.length); 73 | socket.receive(datagram); 74 | if (!socket.isConnected()) 75 | socket.connect(datagram.getAddress(),datagram.getPort()); 76 | rtpp.packet_len = datagram.getLength(); 77 | } 78 | 79 | /** Sends a RTP packet from this socket */ 80 | public void send(RtpPacket rtpp) throws IOException { 81 | datagram.setData(rtpp.packet); 82 | datagram.setLength(rtpp.packet_len); 83 | datagram.setAddress(r_addr); 84 | datagram.setPort(r_port); 85 | socket.send(datagram); 86 | } 87 | 88 | /** Closes this socket */ 89 | public void close() { // socket.close(); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /bin/classes/org/sipdroid/net/.svn/text-base/RtpSocket.java.svn-base: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009 The Sipdroid Open Source Project 3 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 4 | * 5 | * This file is part of Sipdroid (http://www.sipdroid.org) 6 | * 7 | * Sipdroid is free software; you can redistribute it and/or modify 8 | * it under the terms of the GNU General Public License as published by 9 | * the Free Software Foundation; either version 3 of the License, or 10 | * (at your option) any later version. 11 | * 12 | * This source code is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * GNU General Public License for more details. 16 | * 17 | * You should have received a copy of the GNU General Public License 18 | * along with this source code; if not, write to the Free Software 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 | */ 21 | 22 | package org.sipdroid.net; 23 | 24 | import java.net.InetAddress; 25 | import java.net.DatagramPacket; 26 | import java.io.IOException; 27 | 28 | 29 | 30 | /** 31 | * RtpSocket implements a RTP socket for receiving and sending RTP packets. 32 | *

33 | * RtpSocket is associated to a DatagramSocket that is used to send and/or 34 | * receive RtpPackets. 35 | */ 36 | public class RtpSocket { 37 | /** UDP socket */ 38 | SipdroidSocket socket; 39 | DatagramPacket datagram; 40 | 41 | /** Remote address */ 42 | InetAddress r_addr; 43 | 44 | /** Remote port */ 45 | int r_port; 46 | 47 | /** Creates a new RTP socket (only receiver) */ 48 | public RtpSocket(SipdroidSocket datagram_socket) { 49 | socket = datagram_socket; 50 | r_addr = null; 51 | r_port = 0; 52 | datagram = new DatagramPacket(new byte[1],1); 53 | } 54 | 55 | /** Creates a new RTP socket (sender and receiver) */ 56 | public RtpSocket(SipdroidSocket datagram_socket, 57 | InetAddress remote_address, int remote_port) { 58 | socket = datagram_socket; 59 | r_addr = remote_address; 60 | r_port = remote_port; 61 | datagram = new DatagramPacket(new byte[1],1); 62 | } 63 | 64 | /** Returns the RTP SipdroidSocket */ 65 | public SipdroidSocket getDatagramSocket() { 66 | return socket; 67 | } 68 | 69 | /** Receives a RTP packet from this socket */ 70 | public void receive(RtpPacket rtpp) throws IOException { 71 | datagram.setData(rtpp.packet); 72 | datagram.setLength(rtpp.packet.length); 73 | socket.receive(datagram); 74 | if (!socket.isConnected()) 75 | socket.connect(datagram.getAddress(),datagram.getPort()); 76 | rtpp.packet_len = datagram.getLength(); 77 | } 78 | 79 | /** Sends a RTP packet from this socket */ 80 | public void send(RtpPacket rtpp) throws IOException { 81 | datagram.setData(rtpp.packet); 82 | datagram.setLength(rtpp.packet_len); 83 | datagram.setAddress(r_addr); 84 | datagram.setPort(r_port); 85 | socket.send(datagram); 86 | } 87 | 88 | /** Closes this socket */ 89 | public void close() { // socket.close(); 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /src/org/sipdroid/net/Random.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2005 Luca Veltri - University of Parma - Italy 3 | * 4 | * This file is part of MjSip (http://www.mjsip.org) 5 | * 6 | * MjSip is free software; you can redistribute it and/or modify 7 | * it under the terms of the GNU General Public License as published by 8 | * the Free Software Foundation; either version 2 of the License, or 9 | * (at your option) any later version. 10 | * 11 | * MjSip is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU General Public License 17 | * along with MjSip; if not, write to the Free Software 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 | * 20 | * Author(s): 21 | * Luca Veltri (luca.veltri@unipr.it) 22 | */ 23 | 24 | package org.sipdroid.net; 25 | 26 | /** 27 | * Class Random collects some static methods for generating random numbers and 28 | * other stuff. 29 | */ 30 | public class Random { 31 | /** The random seed */ 32 | static final long seed = System.currentTimeMillis(); 33 | // static final long seed=0; 34 | 35 | static java.util.Random rand = new java.util.Random(seed); 36 | 37 | // static java.util.Random rand=new java.util.Random(); 38 | 39 | /** Returns a random integer between 0 and n-1 */ 40 | /* 41 | * static public int nextInt(int n) { seed=(seed*37)%987654321; return 42 | * (int)(seed%n); } 43 | */ 44 | 45 | /** Returns true or false respectively with probability p/100 and (1-p/100) */ 46 | /* 47 | * static boolean percent(int p) { return integer(100) 35 | * RtpSocket is associated to a DatagramSocket that is used to send and/or 36 | * receive RtpPackets. 37 | */ 38 | public class RtpSocket { 39 | // private final static String TAG = "RtpSocket"; 40 | 41 | /** UDP socket */ 42 | DatagramSocket socket; 43 | DatagramPacket datagram; 44 | 45 | /** Remote address */ 46 | InetAddress r_addr; 47 | 48 | /** Remote port */ 49 | int r_port; 50 | 51 | long ms=0; 52 | 53 | /** Creates a new RTP socket (only receiver) */ 54 | public RtpSocket(DatagramSocket datagram_socket) { 55 | socket = datagram_socket; 56 | r_addr = null; 57 | r_port = 0; 58 | datagram = new DatagramPacket(new byte[1],1); 59 | } 60 | 61 | /** Creates a new RTP socket (sender and receiver) */ 62 | public RtpSocket(DatagramSocket datagram_socket, 63 | InetAddress remote_address, int remote_port) { 64 | socket = datagram_socket; 65 | r_addr = remote_address; 66 | r_port = remote_port; 67 | datagram = new DatagramPacket(new byte[1],1); 68 | } 69 | 70 | /** Returns the RTP SipdroidSocket */ 71 | public DatagramSocket getDatagramSocket() { 72 | return socket; 73 | } 74 | 75 | /** Receives a RTP packet from this socket */ 76 | public void receive(RtpPacket rtpp) throws IOException { 77 | 78 | datagram.setData(rtpp.packet); 79 | datagram.setLength(rtpp.packet.length); 80 | socket.receive(datagram); 81 | if (!socket.isConnected()) 82 | socket.connect(datagram.getAddress(),datagram.getPort()); 83 | rtpp.packet_len = datagram.getLength(); 84 | 85 | Log.d("RtpSocket", "Receive Perodic: "+(System.currentTimeMillis()-ms)+" ms"); 86 | ms=System.currentTimeMillis(); 87 | 88 | // Log.i(TAG,"RtpSocket receive : "+datagram.getLength()); 89 | } 90 | 91 | /** Sends a RTP packet from this socket */ 92 | public void send(RtpPacket rtpp) throws IOException { 93 | datagram.setData(rtpp.packet); 94 | datagram.setLength(rtpp.packet_len); 95 | datagram.setAddress(r_addr); 96 | datagram.setPort(r_port); 97 | socket.send(datagram); 98 | Log.d("RtpSocket", "Send Perodic: "+(System.currentTimeMillis()-ms)+" ms"); 99 | ms=System.currentTimeMillis(); 100 | // Log.i(TAG,"RtpSocket send : "+rtpp.packet_len); 101 | } 102 | 103 | /** Closes this socket */ 104 | public void close() { // socket.close(); 105 | } 106 | 107 | } 108 | -------------------------------------------------------------------------------- /src/jay/codec/EchoCancellation.java: -------------------------------------------------------------------------------- 1 | package jay.codec; 2 | 3 | import java.util.LinkedList; 4 | 5 | import android.util.Log; 6 | import jay.func.func; 7 | 8 | public class EchoCancellation implements Runnable{ 9 | 10 | private Speex speex_echo = new Speex(); 11 | private volatile Thread runner; 12 | private final Object mutex = new Object(); 13 | final static int framesize = 160; 14 | final static int filterlength = 1024; 15 | private volatile int CaptureSize = 0; 16 | private volatile int PlaySize = 0; 17 | private volatile boolean isCancelling; 18 | protected LinkedList m_cap_q=new LinkedList(); //store processed data 19 | protected LinkedList m_play_q=new LinkedList(); //store processed data 20 | protected LinkedList m_out_q=new LinkedList(); //store processed data 21 | 22 | public EchoCancellation(){ 23 | speex_echo.echoinit(framesize, filterlength); 24 | } 25 | 26 | public short[] echo_capture(short[] capture) 27 | { 28 | short[] buffer = new short[framesize]; 29 | speex_echo.echocapture(capture,buffer); 30 | return buffer; 31 | } 32 | public void echo_playback(short[] play) 33 | { 34 | // log.debug("start echo playback"); 35 | speex_echo.echoplayback(play); 36 | // log.debug("echo playback finish"); 37 | 38 | } 39 | 40 | public void startThread(){ 41 | if(runner == null){ 42 | runner = new Thread(this); 43 | runner.start(); 44 | } 45 | } 46 | 47 | public void stopThread(){ 48 | if(runner != null){ 49 | Thread moribund = runner; 50 | runner = null; 51 | moribund.interrupt(); 52 | } 53 | } 54 | 55 | public void free() 56 | { 57 | if(speex_echo!=null) 58 | speex_echo.echoclose(); 59 | } 60 | 61 | public void run() { 62 | android.os.Process 63 | .setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO); 64 | while (Thread.currentThread() == runner) { 65 | long ms = System.currentTimeMillis(); 66 | // Log.i("EchoCancel", "currentTime "+ms); 67 | 68 | synchronized (mutex) { 69 | while (isIdle()) { 70 | try { 71 | mutex.wait(); 72 | } catch (InterruptedException e) { 73 | e.printStackTrace(); 74 | } 75 | } 76 | } 77 | synchronized (mutex) { 78 | if(CaptureSize!=0) 79 | { 80 | m_out_q.add(echo_capture(m_cap_q.removeFirst())); 81 | } 82 | if(PlaySize!=0) 83 | { 84 | echo_playback(m_play_q.removeFirst()); 85 | } 86 | setIdle(); 87 | } 88 | Log.i("EchoCancel", "Echo Cancel time is "+(System.currentTimeMillis()-ms)); 89 | } 90 | } 91 | 92 | public void putData(boolean type,short[] data, int size) { 93 | synchronized (mutex) { 94 | short[] temp = new short[size]; 95 | System.arraycopy(data, 0, temp, 0, size); 96 | if(type ==true) //cap 97 | { 98 | m_cap_q.add(temp); 99 | this.CaptureSize = size; 100 | } 101 | else 102 | { 103 | m_play_q.add(temp); 104 | this.PlaySize = size; 105 | } 106 | mutex.notify(); 107 | } 108 | } 109 | 110 | public void putData(boolean type,byte[] data, int size) { 111 | synchronized (mutex) { 112 | int shortsize=size/2; 113 | short buffer[] = new short [shortsize]; 114 | buffer=func.byteArray2ShortArray(data); 115 | short[] temp = new short[shortsize]; 116 | System.arraycopy(buffer, 0, temp, 0, shortsize); 117 | if(type ==true) //cap 118 | { 119 | m_cap_q.add(temp); 120 | this.CaptureSize = shortsize; 121 | } 122 | else 123 | { 124 | m_play_q.add(temp); 125 | this.PlaySize = shortsize; 126 | } 127 | mutex.notify(); 128 | } 129 | } 130 | 131 | public boolean isGetData() 132 | { 133 | return m_out_q.size() == 0 ?false : true; 134 | } 135 | 136 | public short[] getshortData(){ 137 | if (m_out_q.size()>0) { 138 | try { 139 | return m_out_q.removeFirst(); 140 | } catch (Exception e) { 141 | e.printStackTrace(); 142 | return null; 143 | } 144 | } 145 | return null; 146 | 147 | } 148 | 149 | public byte[] getbyteData(){ 150 | return func.shortArray2ByteArray(m_out_q.removeFirst()); 151 | } 152 | 153 | public boolean isIdle() { 154 | return (CaptureSize == 0 && PlaySize==0) ? true : false; 155 | } 156 | 157 | public void setCancelling(boolean isCancelling) { 158 | synchronized (mutex) { 159 | this.isCancelling = isCancelling; 160 | if (this.isCancelling) { 161 | mutex.notify(); 162 | } 163 | } 164 | } 165 | 166 | public void setIdle() 167 | { 168 | if(CaptureSize!=0)CaptureSize=0; 169 | if(PlaySize!=0)PlaySize=0; 170 | } 171 | } -------------------------------------------------------------------------------- /src/jay/dencode/Encoder.java: -------------------------------------------------------------------------------- 1 | package jay.dencode; 2 | 3 | import java.util.LinkedList; 4 | 5 | import android.os.SystemClock; 6 | import android.util.Log; 7 | 8 | import jay.codec.Codec; 9 | import jay.codec.EchoCancellation; 10 | import jay.media.MediaService; 11 | 12 | public class Encoder implements Runnable 13 | { 14 | private final String TAG = "Encoder"; 15 | private EchoCancellation m_ec; 16 | private Codec codec; 17 | private volatile Thread runner; 18 | private final Object mutex = new Object(); 19 | protected LinkedList m_in_q = new LinkedList(); // store 20 | // processed 21 | // data 22 | private int frameSize = 160; 23 | private volatile int leftSize = 0; 24 | public static int num_send; 25 | private int dataLen = 0; 26 | private int Rtp_head = 12; 27 | private long ts; 28 | private byte[] processedData = new byte[frameSize + 12]; 29 | private short[] rawdata = new short[frameSize]; 30 | private short[] output = new short[frameSize]; 31 | 32 | /** 回音消除缓冲包个数 (sipUA默认20)*/ 33 | protected int ec_buffer_pkgs = 20; 34 | 35 | public Encoder(int codeccode) 36 | { 37 | codec = new Codec(codeccode); 38 | codec.init(); 39 | frameSize = codec.getFrameSize(); 40 | this.m_ec = MediaService.m_ec; 41 | } 42 | 43 | /** 44 | * @param codeccode 45 | * 编解码器选择 46 | * 0 - g711u 47 | * 8 - g711a 48 | * 9 - g722 49 | * 101 - speex 50 | * 51 | *@param ec_buffer_pkgs 52 | * 回音消除缓冲包个数 (默认20)延迟{@code ec_buffer_pkgs}个rtp包才 启动回音消除操作 53 | * */ 54 | public Encoder(int codeccode,int ec_buffer_pkgs) 55 | { 56 | codec = new Codec(codeccode); 57 | codec.init(); 58 | frameSize = codec.getFrameSize(); 59 | 60 | this.m_ec = MediaService.m_ec; 61 | this.ec_buffer_pkgs = ec_buffer_pkgs; 62 | } 63 | 64 | public void startThread() 65 | { 66 | if (runner == null) { 67 | runner = new Thread(this); 68 | runner.start(); 69 | } 70 | } 71 | 72 | public void stopThread() 73 | { 74 | if (runner != null) { 75 | Thread moribund = runner; 76 | runner = null; 77 | moribund.interrupt(); 78 | } 79 | } 80 | 81 | public void run() 82 | { 83 | 84 | // 设置线程优先级 85 | android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO); 86 | 87 | int getSize = 0; 88 | while (Thread.currentThread() == runner) { 89 | long ms = System.currentTimeMillis(); 90 | 91 | synchronized (mutex) { 92 | while (isIdle()) { 93 | try { 94 | mutex.wait(); 95 | } catch (InterruptedException e) { 96 | e.printStackTrace(); 97 | } 98 | } 99 | } 100 | synchronized (mutex) { 101 | output = rawdata.clone(); 102 | if (m_ec != null) {// 回声消除 103 | if (Decoder.num_recv > 0) {// 收到对方数据才开始回音消除 104 | if (num_send < ec_buffer_pkgs/* 20 */) // 延迟20个rtp包才 启动回音消除操作 105 | { 106 | num_send++; 107 | } else { 108 | m_ec.putData(true, output, output.length);// 回身消除数据写入 109 | if (m_ec.isGetData()) { 110 | output = m_ec.getshortData();// 获取处理后的数据 111 | } 112 | } 113 | } 114 | } 115 | long time = 0; 116 | time = System.currentTimeMillis(); 117 | getSize = codec.encode(output, 0, processedData, leftSize);// 对回声消除处理后的数据进行编码 118 | Log.e(TAG, "Encoder time = " + (System.currentTimeMillis() - time)); 119 | 120 | // Log.i(TAG, ""+leftSize 121 | // +" size data after encode is "+getSize); 122 | this.dataLen = getSize; 123 | byte tempdata[] = new byte[getSize + Rtp_head];// 存储加上rtp头后的数据 124 | System.arraycopy(processedData, Rtp_head, tempdata, Rtp_head, getSize); 125 | m_in_q.add(tempdata);// 将rtp格式的音频数据加入链表 126 | setIdle(); 127 | 128 | } 129 | 130 | Log.e(TAG, "One time encode time is " + (System.currentTimeMillis() - ms)); 131 | } 132 | free(); 133 | } 134 | 135 | public void putData(long ts, short[] data, int off, int size) 136 | { 137 | synchronized (mutex) { 138 | this.ts = ts; 139 | System.arraycopy(data, off, rawdata, 0, size); 140 | this.leftSize = size; 141 | mutex.notify();// 收到音频数据后,唤醒编码线程 142 | } 143 | } 144 | 145 | public byte[] getData() 146 | { 147 | if (m_in_q.size() > 0) { 148 | return m_in_q.removeFirst(); 149 | } else { 150 | return null; 151 | } 152 | } 153 | 154 | public int getdataLen() 155 | { 156 | return this.dataLen; 157 | } 158 | 159 | public boolean isGetData() 160 | { 161 | return m_in_q.size() == 0 ? false : true; // 判断是否有处理后的数据可获取,当编码后的数据链表为0时,返回false,表示没有数据可以获取 162 | } 163 | 164 | public boolean isIdle() 165 | { 166 | return leftSize == 0 ? true : false;// 编码器是否空闲,当剩余的待处理数据为0时,则空闲 167 | } 168 | 169 | public void setIdle() 170 | { 171 | leftSize = 0; 172 | } 173 | 174 | private void free() 175 | { 176 | Log.i(TAG, "Encoder free"); 177 | num_send = 0; 178 | codec.close(); 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 10 | 11 | 17 | 18 | 25 | 26 | 27 | 28 | 31 | 32 | 38 | 39 | 47 | 48 | 49 | 50 | 53 | 54 | 60 | 61 | 69 | 70 | 71 | 72 | 75 | 76 | 82 | 83 | 91 | 92 | 93 | 94 | 97 | 98 | 104 | 105 | 114 | 115 | 116 | 117 | 120 | 121 |