| | |
| | | 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.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.camnter.easyrecyclerview.widget.EasyRecyclerView; |
| | |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | private List mList; |
| | | private EasyRecyclerView mRecyclerViewRegister, mRecyclerViewUser; |
| | | |
| | | |
| | | //播放 |
| | | |
| | | String mSourceString = "clips/testfile.mp4"; |
| | |
| | | SurfaceHolder mSurfaceHolder1; |
| | | |
| | | VideoSink mSelectedVideoSink; |
| | | VideoSink mNativeCodecPlayerVideoSink; |
| | | |
| | | |
| | | SurfaceHolderVideoSink mSurfaceHolder1VideoSink; |
| | | |
| | | VideoSink mNativeCodecPlayerVideoSink; |
| | | GLViewVideoSink mGLView1VideoSink; |
| | | boolean mCreated = false; |
| | | boolean mIsPlaying = false; |
| | | |
| | | // SurfaceHolderVideoSink mSurfaceHolder1VideoSink; |
| | | // VideoSink mSelectedVideoSink; |
| | | // VideoSink mNativeCodecPlayerVideoSink; |
| | | // SurfaceView mSurfaceView1; |
| | | // SurfaceHolder mSurfaceHolder1; |
| | | // boolean mCreated = false; |
| | | // boolean mIsPlaying = false; |
| | | // String mSourceString = "clips/testfile.mp4"; |
| | | |
| | | /** |
| | | * Native methods, implemented in jni folder |
| | | */ |
| | | // public static native void createEngine(); |
| | | // |
| | | // public static native boolean createStreamingMediaPlayer(AssetManager assetMgr, String filename); |
| | | // |
| | | // public static native void setPlayingStreamingMediaPlayer(boolean isPlaying); |
| | | // |
| | | // public static native void shutdown(); |
| | | // |
| | | // public static native void setSurface(Surface surface); |
| | | // |
| | | // public static native void rewindStreamingMediaPlayer(); |
| | | |
| | | /** Load jni .so on initialization */ |
| | | static { |
| | | System.loadLibrary("native-codec-jni"); |
| | | //System.loadLibrary("rtspface");//xiuxi |
| | | } |
| | | |
| | | |
| | |
| | | |
| | | mGLView1 = (MyGLSurfaceView) 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()); |
| | | |
| | | mSurfaceHolder1 = mSurfaceView1.getHolder(); |
| | | |
| | | mSurfaceHolder1.addCallback(new SurfaceHolder.Callback() { |
| | |
| | | |
| | | }); |
| | | //surfaceview |
| | | // if (mSurfaceHolder1VideoSink == null) { |
| | | // mSurfaceHolder1VideoSink = new SurfaceHolderVideoSink(mSurfaceHolder1); |
| | | // } |
| | | // mSelectedVideoSink = mSurfaceHolder1VideoSink; |
| | | if (mSurfaceHolder1VideoSink == null) { |
| | | mSurfaceHolder1VideoSink = new SurfaceHolderVideoSink(mSurfaceHolder1); |
| | | } |
| | | mSelectedVideoSink = mSurfaceHolder1VideoSink; |
| | | |
| | | |
| | | //openGL |
| | |
| | | return; |
| | | } |
| | | mSelectedVideoSink.useAsSinkForNative(); |
| | | mSurfaceHolder1VideoSink.useAsSinkForNative(); |
| | | //mSelectedVideoSink.useAsSinkForNative(); |
| | | //mSurfaceHolder1VideoSink.useAsSinkForNative(); |
| | | mNativeCodecPlayerVideoSink = mSelectedVideoSink; |
| | | } |
| | | if (mSourceString != null) { |
| | | mCreated = createStreamingMediaPlayer(getResources().getAssets(), |
| | | mSourceString); |
| | | //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 = createPlayer(2, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/main/av_stream"); |
| | | } |
| | | } |
| | | if (mCreated) { |
| | | mIsPlaying = !mIsPlaying; |
| | | setPlayingStreamingMediaPlayer(mIsPlaying); |
| | | //setPlayingStreamingMediaPlayer(mIsPlaying); |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | }); |
| | | thread.start(); |
| | | thread.start();//xiuxi |
| | | } |
| | | |
| | | @Override |
| | |
| | | protected void initData() { |
| | | // switchSurface(); |
| | | mList = new ArrayList(); |
| | | for (int i = 0; i < 25; i++) { |
| | | mList.add(""); |
| | | for (int i = 0; i < 125; i++) { |
| | | mList.add(""+i); |
| | | } |
| | | mAdapter.setList(mList); |
| | | mRecyclerViewRegister.setAdapter(mAdapter); |
| | |
| | | if (mCreated && mNativeCodecPlayerVideoSink != mSelectedVideoSink) { |
| | | // shutdown and recreate on other surface |
| | | Log.i("@@@", "shutting down player"); |
| | | shutdown(); |
| | | RtspFaceNative.shutdown(1); |
| | | mCreated = false; |
| | | mSelectedVideoSink.useAsSinkForNative(); |
| | | mNativeCodecPlayerVideoSink = mSelectedVideoSink; |
| | | if (mSourceString != null) { |
| | | Log.i("@@@", "recreating player"); |
| | | mCreated = createStreamingMediaPlayer(getResources().getAssets(), mSourceString); |
| | | //mCreated = createStreamingMediaPlayer(getResources().getAssets(), mSourceString); |
| | | mIsPlaying = false; |
| | | 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 = createPlayer(2, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/main/av_stream"); |
| | | } |
| | | } |
| | | } |
| | |
| | | public void onPause() { |
| | | mIsPlaying = false; |
| | | mGLView1.onPause(); |
| | | setPlayingStreamingMediaPlayer(false); |
| | | //setPlayingStreamingMediaPlayer(false);//xiuxi |
| | | super.onPause(); |
| | | } |
| | | |
| | |
| | | */ |
| | | @Override |
| | | public void onDestroy() { |
| | | shutdown(); |
| | | RtspFaceNative.shutdown(1); |
| | | mCreated = false; |
| | | super.onDestroy(); |
| | | } |
| | | |
| | | /** |
| | | * Native methods, implemented in jni folder |
| | | */ |
| | | // public static native void createEngine(); |
| | | |
| | | public static native boolean createStreamingMediaPlayer(AssetManager assetMgr, String filename); |
| | | |
| | | public static native void setPlayingStreamingMediaPlayer(boolean isPlaying); |
| | | |
| | | public static native void shutdown(); |
| | | |
| | | public static native void setSurface(Surface surface); |
| | | |
| | | public static native void rewindStreamingMediaPlayer(); |
| | | |
| | | /** Load jni .so on initialization */ |
| | | static { |
| | | System.loadLibrary("native-codec-jni"); |
| | | } |
| | | |
| | | // VideoSink abstracts out the difference between Surface and SurfaceTexture |
| | | // aka SurfaceHolder and GLSurfaceView |
| | |
| | | void useAsSinkForNative() { |
| | | Surface s = mSurfaceHolder.getSurface(); |
| | | Log.i("@@@", "setting surface " + s); |
| | | setSurface(s); |
| | | RtspFaceNative.setSurface(1, s); |
| | | |
| | | |
| | | /*SurfaceTexture st = mSurfaceHolder.getSurfaceTexture(); |
| | | Surface s = new Surface(st); |
| | | RtspFaceNative.setSurface(2, s); |
| | | s.release();*/ |
| | | } |
| | | |
| | | } |
| | |
| | | void useAsSinkForNative() { |
| | | SurfaceTexture st = mMyGLSurfaceView.getSurfaceTexture(); |
| | | Surface s = new Surface(st); |
| | | setSurface(s); |
| | | RtspFaceNative.setSurface(2, s); |
| | | s.release(); |
| | | } |
| | | |