Skip to content

Commit

Permalink
add annotations & eliminate warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Aug 14, 2020
1 parent 2d209a3 commit 95989b4
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 23 deletions.
6 changes: 3 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
xmlns:tools="http://schemas.android.com/tools"
package="com.abedelazizshe.lightcompressor">

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<application
android:allowBackup="true"
Expand All @@ -13,7 +13,7 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="GoogleAppIndexingWarning">
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".VideoPlayerActivity" />
<activity
android:name=".MainActivity"
Expand Down
7 changes: 3 additions & 4 deletions app/src/main/res/layout/activity_video_player.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:background="@color/colorBlack"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/colorBlack">

<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/ep_video_view"
Expand Down
3 changes: 1 addition & 2 deletions lightcompressor/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.abedelazizshe.lightcompressorlibrary" />
<manifest package="com.abedelazizshe.lightcompressorlibrary" />
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
package com.abedelazizshe.lightcompressorlibrary

import androidx.annotation.MainThread
import androidx.annotation.WorkerThread

/**
* Created by AbedElaziz Shehadeh on 27 Jan, 2020
* [email protected]
*/

interface CompressionListener {
@MainThread
fun onStart()

@MainThread
fun onSuccess()

@MainThread
fun onFailure(failureMessage: String)

@WorkerThread
fun onProgress(percent: Float)

@WorkerThread
fun onCancelled()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ package com.abedelazizshe.lightcompressorlibrary
import android.media.*
import android.util.Log
import java.io.File
import java.lang.Exception
import java.lang.IllegalArgumentException
import java.nio.ByteBuffer
import kotlin.math.roundToInt

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,22 +67,22 @@ private void eglSetup() {
throw new RuntimeException("unable to find RGB888+recordable ES2 EGL config");
}

int[] attrib_list = {
int[] attrs = {
EGL14.EGL_CONTEXT_CLIENT_VERSION, 2,
EGL14.EGL_NONE
};

mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrib_list, 0);
mEGLContext = EGL14.eglCreateContext(mEGLDisplay, configs[0], EGL14.EGL_NO_CONTEXT, attrs, 0);
checkEglError("eglCreateContext");
if (mEGLContext == null) {
throw new RuntimeException("null context");
}

int[] surfaceAttribs = {
int[] surfaceAttrs = {
EGL14.EGL_NONE
};
mEGLSurface = EGL14.eglCreateWindowSurface(mEGLDisplay, configs[0], mSurface,
surfaceAttribs, 0);
surfaceAttrs, 0);
checkEglError("eglCreateWindowSurface");
if (mEGLSurface == null) {
throw new RuntimeException("surface was null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,12 @@ private class InterleaveChunkMdat implements Box {
private long contentSize = 1024 * 1024 * 1024;
private long dataOffset = 0;

@Override
public Container getParent() {
return parent;
}

@Override
public long getOffset() {
return dataOffset;
}
Expand All @@ -179,6 +181,7 @@ void setDataOffset(long offset) {
dataOffset = offset;
}

@Override
public void setParent(Container parent) {
this.parent = parent;
}
Expand All @@ -191,10 +194,12 @@ long getContentSize() {
return contentSize;
}

@Override
public String getType() {
return "mdat";
}

@Override
public long getSize() {
return 16 + contentSize;
}
Expand All @@ -208,6 +213,7 @@ public void parse(DataSource dataSource, ByteBuffer header, long contentSize, Bo

}

@Override
public void getBox(WritableByteChannel writableByteChannel) throws IOException {
ByteBuffer bb = ByteBuffer.allocate(16);
long size = getSize();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@

public class OutputSurface implements SurfaceTexture.OnFrameAvailableListener {

// private static final int EGL_OPENGL_ES2_BIT = 4;
// private static final int EGL_OPENGL_ES2_BIT = 4;
// private static final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
private static final int TIMEOUT_MS = 5000;
private EGL10 mEGL;
private EGLDisplay mEGLDisplay = null;
private EGLContext mEGLContext = null;
Expand Down Expand Up @@ -152,7 +153,6 @@ Surface getSurface() {
// }

void awaitNewImage() {
final int TIMEOUT_MS = 5000;
synchronized (mFrameSyncObject) {
while (!mFrameAvailable) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class TextureRenderer {
private static final int TRIANGLE_VERTICES_DATA_STRIDE_BYTES = 5 * FLOAT_SIZE_BYTES;
private static final int TRIANGLE_VERTICES_DATA_POS_OFFSET = 0;
private static final int TRIANGLE_VERTICES_DATA_UV_OFFSET = 3;
private static final float[] mTriangleVerticesData = {
private static final float[] M_TRIANGLE_VERTICES_DATA = {
-1.0f, -1.0f, 0, 0.f, 0.f,
1.0f, -1.0f, 0, 1.f, 0.f,
-1.0f, 1.0f, 0, 0.f, 1.f,
Expand Down Expand Up @@ -71,8 +71,8 @@ public class TextureRenderer {

TextureRenderer(int rotation) {
rotationAngle = rotation;
mTriangleVertices = ByteBuffer.allocateDirect(mTriangleVerticesData.length * FLOAT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer();
mTriangleVertices.put(mTriangleVerticesData).position(0);
mTriangleVertices = ByteBuffer.allocateDirect(M_TRIANGLE_VERTICES_DATA.length * FLOAT_SIZE_BYTES).order(ByteOrder.nativeOrder()).asFloatBuffer();
mTriangleVertices.put(M_TRIANGLE_VERTICES_DATA).position(0);
Matrix.setIdentityM(mSTMatrix, 0);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
import java.util.Map;

public class Track {
private long trackId = 0;
private long trackId;
private ArrayList<Sample> samples = new ArrayList<>();
private long duration = 0;
private long duration;
private String handler;
private AbstractMediaHeaderBox headerBox = null;
private SampleDescriptionBox sampleDescriptionBox = null;
Expand Down Expand Up @@ -135,7 +135,6 @@ public Track(int id, MediaFormat format, boolean isAudio) throws Exception {
} else {
sampleDurations.add((long)1024);
duration = 1024;
isAudio = true;
volume = 1;
timeScale = format.getInteger(MediaFormat.KEY_SAMPLE_RATE);
handler = "soun";
Expand Down

0 comments on commit 95989b4

Please sign in to comment.