EglBaseProvider.smali

.class public Lio/agora/rtc2/gl/EglBaseProvider;
.super Ljava/lang/Object;
.source "EglBaseProvider.java"


# static fields
.field private static final RELEASE_MESSAGE_TEMPLATE:Ljava/lang/String; = "EglBaseProvider released %s unavailable"

.field private static volatile instance:Lio/agora/rtc2/gl/EglBaseProvider;


# instance fields
.field private volatile initialized:Z

.field private localEglBase:Lio/agora/base/internal/video/EglBase;

.field private remoteEglBase:Lio/agora/base/internal/video/EglBase;

.field private rootEglBase:Lio/agora/base/internal/video/EglBase;


# direct methods
.method private constructor <init>()V
    .registers 2

    .line 167
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/4 v0, 0x0

    .line 24
    iput-boolean v0, p0, Lio/agora/rtc2/gl/EglBaseProvider;->initialized:Z

    return-void
.end method

.method public static acquireEglBaseReadLock()V
    .registers 1

    .line 126
    sget-object v0, Lio/agora/base/internal/video/EglBase;->rwlock:Ljava/util/concurrent/locks/ReadWriteLock;

    invoke-interface {v0}, Ljava/util/concurrent/locks/ReadWriteLock;->readLock()Ljava/util/concurrent/locks/Lock;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/concurrent/locks/Lock;->lock()V

    return-void
.end method

.method private checkReleased(Ljava/lang/String;)V
    .registers 4

    .line 180
    sget-object v0, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    if-eqz v0, :cond_5

    return-void

    :cond_5
    const/4 v0, 0x1

    new-array v0, v0, [Ljava/lang/Object;

    const/4 v1, 0x0

    aput-object p1, v0, v1

    const-string p1, "EglBaseProvider released %s unavailable"

    .line 181
    invoke-static {p1, v0}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;

    move-result-object p1

    .line 182
    new-instance v0, Ljava/lang/IllegalStateException;

    invoke-direct {v0, p1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw v0
.end method

.method public static destroy()V
    .registers 2

    .line 39
    const-class v0, Lio/agora/rtc2/gl/EglBaseProvider;

    monitor-enter v0

    .line 40
    :try_start_3
    sget-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    if-eqz v1, :cond_f

    .line 41
    sget-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    invoke-direct {v1}, Lio/agora/rtc2/gl/EglBaseProvider;->release()V

    const/4 v1, 0x0

    .line 42
    sput-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    .line 44
    :cond_f
    monitor-exit v0

    return-void

    :catchall_11
    move-exception v1

    monitor-exit v0
    :try_end_13
    .catchall {:try_start_3 .. :try_end_13} :catchall_11

    throw v1
.end method

.method public static getCurrentEglContext()Lio/agora/base/internal/video/EglBase$Context;
    .registers 4

    .line 94
    invoke-static {}, Lio/agora/base/internal/video/EglBase14;->isEGL14SupportedImpl()Z

    move-result v0

    const/4 v1, 0x0

    if-eqz v0, :cond_19

    .line 95
    invoke-static {}, Landroid/opengl/EGL14;->eglGetCurrentContext()Landroid/opengl/EGLContext;

    move-result-object v0

    .line 96
    sget-object v2, Landroid/opengl/EGL14;->EGL_NO_CONTEXT:Landroid/opengl/EGLContext;

    invoke-static {v0, v2}, Ljava/util/Objects;->equals(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result v2

    if-nez v2, :cond_36

    .line 97
    new-instance v1, Lio/agora/base/internal/video/EglBase14$Context;

    invoke-direct {v1, v0}, Lio/agora/base/internal/video/EglBase14$Context;-><init>(Landroid/opengl/EGLContext;)V

    goto :goto_36

    .line 100
    :cond_19
    invoke-static {}, Ljavax/microedition/khronos/egl/EGLContext;->getEGL()Ljavax/microedition/khronos/egl/EGL;

    move-result-object v0

    check-cast v0, Ljavax/microedition/khronos/egl/EGL10;

    if-eqz v0, :cond_36

    .line 101
    invoke-interface {v0}, Ljavax/microedition/khronos/egl/EGL10;->eglGetCurrentContext()Ljavax/microedition/khronos/egl/EGLContext;

    move-result-object v2

    sget-object v3, Ljavax/microedition/khronos/egl/EGL10;->EGL_NO_CONTEXT:Ljavax/microedition/khronos/egl/EGLContext;

    invoke-static {v2, v3}, Ljava/util/Objects;->equals(Ljava/lang/Object;Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_36

    .line 102
    new-instance v1, Lio/agora/base/internal/video/EglBase10$Context;

    invoke-interface {v0}, Ljavax/microedition/khronos/egl/EGL10;->eglGetCurrentContext()Ljavax/microedition/khronos/egl/EGLContext;

    move-result-object v0

    invoke-direct {v1, v0}, Lio/agora/base/internal/video/EglBase10$Context;-><init>(Ljavax/microedition/khronos/egl/EGLContext;)V

    :cond_36
    :goto_36
    return-object v1
.end method

.method private initialize()V
    .registers 2

    .line 170
    iget-boolean v0, p0, Lio/agora/rtc2/gl/EglBaseProvider;->initialized:Z

    if-eqz v0, :cond_5

    return-void

    .line 173
    :cond_5
    invoke-static {}, Lio/agora/base/internal/video/EglBaseFactory;->create()Lio/agora/base/internal/video/EglBase;

    move-result-object v0

    iput-object v0, p0, Lio/agora/rtc2/gl/EglBaseProvider;->rootEglBase:Lio/agora/base/internal/video/EglBase;

    .line 174
    invoke-interface {v0}, Lio/agora/base/internal/video/EglBase;->getEglBaseContext()Lio/agora/base/internal/video/EglBase$Context;

    move-result-object v0

    invoke-static {v0}, Lio/agora/base/internal/video/EglBaseFactory;->create(Lio/agora/base/internal/video/EglBase$Context;)Lio/agora/base/internal/video/EglBase;

    move-result-object v0

    iput-object v0, p0, Lio/agora/rtc2/gl/EglBaseProvider;->localEglBase:Lio/agora/base/internal/video/EglBase;

    .line 175
    iget-object v0, p0, Lio/agora/rtc2/gl/EglBaseProvider;->rootEglBase:Lio/agora/base/internal/video/EglBase;

    invoke-interface {v0}, Lio/agora/base/internal/video/EglBase;->getEglBaseContext()Lio/agora/base/internal/video/EglBase$Context;

    move-result-object v0

    invoke-static {v0}, Lio/agora/base/internal/video/EglBaseFactory;->create(Lio/agora/base/internal/video/EglBase$Context;)Lio/agora/base/internal/video/EglBase;

    move-result-object v0

    iput-object v0, p0, Lio/agora/rtc2/gl/EglBaseProvider;->remoteEglBase:Lio/agora/base/internal/video/EglBase;

    const/4 v0, 0x1

    .line 176
    iput-boolean v0, p0, Lio/agora/rtc2/gl/EglBaseProvider;->initialized:Z

    return-void
.end method

.method public static instance()Lio/agora/rtc2/gl/EglBaseProvider;
    .registers 2

    .line 29
    const-class v0, Lio/agora/rtc2/gl/EglBaseProvider;

    monitor-enter v0

    .line 30
    :try_start_3
    sget-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    if-nez v1, :cond_e

    .line 31
    new-instance v1, Lio/agora/rtc2/gl/EglBaseProvider;

    invoke-direct {v1}, Lio/agora/rtc2/gl/EglBaseProvider;-><init>()V

    sput-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    .line 33
    :cond_e
    sget-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    monitor-exit v0

    return-object v1

    :catchall_12
    move-exception v1

    .line 34
    monitor-exit v0
    :try_end_14
    .catchall {:try_start_3 .. :try_end_14} :catchall_12

    throw v1
.end method

.method public static isEgl14BaseContext(Lio/agora/base/internal/video/EglBase$Context;)Z
    .registers 1

    .line 110
    instance-of p0, p0, Lio/agora/base/internal/video/EglBase14$Context;

    return p0
.end method

.method public static native nativeExtensionNativeStartFunc(J)V
.end method

.method public static native nativeExtensionNativeStopFunc(J)V
.end method

.method private release()V
    .registers 3

    .line 153
    const-class v0, Lio/agora/rtc2/gl/EglBaseProvider;

    monitor-enter v0

    .line 154
    :try_start_3
    iget-object v1, p0, Lio/agora/rtc2/gl/EglBaseProvider;->remoteEglBase:Lio/agora/base/internal/video/EglBase;

    if-eqz v1, :cond_a

    .line 155
    invoke-interface {v1}, Lio/agora/base/internal/video/EglBase;->release()V

    .line 157
    :cond_a
    iget-object v1, p0, Lio/agora/rtc2/gl/EglBaseProvider;->localEglBase:Lio/agora/base/internal/video/EglBase;

    if-eqz v1, :cond_11

    .line 158
    invoke-interface {v1}, Lio/agora/base/internal/video/EglBase;->release()V

    .line 160
    :cond_11
    iget-object v1, p0, Lio/agora/rtc2/gl/EglBaseProvider;->rootEglBase:Lio/agora/base/internal/video/EglBase;

    if-eqz v1, :cond_18

    .line 161
    invoke-interface {v1}, Lio/agora/base/internal/video/EglBase;->release()V

    :cond_18
    const/4 v1, 0x0

    .line 163
    iput-boolean v1, p0, Lio/agora/rtc2/gl/EglBaseProvider;->initialized:Z

    .line 164
    monitor-exit v0

    return-void

    :catchall_1d
    move-exception v1

    monitor-exit v0
    :try_end_1f
    .catchall {:try_start_3 .. :try_end_1f} :catchall_1d

    throw v1
.end method

.method public static releaseEglBaseReadLock()V
    .registers 1

    .line 131
    sget-object v0, Lio/agora/base/internal/video/EglBase;->rwlock:Ljava/util/concurrent/locks/ReadWriteLock;

    invoke-interface {v0}, Ljava/util/concurrent/locks/ReadWriteLock;->readLock()Ljava/util/concurrent/locks/Lock;

    move-result-object v0

    invoke-interface {v0}, Ljava/util/concurrent/locks/Lock;->unlock()V

    return-void
.end method

.method public static startWithEglBaseLock(J)V
    .registers 3

    .line 136
    sget-object v0, Lio/agora/base/internal/video/EglBase;->lock:Ljava/lang/Object;

    monitor-enter v0

    .line 137
    :try_start_3
    invoke-static {p0, p1}, Lio/agora/rtc2/gl/EglBaseProvider;->nativeExtensionNativeStartFunc(J)V

    .line 138
    monitor-exit v0

    return-void

    :catchall_8
    move-exception p0

    monitor-exit v0
    :try_end_a
    .catchall {:try_start_3 .. :try_end_a} :catchall_8

    throw p0
.end method

.method public static stopWithEglBaseLock(J)V
    .registers 3

    .line 145
    sget-object v0, Lio/agora/base/internal/video/EglBase;->lock:Ljava/lang/Object;

    monitor-enter v0

    .line 146
    :try_start_3
    invoke-static {p0, p1}, Lio/agora/rtc2/gl/EglBaseProvider;->nativeExtensionNativeStopFunc(J)V

    .line 147
    monitor-exit v0

    return-void

    :catchall_8
    move-exception p0

    monitor-exit v0
    :try_end_a
    .catchall {:try_start_3 .. :try_end_a} :catchall_8

    throw p0
.end method


# virtual methods
.method public getLocalEglBase()Lio/agora/base/internal/video/EglBase;
    .registers 3

    .line 56
    const-class v0, Lio/agora/rtc2/gl/EglBaseProvider;

    monitor-enter v0

    :try_start_3
    const-string v1, "getLocalEglBase"

    .line 57
    invoke-direct {p0, v1}, Lio/agora/rtc2/gl/EglBaseProvider;->checkReleased(Ljava/lang/String;)V

    .line 58
    invoke-direct {p0}, Lio/agora/rtc2/gl/EglBaseProvider;->initialize()V

    .line 59
    sget-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    iget-object v1, v1, Lio/agora/rtc2/gl/EglBaseProvider;->localEglBase:Lio/agora/base/internal/video/EglBase;

    monitor-exit v0

    return-object v1

    :catchall_11
    move-exception v1

    .line 60
    monitor-exit v0
    :try_end_13
    .catchall {:try_start_3 .. :try_end_13} :catchall_11

    throw v1
.end method

.method public getLocalEglBaseContext()Lio/agora/base/internal/video/EglBase$Context;
    .registers 3

    .line 65
    const-class v0, Lio/agora/rtc2/gl/EglBaseProvider;

    monitor-enter v0

    :try_start_3
    const-string v1, "getLocalEglBaseContext"

    .line 66
    invoke-direct {p0, v1}, Lio/agora/rtc2/gl/EglBaseProvider;->checkReleased(Ljava/lang/String;)V

    .line 67
    invoke-direct {p0}, Lio/agora/rtc2/gl/EglBaseProvider;->initialize()V

    .line 68
    sget-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    iget-object v1, v1, Lio/agora/rtc2/gl/EglBaseProvider;->localEglBase:Lio/agora/base/internal/video/EglBase;

    invoke-interface {v1}, Lio/agora/base/internal/video/EglBase;->getEglBaseContext()Lio/agora/base/internal/video/EglBase$Context;

    move-result-object v1

    monitor-exit v0

    return-object v1

    :catchall_15
    move-exception v1

    .line 69
    monitor-exit v0
    :try_end_17
    .catchall {:try_start_3 .. :try_end_17} :catchall_15

    throw v1
.end method

.method public getRemoteEglBase()Lio/agora/base/internal/video/EglBase;
    .registers 3

    .line 73
    const-class v0, Lio/agora/rtc2/gl/EglBaseProvider;

    monitor-enter v0

    :try_start_3
    const-string v1, "getRemoteEglBase"

    .line 74
    invoke-direct {p0, v1}, Lio/agora/rtc2/gl/EglBaseProvider;->checkReleased(Ljava/lang/String;)V

    .line 75
    invoke-direct {p0}, Lio/agora/rtc2/gl/EglBaseProvider;->initialize()V

    .line 76
    sget-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    iget-object v1, v1, Lio/agora/rtc2/gl/EglBaseProvider;->remoteEglBase:Lio/agora/base/internal/video/EglBase;

    monitor-exit v0

    return-object v1

    :catchall_11
    move-exception v1

    .line 77
    monitor-exit v0
    :try_end_13
    .catchall {:try_start_3 .. :try_end_13} :catchall_11

    throw v1
.end method

.method public getRemoteEglBaseContext()Lio/agora/base/internal/video/EglBase$Context;
    .registers 3

    .line 82
    const-class v0, Lio/agora/rtc2/gl/EglBaseProvider;

    monitor-enter v0

    :try_start_3
    const-string v1, "getRemoteEglBaseContext"

    .line 83
    invoke-direct {p0, v1}, Lio/agora/rtc2/gl/EglBaseProvider;->checkReleased(Ljava/lang/String;)V

    .line 84
    invoke-direct {p0}, Lio/agora/rtc2/gl/EglBaseProvider;->initialize()V

    .line 85
    sget-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    iget-object v1, v1, Lio/agora/rtc2/gl/EglBaseProvider;->remoteEglBase:Lio/agora/base/internal/video/EglBase;

    invoke-interface {v1}, Lio/agora/base/internal/video/EglBase;->getEglBaseContext()Lio/agora/base/internal/video/EglBase$Context;

    move-result-object v1

    monitor-exit v0

    return-object v1

    :catchall_15
    move-exception v1

    .line 86
    monitor-exit v0
    :try_end_17
    .catchall {:try_start_3 .. :try_end_17} :catchall_15

    throw v1
.end method

.method public getRootEglBase()Lio/agora/base/internal/video/EglBase;
    .registers 3

    .line 48
    const-class v0, Lio/agora/rtc2/gl/EglBaseProvider;

    monitor-enter v0

    :try_start_3
    const-string v1, "getRootEglBase"

    .line 49
    invoke-direct {p0, v1}, Lio/agora/rtc2/gl/EglBaseProvider;->checkReleased(Ljava/lang/String;)V

    .line 50
    invoke-direct {p0}, Lio/agora/rtc2/gl/EglBaseProvider;->initialize()V

    .line 51
    sget-object v1, Lio/agora/rtc2/gl/EglBaseProvider;->instance:Lio/agora/rtc2/gl/EglBaseProvider;

    iget-object v1, v1, Lio/agora/rtc2/gl/EglBaseProvider;->rootEglBase:Lio/agora/base/internal/video/EglBase;

    monitor-exit v0

    return-object v1

    :catchall_11
    move-exception v1

    .line 52
    monitor-exit v0
    :try_end_13
    .catchall {:try_start_3 .. :try_end_13} :catchall_11

    throw v1
.end method

.method public replaceRootBase(Lio/agora/base/internal/video/EglBase$Context;)V
    .registers 4

    .line 115
    const-class v0, Lio/agora/rtc2/gl/EglBaseProvider;

    monitor-enter v0

    .line 116
    :try_start_3
    invoke-direct {p0}, Lio/agora/rtc2/gl/EglBaseProvider;->release()V

    .line 117
    sget-object v1, Lio/agora/base/internal/video/EglBase;->CONFIG_PLAIN:[I

    invoke-static {p1, v1}, Lio/agora/base/internal/video/EglBaseFactory;->create(Lio/agora/base/internal/video/EglBase$Context;[I)Lio/agora/base/internal/video/EglBase;

    move-result-object p1

    iput-object p1, p0, Lio/agora/rtc2/gl/EglBaseProvider;->rootEglBase:Lio/agora/base/internal/video/EglBase;

    .line 118
    invoke-interface {p1}, Lio/agora/base/internal/video/EglBase;->getEglBaseContext()Lio/agora/base/internal/video/EglBase$Context;

    move-result-object p1

    invoke-static {p1}, Lio/agora/base/internal/video/EglBaseFactory;->create(Lio/agora/base/internal/video/EglBase$Context;)Lio/agora/base/internal/video/EglBase;

    move-result-object p1

    iput-object p1, p0, Lio/agora/rtc2/gl/EglBaseProvider;->localEglBase:Lio/agora/base/internal/video/EglBase;

    .line 119
    iget-object p1, p0, Lio/agora/rtc2/gl/EglBaseProvider;->rootEglBase:Lio/agora/base/internal/video/EglBase;

    invoke-interface {p1}, Lio/agora/base/internal/video/EglBase;->getEglBaseContext()Lio/agora/base/internal/video/EglBase$Context;

    move-result-object p1

    invoke-static {p1}, Lio/agora/base/internal/video/EglBaseFactory;->create(Lio/agora/base/internal/video/EglBase$Context;)Lio/agora/base/internal/video/EglBase;

    move-result-object p1

    iput-object p1, p0, Lio/agora/rtc2/gl/EglBaseProvider;->remoteEglBase:Lio/agora/base/internal/video/EglBase;

    const/4 p1, 0x1

    .line 120
    iput-boolean p1, p0, Lio/agora/rtc2/gl/EglBaseProvider;->initialized:Z

    .line 121
    monitor-exit v0

    return-void

    :catchall_29
    move-exception p1

    monitor-exit v0
    :try_end_2b
    .catchall {:try_start_3 .. :try_end_2b} :catchall_29

    throw p1
.end method