2021-06-27 20:44:35 +00:00
|
|
|
package co.discord.media_engine;
|
|
|
|
|
|
|
|
import android.content.Context;
|
|
|
|
import androidx.annotation.AnyThread;
|
2021-10-19 23:48:27 +00:00
|
|
|
import c0.z.d.m;
|
2021-06-27 20:44:35 +00:00
|
|
|
import co.discord.media_engine.internal.ExtensionFunctionsKt;
|
|
|
|
import org.webrtc.Camera1Enumerator;
|
|
|
|
import org.webrtc.Camera2Enumerator;
|
|
|
|
import org.webrtc.CameraEnumerator;
|
|
|
|
import org.webrtc.CameraVideoCapturer;
|
|
|
|
/* compiled from: CameraEnumeratorProvider.kt */
|
|
|
|
public final class CameraEnumeratorProvider {
|
|
|
|
public static final CameraEnumeratorProvider INSTANCE = new CameraEnumeratorProvider();
|
|
|
|
private static final String TAG = "CameraEnumeratorProvider";
|
|
|
|
private static CameraEnumerator enumerator;
|
|
|
|
|
|
|
|
private CameraEnumeratorProvider() {
|
|
|
|
}
|
|
|
|
|
|
|
|
@AnyThread
|
|
|
|
public static final CameraVideoCapturer createCapturer(String str) {
|
|
|
|
m.checkNotNullParameter(str, "cameraName");
|
|
|
|
CameraVideoCapturer createCapturer = get().createCapturer(str, null);
|
|
|
|
m.checkNotNullExpressionValue(createCapturer, "get().createCapturer(cameraName, null)");
|
|
|
|
return createCapturer;
|
|
|
|
}
|
|
|
|
|
|
|
|
@AnyThread
|
|
|
|
public static final synchronized CameraEnumerator get() {
|
|
|
|
CameraEnumerator cameraEnumerator;
|
|
|
|
synchronized (CameraEnumeratorProvider.class) {
|
|
|
|
cameraEnumerator = enumerator;
|
|
|
|
if (cameraEnumerator == null) {
|
2021-08-09 22:50:01 +00:00
|
|
|
ExtensionFunctionsKt.logi(TAG, "init was never called. Use Camera 1 API by default.");
|
2021-06-27 20:44:35 +00:00
|
|
|
cameraEnumerator = new Camera1Enumerator();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return cameraEnumerator;
|
|
|
|
}
|
|
|
|
|
|
|
|
@AnyThread
|
|
|
|
public static final synchronized void maybeInit(Context context) {
|
|
|
|
synchronized (CameraEnumeratorProvider.class) {
|
|
|
|
m.checkNotNullParameter(context, "context");
|
|
|
|
if (enumerator == null) {
|
|
|
|
INSTANCE.init(context, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@AnyThread
|
|
|
|
public final synchronized void init(Context context, boolean z2) {
|
|
|
|
CameraEnumerator cameraEnumerator;
|
|
|
|
m.checkNotNullParameter(context, "context");
|
|
|
|
if (z2) {
|
2021-08-09 22:50:01 +00:00
|
|
|
ExtensionFunctionsKt.logi(TAG, "Override: Forcing Camera 1 API");
|
2021-06-27 20:44:35 +00:00
|
|
|
cameraEnumerator = new Camera1Enumerator();
|
|
|
|
} else if (Camera2Enumerator.isSupported(context)) {
|
2021-08-09 22:50:01 +00:00
|
|
|
ExtensionFunctionsKt.logi(TAG, "Use Camera 2 API");
|
2021-06-27 20:44:35 +00:00
|
|
|
cameraEnumerator = new Camera2Enumerator(context.getApplicationContext());
|
|
|
|
} else {
|
2021-08-09 22:50:01 +00:00
|
|
|
ExtensionFunctionsKt.logi(TAG, "Camera 2 API is not supported. Use Camera 1 API");
|
2021-06-27 20:44:35 +00:00
|
|
|
cameraEnumerator = new Camera1Enumerator();
|
|
|
|
}
|
|
|
|
enumerator = cameraEnumerator;
|
|
|
|
}
|
|
|
|
}
|