| | |
| | | package com.bsk.zhangbo.demoforbsk.ui.fragment; |
| | | |
| | | import android.content.res.AssetManager; |
| | | import android.graphics.Rect; |
| | | import android.graphics.SurfaceTexture; |
| | | import android.os.Bundle; |
| | | import android.support.v4.app.Fragment; |
| | | import android.support.v4.view.ViewPager; |
| | | import android.support.v7.widget.GridLayoutManager; |
| | | import android.support.v7.widget.LinearLayoutManager; |
| | | import android.support.v7.widget.RecyclerView; |
| | |
| | | import android.view.View; |
| | | import android.widget.RadioButton; |
| | | import android.widget.RadioGroup; |
| | | import android.widget.Toast; |
| | | import android.widget.VideoView; |
| | | |
| | | import com.bsk.zhangbo.demoforbsk.R; |
| | | import com.bsk.zhangbo.demoforbsk.adapter.MyFragmentPagerAdapter; |
| | | import com.bsk.zhangbo.demoforbsk.adapter.OneBottomRecylerViewAdapter; |
| | | import com.bsk.zhangbo.demoforbsk.base.BaseFragment; |
| | | import com.bsk.zhangbo.demoforbsk.ui.activity.TestARGB8888Activity; |
| | | import com.bsk.zhangbo.demoforbsk.util.RtspFaceNative; |
| | | import com.bsk.zhangbo.demoforbsk.util.WindowsUtil; |
| | | import com.bsk.zhangbo.demoforbsk.widget.MyGLSurfaceView; |
| | |
| | | import com.orhanobut.logger.Logger; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | import cn.com.basic.face.discern.query.item.FacePhotoItem; |
| | | |
| | | |
| | | /** |
| | |
| | | String mSourceString = "clips/testfile.mp4"; |
| | | |
| | | SurfaceView mSurfaceView1; |
| | | MyGLSurfaceView mGLView1; |
| | | SurfaceView mSurfaceView2; |
| | | SurfaceHolder mSurfaceHolder1; |
| | | |
| | | VideoSink mSelectedVideoSink; |
| | |
| | | |
| | | /** Load jni .so on initialization */ |
| | | static { |
| | | //System.loadLibrary("rtspface");//xiuxi |
| | | System.loadLibrary("rtspface");//xiuxi |
| | | } |
| | | |
| | | |
| | |
| | | mAdapter = new OneBottomRecylerViewAdapter(getActivity()); |
| | | |
| | | |
| | | mGLView1 = (MyGLSurfaceView) view.findViewById(R.id.surfaceview2); |
| | | mSurfaceView2 = (SurfaceView) view.findViewById(R.id.surfaceview2); |
| | | mSurfaceView1 = (SurfaceView) view.findViewById(R.id.surfaceview1); |
| | | RtspFaceNative.init(); |
| | | try { |
| | | Thread.sleep(3000); |
| | | }catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | RtspFaceNative.setSurface(1, mSurfaceView1.getHolder().getSurface()); |
| | | RtspFaceNative.setSurface(2, mGLView1.getHolder().getSurface()); |
| | | RtspFaceNative.setSurface(2, mSurfaceView2.getHolder().getSurface()); |
| | | |
| | | mSurfaceHolder1 = mSurfaceView1.getHolder(); |
| | | |
| | |
| | | |
| | | |
| | | //openGL |
| | | mGLView1.onResume(); |
| | | if(mSurfaceView2 instanceof MyGLSurfaceView) { |
| | | ((MyGLSurfaceView)mSurfaceView2).onResume(); |
| | | } |
| | | if (mGLView1VideoSink == null) { |
| | | mGLView1VideoSink = new GLViewVideoSink(mGLView1); |
| | | mGLView1VideoSink = new GLViewVideoSink(mSurfaceView2); |
| | | } |
| | | mSelectedVideoSink = mGLView1VideoSink; |
| | | |
| | |
| | | if (mSourceString != null) { |
| | | //mCreated = createStreamingMediaPlayer(getResources().getAssets(), |
| | | // mSourceString); |
| | | mCreated = RtspFaceNative.createPlayer(1, "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/main/av_stream"); |
| | | 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/sub/av_stream"); |
| | | ////mCreated = createPlayer(2, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/main/av_stream"); |
| | | } |
| | | } |
| | |
| | | } |
| | | }); |
| | | thread.start();//xiuxi |
| | | } |
| | | |
| | | @Override |
| | | protected void initToolbar(Bundle savedInstanceState) { |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | // switchSurface(); |
| | | mList = new ArrayList(); |
| | | for (int i = 0; i < 125; i++) { |
| | | mList.add(""+i); |
| | | FacePhotoItem item = new FacePhotoItem(); |
| | | //item.setType(); |
| | | mList.add(item); |
| | | } |
| | | mAdapter.setList(mList); |
| | | mRecyclerViewRegister.setAdapter(mAdapter); |
| | | |
| | | } |
| | | |
| | | private class SpaceItemDecoration extends RecyclerView.ItemDecoration { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | void switchSurface() { |
| | | if (mCreated && mNativeCodecPlayerVideoSink != mSelectedVideoSink) { |
| | |
| | | @Override |
| | | public void onPause() { |
| | | mIsPlaying = false; |
| | | mGLView1.onPause(); |
| | | if(mSurfaceView2 instanceof MyGLSurfaceView) { |
| | | ((MyGLSurfaceView)mSurfaceView2).onPause(); |
| | | } |
| | | //setPlayingStreamingMediaPlayer(false);//xiuxi |
| | | super.onPause(); |
| | | } |
| | |
| | | @Override |
| | | public void onResume() { |
| | | super.onResume(); |
| | | mGLView1.onResume(); |
| | | if(mSurfaceView2 instanceof MyGLSurfaceView) { |
| | | ((MyGLSurfaceView)mSurfaceView2).onResume(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | |
| | | static class GLViewVideoSink extends VideoSink { |
| | | |
| | | private final MyGLSurfaceView mMyGLSurfaceView; |
| | | private final SurfaceView SurfaceView; |
| | | private final SurfaceHolder mSurfaceHolder; |
| | | |
| | | GLViewVideoSink(MyGLSurfaceView myGLSurfaceView) { |
| | | mMyGLSurfaceView = myGLSurfaceView; |
| | | GLViewVideoSink(SurfaceView myGLSurfaceView) { |
| | | SurfaceView = myGLSurfaceView; |
| | | mSurfaceHolder = SurfaceView.getHolder(); |
| | | } |
| | | |
| | | @Override |
| | | void setFixedSize(int width, int height) { |
| | | mSurfaceHolder.setFixedSize(width, height); |
| | | } |
| | | |
| | | @Override |
| | | void useAsSinkForNative() { |
| | | SurfaceTexture st = mMyGLSurfaceView.getSurfaceTexture(); |
| | | Surface s = new Surface(st); |
| | | RtspFaceNative.setSurface(2, s); |
| | | s.release(); |
| | | if(SurfaceView instanceof MyGLSurfaceView) { |
| | | SurfaceTexture st = ((MyGLSurfaceView)SurfaceView).getSurfaceTexture(); |
| | | Surface s = new Surface(st); |
| | | RtspFaceNative.setSurface(2, s); |
| | | s.release(); |
| | | } else { |
| | | RtspFaceNative.setSurface(2, SurfaceView.getHolder().getSurface()); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |