diff --git a/Readme.md b/Readme.md index 3c61fcd..1c95b66 100644 --- a/Readme.md +++ b/Readme.md @@ -3,6 +3,8 @@ This is a basic project with latest WebRTC native libraries and java classes. -The WebRTC commit hash is: 2d86b258e010de4b5316bbc5e70f93f7374e8c56 +Here you can find Chromium branches. -I've built WebRTC libs with my script that you can find on this repo. \ No newline at end of file +This project refer to this branch (M119 version). + +I've built WebRTC libs with my script that you can find in this repo. \ No newline at end of file diff --git a/app/libs/arm/libjingle_peerconnection_so.so b/app/libs/arm/libjingle_peerconnection_so.so index c4e2a92..6bc6525 100755 Binary files a/app/libs/arm/libjingle_peerconnection_so.so and b/app/libs/arm/libjingle_peerconnection_so.so differ diff --git a/app/libs/arm64/libjingle_peerconnection_so.so b/app/libs/arm64/libjingle_peerconnection_so.so index be4ad37..a79fe1e 100755 Binary files a/app/libs/arm64/libjingle_peerconnection_so.so and b/app/libs/arm64/libjingle_peerconnection_so.so differ diff --git a/app/libs/x64/libjingle_peerconnection_so.so b/app/libs/x64/libjingle_peerconnection_so.so index eb40909..a9700cf 100755 Binary files a/app/libs/x64/libjingle_peerconnection_so.so and b/app/libs/x64/libjingle_peerconnection_so.so differ diff --git a/app/libs/x86/libjingle_peerconnection_so.so b/app/libs/x86/libjingle_peerconnection_so.so index 642723f..54c771c 100755 Binary files a/app/libs/x86/libjingle_peerconnection_so.so and b/app/libs/x86/libjingle_peerconnection_so.so differ diff --git a/app/src/main/java/org/webrtc/CameraCapturer.java b/app/src/main/java/org/webrtc/CameraCapturer.java index 1922a52..d28ecfd 100644 --- a/app/src/main/java/org/webrtc/CameraCapturer.java +++ b/app/src/main/java/org/webrtc/CameraCapturer.java @@ -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(); @@ -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; diff --git a/app/src/main/java/org/webrtc/EglBase10Impl.java b/app/src/main/java/org/webrtc/EglBase10Impl.java index caa10e7..c8c7e6a 100644 --- a/app/src/main/java/org/webrtc/EglBase10Impl.java +++ b/app/src/main/java/org/webrtc/EglBase10Impl.java @@ -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(); @@ -112,7 +111,6 @@ public EglConnection(EGLContext sharedContext, int[] configAttributes) { } egl.eglDestroyContext(eglDisplay, eglContext); egl.eglTerminate(eglDisplay); - currentSurface = EGL10.EGL_NO_SURFACE; }); } @@ -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. @@ -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()); } @@ -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 diff --git a/app/src/main/java/org/webrtc/EglBase14Impl.java b/app/src/main/java/org/webrtc/EglBase14Impl.java index 22cee86..a9a084a 100644 --- a/app/src/main/java/org/webrtc/EglBase14Impl.java +++ b/app/src/main/java/org/webrtc/EglBase14Impl.java @@ -46,7 +46,7 @@ public long getNativeEglContext() { return egl14Context.getNativeHandle(); } - public Context(android.opengl.EGLContext eglContext) { + public Context(EGLContext eglContext) { this.egl14Context = eglContext; } } @@ -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(); @@ -74,7 +73,6 @@ public EglConnection(EGLContext sharedContext, int[] configAttributes) { } EGL14.eglReleaseThread(); EGL14.eglTerminate(eglDisplay); - currentSurface = EGL14.EGL_NO_SURFACE; }); } @@ -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. @@ -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 diff --git a/app/src/main/java/org/webrtc/EglRenderer.java b/app/src/main/java/org/webrtc/EglRenderer.java index 0a0479b..202094a 100644 --- a/app/src/main/java/org/webrtc/EglRenderer.java +++ b/app/src/main/java/org/webrtc/EglRenderer.java @@ -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; } @@ -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; } @@ -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; } @@ -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) { @@ -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`. */ @@ -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); } } @@ -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(); } diff --git a/app/src/main/java/org/webrtc/EglThread.java b/app/src/main/java/org/webrtc/EglThread.java index 73323d5..47f7810 100644 --- a/app/src/main/java/org/webrtc/EglThread.java +++ b/app/src/main/java/org/webrtc/EglThread.java @@ -21,7 +21,7 @@ import org.webrtc.EglBase.EglConnection; /** EGL graphics thread that allows multiple clients to share the same underlying EGLContext. */ -public class EglThread implements RenderSynchronizer.Listener { +public class EglThread { /** Callback for externally managed reference count. */ public interface ReleaseMonitor { /** @@ -31,21 +31,8 @@ public interface ReleaseMonitor { boolean onRelease(EglThread eglThread); } - /** Interface for clients to schedule rendering updates that will run synchronized. */ - public interface RenderUpdate { - - /** - * Called by EglThread when the rendering window is open. `runsInline` is true when the update - * is executed directly while the client schedules the update. - */ - void update(boolean runsInline); - } - - public static EglThread create( - @Nullable ReleaseMonitor releaseMonitor, - @Nullable final EglBase.Context sharedContext, - final int[] configAttributes, - @Nullable RenderSynchronizer renderSynchronizer) { + public static EglThread create(@Nullable ReleaseMonitor releaseMonitor, + @Nullable final EglBase.Context sharedContext, final int[] configAttributes) { final HandlerThread renderThread = new HandlerThread("EglThread"); renderThread.start(); HandlerWithExceptionCallbacks handler = @@ -66,17 +53,7 @@ public static EglThread create( }); return new EglThread( - releaseMonitor != null ? releaseMonitor : eglThread -> true, - handler, - eglConnection, - renderSynchronizer); - } - - public static EglThread create( - @Nullable ReleaseMonitor releaseMonitor, - @Nullable final EglBase.Context sharedContext, - final int[] configAttributes) { - return create(releaseMonitor, sharedContext, configAttributes, /* renderSynchronizer= */ null); + releaseMonitor != null ? releaseMonitor : eglThread -> true, handler, eglConnection); } /** @@ -121,22 +98,12 @@ public void removeExceptionCallback(Runnable callback) { private final ReleaseMonitor releaseMonitor; private final HandlerWithExceptionCallbacks handler; private final EglConnection eglConnection; - private final RenderSynchronizer renderSynchronizer; - private final List pendingRenderUpdates = new ArrayList<>(); - private boolean renderWindowOpen = true; - - private EglThread( - ReleaseMonitor releaseMonitor, - HandlerWithExceptionCallbacks handler, - EglConnection eglConnection, - RenderSynchronizer renderSynchronizer) { + + private EglThread(ReleaseMonitor releaseMonitor, HandlerWithExceptionCallbacks handler, + EglConnection eglConnection) { this.releaseMonitor = releaseMonitor; this.handler = handler; this.eglConnection = eglConnection; - this.renderSynchronizer = renderSynchronizer; - if (renderSynchronizer != null) { - renderSynchronizer.registerListener(this); - } } public void release() { @@ -145,10 +112,6 @@ public void release() { return; } - if (renderSynchronizer != null) { - renderSynchronizer.removeListener(this); - } - handler.post(eglConnection::release); handler.getLooper().quitSafely(); } @@ -183,34 +146,4 @@ public void addExceptionCallback(Runnable callback) { public void removeExceptionCallback(Runnable callback) { handler.removeExceptionCallback(callback); } - - /** - * Schedules a render update (like swapBuffers) to be run in sync with other updates on the next - * open render window. If the render window is currently open the update will run immediately. - * This method must be called on the EglThread during a render pass. - */ - public void scheduleRenderUpdate(RenderUpdate update) { - if (renderWindowOpen) { - update.update(/* runsInline = */true); - } else { - pendingRenderUpdates.add(update); - } - } - - @Override - public void onRenderWindowOpen() { - handler.post( - () -> { - renderWindowOpen = true; - for (RenderUpdate update : pendingRenderUpdates) { - update.update(/* runsInline = */false); - } - pendingRenderUpdates.clear(); - }); - } - - @Override - public void onRenderWindowClose() { - handler.post(() -> renderWindowOpen = false); - } } diff --git a/app/src/main/java/org/webrtc/EncodedImage.java b/app/src/main/java/org/webrtc/EncodedImage.java index a6eef67..9ad8cec 100644 --- a/app/src/main/java/org/webrtc/EncodedImage.java +++ b/app/src/main/java/org/webrtc/EncodedImage.java @@ -127,7 +127,7 @@ public static class Builder { private int encodedWidth; private int encodedHeight; private long captureTimeNs; - private EncodedImage.FrameType frameType; + private FrameType frameType; private int rotation; private @Nullable Integer qp; @@ -160,7 +160,7 @@ public Builder setCaptureTimeNs(long captureTimeNs) { return this; } - public Builder setFrameType(EncodedImage.FrameType frameType) { + public Builder setFrameType(FrameType frameType) { this.frameType = frameType; return this; } diff --git a/app/src/main/java/org/webrtc/HardwareVideoEncoder.java b/app/src/main/java/org/webrtc/HardwareVideoEncoder.java index 4512d9a..b1c5bac 100644 --- a/app/src/main/java/org/webrtc/HardwareVideoEncoder.java +++ b/app/src/main/java/org/webrtc/HardwareVideoEncoder.java @@ -292,7 +292,7 @@ private VideoCodecStatus initEncodeInternal() { updateInputFormat(codec.getInputFormat()); codec.start(); - } catch (IllegalArgumentException | IllegalStateException e) { + } catch (IllegalStateException e) { Logging.e(TAG, "initEncodeInternal failed", e); release(); return VideoCodecStatus.FALLBACK_SOFTWARE; @@ -780,10 +780,10 @@ protected void fillInputBuffer(ByteBuffer buffer, VideoFrame.Buffer frame) { protected boolean isSemiPlanar(int colorFormat) { switch (colorFormat) { - case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar: + case CodecCapabilities.COLOR_FormatYUV420Planar: return false; - case MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar: - case MediaCodecInfo.CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar: + case CodecCapabilities.COLOR_FormatYUV420SemiPlanar: + case CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar: case MediaCodecUtils.COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m: return true; default: diff --git a/app/src/main/java/org/webrtc/JavaI420Buffer.java b/app/src/main/java/org/webrtc/JavaI420Buffer.java index 322b8f3..1e49ffc 100644 --- a/app/src/main/java/org/webrtc/JavaI420Buffer.java +++ b/app/src/main/java/org/webrtc/JavaI420Buffer.java @@ -15,7 +15,7 @@ import org.webrtc.VideoFrame.I420Buffer; /** Implementation of VideoFrame.I420Buffer backed by Java direct byte buffers. */ -public class JavaI420Buffer implements VideoFrame.I420Buffer { +public class JavaI420Buffer implements I420Buffer { private final int width; private final int height; private final ByteBuffer dataY; diff --git a/app/src/main/java/org/webrtc/MediaCodecUtils.java b/app/src/main/java/org/webrtc/MediaCodecUtils.java index 5417fec..60941ec 100644 --- a/app/src/main/java/org/webrtc/MediaCodecUtils.java +++ b/app/src/main/java/org/webrtc/MediaCodecUtils.java @@ -50,14 +50,14 @@ class MediaCodecUtils { // Color formats supported by hardware encoder - in order of preference. static final int[] ENCODER_COLOR_FORMATS = { - MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420Planar, - MediaCodecInfo.CodecCapabilities.COLOR_FormatYUV420SemiPlanar, - MediaCodecInfo.CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar, + CodecCapabilities.COLOR_FormatYUV420Planar, + CodecCapabilities.COLOR_FormatYUV420SemiPlanar, + CodecCapabilities.COLOR_QCOM_FormatYUV420SemiPlanar, MediaCodecUtils.COLOR_QCOM_FORMATYUV420PackedSemiPlanar32m}; // Color formats supported by texture mode encoding - in order of preference. static final int[] TEXTURE_COLOR_FORMATS = - new int[] {MediaCodecInfo.CodecCapabilities.COLOR_FormatSurface}; + new int[] {CodecCapabilities.COLOR_FormatSurface}; static @Nullable Integer selectColorFormat( int[] supportedColorFormats, CodecCapabilities capabilities) { @@ -102,11 +102,11 @@ static boolean isHardwareAccelerated(MediaCodecInfo info) { } @TargetApi(29) - private static boolean isHardwareAcceleratedQOrHigher(android.media.MediaCodecInfo codecInfo) { + private static boolean isHardwareAcceleratedQOrHigher(MediaCodecInfo codecInfo) { return codecInfo.isHardwareAccelerated(); } - static boolean isSoftwareOnly(android.media.MediaCodecInfo codecInfo) { + static boolean isSoftwareOnly(MediaCodecInfo codecInfo) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { return isSoftwareOnlyQOrHigher(codecInfo); } @@ -120,7 +120,7 @@ static boolean isSoftwareOnly(android.media.MediaCodecInfo codecInfo) { } @TargetApi(29) - private static boolean isSoftwareOnlyQOrHigher(android.media.MediaCodecInfo codecInfo) { + private static boolean isSoftwareOnlyQOrHigher(MediaCodecInfo codecInfo) { return codecInfo.isSoftwareOnly(); } diff --git a/app/src/main/java/org/webrtc/MediaCodecWrapper.java b/app/src/main/java/org/webrtc/MediaCodecWrapper.java index 11e0f58..6a1bfe3 100644 --- a/app/src/main/java/org/webrtc/MediaCodecWrapper.java +++ b/app/src/main/java/org/webrtc/MediaCodecWrapper.java @@ -19,7 +19,7 @@ import java.nio.ByteBuffer; /** - * Subset of methods defined in {@link android.media.MediaCodec} needed by + * Subset of methods defined in {@link MediaCodec} needed by * {@link HardwareVideoEncoder} and {@link AndroidVideoDecoder}. This interface * exists to allow mocking and using a fake implementation in tests. */ diff --git a/app/src/main/java/org/webrtc/MediaCodecWrapperFactoryImpl.java b/app/src/main/java/org/webrtc/MediaCodecWrapperFactoryImpl.java index 207492f..1fdc125 100644 --- a/app/src/main/java/org/webrtc/MediaCodecWrapperFactoryImpl.java +++ b/app/src/main/java/org/webrtc/MediaCodecWrapperFactoryImpl.java @@ -22,7 +22,7 @@ /** * Implementation of MediaCodecWrapperFactory that returns MediaCodecInterfaces wrapping - * {@link android.media.MediaCodec} objects. + * {@link MediaCodec} objects. */ class MediaCodecWrapperFactoryImpl implements MediaCodecWrapperFactory { private static class MediaCodecWrapperImpl implements MediaCodecWrapper { diff --git a/app/src/main/java/org/webrtc/NetworkMonitorAutoDetect.java b/app/src/main/java/org/webrtc/NetworkMonitorAutoDetect.java index a6f24c2..0d4be44 100644 --- a/app/src/main/java/org/webrtc/NetworkMonitorAutoDetect.java +++ b/app/src/main/java/org/webrtc/NetworkMonitorAutoDetect.java @@ -404,8 +404,8 @@ long getDefaultNetId() { } NetworkState networkState = getNetworkState(network); - NetworkChangeDetector.ConnectionType connectionType = getConnectionType(networkState); - if (connectionType == NetworkChangeDetector.ConnectionType.CONNECTION_NONE) { + ConnectionType connectionType = getConnectionType(networkState); + if (connectionType == ConnectionType.CONNECTION_NONE) { // This may not be an error. The OS may signal a network event with connection type // NONE when the network disconnects. Logging.d(TAG, "Network " + network.toString() + " is disconnected"); @@ -414,8 +414,8 @@ long getDefaultNetId() { // Some android device may return a CONNECTION_UNKNOWN_CELLULAR or CONNECTION_UNKNOWN type, // which appears to be usable. Just log them here. - if (connectionType == NetworkChangeDetector.ConnectionType.CONNECTION_UNKNOWN - || connectionType == NetworkChangeDetector.ConnectionType.CONNECTION_UNKNOWN_CELLULAR) { + if (connectionType == ConnectionType.CONNECTION_UNKNOWN + || connectionType == ConnectionType.CONNECTION_UNKNOWN_CELLULAR) { Logging.d(TAG, "Network " + network.toString() + " connection type is " + connectionType + " because it has type " + networkState.getNetworkType() + " and subtype " + networkState.getNetworkSubType()); @@ -536,12 +536,12 @@ static class WifiDirectManagerDelegate extends BroadcastReceiver { // (NETWORK_UNSPECIFIED) for these addresses. private static final int WIFI_P2P_NETWORK_HANDLE = 0; private final Context context; - private final NetworkChangeDetector.Observer observer; + private final Observer observer; // Network information about a WifiP2p (aka WiFi-Direct) network, or null if no such network is // connected. @Nullable private NetworkInformation wifiP2pNetworkInfo; - WifiDirectManagerDelegate(NetworkChangeDetector.Observer observer, Context context) { + WifiDirectManagerDelegate(Observer observer, Context context) { this.context = context; this.observer = observer; IntentFilter intentFilter = new IntentFilter(); @@ -607,8 +607,8 @@ private void onWifiP2pGroupChange(@Nullable WifiP2pGroup wifiP2pGroup) { } wifiP2pNetworkInfo = new NetworkInformation(wifiP2pGroup.getInterface(), - NetworkChangeDetector.ConnectionType.CONNECTION_WIFI, - NetworkChangeDetector.ConnectionType.CONNECTION_NONE, WIFI_P2P_NETWORK_HANDLE, + ConnectionType.CONNECTION_WIFI, + ConnectionType.CONNECTION_NONE, WIFI_P2P_NETWORK_HANDLE, ipAddresses); observer.onNetworkConnect(wifiP2pNetworkInfo); } @@ -626,7 +626,7 @@ private void onWifiP2pStateChange(int state) { private static final String TAG = "NetworkMonitorAutoDetect"; // Observer for the connection type change. - private final NetworkChangeDetector.Observer observer; + private final Observer observer; private final IntentFilter intentFilter; private final Context context; // Used to request mobile network. It does not do anything except for keeping @@ -643,12 +643,12 @@ private void onWifiP2pStateChange(int state) { @GuardedBy("availableNetworks") final Set availableNetworks = new HashSet<>(); private boolean isRegistered; - private NetworkChangeDetector.ConnectionType connectionType; + private ConnectionType connectionType; private String wifiSSID; /** Constructs a NetworkMonitorAutoDetect. Should only be called on UI thread. */ @SuppressLint("NewApi") - public NetworkMonitorAutoDetect(NetworkChangeDetector.Observer observer, Context context) { + public NetworkMonitorAutoDetect(Observer observer, Context context) { this.observer = observer; this.context = context; String fieldTrialsString = observer.getFieldTrialsString(); @@ -672,7 +672,7 @@ public NetworkMonitorAutoDetect(NetworkChangeDetector.Observer observer, Context NetworkCallback tempNetworkCallback = new NetworkCallback(); try { connectivityManagerDelegate.requestMobileNetwork(tempNetworkCallback); - } catch (java.lang.SecurityException e) { + } catch (SecurityException e) { Logging.w(TAG, "Unable to obtain permission to request a cellular network."); tempNetworkCallback = null; } @@ -783,21 +783,21 @@ public long getDefaultNetId() { return connectivityManagerDelegate.getDefaultNetId(); } - private static NetworkChangeDetector.ConnectionType getConnectionType( + private static ConnectionType getConnectionType( boolean isConnected, int networkType, int networkSubtype) { if (!isConnected) { - return NetworkChangeDetector.ConnectionType.CONNECTION_NONE; + return ConnectionType.CONNECTION_NONE; } switch (networkType) { case ConnectivityManager.TYPE_ETHERNET: - return NetworkChangeDetector.ConnectionType.CONNECTION_ETHERNET; + return ConnectionType.CONNECTION_ETHERNET; case ConnectivityManager.TYPE_WIFI: - return NetworkChangeDetector.ConnectionType.CONNECTION_WIFI; + return ConnectionType.CONNECTION_WIFI; case ConnectivityManager.TYPE_WIMAX: - return NetworkChangeDetector.ConnectionType.CONNECTION_4G; + return ConnectionType.CONNECTION_4G; case ConnectivityManager.TYPE_BLUETOOTH: - return NetworkChangeDetector.ConnectionType.CONNECTION_BLUETOOTH; + return ConnectionType.CONNECTION_BLUETOOTH; case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: @@ -809,7 +809,7 @@ private static NetworkChangeDetector.ConnectionType getConnectionType( case TelephonyManager.NETWORK_TYPE_1xRTT: case TelephonyManager.NETWORK_TYPE_IDEN: case TelephonyManager.NETWORK_TYPE_GSM: - return NetworkChangeDetector.ConnectionType.CONNECTION_2G; + return ConnectionType.CONNECTION_2G; case TelephonyManager.NETWORK_TYPE_UMTS: case TelephonyManager.NETWORK_TYPE_EVDO_0: case TelephonyManager.NETWORK_TYPE_EVDO_A: @@ -820,36 +820,36 @@ private static NetworkChangeDetector.ConnectionType getConnectionType( case TelephonyManager.NETWORK_TYPE_EHRPD: case TelephonyManager.NETWORK_TYPE_HSPAP: case TelephonyManager.NETWORK_TYPE_TD_SCDMA: - return NetworkChangeDetector.ConnectionType.CONNECTION_3G; + return ConnectionType.CONNECTION_3G; case TelephonyManager.NETWORK_TYPE_LTE: case TelephonyManager.NETWORK_TYPE_IWLAN: - return NetworkChangeDetector.ConnectionType.CONNECTION_4G; + return ConnectionType.CONNECTION_4G; case TelephonyManager.NETWORK_TYPE_NR: - return NetworkChangeDetector.ConnectionType.CONNECTION_5G; + return ConnectionType.CONNECTION_5G; default: - return NetworkChangeDetector.ConnectionType.CONNECTION_UNKNOWN_CELLULAR; + return ConnectionType.CONNECTION_UNKNOWN_CELLULAR; } case ConnectivityManager.TYPE_VPN: - return NetworkChangeDetector.ConnectionType.CONNECTION_VPN; + return ConnectionType.CONNECTION_VPN; default: - return NetworkChangeDetector.ConnectionType.CONNECTION_UNKNOWN; + return ConnectionType.CONNECTION_UNKNOWN; } } - public static NetworkChangeDetector.ConnectionType getConnectionType(NetworkState networkState) { + public static ConnectionType getConnectionType(NetworkState networkState) { return getConnectionType(networkState.isConnected(), networkState.getNetworkType(), networkState.getNetworkSubType()); } @Override - public NetworkChangeDetector.ConnectionType getCurrentConnectionType() { + public ConnectionType getCurrentConnectionType() { return getConnectionType(getCurrentNetworkState()); } - private static NetworkChangeDetector.ConnectionType getUnderlyingConnectionTypeForVpn( + private static ConnectionType getUnderlyingConnectionTypeForVpn( NetworkState networkState) { if (networkState.getNetworkType() != ConnectivityManager.TYPE_VPN) { - return NetworkChangeDetector.ConnectionType.CONNECTION_NONE; + return ConnectionType.CONNECTION_NONE; } return getConnectionType(networkState.isConnected(), networkState.getUnderlyingNetworkTypeForVpn(), @@ -857,7 +857,7 @@ private static NetworkChangeDetector.ConnectionType getUnderlyingConnectionTypeF } private String getWifiSSID(NetworkState networkState) { - if (getConnectionType(networkState) != NetworkChangeDetector.ConnectionType.CONNECTION_WIFI) + if (getConnectionType(networkState) != ConnectionType.CONNECTION_WIFI) return ""; return wifiManagerDelegate.getWifiSSID(); } @@ -872,7 +872,7 @@ public void onReceive(Context context, Intent intent) { } private void connectionTypeChanged(NetworkState networkState) { - NetworkChangeDetector.ConnectionType newConnectionType = getConnectionType(networkState); + ConnectionType newConnectionType = getConnectionType(networkState); String newWifiSSID = getWifiSSID(networkState); if (newConnectionType == connectionType && newWifiSSID.equals(wifiSSID)) return; diff --git a/app/src/main/java/org/webrtc/PeerConnectionFactory.java b/app/src/main/java/org/webrtc/PeerConnectionFactory.java index c46718f..dc79ad4 100644 --- a/app/src/main/java/org/webrtc/PeerConnectionFactory.java +++ b/app/src/main/java/org/webrtc/PeerConnectionFactory.java @@ -124,8 +124,8 @@ public Builder setInjectableLogger(Loggable loggable, Severity severity) { return this; } - public PeerConnectionFactory.InitializationOptions createInitializationOptions() { - return new PeerConnectionFactory.InitializationOptions(applicationContext, fieldTrials, + public InitializationOptions createInitializationOptions() { + return new InitializationOptions(applicationContext, fieldTrials, enableInternalTracer, nativeLibraryLoader, nativeLibraryName, loggable, loggableSeverity); } diff --git a/app/src/main/java/org/webrtc/SurfaceTextureHelper.java b/app/src/main/java/org/webrtc/SurfaceTextureHelper.java index 3ea2273..5b72e3c 100644 --- a/app/src/main/java/org/webrtc/SurfaceTextureHelper.java +++ b/app/src/main/java/org/webrtc/SurfaceTextureHelper.java @@ -57,7 +57,7 @@ public interface FrameRefMonitor { * closer to actual creation time. */ public static SurfaceTextureHelper create(final String threadName, - final EglBase.Context sharedContext, boolean alignTimestamps, final YuvConverter yuvConverter, + final Context sharedContext, boolean alignTimestamps, final YuvConverter yuvConverter, FrameRefMonitor frameRefMonitor) { final HandlerThread thread = new HandlerThread(threadName); thread.start(); @@ -85,10 +85,10 @@ public SurfaceTextureHelper call() { /** * Same as above with alignTimestamps set to false and yuvConverter set to new YuvConverter. * - * @see #create(String, EglBase.Context, boolean, YuvConverter, FrameRefMonitor) + * @see #create(String, Context, boolean, YuvConverter, FrameRefMonitor) */ public static SurfaceTextureHelper create( - final String threadName, final EglBase.Context sharedContext) { + final String threadName, final Context sharedContext) { return create(threadName, sharedContext, /* alignTimestamps= */ false, new YuvConverter(), /*frameRefMonitor=*/null); } @@ -96,10 +96,10 @@ public static SurfaceTextureHelper create( /** * Same as above with yuvConverter set to new YuvConverter. * - * @see #create(String, EglBase.Context, boolean, YuvConverter, FrameRefMonitor) + * @see #create(String, Context, boolean, YuvConverter, FrameRefMonitor) */ public static SurfaceTextureHelper create( - final String threadName, final EglBase.Context sharedContext, boolean alignTimestamps) { + final String threadName, final Context sharedContext, boolean alignTimestamps) { return create( threadName, sharedContext, alignTimestamps, new YuvConverter(), /*frameRefMonitor=*/null); } @@ -107,10 +107,10 @@ public static SurfaceTextureHelper create( /** * Create a SurfaceTextureHelper without frame ref monitor. * - * @see #create(String, EglBase.Context, boolean, YuvConverter, FrameRefMonitor) + * @see #create(String, Context, boolean, YuvConverter, FrameRefMonitor) */ public static SurfaceTextureHelper create(final String threadName, - final EglBase.Context sharedContext, boolean alignTimestamps, YuvConverter yuvConverter) { + final Context sharedContext, boolean alignTimestamps, YuvConverter yuvConverter) { return create( threadName, sharedContext, alignTimestamps, yuvConverter, /*frameRefMonitor=*/null); } @@ -359,7 +359,7 @@ private void tryDeliverTextureFrame() { if (timestampAligner != null) { timestampNs = timestampAligner.translateTimestamp(timestampNs); } - final VideoFrame.TextureBuffer buffer = + final TextureBuffer buffer = new TextureBufferImpl(textureWidth, textureHeight, TextureBuffer.Type.OES, oesTextureId, RendererCommon.convertMatrixToAndroidGraphicsMatrix(transformMatrix), handler, yuvConverter, textureRefCountMonitor); diff --git a/app/src/main/java/org/webrtc/TextureBufferImpl.java b/app/src/main/java/org/webrtc/TextureBufferImpl.java index 7e2bed8..b8b6ed1 100644 --- a/app/src/main/java/org/webrtc/TextureBufferImpl.java +++ b/app/src/main/java/org/webrtc/TextureBufferImpl.java @@ -83,7 +83,7 @@ private TextureBufferImpl(int unscaledWidth, int unscaledHeight, int width, int } @Override - public VideoFrame.TextureBuffer.Type getType() { + public Type getType() { return type; } diff --git a/app/src/main/java/org/webrtc/VideoEncoder.java b/app/src/main/java/org/webrtc/VideoEncoder.java index 0d8cf83..7580ffc 100644 --- a/app/src/main/java/org/webrtc/VideoEncoder.java +++ b/app/src/main/java/org/webrtc/VideoEncoder.java @@ -35,7 +35,7 @@ public class Settings { public Settings(int numberOfCores, int width, int height, int startBitrate, int maxFramerate, int numberOfSimulcastStreams, boolean automaticResizeOn) { this(numberOfCores, width, height, startBitrate, maxFramerate, numberOfSimulcastStreams, - automaticResizeOn, new VideoEncoder.Capabilities(false /* lossNotification */)); + automaticResizeOn, new Capabilities(false /* lossNotification */)); } @CalledByNative("Settings") diff --git a/app/src/main/java/org/webrtc/audio/AudioDeviceModule.java b/app/src/main/java/org/webrtc/audio/AudioDeviceModule.java index 5a0bf5c..c4bb45f 100644 --- a/app/src/main/java/org/webrtc/audio/AudioDeviceModule.java +++ b/app/src/main/java/org/webrtc/audio/AudioDeviceModule.java @@ -43,14 +43,4 @@ public interface AudioDeviceModule { default boolean setNoiseSuppressorEnabled(boolean enabled) { return false; } - - /** - * Sets the preferred field dimension for the built-in microphone. Returns - * true if setting was successful, otherwise false is returned. - * This functionality can be implemented with - * {@code android.media.MicrophoneDirection.setPreferredMicrophoneFieldDimension}. - */ - default boolean setPreferredMicrophoneFieldDimension(float dimension) { - return false; - } }