import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import net.reecam.IpCamera;
import net.reecam.IpCamera.PTZ_COMMAND;
import net.reecam.SimpleAudioTrack;
import android.R.bool;
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.AudioTrack;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.format.Time;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.misc.objc.NSData;
import com.misc.objc.NSNotification;
import com.misc.objc.NSNotificationCenter;
import com.misc.objc.NSSelector;
/**
* show camera video, play audio and capture talk
* @author Thomas Yi
*/
public class CameraVideo extends Activity {
IpCamera camera;
Thread arthread = null, apthread = null;
boolean iscapturing = false;
private Handler mChildHandler;
boolean isrecording = false;
GestureDetector mGestureDetector;
PopupWindow controlWindow;
private boolean controlViewShow=false;
//控制台处理
LayoutInflater inflater;
View controlView;
View headView;
View footView;
private boolean audioAble=false;
private boolean talkAble=false;
private boolean videoAble=false;
private boolean cameraAble=false;
//上下左右按键
private Button upButton,downButton,leftButton,rightButton;
class MyGestureListener implements GestureDetector.OnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float vX,
float vY) {
float x, y;
x = e1.getX() - e2.getX();
y = e1.getY() - e2.getY();
if ((y <= 50) && y >= -50) {
if (x > 120) {
// camera.set_flip(1);
camera.ptz_control(PTZ_COMMAND.P_RIGHT);
return true;
} else if (x < -120) {
camera.ptz_control(PTZ_COMMAND.P_LEFT);
return true;
}
}
if ((x <= 50) && x >= -50) {
if (y > 120) {
// camera.set_flip(1);
camera.ptz_control(PTZ_COMMAND.T_DOWN);
return true;
} else if (y < -120) {
camera.ptz_control(PTZ_COMMAND.T_UP);
return true;
}
}
return false;
}
@Override
public boolean onDown(MotionEvent e) {
// TODO Auto-generated method stub
return true;
}
@Override
public void onLongPress(MotionEvent e) {
// TODO Auto-generated method stub
Log.e("type:", "Long Press!");
NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
nc.postNotification(CameraActivityGroup.ACTION_SHOW_FULLSCREEN_VIDEO, camera, null);
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
// TODO Auto-generated method stub
return true;
}
@Override
public void onShowPress(MotionEvent e) {
// TODO Auto-generated method stub
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
// TODO Auto-generated method stub
camera.ptz_control(PTZ_COMMAND.PT_STOP);
return true;
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return mGestureDetector.onTouchEvent(event);
}
import java.io.DataInputStream;
import java.io.FileInputStream;
import net.reecam.IpCamera;
import net.reecam.IpCamera.PTZ_COMMAND;
import net.reecam.SimpleAudioTrack;
import android.R.bool;
import android.app.Activity;
import android.content.res.Configuration;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioRecord;
import android.media.AudioTrack;
import android.media.MediaRecorder;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.text.format.Time;
import android.util.Log;
import android.view.GestureDetector;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnKeyListener;
import android.view.View.OnTouchListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;
import android.widget.ToggleButton;
import com.misc.objc.NSData;
import com.misc.objc.NSNotification;
import com.misc.objc.NSNotificationCenter;
import com.misc.objc.NSSelector;
/**
* show camera video, play audio and capture talk
* @author Thomas Yi
*/
public class CameraVideo extends Activity {
IpCamera camera;
Thread arthread = null, apthread = null;
boolean iscapturing = false;
private Handler mChildHandler;
boolean isrecording = false;
GestureDetector mGestureDetector;
PopupWindow controlWindow;
private boolean controlViewShow=false;
//控制台处理
LayoutInflater inflater;
View controlView;
View headView;
View footView;
private boolean audioAble=false;
private boolean talkAble=false;
private boolean videoAble=false;
private boolean cameraAble=false;
//上下左右按键
private Button upButton,downButton,leftButton,rightButton;
class MyGestureListener implements GestureDetector.OnGestureListener {
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float vX,
float vY) {
float x, y;
x = e1.getX() - e2.getX();
y = e1.getY() - e2.getY();
if ((y <= 50) && y >= -50) {
if (x > 120) {
// camera.set_flip(1);
camera.ptz_control(PTZ_COMMAND.P_RIGHT);
return true;
} else if (x < -120) {
camera.ptz_control(PTZ_COMMAND.P_LEFT);
return true;
}
}
if ((x <= 50) && x >= -50) {
if (y > 120) {
// camera.set_flip(1);
camera.ptz_control(PTZ_COMMAND.T_DOWN);
return true;
} else if (y < -120) {
camera.ptz_control(PTZ_COMMAND.T_UP);
return true;
}
}
return false;
}
@Override
public boolean onDown(MotionEvent e) {
// TODO Auto-generated method stub
return true;
}
@Override
public void onLongPress(MotionEvent e) {
// TODO Auto-generated method stub
Log.e("type:", "Long Press!");
NSNotificationCenter nc = NSNotificationCenter.defaultCenter();
nc.postNotification(CameraActivityGroup.ACTION_SHOW_FULLSCREEN_VIDEO, camera, null);
}
@Override
public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX, float distanceY) {
// TODO Auto-generated method stub
return true;
}
@Override
public void onShowPress(MotionEvent e) {
// TODO Auto-generated method stub
}
@Override
public boolean onSingleTapUp(MotionEvent e) {
// TODO Auto-generated method stub
camera.ptz_control(PTZ_COMMAND.PT_STOP);
return true;
}
}
@Override
public boolean onTouchEvent(MotionEvent event) {
return mGestureDetector.onTouchEvent(event);
}