Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Unified Diff: webrtc/api/java/src/org/webrtc/MediaCodecVideoEncoder.java

Issue 1828203002: Android HW encoder: Add support for textures when using EGL 1.0 (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase, add full url to bug, and log a warning when using EGL10 in encoder. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/java/jni/peerconnection_jni.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/java/src/org/webrtc/MediaCodecVideoEncoder.java
diff --git a/webrtc/api/java/src/org/webrtc/MediaCodecVideoEncoder.java b/webrtc/api/java/src/org/webrtc/MediaCodecVideoEncoder.java
index d017becb67035a6c190332bec3733f4cf77d77b5..c5051d221cfff0ae044f3aa50e71cf0609317db6 100644
--- a/webrtc/api/java/src/org/webrtc/MediaCodecVideoEncoder.java
+++ b/webrtc/api/java/src/org/webrtc/MediaCodecVideoEncoder.java
@@ -63,7 +63,7 @@ public class MediaCodecVideoEncoder {
private Thread mediaCodecThread;
private MediaCodec mediaCodec;
private ByteBuffer[] outputBuffers;
- private EglBase14 eglBase;
+ private EglBase eglBase;
private int width;
private int height;
private Surface inputSurface;
@@ -278,7 +278,7 @@ public class MediaCodecVideoEncoder {
}
boolean initEncode(VideoCodecType type, int width, int height, int kbps, int fps,
- EglBase14.Context sharedContext) {
+ EglBase.Context sharedContext) {
final boolean useSurface = sharedContext != null;
Logging.d(TAG, "Java initEncode: " + type + " : " + width + " x " + height +
". @ " + kbps + " kbps. Fps: " + fps + ". Encode from texture : " + useSurface);
@@ -333,7 +333,11 @@ public class MediaCodecVideoEncoder {
format, null, null, MediaCodec.CONFIGURE_FLAG_ENCODE);
if (useSurface) {
- eglBase = new EglBase14(sharedContext, EglBase.CONFIG_RECORDABLE);
+ eglBase = EglBase.create(sharedContext, EglBase.CONFIG_RECORDABLE);
+ if (!(eglBase instanceof EglBase14)) {
+ Logging.e(TAG, "Using EGL version other than 1.4 -"
+ + " will not be able to set presentation timestamp.");
+ }
// Create an input surface and keep a reference since we must release the surface when done.
inputSurface = mediaCodec.createInputSurface();
eglBase.createSurface(inputSurface);
@@ -396,7 +400,16 @@ public class MediaCodecVideoEncoder {
// but it's a workaround for bug webrtc:5147.
GLES20.glClear(GLES20.GL_COLOR_BUFFER_BIT);
drawer.drawOes(oesTextureId, transformationMatrix, 0, 0, width, height);
- eglBase.swapBuffers(TimeUnit.MICROSECONDS.toNanos(presentationTimestampUs));
+ if (eglBase instanceof EglBase14) {
+ ((EglBase14) eglBase).swapBuffers(TimeUnit.MICROSECONDS.toNanos(presentationTimestampUs));
+ } else {
+ // |eglBase| is not always an instance of EglBase14 because of bug
+ // https://bugs.chromium.org/p/webrtc/issues/detail?id=5702. Setting the presentation
+ // timestamp might be important for qualcomm's encoders to determine a reasonable per-frame
+ // encode budget. This means that the encoder might produce low quality encoded delta frames
+ // for low frame rates even for high bitrates.
+ eglBase.swapBuffers();
+ }
return true;
}
catch (RuntimeException e) {
« no previous file with comments | « webrtc/api/java/jni/peerconnection_jni.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698