Skip to content

Commit

Permalink
Now wokrs on a None uPnP router, need testing in uPnP router.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhou Chang committed Nov 2, 2012
1 parent de72e9f commit 52f5c86
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/teaonly/droideye/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ public void onCreate(Bundle savedInstanceState) {
videoFrames[i] = new VideoFrame(1024*1024*2);
}

System.loadLibrary("mp3encoder");
System.loadLibrary("natpmp");

initAudio();
initCamera();
}
Expand Down Expand Up @@ -181,7 +184,6 @@ private void initAudio() {
if ( audioLoop == null)
audioLoop = new StreamingLoop("teaonly.droideye");

System.loadLibrary("mp3encoder");
}

private void initCamera() {
Expand Down Expand Up @@ -229,6 +231,8 @@ private boolean initWebServer() {
tvMessage1.setText( getString(R.string.msg_access_local) + " http://" + ipAddr + ":8080" );
tvMessage2.setText( getString(R.string.msg_access_query));
tvMessage2.setVisibility(View.VISIBLE);
NatPMPClient natQuery = new NatPMPClient();
natQuery.start();
return true;
} else {
tvMessage1.setText( getString(R.string.msg_error) );
Expand Down Expand Up @@ -423,12 +427,13 @@ public void run() {


static private native String nativeQueryInternet();
private class NatPMPClinet extends Thread {
String ret = nativeQueryInternet();
private class NatPMPClient extends Thread {
String queryResult;
Handler handleQueryResult = new Handler(getMainLooper());
@Override
public void run(){
Handler handleQueryResult = new Handler(getMainLooper());
if ( ret.startsWith("error:") ) {
queryResult = nativeQueryInternet();
if ( queryResult.startsWith("error:") ) {
handleQueryResult.post( new Runnable() {
@Override
public void run() {
Expand All @@ -439,7 +444,7 @@ public void run() {
handleQueryResult.post( new Runnable() {
@Override
public void run() {
tvMessage2.setText( getString(R.string.msg_access_internet) + " " + ret );
tvMessage2.setText( getString(R.string.msg_access_internet) + " " + queryResult );
}
});
}
Expand Down

0 comments on commit 52f5c86

Please sign in to comment.