Rabbit-R1/original r1/smali/smali_classes3/org/webrtc/VideoFileRenderer.smali
2024-05-21 17:08:36 -04:00

702 lines
19 KiB
Smali

.class public Lorg/webrtc/VideoFileRenderer;
.super Ljava/lang/Object;
.source "VideoFileRenderer.java"
# interfaces
.implements Lorg/webrtc/VideoSink;
# static fields
.field private static final TAG:Ljava/lang/String; = "VideoFileRenderer"
# instance fields
.field private eglBase:Lorg/webrtc/EglBase;
.field private final fileThread:Landroid/os/HandlerThread;
.field private final fileThreadHandler:Landroid/os/Handler;
.field private frameCount:I
.field private final outputFileHeight:I
.field private final outputFileName:Ljava/lang/String;
.field private final outputFileWidth:I
.field private final outputFrameBuffer:Ljava/nio/ByteBuffer;
.field private final outputFrameSize:I
.field private final renderThread:Landroid/os/HandlerThread;
.field private final renderThreadHandler:Landroid/os/Handler;
.field private final videoOutFile:Ljava/io/FileOutputStream;
.field private yuvConverter:Lorg/webrtc/YuvConverter;
# direct methods
.method public constructor <init>(Ljava/lang/String;IILorg/webrtc/EglBase$Context;)V
.locals 2
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 42
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 43
rem-int/lit8 v0, p2, 0x2
const/4 v1, 0x1
if-eq v0, v1, :cond_0
rem-int/lit8 v0, p3, 0x2
if-eq v0, v1, :cond_0
iput-object p1, p0, Lorg/webrtc/VideoFileRenderer;->outputFileName:Ljava/lang/String;
iput p2, p0, Lorg/webrtc/VideoFileRenderer;->outputFileWidth:I
iput p3, p0, Lorg/webrtc/VideoFileRenderer;->outputFileHeight:I
mul-int v0, p2, p3
mul-int/lit8 v0, v0, 0x3
.line 51
div-int/lit8 v0, v0, 0x2
iput v0, p0, Lorg/webrtc/VideoFileRenderer;->outputFrameSize:I
.line 52
invoke-static {v0}, Ljava/nio/ByteBuffer;->allocateDirect(I)Ljava/nio/ByteBuffer;
move-result-object v0
iput-object v0, p0, Lorg/webrtc/VideoFileRenderer;->outputFrameBuffer:Ljava/nio/ByteBuffer;
.line 54
new-instance v0, Ljava/io/FileOutputStream;
invoke-direct {v0, p1}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;)V
iput-object v0, p0, Lorg/webrtc/VideoFileRenderer;->videoOutFile:Ljava/io/FileOutputStream;
.line 55
new-instance p1, Ljava/lang/StringBuilder;
const-string v1, "YUV4MPEG2 C420 W"
invoke-direct {p1, v1}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
invoke-virtual {p1, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
move-result-object p1
const-string p2, " H"
invoke-virtual {p1, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object p1
invoke-virtual {p1, p3}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
move-result-object p1
const-string p2, " Ip F30:1 A1:1\n"
invoke-virtual {p1, p2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object p1
invoke-virtual {p1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
const-string p2, "US-ASCII"
.line 57
invoke-static {p2}, Ljava/nio/charset/Charset;->forName(Ljava/lang/String;)Ljava/nio/charset/Charset;
move-result-object p2
invoke-virtual {p1, p2}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B
move-result-object p1
.line 55
invoke-virtual {v0, p1}, Ljava/io/FileOutputStream;->write([B)V
.line 59
new-instance p1, Landroid/os/HandlerThread;
const-string p2, "VideoFileRendererRenderThread"
invoke-direct {p1, p2}, Landroid/os/HandlerThread;-><init>(Ljava/lang/String;)V
iput-object p1, p0, Lorg/webrtc/VideoFileRenderer;->renderThread:Landroid/os/HandlerThread;
.line 60
invoke-virtual {p1}, Landroid/os/HandlerThread;->start()V
.line 61
new-instance p2, Landroid/os/Handler;
invoke-virtual {p1}, Landroid/os/HandlerThread;->getLooper()Landroid/os/Looper;
move-result-object p1
invoke-direct {p2, p1}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V
iput-object p2, p0, Lorg/webrtc/VideoFileRenderer;->renderThreadHandler:Landroid/os/Handler;
.line 63
new-instance p1, Landroid/os/HandlerThread;
const-string p3, "VideoFileRendererFileThread"
invoke-direct {p1, p3}, Landroid/os/HandlerThread;-><init>(Ljava/lang/String;)V
iput-object p1, p0, Lorg/webrtc/VideoFileRenderer;->fileThread:Landroid/os/HandlerThread;
.line 64
invoke-virtual {p1}, Landroid/os/HandlerThread;->start()V
.line 65
new-instance p3, Landroid/os/Handler;
invoke-virtual {p1}, Landroid/os/HandlerThread;->getLooper()Landroid/os/Looper;
move-result-object p1
invoke-direct {p3, p1}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V
iput-object p3, p0, Lorg/webrtc/VideoFileRenderer;->fileThreadHandler:Landroid/os/Handler;
.line 67
new-instance p1, Lorg/webrtc/VideoFileRenderer$1;
invoke-direct {p1, p0, p4}, Lorg/webrtc/VideoFileRenderer$1;-><init>(Lorg/webrtc/VideoFileRenderer;Lorg/webrtc/EglBase$Context;)V
invoke-static {p2, p1}, Lorg/webrtc/ThreadUtils;->invokeAtFrontUninterruptibly(Landroid/os/Handler;Ljava/lang/Runnable;)V
return-void
.line 44
:cond_0
new-instance p0, Ljava/lang/IllegalArgumentException;
const-string p1, "Does not support uneven width or height"
invoke-direct {p0, p1}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p0
.end method
.method static synthetic access$000(Lorg/webrtc/VideoFileRenderer;)Lorg/webrtc/EglBase;
.locals 0
.line 24
iget-object p0, p0, Lorg/webrtc/VideoFileRenderer;->eglBase:Lorg/webrtc/EglBase;
return-object p0
.end method
.method static synthetic access$002(Lorg/webrtc/VideoFileRenderer;Lorg/webrtc/EglBase;)Lorg/webrtc/EglBase;
.locals 0
.line 24
iput-object p1, p0, Lorg/webrtc/VideoFileRenderer;->eglBase:Lorg/webrtc/EglBase;
return-object p1
.end method
.method static synthetic access$102(Lorg/webrtc/VideoFileRenderer;Lorg/webrtc/YuvConverter;)Lorg/webrtc/YuvConverter;
.locals 0
.line 24
iput-object p1, p0, Lorg/webrtc/VideoFileRenderer;->yuvConverter:Lorg/webrtc/YuvConverter;
return-object p1
.end method
.method private renderFrameOnRenderThread(Lorg/webrtc/VideoFrame;)V
.locals 8
.line 85
invoke-virtual {p1}, Lorg/webrtc/VideoFrame;->getBuffer()Lorg/webrtc/VideoFrame$Buffer;
move-result-object v0
.line 89
invoke-virtual {p1}, Lorg/webrtc/VideoFrame;->getRotation()I
move-result v1
rem-int/lit16 v1, v1, 0xb4
if-nez v1, :cond_0
iget v1, p0, Lorg/webrtc/VideoFileRenderer;->outputFileWidth:I
goto :goto_0
:cond_0
iget v1, p0, Lorg/webrtc/VideoFileRenderer;->outputFileHeight:I
:goto_0
move v5, v1
.line 90
invoke-virtual {p1}, Lorg/webrtc/VideoFrame;->getRotation()I
move-result v1
rem-int/lit16 v1, v1, 0xb4
if-nez v1, :cond_1
iget v1, p0, Lorg/webrtc/VideoFileRenderer;->outputFileHeight:I
goto :goto_1
:cond_1
iget v1, p0, Lorg/webrtc/VideoFileRenderer;->outputFileWidth:I
:goto_1
move v6, v1
.line 92
invoke-interface {v0}, Lorg/webrtc/VideoFrame$Buffer;->getWidth()I
move-result v1
int-to-float v1, v1
invoke-interface {v0}, Lorg/webrtc/VideoFrame$Buffer;->getHeight()I
move-result v2
int-to-float v2, v2
div-float/2addr v1, v2
int-to-float v2, v5
int-to-float v3, v6
div-float/2addr v2, v3
.line 96
invoke-interface {v0}, Lorg/webrtc/VideoFrame$Buffer;->getWidth()I
move-result v3
.line 97
invoke-interface {v0}, Lorg/webrtc/VideoFrame$Buffer;->getHeight()I
move-result v4
cmpl-float v7, v2, v1
if-lez v7, :cond_2
int-to-float v4, v4
div-float/2addr v1, v2
mul-float/2addr v4, v1
float-to-int v1, v4
move v4, v1
goto :goto_2
:cond_2
int-to-float v3, v3
div-float/2addr v2, v1
mul-float/2addr v3, v2
float-to-int v1, v3
move v3, v1
.line 104
:goto_2
invoke-interface {v0}, Lorg/webrtc/VideoFrame$Buffer;->getWidth()I
move-result v1
sub-int/2addr v1, v3
div-int/lit8 v1, v1, 0x2
.line 105
invoke-interface {v0}, Lorg/webrtc/VideoFrame$Buffer;->getHeight()I
move-result v2
sub-int/2addr v2, v4
div-int/lit8 v2, v2, 0x2
.line 108
invoke-interface/range {v0 .. v6}, Lorg/webrtc/VideoFrame$Buffer;->cropAndScale(IIIIII)Lorg/webrtc/VideoFrame$Buffer;
move-result-object v0
.line 109
invoke-virtual {p1}, Lorg/webrtc/VideoFrame;->release()V
.line 111
invoke-interface {v0}, Lorg/webrtc/VideoFrame$Buffer;->toI420()Lorg/webrtc/VideoFrame$I420Buffer;
move-result-object v1
.line 112
invoke-interface {v0}, Lorg/webrtc/VideoFrame$Buffer;->release()V
iget-object v0, p0, Lorg/webrtc/VideoFileRenderer;->fileThreadHandler:Landroid/os/Handler;
.line 114
new-instance v2, Lorg/webrtc/VideoFileRenderer$$ExternalSyntheticLambda3;
invoke-direct {v2, p0, v1, p1}, Lorg/webrtc/VideoFileRenderer$$ExternalSyntheticLambda3;-><init>(Lorg/webrtc/VideoFileRenderer;Lorg/webrtc/VideoFrame$I420Buffer;Lorg/webrtc/VideoFrame;)V
invoke-virtual {v0, v2}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
return-void
.end method
# virtual methods
.method synthetic lambda$onFrame$0$org-webrtc-VideoFileRenderer(Lorg/webrtc/VideoFrame;)V
.locals 0
.line 81
invoke-direct {p0, p1}, Lorg/webrtc/VideoFileRenderer;->renderFrameOnRenderThread(Lorg/webrtc/VideoFrame;)V
return-void
.end method
.method synthetic lambda$release$2$org-webrtc-VideoFileRenderer(Ljava/util/concurrent/CountDownLatch;)V
.locals 1
.line 0
iget-object v0, p0, Lorg/webrtc/VideoFileRenderer;->yuvConverter:Lorg/webrtc/YuvConverter;
.line 137
invoke-virtual {v0}, Lorg/webrtc/YuvConverter;->release()V
iget-object v0, p0, Lorg/webrtc/VideoFileRenderer;->eglBase:Lorg/webrtc/EglBase;
.line 138
invoke-interface {v0}, Lorg/webrtc/EglBase;->release()V
iget-object p0, p0, Lorg/webrtc/VideoFileRenderer;->renderThread:Landroid/os/HandlerThread;
.line 139
invoke-virtual {p0}, Landroid/os/HandlerThread;->quit()Z
.line 140
invoke-virtual {p1}, Ljava/util/concurrent/CountDownLatch;->countDown()V
return-void
.end method
.method synthetic lambda$release$3$org-webrtc-VideoFileRenderer()V
.locals 3
.line 0
const-string v0, "Video written to disk as "
:try_start_0
iget-object v1, p0, Lorg/webrtc/VideoFileRenderer;->videoOutFile:Ljava/io/FileOutputStream;
.line 145
invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V
const-string v1, "VideoFileRenderer"
.line 146
new-instance v2, Ljava/lang/StringBuilder;
invoke-direct {v2, v0}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
iget-object v0, p0, Lorg/webrtc/VideoFileRenderer;->outputFileName:Ljava/lang/String;
invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
const-string v2, ". The number of frames is "
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
iget v2, p0, Lorg/webrtc/VideoFileRenderer;->frameCount:I
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
move-result-object v0
const-string v2, " and the dimensions of the frames are "
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
iget v2, p0, Lorg/webrtc/VideoFileRenderer;->outputFileWidth:I
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
move-result-object v0
const-string v2, "x"
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
iget v2, p0, Lorg/webrtc/VideoFileRenderer;->outputFileHeight:I
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;
move-result-object v0
const-string v2, "."
invoke-virtual {v0, v2}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v0
invoke-static {v1, v0}, Lorg/webrtc/Logging;->d(Ljava/lang/String;Ljava/lang/String;)V
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
iget-object p0, p0, Lorg/webrtc/VideoFileRenderer;->fileThread:Landroid/os/HandlerThread;
.line 153
invoke-virtual {p0}, Landroid/os/HandlerThread;->quit()Z
return-void
:catch_0
move-exception p0
.line 151
new-instance v0, Ljava/lang/RuntimeException;
const-string v1, "Error closing output file"
invoke-direct {v0, v1, p0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw v0
.end method
.method synthetic lambda$renderFrameOnRenderThread$1$org-webrtc-VideoFileRenderer(Lorg/webrtc/VideoFrame$I420Buffer;Lorg/webrtc/VideoFrame;)V
.locals 10
.line 115
invoke-interface {p1}, Lorg/webrtc/VideoFrame$I420Buffer;->getDataY()Ljava/nio/ByteBuffer;
move-result-object v0
invoke-interface {p1}, Lorg/webrtc/VideoFrame$I420Buffer;->getStrideY()I
move-result v1
invoke-interface {p1}, Lorg/webrtc/VideoFrame$I420Buffer;->getDataU()Ljava/nio/ByteBuffer;
move-result-object v2
invoke-interface {p1}, Lorg/webrtc/VideoFrame$I420Buffer;->getStrideU()I
move-result v3
.line 116
invoke-interface {p1}, Lorg/webrtc/VideoFrame$I420Buffer;->getDataV()Ljava/nio/ByteBuffer;
move-result-object v4
invoke-interface {p1}, Lorg/webrtc/VideoFrame$I420Buffer;->getStrideV()I
move-result v5
iget-object v6, p0, Lorg/webrtc/VideoFileRenderer;->outputFrameBuffer:Ljava/nio/ByteBuffer;
invoke-interface {p1}, Lorg/webrtc/VideoFrame$I420Buffer;->getWidth()I
move-result v7
invoke-interface {p1}, Lorg/webrtc/VideoFrame$I420Buffer;->getHeight()I
move-result v8
.line 117
invoke-virtual {p2}, Lorg/webrtc/VideoFrame;->getRotation()I
move-result v9
.line 115
invoke-static/range {v0 .. v9}, Lorg/webrtc/YuvHelper;->I420Rotate(Ljava/nio/ByteBuffer;ILjava/nio/ByteBuffer;ILjava/nio/ByteBuffer;ILjava/nio/ByteBuffer;III)V
.line 118
invoke-interface {p1}, Lorg/webrtc/VideoFrame$I420Buffer;->release()V
:try_start_0
iget-object p1, p0, Lorg/webrtc/VideoFileRenderer;->videoOutFile:Ljava/io/FileOutputStream;
const-string p2, "FRAME\n"
const-string v0, "US-ASCII"
.line 121
invoke-static {v0}, Ljava/nio/charset/Charset;->forName(Ljava/lang/String;)Ljava/nio/charset/Charset;
move-result-object v0
invoke-virtual {p2, v0}, Ljava/lang/String;->getBytes(Ljava/nio/charset/Charset;)[B
move-result-object p2
invoke-virtual {p1, p2}, Ljava/io/FileOutputStream;->write([B)V
iget-object p1, p0, Lorg/webrtc/VideoFileRenderer;->videoOutFile:Ljava/io/FileOutputStream;
iget-object p2, p0, Lorg/webrtc/VideoFileRenderer;->outputFrameBuffer:Ljava/nio/ByteBuffer;
.line 123
invoke-virtual {p2}, Ljava/nio/ByteBuffer;->array()[B
move-result-object p2
iget-object v0, p0, Lorg/webrtc/VideoFileRenderer;->outputFrameBuffer:Ljava/nio/ByteBuffer;
invoke-virtual {v0}, Ljava/nio/ByteBuffer;->arrayOffset()I
move-result v0
iget v1, p0, Lorg/webrtc/VideoFileRenderer;->outputFrameSize:I
.line 122
invoke-virtual {p1, p2, v0, v1}, Ljava/io/FileOutputStream;->write([BII)V
:try_end_0
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
iget p1, p0, Lorg/webrtc/VideoFileRenderer;->frameCount:I
add-int/lit8 p1, p1, 0x1
iput p1, p0, Lorg/webrtc/VideoFileRenderer;->frameCount:I
return-void
:catch_0
move-exception p0
.line 125
new-instance p1, Ljava/lang/RuntimeException;
const-string p2, "Error writing video to disk"
invoke-direct {p1, p2, p0}, Ljava/lang/RuntimeException;-><init>(Ljava/lang/String;Ljava/lang/Throwable;)V
throw p1
.end method
.method public onFrame(Lorg/webrtc/VideoFrame;)V
.locals 2
.line 80
invoke-virtual {p1}, Lorg/webrtc/VideoFrame;->retain()V
iget-object v0, p0, Lorg/webrtc/VideoFileRenderer;->renderThreadHandler:Landroid/os/Handler;
.line 81
new-instance v1, Lorg/webrtc/VideoFileRenderer$$ExternalSyntheticLambda2;
invoke-direct {v1, p0, p1}, Lorg/webrtc/VideoFileRenderer$$ExternalSyntheticLambda2;-><init>(Lorg/webrtc/VideoFileRenderer;Lorg/webrtc/VideoFrame;)V
invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
return-void
.end method
.method public release()V
.locals 3
.line 135
new-instance v0, Ljava/util/concurrent/CountDownLatch;
const/4 v1, 0x1
invoke-direct {v0, v1}, Ljava/util/concurrent/CountDownLatch;-><init>(I)V
iget-object v1, p0, Lorg/webrtc/VideoFileRenderer;->renderThreadHandler:Landroid/os/Handler;
.line 136
new-instance v2, Lorg/webrtc/VideoFileRenderer$$ExternalSyntheticLambda0;
invoke-direct {v2, p0, v0}, Lorg/webrtc/VideoFileRenderer$$ExternalSyntheticLambda0;-><init>(Lorg/webrtc/VideoFileRenderer;Ljava/util/concurrent/CountDownLatch;)V
invoke-virtual {v1, v2}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
.line 142
invoke-static {v0}, Lorg/webrtc/ThreadUtils;->awaitUninterruptibly(Ljava/util/concurrent/CountDownLatch;)V
iget-object v0, p0, Lorg/webrtc/VideoFileRenderer;->fileThreadHandler:Landroid/os/Handler;
.line 143
new-instance v1, Lorg/webrtc/VideoFileRenderer$$ExternalSyntheticLambda1;
invoke-direct {v1, p0}, Lorg/webrtc/VideoFileRenderer$$ExternalSyntheticLambda1;-><init>(Lorg/webrtc/VideoFileRenderer;)V
invoke-virtual {v0, v1}, Landroid/os/Handler;->post(Ljava/lang/Runnable;)Z
:try_start_0
iget-object p0, p0, Lorg/webrtc/VideoFileRenderer;->fileThread:Landroid/os/HandlerThread;
.line 156
invoke-virtual {p0}, Landroid/os/HandlerThread;->join()V
:try_end_0
.catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_0
:catch_0
move-exception p0
.line 158
invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
move-result-object v0
invoke-virtual {v0}, Ljava/lang/Thread;->interrupt()V
const-string v0, "VideoFileRenderer"
const-string v1, "Interrupted while waiting for the write to disk to complete."
.line 159
invoke-static {v0, v1, p0}, Lorg/webrtc/Logging;->e(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
:goto_0
return-void
.end method