| 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) {
|
|
|