AppRTCDemo(android): run in full-screen & immersive mode.
Also: - Only show stats HUD on demand - Only collect stats when HUD is showing - Don't render solid green frame when video is not present in either direction R=glaznev@webrtc.org Review URL: https://webrtc-codereview.appspot.com/12639004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@6275 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
parent
21a5d449b7
commit
abe01dd634
@ -109,7 +109,7 @@ public class AppRTCDemoActivity extends Activity
|
|||||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||||
|
|
||||||
Point displaySize = new Point();
|
Point displaySize = new Point();
|
||||||
getWindowManager().getDefaultDisplay().getSize(displaySize);
|
getWindowManager().getDefaultDisplay().getRealSize(displaySize);
|
||||||
vsv = new VideoStreamsView(this, displaySize);
|
vsv = new VideoStreamsView(this, displaySize);
|
||||||
vsv.setOnClickListener(new View.OnClickListener() {
|
vsv.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override public void onClick(View v) {
|
@Override public void onClick(View v) {
|
||||||
@ -117,11 +117,14 @@ public class AppRTCDemoActivity extends Activity
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
setContentView(vsv);
|
setContentView(vsv);
|
||||||
|
logAndToast("Tap the screen to toggle stats visibility");
|
||||||
|
|
||||||
hudView = new TextView(this);
|
hudView = new TextView(this);
|
||||||
hudView.setTextColor(Color.BLACK);
|
hudView.setTextColor(Color.BLACK);
|
||||||
hudView.setBackgroundColor(Color.WHITE);
|
hudView.setBackgroundColor(Color.WHITE);
|
||||||
hudView.setAlpha(0.4f);
|
hudView.setAlpha(0.4f);
|
||||||
hudView.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5);
|
hudView.setTextSize(TypedValue.COMPLEX_UNIT_PT, 5);
|
||||||
|
hudView.setVisibility(View.INVISIBLE);
|
||||||
addContentView(hudView, hudLayout);
|
addContentView(hudView, hudLayout);
|
||||||
|
|
||||||
if (!factoryStaticInitialized) {
|
if (!factoryStaticInitialized) {
|
||||||
@ -189,9 +192,6 @@ public class AppRTCDemoActivity extends Activity
|
|||||||
|
|
||||||
// Update the heads-up display with information from |reports|.
|
// Update the heads-up display with information from |reports|.
|
||||||
private void updateHUD(StatsReport[] reports) {
|
private void updateHUD(StatsReport[] reports) {
|
||||||
if (hudView.getText().length() == 0) {
|
|
||||||
logAndToast("Tap the screen to toggle stats visibility");
|
|
||||||
}
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (StatsReport report : reports) {
|
for (StatsReport report : reports) {
|
||||||
if (!report.id.equals("bweforvideo")) {
|
if (!report.id.equals("bweforvideo")) {
|
||||||
@ -264,6 +264,10 @@ public class AppRTCDemoActivity extends Activity
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final Runnable runnableThis = this;
|
final Runnable runnableThis = this;
|
||||||
|
if (hudView.getVisibility() == View.INVISIBLE) {
|
||||||
|
vsv.postDelayed(runnableThis, 1000);
|
||||||
|
return;
|
||||||
|
}
|
||||||
boolean success = finalPC.getStats(new StatsObserver() {
|
boolean success = finalPC.getStats(new StatsObserver() {
|
||||||
public void onComplete(final StatsReport[] reports) {
|
public void onComplete(final StatsReport[] reports) {
|
||||||
runOnUiThread(new Runnable() {
|
runOnUiThread(new Runnable() {
|
||||||
|
@ -40,6 +40,7 @@ import java.nio.ByteBuffer;
|
|||||||
import java.nio.ByteOrder;
|
import java.nio.ByteOrder;
|
||||||
import java.nio.FloatBuffer;
|
import java.nio.FloatBuffer;
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
import javax.microedition.khronos.egl.EGLConfig;
|
import javax.microedition.khronos.egl.EGLConfig;
|
||||||
import javax.microedition.khronos.opengles.GL10;
|
import javax.microedition.khronos.opengles.GL10;
|
||||||
@ -64,6 +65,8 @@ public class VideoStreamsView
|
|||||||
private Point screenDimensions;
|
private Point screenDimensions;
|
||||||
// [0] are local Y,U,V, [1] are remote Y,U,V.
|
// [0] are local Y,U,V, [1] are remote Y,U,V.
|
||||||
private int[][] yuvTextures = { { -1, -1, -1}, {-1, -1, -1 }};
|
private int[][] yuvTextures = { { -1, -1, -1}, {-1, -1, -1 }};
|
||||||
|
private EnumSet<Endpoint> seenFrameInDirection =
|
||||||
|
EnumSet.noneOf(Endpoint.class);
|
||||||
private int posLocation = -1;
|
private int posLocation = -1;
|
||||||
private long lastFPSLogTime = System.nanoTime();
|
private long lastFPSLogTime = System.nanoTime();
|
||||||
private long numFramesSinceLastLog = 0;
|
private long numFramesSinceLastLog = 0;
|
||||||
@ -115,10 +118,12 @@ public class VideoStreamsView
|
|||||||
remoteFrame = framesToRender.remove(Endpoint.REMOTE);
|
remoteFrame = framesToRender.remove(Endpoint.REMOTE);
|
||||||
}
|
}
|
||||||
if (localFrame != null) {
|
if (localFrame != null) {
|
||||||
|
seenFrameInDirection.add(Endpoint.LOCAL);
|
||||||
texImage2D(localFrame, yuvTextures[0]);
|
texImage2D(localFrame, yuvTextures[0]);
|
||||||
framePool.returnFrame(localFrame);
|
framePool.returnFrame(localFrame);
|
||||||
}
|
}
|
||||||
if (remoteFrame != null) {
|
if (remoteFrame != null) {
|
||||||
|
seenFrameInDirection.add(Endpoint.REMOTE);
|
||||||
texImage2D(remoteFrame, yuvTextures[1]);
|
texImage2D(remoteFrame, yuvTextures[1]);
|
||||||
framePool.returnFrame(remoteFrame);
|
framePool.returnFrame(remoteFrame);
|
||||||
}
|
}
|
||||||
@ -167,8 +172,12 @@ public class VideoStreamsView
|
|||||||
@Override
|
@Override
|
||||||
public void onDrawFrame(GL10 unused) {
|
public void onDrawFrame(GL10 unused) {
|
||||||
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
|
||||||
|
if (seenFrameInDirection.contains(Endpoint.REMOTE)) {
|
||||||
drawRectangle(yuvTextures[1], remoteVertices);
|
drawRectangle(yuvTextures[1], remoteVertices);
|
||||||
|
}
|
||||||
|
if (seenFrameInDirection.contains(Endpoint.LOCAL)) {
|
||||||
drawRectangle(yuvTextures[0], localVertices);
|
drawRectangle(yuvTextures[0], localVertices);
|
||||||
|
}
|
||||||
++numFramesSinceLastLog;
|
++numFramesSinceLastLog;
|
||||||
long now = System.nanoTime();
|
long now = System.nanoTime();
|
||||||
if (lastFPSLogTime == -1 || now - lastFPSLogTime > 1e9) {
|
if (lastFPSLogTime == -1 || now - lastFPSLogTime > 1e9) {
|
||||||
@ -210,6 +219,13 @@ public class VideoStreamsView
|
|||||||
checkNoGLES2Error();
|
checkNoGLES2Error();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onAttachedToWindow() {
|
||||||
|
super.onAttachedToWindow();
|
||||||
|
setSystemUiVisibility(SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
||||||
|
SYSTEM_UI_FLAG_FULLSCREEN | SYSTEM_UI_FLAG_IMMERSIVE_STICKY);
|
||||||
|
}
|
||||||
|
|
||||||
// Wrap a float[] in a direct FloatBuffer using native byte order.
|
// Wrap a float[] in a direct FloatBuffer using native byte order.
|
||||||
private static FloatBuffer directNativeFloatBuffer(float[] array) {
|
private static FloatBuffer directNativeFloatBuffer(float[] array) {
|
||||||
FloatBuffer buffer = ByteBuffer.allocateDirect(array.length * 4).order(
|
FloatBuffer buffer = ByteBuffer.allocateDirect(array.length * 4).order(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user