Skip to content
Merged

CI #2

Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Get rid of Dagger
  • Loading branch information
hannesa2 committed Jul 31, 2021
commit 78856df4ab864a234e697ca8e40cc8c0bbe2b031
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.github.hiteshsondhi88.sampleffmpeg;

import android.app.Instrumentation;
import android.os.Environment;
import android.test.ActivityInstrumentationTestCase2;
import android.util.Log;

import java.io.File;

import javax.inject.Inject;

import com.github.hiteshsondhi88.libffmpeg.FFmpeg;
import com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteResponseHandler;
import com.github.hiteshsondhi88.libffmpeg.FFmpegLoadBinaryResponseHandler;
Expand All @@ -19,7 +18,6 @@ public class FFmpegInstrumentationTest extends ActivityInstrumentationTestCase2<

private static final String TAG = FFmpegInstrumentationTest.class.getSimpleName();

@Inject
FFmpeg ffmpeg;

public FFmpegInstrumentationTest() {
Expand All @@ -30,6 +28,7 @@ public FFmpegInstrumentationTest() {
protected void setUp() throws Exception {
super.setUp();
assertNotNull(getActivity());
ffmpeg = FFmpeg.getInstance(new Instrumentation().getContext());
ffmpeg = getActivity().ffmpeg;
assertNotNull(ffmpeg);
ffmpeg.loadBinary(new FFmpegLoadBinaryResponseHandler() {
Expand Down Expand Up @@ -123,21 +122,23 @@ public void testFFmpegAVItoMP4Usingx264() {

public void testLibass() {
File outass = new File(getFFmpegFilesDir(), "output.ass");
checkFFmpegCommon("-y -i "+getSrtSampleFile()+" "+outass.getAbsolutePath(), outass);
checkFFmpegCommon("-y -i " + getSrtSampleFile() + " " + outass.getAbsolutePath(), outass);
}

private void checkFFmpegConvertUsingx264(File inputFile, File outputFile) {
checkFFmpegCommon("-y -i "+inputFile.getAbsolutePath()+" -c:v libx264 -preset ultrafast "+outputFile.getAbsolutePath(), outputFile);
checkFFmpegCommon("-y -i " + inputFile.getAbsolutePath() + " -c:v libx264 -preset ultrafast " + outputFile.getAbsolutePath(), outputFile);
}

private void checkFFmpegConvertCommon(File inputFile, File outputFile) {
checkFFmpegCommon("-y -i "+inputFile.getAbsolutePath()+" "+outputFile.getAbsolutePath(), outputFile);
checkFFmpegCommon("-y -i " + inputFile.getAbsolutePath() + " " + outputFile.getAbsolutePath(), outputFile);
}

private void checkFFmpegCommon(final String cmd, final File outputFile) {
Log.d(TAG, "start : "+outputFile.getAbsolutePath());
Log.d(TAG, "start : " + outputFile.getAbsolutePath());
try {
ffmpeg.execute(cmd, new FFmpegExecuteResponseHandler() {
String[] array = new String[1];
array[0] = cmd;
ffmpeg.execute(array, new FFmpegExecuteResponseHandler() {

@Override
public void onStart() {
Expand All @@ -146,7 +147,7 @@ public void onStart() {

@Override
public void onProgress(String message) {
Log.d(TAG, "progress : "+message);
Log.d(TAG, "progress : " + message);
}

@Override
Expand All @@ -161,7 +162,7 @@ public void onSuccess(String message) {

@Override
public void onFinish() {
Log.d(TAG, "done : "+outputFile.getAbsolutePath());
Log.d(TAG, "done : " + outputFile.getAbsolutePath());
synchronized (FFmpegInstrumentationTest.this) {
FFmpegInstrumentationTest.this.notify();
}
Expand Down
20 changes: 8 additions & 12 deletions app/src/main/java/com/github/hiteshsondhi88/sampleffmpeg/Home.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
import android.widget.TextView;
import android.widget.Toast;

import javax.inject.Inject;

import butterknife.ButterKnife;
import butterknife.InjectView;
import dagger.ObjectGraph;

import com.github.hiteshsondhi88.libffmpeg.ExecuteBinaryResponseHandler;
import com.github.hiteshsondhi88.libffmpeg.FFmpeg;
Expand All @@ -30,8 +27,7 @@ public class Home extends Activity implements View.OnClickListener {

private static final String TAG = Home.class.getSimpleName();

@Inject
FFmpeg ffmpeg;
public FFmpeg ffmpeg;

@InjectView(R.id.command)
EditText commandEditText;
Expand All @@ -49,7 +45,6 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
ButterKnife.inject(this);
ObjectGraph.create(new DaggerDependencyModule(this)).inject(this);

loadFFMpegBinary();
initUI();
Expand All @@ -64,6 +59,7 @@ private void initUI() {

private void loadFFMpegBinary() {
try {
FFmpeg ffmpeg = FFmpeg.getInstance(getApplicationContext());
ffmpeg.loadBinary(new LoadBinaryResponseHandler() {
@Override
public void onFailure() {
Expand All @@ -80,19 +76,19 @@ private void execFFmpegBinary(final String[] command) {
ffmpeg.execute(command, new ExecuteBinaryResponseHandler() {
@Override
public void onFailure(String s) {
addTextViewToLayout("FAILED with output : "+s);
addTextViewToLayout("FAILED with output : " + s);
}

@Override
public void onSuccess(String s) {
addTextViewToLayout("SUCCESS with output : "+s);
addTextViewToLayout("SUCCESS with output : " + s);
}

@Override
public void onProgress(String s) {
Log.d(TAG, "Started command : ffmpeg "+command);
addTextViewToLayout("progress : "+s);
progressDialog.setMessage("Processing\n"+s);
Log.d(TAG, "Started command : ffmpeg " + command);
addTextViewToLayout("progress : " + s);
progressDialog.setMessage("Processing\n" + s);
}

@Override
Expand All @@ -106,7 +102,7 @@ public void onStart() {

@Override
public void onFinish() {
Log.d(TAG, "Finished command : ffmpeg "+command);
Log.d(TAG, "Finished command : ffmpeg " + command);
progressDialog.dismiss();
}
});
Expand Down