Testing video streaming framerate.

This commit is contained in:
2014-01-13 14:33:35 -04:30
parent 1dc0f5b47f
commit c6f310884a
3 changed files with 41 additions and 2 deletions

1
.gitignore vendored
View File

@@ -18,6 +18,7 @@ local.properties
# Eclipse project files
.classpath
.project
libs/
# Proguard folder generated by Eclipse
proguard/

View File

@@ -28,11 +28,13 @@ import ve.ucv.ciens.ccg.nxtar.utils.Size;
import com.badlogic.gdx.Application;
import com.badlogic.gdx.ApplicationListener;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.FPSLogger;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.graphics.Pixmap;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.Texture.TextureFilter;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
@@ -47,6 +49,8 @@ public class NxtARCore implements ApplicationListener, NetworkConnectionListener
private Sprite sprite;
private Toaster toaster;
private MulticastEnabler mcastEnabler;
private FPSLogger fps;
private BitmapFont font;
private int connections;
private VideoFrameMonitor frameMonitor;
@@ -71,7 +75,10 @@ public class NxtARCore implements ApplicationListener, NetworkConnectionListener
float w = Gdx.graphics.getWidth();
float h = Gdx.graphics.getHeight();
Gdx.app.setLogLevel(Application.LOG_DEBUG);
fps = new FPSLogger();
font = new BitmapFont();
//Gdx.app.setLogLevel(Application.LOG_NONE);
camera = new OrthographicCamera(1, h/w);
batch = new SpriteBatch();
@@ -103,6 +110,7 @@ public class NxtARCore implements ApplicationListener, NetworkConnectionListener
public void dispose() {
batch.dispose();
texture.dispose();
font.dispose();
}
@Override
@@ -129,18 +137,27 @@ public class NxtARCore implements ApplicationListener, NetworkConnectionListener
TextureRegion region = new TextureRegion(texture, 0, 0, dimensions.getWidth(), dimensions.getHeight());
sprite = new Sprite(region);
sprite.setSize(0.9f, 0.9f * sprite.getHeight() / sprite.getWidth());
sprite.setSize(0.9f, 0.9f * sprite.getWidth() / sprite.getHeight());
sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2);
sprite.setPosition(-sprite.getWidth()/2, -sprite.getHeight()/2);
sprite.rotate90(true);
batch.setProjectionMatrix(camera.combined);
batch.begin();{
sprite.draw(batch);
font.setColor(0.0f, 0.0f, 0.0f, 1.0f);
font.setScale(100.0f);
font.draw(batch, String.format("Render FPS: %d", Gdx.graphics.getFramesPerSecond()), 10, 300);
}batch.end();
Gdx.app.log("Main", String.format("Network FPS: %d", videoThread.getFps()));
Gdx.app.log("Main", String.format("Render FPS: %d", Gdx.graphics.getFramesPerSecond()));
texture.dispose();
temp.dispose();
image.dispose();
//fps.log();
}
}

View File

@@ -50,10 +50,15 @@ public class VideoStreamingThread extends Thread {
private ObjectInputStream reader;
private ObjectOutputStream writer;
private VideoFrameMonitor frameMonitor;
private long then;
private long now;
private long delta;
private int fps;
private VideoStreamingThread(){
super(THREAD_NAME);
fps = 0;
netListener = null;
toaster = null;
protocolStarted = false;
@@ -330,9 +335,14 @@ public class VideoStreamingThread extends Thread {
Gdx.app.debug(TAG, CLASS_NAME + ".run() :: Received something unknown.");
}
}
public int getFps(){
return fps;
}
@Override
public void run(){
int frames = 0;
// Listen on the server socket until a client successfully connects.
do{
try{
@@ -349,8 +359,19 @@ public class VideoStreamingThread extends Thread {
}
}while(client != null && !client.isConnected());
then = System.currentTimeMillis();
while(!done){
receiveImage();
frames++;
now = System.currentTimeMillis();
delta = now - then;
if(delta >= 1000){
fps = frames;
frames = 0;
then = now;
delta = 0;
}
}
try{