Skip to content

Commit

Permalink
M119 release
Browse files Browse the repository at this point in the history
  • Loading branch information
rfazi committed Nov 25, 2023
1 parent b950fd7 commit 12708fb
Show file tree
Hide file tree
Showing 22 changed files with 118 additions and 237 deletions.
6 changes: 4 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

This is a basic project with latest WebRTC native libraries and java classes.

The <a href='https://webrtc.googlesource.com/src/'>WebRTC</a> commit hash is: <b>2d86b258e010de4b5316bbc5e70f93f7374e8c56</b>
<a href='https://chromiumdash.appspot.com/branches'>Here</a> you can find Chromium branches.

I've built WebRTC libs with my script that you can find on <a href='https://github.com/rfazi/android_webrtc_build'>this repo</a>.
This project refer to <a href='https://chromium.googlesource.com/chromium/src.git/+log/refs/branch-heads/6045'>this</a> branch (M119 version).

I've built WebRTC libs with my script that you can find in <a href='https://github.com/rfazi/android_webrtc_build'>this repo</a>.
Binary file modified app/libs/arm/libjingle_peerconnection_so.so
Binary file not shown.
Binary file modified app/libs/arm64/libjingle_peerconnection_so.so
Binary file not shown.
Binary file modified app/libs/x64/libjingle_peerconnection_so.so
Binary file not shown.
Binary file modified app/libs/x86/libjingle_peerconnection_so.so
Binary file not shown.
4 changes: 2 additions & 2 deletions app/src/main/java/org/webrtc/CameraCapturer.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ public void run() {
// -------------------------
private Handler cameraThreadHandler;
private Context applicationContext;
private org.webrtc.CapturerObserver capturerObserver;
private CapturerObserver capturerObserver;
private SurfaceTextureHelper surfaceHelper;

private final Object stateLock = new Object();
Expand Down Expand Up @@ -234,7 +234,7 @@ public void onCameraClosed() {}

@Override
public void initialize(SurfaceTextureHelper surfaceTextureHelper, Context applicationContext,
org.webrtc.CapturerObserver capturerObserver) {
CapturerObserver capturerObserver) {
this.applicationContext = applicationContext;
this.capturerObserver = capturerObserver;
this.surfaceHelper = surfaceTextureHelper;
Expand Down
47 changes: 17 additions & 30 deletions app/src/main/java/org/webrtc/EglBase10Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ public static class EglConnection implements EglBase10.EglConnection {
private final EGLDisplay eglDisplay;
private final EGLConfig eglConfig;
private final RefCountDelegate refCountDelegate;
private EGLSurface currentSurface = EGL10.EGL_NO_SURFACE;

public EglConnection(EGLContext sharedContext, int[] configAttributes) {
egl = (EGL10) EGLContext.getEGL();
Expand All @@ -112,7 +111,6 @@ public EglConnection(EGLContext sharedContext, int[] configAttributes) {
}
egl.eglDestroyContext(eglDisplay, eglContext);
egl.eglTerminate(eglDisplay);
currentSurface = EGL10.EGL_NO_SURFACE;
});
}

Expand Down Expand Up @@ -154,31 +152,6 @@ public EGLDisplay getDisplay() {
public EGLConfig getConfig() {
return eglConfig;
}

public void makeCurrent(EGLSurface eglSurface) {
if (egl.eglGetCurrentContext() == eglContext && currentSurface == eglSurface) {
return;
}

synchronized (EglBase.lock) {
if (!egl.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
throw new GLException(egl.eglGetError(),
"eglMakeCurrent failed: 0x" + Integer.toHexString(egl.eglGetError()));
}
}
currentSurface = eglSurface;
}

public void detachCurrent() {
synchronized (EglBase.lock) {
if (!egl.eglMakeCurrent(
eglDisplay, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT)) {
throw new GLException(egl.eglGetError(),
"eglDetachCurrent failed: 0x" + Integer.toHexString(egl.eglGetError()));
}
}
currentSurface = EGL10.EGL_NO_SURFACE;
}
}

// Create a new context with the specified config type, sharing data with sharedContext.
Expand Down Expand Up @@ -312,7 +285,7 @@ public void createPbufferSurface(int width, int height) {
}

@Override
public org.webrtc.EglBase.Context getEglBaseContext() {
public EglBase.Context getEglBaseContext() {
return new Context(
eglConnection.getEgl(), eglConnection.getContext(), eglConnection.getConfig());
}
Expand Down Expand Up @@ -366,13 +339,27 @@ public void makeCurrent() {
if (eglSurface == EGL10.EGL_NO_SURFACE) {
throw new RuntimeException("No EGLSurface - can't make current");
}
eglConnection.makeCurrent(eglSurface);
synchronized (EglBase.lock) {
EGL10 egl = eglConnection.getEgl();
if (!egl.eglMakeCurrent(
eglConnection.getDisplay(), eglSurface, eglSurface, eglConnection.getContext())) {
throw new GLException(egl.eglGetError(),
"eglMakeCurrent failed: 0x" + Integer.toHexString(egl.eglGetError()));
}
}
}

// Detach the current EGL context, so that it can be made current on another thread.
@Override
public void detachCurrent() {
eglConnection.detachCurrent();
synchronized (EglBase.lock) {
EGL10 egl = eglConnection.getEgl();
if (!egl.eglMakeCurrent(eglConnection.getDisplay(), EGL10.EGL_NO_SURFACE,
EGL10.EGL_NO_SURFACE, EGL10.EGL_NO_CONTEXT)) {
throw new GLException(egl.eglGetError(),
"eglDetachCurrent failed: 0x" + Integer.toHexString(egl.eglGetError()));
}
}
}

@Override
Expand Down
45 changes: 15 additions & 30 deletions app/src/main/java/org/webrtc/EglBase14Impl.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public long getNativeEglContext() {
return egl14Context.getNativeHandle();
}

public Context(android.opengl.EGLContext eglContext) {
public Context(EGLContext eglContext) {
this.egl14Context = eglContext;
}
}
Expand All @@ -56,7 +56,6 @@ public static class EglConnection implements EglBase14.EglConnection {
private final EGLDisplay eglDisplay;
private final EGLConfig eglConfig;
private final RefCountDelegate refCountDelegate;
private EGLSurface currentSurface = EGL14.EGL_NO_SURFACE;

public EglConnection(EGLContext sharedContext, int[] configAttributes) {
eglDisplay = getEglDisplay();
Expand All @@ -74,7 +73,6 @@ public EglConnection(EGLContext sharedContext, int[] configAttributes) {
}
EGL14.eglReleaseThread();
EGL14.eglTerminate(eglDisplay);
currentSurface = EGL14.EGL_NO_SURFACE;
});
}

Expand Down Expand Up @@ -110,31 +108,6 @@ public EGLDisplay getDisplay() {
public EGLConfig getConfig() {
return eglConfig;
}

public void makeCurrent(EGLSurface eglSurface) {
if (EGL14.eglGetCurrentContext() == eglContext && currentSurface == eglSurface) {
return;
}

synchronized (EglBase.lock) {
if (!EGL14.eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)) {
throw new GLException(EGL14.eglGetError(),
"eglMakeCurrent failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
}
}
currentSurface = eglSurface;
}

public void detachCurrent() {
synchronized (EglBase.lock) {
if (!EGL14.eglMakeCurrent(
eglDisplay, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT)) {
throw new GLException(EGL14.eglGetError(),
"eglDetachCurrent failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
}
}
currentSurface = EGL14.EGL_NO_SURFACE;
}
}
// Create a new context with the specified config type, sharing data with sharedContext.
// `sharedContext` may be null.
Expand Down Expand Up @@ -251,13 +224,25 @@ public void makeCurrent() {
if (eglSurface == EGL14.EGL_NO_SURFACE) {
throw new RuntimeException("No EGLSurface - can't make current");
}
eglConnection.makeCurrent(eglSurface);
synchronized (EglBase.lock) {
if (!EGL14.eglMakeCurrent(
eglConnection.getDisplay(), eglSurface, eglSurface, eglConnection.getContext())) {
throw new GLException(EGL14.eglGetError(),
"eglMakeCurrent failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
}
}
}

// Detach the current EGL context, so that it can be made current on another thread.
@Override
public void detachCurrent() {
eglConnection.detachCurrent();
synchronized (EglBase.lock) {
if (!EGL14.eglMakeCurrent(eglConnection.getDisplay(), EGL14.EGL_NO_SURFACE,
EGL14.EGL_NO_SURFACE, EGL14.EGL_NO_CONTEXT)) {
throw new GLException(EGL14.eglGetError(),
"eglDetachCurrent failed: 0x" + Integer.toHexString(EGL14.eglGetError()));
}
}
}

@Override
Expand Down
44 changes: 14 additions & 30 deletions app/src/main/java/org/webrtc/EglRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@ public void printStackTrace() {
* Set if the video stream should be mirrored horizontally or not.
*/
public void setMirror(final boolean mirror) {
logD("setMirrorHorizontally: " + mirror);
synchronized (layoutLock) {
this.mirrorHorizontally = mirror;
}
Expand All @@ -341,6 +342,7 @@ public void setMirror(final boolean mirror) {
* Set if the video stream should be mirrored vertically or not.
*/
public void setMirrorVertically(final boolean mirrorVertically) {
logD("setMirrorVertically: " + mirrorVertically);
synchronized (layoutLock) {
this.mirrorVertically = mirrorVertically;
}
Expand All @@ -351,6 +353,7 @@ public void setMirrorVertically(final boolean mirrorVertically) {
* Set this to 0 to disable cropping.
*/
public void setLayoutAspectRatio(float layoutAspectRatio) {
logD("setLayoutAspectRatio: " + layoutAspectRatio);
synchronized (layoutLock) {
this.layoutAspectRatio = layoutAspectRatio;
}
Expand All @@ -363,6 +366,7 @@ public void setLayoutAspectRatio(float layoutAspectRatio) {
* reduction.
*/
public void setFpsReduction(float fps) {
logD("setFpsReduction: " + fps);
synchronized (fpsReductionLock) {
final long previousRenderPeriodNs = minRenderPeriodNs;
if (fps <= 0) {
Expand Down Expand Up @@ -558,32 +562,6 @@ public void clearImage(final float r, final float g, final float b, final float
}
}

private void swapBuffersOnRenderThread(final VideoFrame frame, long swapBuffersStartTimeNs) {
synchronized (threadLock) {
if (eglThread != null) {
eglThread.scheduleRenderUpdate(
runsInline -> {
if (!runsInline) {
if (eglBase == null || !eglBase.hasSurface()) {
return;
}
eglBase.makeCurrent();
}

if (usePresentationTimeStamp) {
eglBase.swapBuffers(frame.getTimestampNs());
} else {
eglBase.swapBuffers();
}

synchronized (statisticsLock) {
renderSwapBufferTimeNs += (System.nanoTime() - swapBuffersStartTimeNs);
}
});
}
}
}

/**
* Renders and releases `pendingFrame`.
*/
Expand Down Expand Up @@ -660,11 +638,17 @@ private void renderFrameOnRenderThread() {
eglBase.surfaceWidth(), eglBase.surfaceHeight());

final long swapBuffersStartTimeNs = System.nanoTime();
swapBuffersOnRenderThread(frame, swapBuffersStartTimeNs);
if (usePresentationTimeStamp) {
eglBase.swapBuffers(frame.getTimestampNs());
} else {
eglBase.swapBuffers();
}

final long currentTimeNs = System.nanoTime();
synchronized (statisticsLock) {
++framesRendered;
renderTimeNs += (swapBuffersStartTimeNs - startTimeNs);
renderTimeNs += (currentTimeNs - startTimeNs);
renderSwapBufferTimeNs += (currentTimeNs - swapBuffersStartTimeNs);
}
}

Expand All @@ -679,8 +663,8 @@ private void renderFrameOnRenderThread() {
drawer.release();
frameDrawer.release();
bitmapTextureFramebuffer.release();
// Continue here on purpose and retry again for next frame. In worst case, this is a
// continuous problem and no more frames will be drawn.
// Continue here on purpose and retry again for next frame. In worst case, this is a continous
// problem and no more frames will be drawn.
} finally {
frame.release();
}
Expand Down
Loading

0 comments on commit 12708fb

Please sign in to comment.