Android: Expose EglBase.swapBuffers with presentation time

This function is currently only available in EglBase14, which is not in
the api. This CL adds the swapBuffer method to the public EglBase
interface. For EglBase10, the presentation time is just ignored.

BUG=webrtc:8155

Review-Url: https://codereview.webrtc.org/3003843002
Cr-Original-Commit-Position: refs/heads/master@{#19518}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 4781552f6098d07c4af909ab0740e6b4358fd32b
diff --git a/sdk/android/api/org/webrtc/EglBase.java b/sdk/android/api/org/webrtc/EglBase.java
index 619022c..2a8d4e4 100644
--- a/sdk/android/api/org/webrtc/EglBase.java
+++ b/sdk/android/api/org/webrtc/EglBase.java
@@ -19,7 +19,8 @@
  * Holds EGL state and utility methods for handling an egl 1.0 EGLContext, an EGLDisplay,
  * and an EGLSurface.
  */
-public abstract class EglBase {
+@SuppressWarnings("StaticOrDefaultInterfaceMethod")
+public interface EglBase {
   // EGL wrapper for an actual EGLContext.
   public static class Context {}
 
@@ -33,9 +34,9 @@
   // https://android.googlesource.com/platform/frameworks/base/+/master/opengl/java/android/opengl/EGL14.java
   // This is similar to how GlSurfaceView does:
   // http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.1.1_r1/android/opengl/GLSurfaceView.java#760
-  private static final int EGL_OPENGL_ES2_BIT = 4;
+  public static final int EGL_OPENGL_ES2_BIT = 4;
   // Android-specific extension.
-  private static final int EGL_RECORDABLE_ANDROID = 0x3142;
+  public static final int EGL_RECORDABLE_ANDROID = 0x3142;
 
   // clang-format off
   public static final int[] CONFIG_PLAIN = {
@@ -140,32 +141,34 @@
     return new EglBase14(new EglBase14.Context(sharedContext), configAttributes);
   }
 
-  public abstract void createSurface(Surface surface);
+  void createSurface(Surface surface);
 
   // Create EGLSurface from the Android SurfaceTexture.
-  public abstract void createSurface(SurfaceTexture surfaceTexture);
+  void createSurface(SurfaceTexture surfaceTexture);
 
   // Create dummy 1x1 pixel buffer surface so the context can be made current.
-  public abstract void createDummyPbufferSurface();
+  void createDummyPbufferSurface();
 
-  public abstract void createPbufferSurface(int width, int height);
+  void createPbufferSurface(int width, int height);
 
-  public abstract Context getEglBaseContext();
+  Context getEglBaseContext();
 
-  public abstract boolean hasSurface();
+  boolean hasSurface();
 
-  public abstract int surfaceWidth();
+  int surfaceWidth();
 
-  public abstract int surfaceHeight();
+  int surfaceHeight();
 
-  public abstract void releaseSurface();
+  void releaseSurface();
 
-  public abstract void release();
+  void release();
 
-  public abstract void makeCurrent();
+  void makeCurrent();
 
   // Detach the current EGL context, so that it can be made current on another thread.
-  public abstract void detachCurrent();
+  void detachCurrent();
 
-  public abstract void swapBuffers();
+  void swapBuffers();
+
+  void swapBuffers(long presentationTimeStampNs);
 }
diff --git a/sdk/android/src/java/org/webrtc/EglBase10.java b/sdk/android/src/java/org/webrtc/EglBase10.java
index e42bfaa..70200fa 100644
--- a/sdk/android/src/java/org/webrtc/EglBase10.java
+++ b/sdk/android/src/java/org/webrtc/EglBase10.java
@@ -26,7 +26,7 @@
  * Holds EGL state and utility methods for handling an egl 1.0 EGLContext, an EGLDisplay,
  * and an EGLSurface.
  */
-class EglBase10 extends EglBase {
+class EglBase10 implements EglBase {
   // This constant is taken from EGL14.EGL_CONTEXT_CLIENT_VERSION.
   private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
 
@@ -252,6 +252,12 @@
     }
   }
 
+  @Override
+  public void swapBuffers(long timeStampNs) {
+    // Setting presentation time is not supported for EGL 1.0.
+    swapBuffers();
+  }
+
   // Return an EGLDisplay, or die trying.
   private EGLDisplay getEglDisplay() {
     EGLDisplay eglDisplay = egl.eglGetDisplay(EGL10.EGL_DEFAULT_DISPLAY);
diff --git a/sdk/android/src/java/org/webrtc/EglBase14.java b/sdk/android/src/java/org/webrtc/EglBase14.java
index 9fcc536..44d16d5 100644
--- a/sdk/android/src/java/org/webrtc/EglBase14.java
+++ b/sdk/android/src/java/org/webrtc/EglBase14.java
@@ -25,7 +25,7 @@
  * and an EGLSurface.
  */
 @TargetApi(18)
-class EglBase14 extends EglBase {
+class EglBase14 implements EglBase {
   private static final String TAG = "EglBase14";
   private static final int EGLExt_SDK_VERSION = android.os.Build.VERSION_CODES.JELLY_BEAN_MR2;
   private static final int CURRENT_SDK_VERSION = android.os.Build.VERSION.SDK_INT;
@@ -196,6 +196,7 @@
     }
   }
 
+  @Override
   public void swapBuffers(long timeStampNs) {
     checkIsNotReleased();
     if (eglSurface == EGL14.EGL_NO_SURFACE) {