-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
140 additions
and
11 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
109 changes: 109 additions & 0 deletions
109
app/src/main/java/com/andev/androidshaderdemo/activity/SplitScreenOneActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
package com.andev.androidshaderdemo.activity; | ||
|
||
|
||
import android.graphics.SurfaceTexture; | ||
import android.opengl.EGLContext; | ||
import android.os.Bundle; | ||
import android.os.Handler; | ||
import android.os.HandlerThread; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.SurfaceHolder; | ||
import android.view.SurfaceView; | ||
|
||
import com.andev.androidshaderdemo.R; | ||
import com.andev.androidshaderdemo.record.render.OffScreenRender; | ||
import com.andev.androidshaderdemo.record.render.OnFrameAvailableCallback; | ||
import com.andev.androidshaderdemo.record.render.OnRenderStateCallback; | ||
import com.andev.androidshaderdemo.record.utils.VideoFrameData; | ||
import com.andev.androidshaderdemo.record.widget.CameraSurfaceView; | ||
|
||
import javax.microedition.khronos.opengles.GL10; | ||
|
||
public class SplitScreenOneActivity extends AppCompatActivity implements OnRenderStateCallback, | ||
OnFrameAvailableCallback { | ||
|
||
CameraSurfaceView cameraSurfaceView; | ||
SurfaceView surfaceView; | ||
EGLContext eglContext; | ||
|
||
OffScreenRender offScreenRender; | ||
|
||
private HandlerThread handlerThread; | ||
private Handler previewHandler; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.split_screen_one_layout); | ||
|
||
initViews(); | ||
} | ||
|
||
private void initViews(){ | ||
cameraSurfaceView = (CameraSurfaceView)findViewById(R.id.cameraSurfaceView); | ||
surfaceView = (SurfaceView)findViewById(R.id.surfaceView); | ||
|
||
handlerThread = new HandlerThread("preview"); | ||
handlerThread.start(); | ||
previewHandler = new Handler(handlerThread.getLooper()); | ||
|
||
cameraSurfaceView.setOnRenderStateCallback(this); | ||
cameraSurfaceView.setOnFrameAvailableCallback(this); | ||
} | ||
|
||
|
||
@Override | ||
public void onSurfaceCreatedCallback(GL10 gl, final EGLContext eglContext, SurfaceTexture surfaceTexture) { | ||
this.eglContext = eglContext; | ||
|
||
surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() { | ||
@Override | ||
public void surfaceCreated(SurfaceHolder surfaceHolder) { | ||
previewHandler.post(new Runnable() { | ||
@Override | ||
public void run() { | ||
offScreenRender = new OffScreenRender(eglContext, surfaceView.getHolder().getSurface()); | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) { | ||
|
||
} | ||
|
||
@Override | ||
public void surfaceDestroyed(SurfaceHolder surfaceHolder) { | ||
|
||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onSurfaceChangedCallback(GL10 gl, int width, int height) { | ||
|
||
} | ||
|
||
|
||
@Override | ||
public void onFrameAvailableCallback(final VideoFrameData frameData) { | ||
previewHandler.post(new Runnable() { | ||
@Override | ||
public void run() { | ||
if(offScreenRender != null){ | ||
offScreenRender.draw(frameData.getFilter(), frameData.getMatrix(), frameData.getTextureId() | ||
,frameData.getTimestamp()); | ||
} | ||
} | ||
}); | ||
} | ||
|
||
@Override | ||
public void onStop(){ | ||
super.onStop(); | ||
|
||
cameraSurfaceView.stopPreview(); | ||
offScreenRender.release(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:orientation="vertical"> | ||
|
||
<com.andev.androidshaderdemo.record.widget.CameraSurfaceView | ||
android:id="@+id/cameraSurfaceView" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_weight="1" | ||
/> | ||
|
||
<SurfaceView | ||
android:id="@+id/surfaceView" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_weight="1"/> | ||
|
||
</LinearLayout> |