Move ring test from mediastreamer2.

This commit is contained in:
Guillaume Beraudo 2011-04-07 10:54:57 +02:00
parent cd30b8d01e
commit be31599503
2 changed files with 74 additions and 1 deletions

View file

@ -0,0 +1,73 @@
/*
Ring.java
Copyright (C) 2010 Belledonne Communications, Grenoble, France
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
package org.mediastreamer2.test;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import org.linphone.R;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class Ring extends Activity {
Thread mWorkerThread = new Thread("Worker Thread");
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ring);
try {
try {
System.loadLibrary("ring");
} catch (UnsatisfiedLinkError e) {
Log.e("mediastreamer2", "cannot load libring.so, did you compile SDK with ndk-build RING=yes ", e);
}
final File lFileToPlay = getFileStreamPath("oldphone_mono.wav");
if (!lFileToPlay.exists()) {
FileOutputStream lOutputStream = openFileOutput ("oldphone_mono.wav", 0);
InputStream lInputStream = getResources().openRawResource(R.raw.oldphone_mono);
int readByte;
while (( readByte = lInputStream.read())!=-1) {
lOutputStream.write(readByte);
}
lOutputStream.flush();
lOutputStream.close();
lInputStream.close();
}
init();
mWorkerThread = new Thread(new Runnable() {
public void run() {
play(lFileToPlay.getAbsolutePath());
echo(44100);
}
},"Worker Thread");
mWorkerThread.start();
} catch (Exception e) {
Log.e("ring","error",e);
}
}
native void play(String file);
native void echo(int freq);
native void init();
}

@ -1 +1 @@
Subproject commit c807039a86749ea5cdb58291af66f066060e49d2 Subproject commit 50bf22bd7c882578f2a2ffcbf0f2677762ba647a