| | |
| | | import android.app.Activity; |
| | | import android.graphics.PixelFormat; |
| | | import android.graphics.SurfaceTexture; |
| | | import android.graphics.drawable.Drawable; |
| | | import android.os.Bundle; |
| | | import android.util.Log; |
| | | import android.view.Surface; |
| | |
| | | import android.widget.Button; |
| | | import android.widget.CompoundButton; |
| | | import android.widget.CompoundButton.OnCheckedChangeListener; |
| | | import android.widget.ImageButton; |
| | | import android.widget.ImageView; |
| | | import android.widget.RadioButton; |
| | | import android.widget.Spinner; |
| | | import android.content.Context; |
| | | import android.graphics.Bitmap; |
| | | import android.graphics.BitmapFactory; |
| | | import android.graphics.Canvas; |
| | | import android.util.AttributeSet; |
| | | import android.widget.Button; |
| | | import android.widget.TextView; |
| | | |
| | | import java.nio.ByteBuffer; |
| | | |
| | | import cn.com.basic.face.util.NativeImg; |
| | | import cn.com.basic.face.util.RtspFaceNative; |
| | | |
| | | public class NativeCodec extends Activity { |
| | |
| | | boolean mCreated = false; |
| | | boolean mIsPlaying = false; |
| | | |
| | | |
| | | public static NativeImg faceImg = null; |
| | | |
| | | /** Called when the activity is first created. */ |
| | | @Override |
| | |
| | | super.onCreate(icicle); |
| | | setContentView(R.layout.main); |
| | | |
| | | ThisActivity = this; |
| | | |
| | | RtspFaceNative.init(); |
| | | RtspFaceNative.setLocalIP("192.168.1.10"); |
| | | |
| | | mGLView1 = (MyGLSurfaceView) findViewById(R.id.glsurfaceview1); |
| | | |
| | |
| | | //mCreated = createStreamingMediaPlayer(getResources().getAssets(), mSourceString); |
| | | //#todo ok |
| | | mCreated = RtspFaceNative.createPlayer(1, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/sub/av_stream"); |
| | | //mCreated = RtspFaceNative.createPlayer(2, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/main/av_stream"); |
| | | //mCreated = RtspFaceNative.createPlayer(2, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/sub/av_stream"); |
| | | //mCreated = createPlayer(1, "rtsp://192.168.1.56:8554"); |
| | | |
| | | RtspFaceNative.setFaceCallback(1, "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); |
| | | //RtspFaceNative.setFaceCallback(2, "cn/com/basic/face/util/RtspFaceNative", "faceCallBack"); |
| | | |
| | | //byte[] arr = new byte[5]; |
| | | //arr[0] = 3; arr[1] = 4; arr[2] = 5; |
| | |
| | | } |
| | | |
| | | }); |
| | | |
| | | ((Button) findViewById(R.id.addface_native)).setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View view) { |
| | | Log.i("@@@", "addface_native onClick"); |
| | | |
| | | } |
| | | |
| | | }); |
| | | |
| | | ((ImageView) findViewById(R.id.addface_image)).setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View view) { |
| | | Log.i("@@@", "addface_image onClick"); |
| | | //ImageView image = (ImageView)ThisActivity.findViewById(R.id.addface_image); |
| | | //image.setImageBitmap(faceBitmap); |
| | | } |
| | | |
| | | }); |
| | | |
| | | ((Button) findViewById(R.id.addface_native)).setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View view) { |
| | | Log.i("@@@", "addface_image onClick"); |
| | | RtspFaceNative.dbgFaceAdd(ThisActivity.faceImg); |
| | | } |
| | | |
| | | }); |
| | | |
| | | } |
| | | |
| | | static NativeCodec ThisActivity; |
| | | |
| | | public static void setFaceDrawable(NativeImg img) |
| | | { |
| | | //ImageView image = (ImageView)ThisActivity.findViewById(R.id.addface_image); |
| | | //return image; |
| | | |
| | | ThisActivity.faceImg = img; |
| | | |
| | | //ImageView image = (ImageView)ThisActivity.findViewById(R.id.addface_image); |
| | | //image.callOnClick(); |
| | | |
| | | new Thread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | ThisActivity.runOnUiThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | Bitmap bitmap = Bitmap.createBitmap(faceImg.width, faceImg.height, Bitmap.Config.ARGB_8888); |
| | | ByteBuffer byteBuffer = ByteBuffer.wrap(faceImg.image, 0, faceImg.size); |
| | | bitmap.copyPixelsFromBuffer(byteBuffer); |
| | | |
| | | ImageView image = (ImageView)ThisActivity.findViewById(R.id.addface_image); |
| | | image.setImageBitmap(bitmap); |
| | | |
| | | TextView textView1 = (TextView)ThisActivity.findViewById(R.id.textView1); |
| | | textView1.setText(RtspFaceNative.dbgGetLog()); |
| | | } |
| | | }); |
| | | } |
| | | }).start(); |
| | | } |
| | | |
| | | void switchSurface() { |