948 lines
28 KiB
Smali
948 lines
28 KiB
Smali
.class public Lorg/webrtc/Camera1Session;
|
|
.super Ljava/lang/Object;
|
|
.source "Camera1Session.java"
|
|
|
|
# interfaces
|
|
.implements Lorg/webrtc/CameraSession;
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Lorg/webrtc/Camera1Session$SessionState;
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# static fields
|
|
.field public static final NUMBER_OF_CAPTURE_BUFFERS:I = 0x3
|
|
|
|
.field public static final TAG:Ljava/lang/String; = "Camera1Session"
|
|
|
|
.field public static final camera1ResolutionHistogram:Lorg/webrtc/Histogram;
|
|
|
|
.field public static final camera1StartTimeMsHistogram:Lorg/webrtc/Histogram;
|
|
|
|
.field public static final camera1StopTimeMsHistogram:Lorg/webrtc/Histogram;
|
|
|
|
|
|
# instance fields
|
|
.field public final applicationContext:Landroid/content/Context;
|
|
|
|
.field public final camera:Landroid/hardware/Camera;
|
|
|
|
.field public final cameraId:I
|
|
|
|
.field public final cameraThreadHandler:Landroid/os/Handler;
|
|
|
|
.field public final captureFormat:Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;
|
|
|
|
.field public final captureToTexture:Z
|
|
|
|
.field public final constructionTimeNs:J
|
|
|
|
.field public final events:Lorg/webrtc/CameraSession$Events;
|
|
|
|
.field public firstFrameReported:Z
|
|
|
|
.field public final info:Landroid/hardware/Camera$CameraInfo;
|
|
|
|
.field public state:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
.field public final surfaceTextureHelper:Lorg/webrtc/SurfaceTextureHelper;
|
|
|
|
|
|
# direct methods
|
|
.method public static constructor <clinit>()V
|
|
.locals 4
|
|
|
|
const/16 v0, 0x32
|
|
|
|
const/16 v1, 0x2710
|
|
|
|
const/4 v2, 0x1
|
|
|
|
const-string v3, "WebRTC.Android.Camera1.StartTimeMs"
|
|
|
|
invoke-static {v3, v2, v1, v0}, Lorg/webrtc/Histogram;->createCounts(Ljava/lang/String;III)Lorg/webrtc/Histogram;
|
|
|
|
move-result-object v3
|
|
|
|
sput-object v3, Lorg/webrtc/Camera1Session;->camera1StartTimeMsHistogram:Lorg/webrtc/Histogram;
|
|
|
|
const-string v3, "WebRTC.Android.Camera1.StopTimeMs"
|
|
|
|
invoke-static {v3, v2, v1, v0}, Lorg/webrtc/Histogram;->createCounts(Ljava/lang/String;III)Lorg/webrtc/Histogram;
|
|
|
|
move-result-object v0
|
|
|
|
sput-object v0, Lorg/webrtc/Camera1Session;->camera1StopTimeMsHistogram:Lorg/webrtc/Histogram;
|
|
|
|
sget-object v0, Lorg/webrtc/CameraEnumerationAndroid;->COMMON_RESOLUTIONS:Ljava/util/ArrayList;
|
|
|
|
invoke-virtual {v0}, Ljava/util/ArrayList;->size()I
|
|
|
|
move-result v0
|
|
|
|
const-string v1, "WebRTC.Android.Camera1.Resolution"
|
|
|
|
invoke-static {v1, v0}, Lorg/webrtc/Histogram;->createEnumeration(Ljava/lang/String;I)Lorg/webrtc/Histogram;
|
|
|
|
move-result-object v0
|
|
|
|
sput-object v0, Lorg/webrtc/Camera1Session;->camera1ResolutionHistogram:Lorg/webrtc/Histogram;
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public constructor <init>(Lorg/webrtc/CameraSession$Events;ZLandroid/content/Context;Lorg/webrtc/SurfaceTextureHelper;ILandroid/hardware/Camera;Landroid/hardware/Camera$CameraInfo;Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;J)V
|
|
.locals 2
|
|
|
|
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
|
|
|
|
new-instance v0, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v1, "Create new camera1 session on camera "
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0, p5}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "Camera1Session"
|
|
|
|
invoke-static {v1, v0}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
new-instance v0, Landroid/os/Handler;
|
|
|
|
invoke-direct {v0}, Landroid/os/Handler;-><init>()V
|
|
|
|
iput-object v0, p0, Lorg/webrtc/Camera1Session;->cameraThreadHandler:Landroid/os/Handler;
|
|
|
|
iput-object p1, p0, Lorg/webrtc/Camera1Session;->events:Lorg/webrtc/CameraSession$Events;
|
|
|
|
iput-boolean p2, p0, Lorg/webrtc/Camera1Session;->captureToTexture:Z
|
|
|
|
iput-object p3, p0, Lorg/webrtc/Camera1Session;->applicationContext:Landroid/content/Context;
|
|
|
|
iput-object p4, p0, Lorg/webrtc/Camera1Session;->surfaceTextureHelper:Lorg/webrtc/SurfaceTextureHelper;
|
|
|
|
iput p5, p0, Lorg/webrtc/Camera1Session;->cameraId:I
|
|
|
|
iput-object p6, p0, Lorg/webrtc/Camera1Session;->camera:Landroid/hardware/Camera;
|
|
|
|
iput-object p7, p0, Lorg/webrtc/Camera1Session;->info:Landroid/hardware/Camera$CameraInfo;
|
|
|
|
iput-object p8, p0, Lorg/webrtc/Camera1Session;->captureFormat:Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;
|
|
|
|
iput-wide p9, p0, Lorg/webrtc/Camera1Session;->constructionTimeNs:J
|
|
|
|
iget p1, p8, Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;->width:I
|
|
|
|
iget p2, p8, Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;->height:I
|
|
|
|
invoke-virtual {p4, p1, p2}, Lorg/webrtc/SurfaceTextureHelper;->setTextureSize(II)V
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->startCapturing()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static synthetic access$000(Lorg/webrtc/Camera1Session;)V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->stopInternal()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static synthetic access$100(Lorg/webrtc/Camera1Session;)Lorg/webrtc/CameraSession$Events;
|
|
.locals 0
|
|
|
|
iget-object p0, p0, Lorg/webrtc/Camera1Session;->events:Lorg/webrtc/CameraSession$Events;
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static synthetic access$1000(Lorg/webrtc/Camera1Session;)Landroid/os/Handler;
|
|
.locals 0
|
|
|
|
iget-object p0, p0, Lorg/webrtc/Camera1Session;->cameraThreadHandler:Landroid/os/Handler;
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static synthetic access$200(Lorg/webrtc/Camera1Session;)V
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->checkIsOnCameraThread()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static synthetic access$300(Lorg/webrtc/Camera1Session;)Landroid/hardware/Camera;
|
|
.locals 0
|
|
|
|
iget-object p0, p0, Lorg/webrtc/Camera1Session;->camera:Landroid/hardware/Camera;
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static synthetic access$400(Lorg/webrtc/Camera1Session;)Lorg/webrtc/Camera1Session$SessionState;
|
|
.locals 0
|
|
|
|
iget-object p0, p0, Lorg/webrtc/Camera1Session;->state:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static synthetic access$500(Lorg/webrtc/Camera1Session;)Z
|
|
.locals 0
|
|
|
|
iget-boolean p0, p0, Lorg/webrtc/Camera1Session;->firstFrameReported:Z
|
|
|
|
return p0
|
|
.end method
|
|
|
|
.method public static synthetic access$502(Lorg/webrtc/Camera1Session;Z)Z
|
|
.locals 0
|
|
|
|
iput-boolean p1, p0, Lorg/webrtc/Camera1Session;->firstFrameReported:Z
|
|
|
|
return p1
|
|
.end method
|
|
|
|
.method public static synthetic access$600(Lorg/webrtc/Camera1Session;)J
|
|
.locals 2
|
|
|
|
iget-wide v0, p0, Lorg/webrtc/Camera1Session;->constructionTimeNs:J
|
|
|
|
return-wide v0
|
|
.end method
|
|
|
|
.method public static synthetic access$700()Lorg/webrtc/Histogram;
|
|
.locals 1
|
|
|
|
sget-object v0, Lorg/webrtc/Camera1Session;->camera1StartTimeMsHistogram:Lorg/webrtc/Histogram;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public static synthetic access$800(Lorg/webrtc/Camera1Session;)Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;
|
|
.locals 0
|
|
|
|
iget-object p0, p0, Lorg/webrtc/Camera1Session;->captureFormat:Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method public static synthetic access$900(Lorg/webrtc/Camera1Session;)I
|
|
.locals 0
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->getFrameOrientation()I
|
|
|
|
move-result p0
|
|
|
|
return p0
|
|
.end method
|
|
|
|
.method private checkIsOnCameraThread()V
|
|
.locals 2
|
|
|
|
invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
|
|
|
|
move-result-object v0
|
|
|
|
iget-object v1, p0, Lorg/webrtc/Camera1Session;->cameraThreadHandler:Landroid/os/Handler;
|
|
|
|
invoke-virtual {v1}, Landroid/os/Handler;->getLooper()Landroid/os/Looper;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v1}, Landroid/os/Looper;->getThread()Ljava/lang/Thread;
|
|
|
|
move-result-object v1
|
|
|
|
if-ne v0, v1, :cond_0
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
new-instance v0, Ljava/lang/IllegalStateException;
|
|
|
|
const-string v1, "Wrong thread"
|
|
|
|
invoke-direct {v0, v1}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public static create(Lorg/webrtc/CameraSession$CreateSessionCallback;Lorg/webrtc/CameraSession$Events;ZLandroid/content/Context;Lorg/webrtc/SurfaceTextureHelper;IIII)V
|
|
.locals 14
|
|
|
|
move-object v1, p0
|
|
|
|
move/from16 v0, p2
|
|
|
|
move/from16 v7, p5
|
|
|
|
move/from16 v2, p6
|
|
|
|
move/from16 v3, p7
|
|
|
|
invoke-static {}, Ljava/lang/System;->nanoTime()J
|
|
|
|
move-result-wide v11
|
|
|
|
new-instance v4, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v4}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v5, "Open camera "
|
|
|
|
invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v4, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v4
|
|
|
|
const-string v5, "Camera1Session"
|
|
|
|
invoke-static {v5, v4}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
invoke-interface {p1}, Lorg/webrtc/CameraSession$Events;->onCameraOpening()V
|
|
|
|
:try_start_0
|
|
invoke-static/range {p5 .. p5}, Landroid/hardware/Camera;->open(I)Landroid/hardware/Camera;
|
|
|
|
move-result-object v8
|
|
:try_end_0
|
|
.catch Ljava/lang/RuntimeException; {:try_start_0 .. :try_end_0} :catch_3
|
|
|
|
if-nez v8, :cond_0
|
|
|
|
sget-object v0, Lorg/webrtc/CameraSession$FailureType;->ERROR:Lorg/webrtc/CameraSession$FailureType;
|
|
|
|
new-instance v2, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v3, "android.hardware.Camera.open returned null for camera id = "
|
|
|
|
invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v2, v7}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-interface {p0, v0, v2}, Lorg/webrtc/CameraSession$CreateSessionCallback;->onFailure(Lorg/webrtc/CameraSession$FailureType;Ljava/lang/String;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
:try_start_1
|
|
invoke-virtual/range {p4 .. p4}, Lorg/webrtc/SurfaceTextureHelper;->getSurfaceTexture()Landroid/graphics/SurfaceTexture;
|
|
|
|
move-result-object v4
|
|
|
|
invoke-virtual {v8, v4}, Landroid/hardware/Camera;->setPreviewTexture(Landroid/graphics/SurfaceTexture;)V
|
|
:try_end_1
|
|
.catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_2
|
|
.catch Ljava/lang/RuntimeException; {:try_start_1 .. :try_end_1} :catch_1
|
|
|
|
new-instance v9, Landroid/hardware/Camera$CameraInfo;
|
|
|
|
invoke-direct {v9}, Landroid/hardware/Camera$CameraInfo;-><init>()V
|
|
|
|
invoke-static {v7, v9}, Landroid/hardware/Camera;->getCameraInfo(ILandroid/hardware/Camera$CameraInfo;)V
|
|
|
|
:try_start_2
|
|
invoke-virtual {v8}, Landroid/hardware/Camera;->getParameters()Landroid/hardware/Camera$Parameters;
|
|
|
|
move-result-object v4
|
|
|
|
move/from16 v5, p8
|
|
|
|
invoke-static {v4, v2, v3, v5}, Lorg/webrtc/Camera1Session;->findClosestCaptureFormat(Landroid/hardware/Camera$Parameters;III)Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;
|
|
|
|
move-result-object v10
|
|
|
|
invoke-static {v4, v2, v3}, Lorg/webrtc/Camera1Session;->findClosestPictureSize(Landroid/hardware/Camera$Parameters;II)Lorg/webrtc/Size;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-static {v8, v4, v10, v2, v0}, Lorg/webrtc/Camera1Session;->updateCameraParameters(Landroid/hardware/Camera;Landroid/hardware/Camera$Parameters;Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;Lorg/webrtc/Size;Z)V
|
|
:try_end_2
|
|
.catch Ljava/lang/RuntimeException; {:try_start_2 .. :try_end_2} :catch_0
|
|
|
|
const/4 v2, 0x0
|
|
|
|
if-nez v0, :cond_1
|
|
|
|
invoke-virtual {v10}, Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;->frameSize()I
|
|
|
|
move-result v3
|
|
|
|
const/4 v4, 0x0
|
|
|
|
:goto_0
|
|
const/4 v5, 0x3
|
|
|
|
if-ge v4, v5, :cond_1
|
|
|
|
invoke-static {v3}, Ljava/nio/ByteBuffer;->allocateDirect(I)Ljava/nio/ByteBuffer;
|
|
|
|
move-result-object v5
|
|
|
|
invoke-virtual {v5}, Ljava/nio/ByteBuffer;->array()[B
|
|
|
|
move-result-object v5
|
|
|
|
invoke-virtual {v8, v5}, Landroid/hardware/Camera;->addCallbackBuffer([B)V
|
|
|
|
add-int/lit8 v4, v4, 0x1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
invoke-virtual {v8, v2}, Landroid/hardware/Camera;->setDisplayOrientation(I)V
|
|
|
|
new-instance v13, Lorg/webrtc/Camera1Session;
|
|
|
|
move-object v2, v13
|
|
|
|
move-object v3, p1
|
|
|
|
move/from16 v4, p2
|
|
|
|
move-object/from16 v5, p3
|
|
|
|
move-object/from16 v6, p4
|
|
|
|
move/from16 v7, p5
|
|
|
|
invoke-direct/range {v2 .. v12}, Lorg/webrtc/Camera1Session;-><init>(Lorg/webrtc/CameraSession$Events;ZLandroid/content/Context;Lorg/webrtc/SurfaceTextureHelper;ILandroid/hardware/Camera;Landroid/hardware/Camera$CameraInfo;Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;J)V
|
|
|
|
invoke-interface {p0, v13}, Lorg/webrtc/CameraSession$CreateSessionCallback;->onDone(Lorg/webrtc/CameraSession;)V
|
|
|
|
return-void
|
|
|
|
:catch_0
|
|
move-exception v0
|
|
|
|
invoke-virtual {v8}, Landroid/hardware/Camera;->release()V
|
|
|
|
sget-object v2, Lorg/webrtc/CameraSession$FailureType;->ERROR:Lorg/webrtc/CameraSession$FailureType;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/RuntimeException;->getMessage()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-interface {p0, v2, v0}, Lorg/webrtc/CameraSession$CreateSessionCallback;->onFailure(Lorg/webrtc/CameraSession$FailureType;Ljava/lang/String;)V
|
|
|
|
return-void
|
|
|
|
:catch_1
|
|
move-exception v0
|
|
|
|
goto :goto_1
|
|
|
|
:catch_2
|
|
move-exception v0
|
|
|
|
:goto_1
|
|
invoke-virtual {v8}, Landroid/hardware/Camera;->release()V
|
|
|
|
sget-object v2, Lorg/webrtc/CameraSession$FailureType;->ERROR:Lorg/webrtc/CameraSession$FailureType;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-interface {p0, v2, v0}, Lorg/webrtc/CameraSession$CreateSessionCallback;->onFailure(Lorg/webrtc/CameraSession$FailureType;Ljava/lang/String;)V
|
|
|
|
return-void
|
|
|
|
:catch_3
|
|
move-exception v0
|
|
|
|
move-object v2, v0
|
|
|
|
sget-object v0, Lorg/webrtc/CameraSession$FailureType;->ERROR:Lorg/webrtc/CameraSession$FailureType;
|
|
|
|
invoke-virtual {v2}, Ljava/lang/RuntimeException;->getMessage()Ljava/lang/String;
|
|
|
|
move-result-object v2
|
|
|
|
invoke-interface {p0, v0, v2}, Lorg/webrtc/CameraSession$CreateSessionCallback;->onFailure(Lorg/webrtc/CameraSession$FailureType;Ljava/lang/String;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static findClosestCaptureFormat(Landroid/hardware/Camera$Parameters;III)Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;
|
|
.locals 3
|
|
|
|
invoke-virtual {p0}, Landroid/hardware/Camera$Parameters;->getSupportedPreviewFpsRange()Ljava/util/List;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-static {v0}, Lorg/webrtc/Camera1Enumerator;->convertFramerates(Ljava/util/List;)Ljava/util/List;
|
|
|
|
move-result-object v0
|
|
|
|
new-instance v1, Ljava/lang/StringBuilder;
|
|
|
|
invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
|
|
|
|
const-string v2, "Available fps ranges: "
|
|
|
|
invoke-virtual {v1, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v1
|
|
|
|
const-string v2, "Camera1Session"
|
|
|
|
invoke-static {v2, v1}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
invoke-static {v0, p3}, Lorg/webrtc/CameraEnumerationAndroid;->getClosestSupportedFramerateRange(Ljava/util/List;I)Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange;
|
|
|
|
move-result-object p3
|
|
|
|
invoke-virtual {p0}, Landroid/hardware/Camera$Parameters;->getSupportedPreviewSizes()Ljava/util/List;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {p0}, Lorg/webrtc/Camera1Enumerator;->convertSizes(Ljava/util/List;)Ljava/util/List;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {p0, p1, p2}, Lorg/webrtc/CameraEnumerationAndroid;->getClosestSupportedSize(Ljava/util/List;II)Lorg/webrtc/Size;
|
|
|
|
move-result-object p0
|
|
|
|
sget-object p1, Lorg/webrtc/Camera1Session;->camera1ResolutionHistogram:Lorg/webrtc/Histogram;
|
|
|
|
invoke-static {p1, p0}, Lorg/webrtc/CameraEnumerationAndroid;->reportCameraResolution(Lorg/webrtc/Histogram;Lorg/webrtc/Size;)V
|
|
|
|
new-instance p1, Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;
|
|
|
|
iget p2, p0, Lorg/webrtc/Size;->width:I
|
|
|
|
iget p0, p0, Lorg/webrtc/Size;->height:I
|
|
|
|
invoke-direct {p1, p2, p0, p3}, Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;-><init>(IILorg/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange;)V
|
|
|
|
return-object p1
|
|
.end method
|
|
|
|
.method public static findClosestPictureSize(Landroid/hardware/Camera$Parameters;II)Lorg/webrtc/Size;
|
|
.locals 0
|
|
|
|
invoke-virtual {p0}, Landroid/hardware/Camera$Parameters;->getSupportedPictureSizes()Ljava/util/List;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {p0}, Lorg/webrtc/Camera1Enumerator;->convertSizes(Ljava/util/List;)Ljava/util/List;
|
|
|
|
move-result-object p0
|
|
|
|
invoke-static {p0, p1, p2}, Lorg/webrtc/CameraEnumerationAndroid;->getClosestSupportedSize(Ljava/util/List;II)Lorg/webrtc/Size;
|
|
|
|
move-result-object p0
|
|
|
|
return-object p0
|
|
.end method
|
|
|
|
.method private getFrameOrientation()I
|
|
.locals 2
|
|
|
|
iget-object v0, p0, Lorg/webrtc/Camera1Session;->applicationContext:Landroid/content/Context;
|
|
|
|
invoke-static {v0}, Le0/d/g0;->a(Landroid/content/Context;)I
|
|
|
|
move-result v0
|
|
|
|
iget-object v1, p0, Lorg/webrtc/Camera1Session;->info:Landroid/hardware/Camera$CameraInfo;
|
|
|
|
iget v1, v1, Landroid/hardware/Camera$CameraInfo;->facing:I
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
rsub-int v0, v0, 0x168
|
|
|
|
:cond_0
|
|
iget-object v1, p0, Lorg/webrtc/Camera1Session;->info:Landroid/hardware/Camera$CameraInfo;
|
|
|
|
iget v1, v1, Landroid/hardware/Camera$CameraInfo;->orientation:I
|
|
|
|
add-int/2addr v1, v0
|
|
|
|
rem-int/lit16 v1, v1, 0x168
|
|
|
|
return v1
|
|
.end method
|
|
|
|
.method private listenForBytebufferFrames()V
|
|
.locals 2
|
|
|
|
iget-object v0, p0, Lorg/webrtc/Camera1Session;->camera:Landroid/hardware/Camera;
|
|
|
|
new-instance v1, Lorg/webrtc/Camera1Session$2;
|
|
|
|
invoke-direct {v1, p0}, Lorg/webrtc/Camera1Session$2;-><init>(Lorg/webrtc/Camera1Session;)V
|
|
|
|
invoke-virtual {v0, v1}, Landroid/hardware/Camera;->setPreviewCallbackWithBuffer(Landroid/hardware/Camera$PreviewCallback;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private listenForTextureFrames()V
|
|
.locals 2
|
|
|
|
iget-object v0, p0, Lorg/webrtc/Camera1Session;->surfaceTextureHelper:Lorg/webrtc/SurfaceTextureHelper;
|
|
|
|
new-instance v1, Le0/d/e;
|
|
|
|
invoke-direct {v1, p0}, Le0/d/e;-><init>(Lorg/webrtc/Camera1Session;)V
|
|
|
|
invoke-virtual {v0, v1}, Lorg/webrtc/SurfaceTextureHelper;->startListening(Lorg/webrtc/VideoSink;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method private startCapturing()V
|
|
.locals 2
|
|
|
|
const-string v0, "Camera1Session"
|
|
|
|
const-string v1, "Start capturing"
|
|
|
|
invoke-static {v0, v1}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->checkIsOnCameraThread()V
|
|
|
|
sget-object v0, Lorg/webrtc/Camera1Session$SessionState;->RUNNING:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
iput-object v0, p0, Lorg/webrtc/Camera1Session;->state:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
iget-object v0, p0, Lorg/webrtc/Camera1Session;->camera:Landroid/hardware/Camera;
|
|
|
|
new-instance v1, Lorg/webrtc/Camera1Session$1;
|
|
|
|
invoke-direct {v1, p0}, Lorg/webrtc/Camera1Session$1;-><init>(Lorg/webrtc/Camera1Session;)V
|
|
|
|
invoke-virtual {v0, v1}, Landroid/hardware/Camera;->setErrorCallback(Landroid/hardware/Camera$ErrorCallback;)V
|
|
|
|
iget-boolean v0, p0, Lorg/webrtc/Camera1Session;->captureToTexture:Z
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->listenForTextureFrames()V
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->listenForBytebufferFrames()V
|
|
|
|
:goto_0
|
|
:try_start_0
|
|
iget-object v0, p0, Lorg/webrtc/Camera1Session;->camera:Landroid/hardware/Camera;
|
|
|
|
invoke-virtual {v0}, Landroid/hardware/Camera;->startPreview()V
|
|
:try_end_0
|
|
.catch Ljava/lang/RuntimeException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
goto :goto_1
|
|
|
|
:catch_0
|
|
move-exception v0
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->stopInternal()V
|
|
|
|
iget-object v1, p0, Lorg/webrtc/Camera1Session;->events:Lorg/webrtc/CameraSession$Events;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/RuntimeException;->getMessage()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-interface {v1, p0, v0}, Lorg/webrtc/CameraSession$Events;->onCameraError(Lorg/webrtc/CameraSession;Ljava/lang/String;)V
|
|
|
|
:goto_1
|
|
return-void
|
|
.end method
|
|
|
|
.method private stopInternal()V
|
|
.locals 3
|
|
|
|
const-string v0, "Camera1Session"
|
|
|
|
const-string v1, "Stop internal"
|
|
|
|
invoke-static {v0, v1}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->checkIsOnCameraThread()V
|
|
|
|
iget-object v1, p0, Lorg/webrtc/Camera1Session;->state:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
sget-object v2, Lorg/webrtc/Camera1Session$SessionState;->STOPPED:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
if-ne v1, v2, :cond_0
|
|
|
|
const-string v1, "Camera is already stopped"
|
|
|
|
invoke-static {v0, v1}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
iput-object v2, p0, Lorg/webrtc/Camera1Session;->state:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
iget-object v1, p0, Lorg/webrtc/Camera1Session;->surfaceTextureHelper:Lorg/webrtc/SurfaceTextureHelper;
|
|
|
|
invoke-virtual {v1}, Lorg/webrtc/SurfaceTextureHelper;->stopListening()V
|
|
|
|
iget-object v1, p0, Lorg/webrtc/Camera1Session;->camera:Landroid/hardware/Camera;
|
|
|
|
invoke-virtual {v1}, Landroid/hardware/Camera;->stopPreview()V
|
|
|
|
iget-object v1, p0, Lorg/webrtc/Camera1Session;->camera:Landroid/hardware/Camera;
|
|
|
|
invoke-virtual {v1}, Landroid/hardware/Camera;->release()V
|
|
|
|
iget-object v1, p0, Lorg/webrtc/Camera1Session;->events:Lorg/webrtc/CameraSession$Events;
|
|
|
|
invoke-interface {v1, p0}, Lorg/webrtc/CameraSession$Events;->onCameraClosed(Lorg/webrtc/CameraSession;)V
|
|
|
|
const-string v1, "Stop done"
|
|
|
|
invoke-static {v0, v1}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public static updateCameraParameters(Landroid/hardware/Camera;Landroid/hardware/Camera$Parameters;Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;Lorg/webrtc/Size;Z)V
|
|
.locals 3
|
|
|
|
invoke-virtual {p1}, Landroid/hardware/Camera$Parameters;->getSupportedFocusModes()Ljava/util/List;
|
|
|
|
move-result-object v0
|
|
|
|
iget-object v1, p2, Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;->framerate:Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange;
|
|
|
|
iget v2, v1, Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange;->min:I
|
|
|
|
iget v1, v1, Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat$FramerateRange;->max:I
|
|
|
|
invoke-virtual {p1, v2, v1}, Landroid/hardware/Camera$Parameters;->setPreviewFpsRange(II)V
|
|
|
|
iget v1, p2, Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;->width:I
|
|
|
|
iget p2, p2, Lorg/webrtc/CameraEnumerationAndroid$CaptureFormat;->height:I
|
|
|
|
invoke-virtual {p1, v1, p2}, Landroid/hardware/Camera$Parameters;->setPreviewSize(II)V
|
|
|
|
iget p2, p3, Lorg/webrtc/Size;->width:I
|
|
|
|
iget p3, p3, Lorg/webrtc/Size;->height:I
|
|
|
|
invoke-virtual {p1, p2, p3}, Landroid/hardware/Camera$Parameters;->setPictureSize(II)V
|
|
|
|
if-nez p4, :cond_0
|
|
|
|
const/16 p2, 0x11
|
|
|
|
invoke-virtual {p1, p2}, Landroid/hardware/Camera$Parameters;->setPreviewFormat(I)V
|
|
|
|
:cond_0
|
|
invoke-virtual {p1}, Landroid/hardware/Camera$Parameters;->isVideoStabilizationSupported()Z
|
|
|
|
move-result p2
|
|
|
|
if-eqz p2, :cond_1
|
|
|
|
const/4 p2, 0x1
|
|
|
|
invoke-virtual {p1, p2}, Landroid/hardware/Camera$Parameters;->setVideoStabilization(Z)V
|
|
|
|
:cond_1
|
|
const-string p2, "continuous-video"
|
|
|
|
invoke-interface {v0, p2}, Ljava/util/List;->contains(Ljava/lang/Object;)Z
|
|
|
|
move-result p3
|
|
|
|
if-eqz p3, :cond_2
|
|
|
|
invoke-virtual {p1, p2}, Landroid/hardware/Camera$Parameters;->setFocusMode(Ljava/lang/String;)V
|
|
|
|
:cond_2
|
|
invoke-virtual {p0, p1}, Landroid/hardware/Camera;->setParameters(Landroid/hardware/Camera$Parameters;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public synthetic a(Lorg/webrtc/VideoFrame;)V
|
|
.locals 6
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->checkIsOnCameraThread()V
|
|
|
|
iget-object v0, p0, Lorg/webrtc/Camera1Session;->state:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
sget-object v1, Lorg/webrtc/Camera1Session$SessionState;->RUNNING:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
if-eq v0, v1, :cond_0
|
|
|
|
const-string p1, "Camera1Session"
|
|
|
|
const-string v0, "Texture frame captured but camera is no longer running."
|
|
|
|
invoke-static {p1, v0}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
iget-boolean v0, p0, Lorg/webrtc/Camera1Session;->firstFrameReported:Z
|
|
|
|
const/4 v1, 0x1
|
|
|
|
if-nez v0, :cond_1
|
|
|
|
sget-object v0, Ljava/util/concurrent/TimeUnit;->NANOSECONDS:Ljava/util/concurrent/TimeUnit;
|
|
|
|
invoke-static {}, Ljava/lang/System;->nanoTime()J
|
|
|
|
move-result-wide v2
|
|
|
|
iget-wide v4, p0, Lorg/webrtc/Camera1Session;->constructionTimeNs:J
|
|
|
|
sub-long/2addr v2, v4
|
|
|
|
invoke-virtual {v0, v2, v3}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
|
|
|
|
move-result-wide v2
|
|
|
|
long-to-int v0, v2
|
|
|
|
sget-object v2, Lorg/webrtc/Camera1Session;->camera1StartTimeMsHistogram:Lorg/webrtc/Histogram;
|
|
|
|
invoke-virtual {v2, v0}, Lorg/webrtc/Histogram;->addSample(I)V
|
|
|
|
iput-boolean v1, p0, Lorg/webrtc/Camera1Session;->firstFrameReported:Z
|
|
|
|
:cond_1
|
|
new-instance v0, Lorg/webrtc/VideoFrame;
|
|
|
|
invoke-virtual {p1}, Lorg/webrtc/VideoFrame;->getBuffer()Lorg/webrtc/VideoFrame$Buffer;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Lorg/webrtc/TextureBufferImpl;
|
|
|
|
iget-object v3, p0, Lorg/webrtc/Camera1Session;->info:Landroid/hardware/Camera$CameraInfo;
|
|
|
|
iget v3, v3, Landroid/hardware/Camera$CameraInfo;->facing:I
|
|
|
|
const/4 v4, 0x0
|
|
|
|
if-ne v3, v1, :cond_2
|
|
|
|
goto :goto_0
|
|
|
|
:cond_2
|
|
const/4 v1, 0x0
|
|
|
|
:goto_0
|
|
invoke-static {v2, v1, v4}, Le0/d/g0;->a(Lorg/webrtc/TextureBufferImpl;ZI)Lorg/webrtc/VideoFrame$TextureBuffer;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->getFrameOrientation()I
|
|
|
|
move-result v2
|
|
|
|
invoke-virtual {p1}, Lorg/webrtc/VideoFrame;->getTimestampNs()J
|
|
|
|
move-result-wide v3
|
|
|
|
invoke-direct {v0, v1, v2, v3, v4}, Lorg/webrtc/VideoFrame;-><init>(Lorg/webrtc/VideoFrame$Buffer;IJ)V
|
|
|
|
iget-object p1, p0, Lorg/webrtc/Camera1Session;->events:Lorg/webrtc/CameraSession$Events;
|
|
|
|
invoke-interface {p1, p0, v0}, Lorg/webrtc/CameraSession$Events;->onFrameCaptured(Lorg/webrtc/CameraSession;Lorg/webrtc/VideoFrame;)V
|
|
|
|
invoke-virtual {v0}, Lorg/webrtc/VideoFrame;->release()V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public stop()V
|
|
.locals 5
|
|
|
|
const-string v0, "Stop camera1 session on camera "
|
|
|
|
invoke-static {v0}, Lf/e/b/a/a;->a(Ljava/lang/String;)Ljava/lang/StringBuilder;
|
|
|
|
move-result-object v0
|
|
|
|
iget v1, p0, Lorg/webrtc/Camera1Session;->cameraId:I
|
|
|
|
invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
|
|
|
|
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
const-string v1, "Camera1Session"
|
|
|
|
invoke-static {v1, v0}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->checkIsOnCameraThread()V
|
|
|
|
iget-object v0, p0, Lorg/webrtc/Camera1Session;->state:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
sget-object v1, Lorg/webrtc/Camera1Session$SessionState;->STOPPED:Lorg/webrtc/Camera1Session$SessionState;
|
|
|
|
if-eq v0, v1, :cond_0
|
|
|
|
invoke-static {}, Ljava/lang/System;->nanoTime()J
|
|
|
|
move-result-wide v0
|
|
|
|
invoke-direct {p0}, Lorg/webrtc/Camera1Session;->stopInternal()V
|
|
|
|
sget-object v2, Ljava/util/concurrent/TimeUnit;->NANOSECONDS:Ljava/util/concurrent/TimeUnit;
|
|
|
|
invoke-static {}, Ljava/lang/System;->nanoTime()J
|
|
|
|
move-result-wide v3
|
|
|
|
sub-long/2addr v3, v0
|
|
|
|
invoke-virtual {v2, v3, v4}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
|
|
|
|
move-result-wide v0
|
|
|
|
long-to-int v1, v0
|
|
|
|
sget-object v0, Lorg/webrtc/Camera1Session;->camera1StopTimeMsHistogram:Lorg/webrtc/Histogram;
|
|
|
|
invoke-virtual {v0, v1}, Lorg/webrtc/Histogram;->addSample(I)V
|
|
|
|
:cond_0
|
|
return-void
|
|
.end method
|