Don't decode video on the emulator for performance reasons.

This commit is contained in:
Cameron Gutman 2013-11-20 01:33:38 -05:00
parent f672befaa7
commit bd6338730d

View File

@ -20,6 +20,7 @@ import com.limelight.nvstream.av.video.CpuDecoderRenderer;
import com.limelight.nvstream.av.video.DecoderRenderer; import com.limelight.nvstream.av.video.DecoderRenderer;
import com.limelight.nvstream.av.video.MediaCodecDecoderRenderer; import com.limelight.nvstream.av.video.MediaCodecDecoderRenderer;
import android.os.Build;
import android.view.Surface; import android.view.Surface;
public class NvVideoStream { public class NvVideoStream {
@ -126,22 +127,22 @@ public class NvVideoStream {
} }
public void setupDecoderRenderer(Surface renderTarget) { public void setupDecoderRenderer(Surface renderTarget) {
boolean requiresCpuDecoding = true; if (Build.HARDWARE.equals("goldfish")) {
// Emulator - don't render video (it's slow!)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) { decrend = null;
if (MediaCodecDecoderRenderer.hasWhitelistedDecoder()) {
requiresCpuDecoding = false;
}
} }
else if (MediaCodecDecoderRenderer.hasWhitelistedDecoder()) {
if (requiresCpuDecoding) { // Hardware decoding
decrend = new CpuDecoderRenderer();
}
else {
decrend = new MediaCodecDecoderRenderer(); decrend = new MediaCodecDecoderRenderer();
} }
else {
// Software decoding
decrend = new CpuDecoderRenderer();
}
decrend.setup(1280, 720, renderTarget); if (decrend != null) {
decrend.setup(1280, 720, renderTarget);
}
} }
public void startVideoStream(final String host, final Surface surface) public void startVideoStream(final String host, final Surface surface)
@ -180,19 +181,21 @@ public class NvVideoStream {
return; return;
} }
// Start the receive thread early to avoid missing if (decrend != null) {
// early packets // Start the receive thread early to avoid missing
startReceiveThread(); // early packets
startReceiveThread();
// Start the depacketizer thread to deal with the RTP data // Start the depacketizer thread to deal with the RTP data
startDepacketizerThread(); startDepacketizerThread();
// Start decoding the data we're receiving // Start decoding the data we're receiving
startDecoderThread(); startDecoderThread();
// Start the renderer // Start the renderer
decrend.start(); decrend.start();
startedRendering = true; startedRendering = true;
}
} }
}; };
threads.add(t); threads.add(t);