Skip to content

Commit 628ef00

Browse files
author
Hitesh Sondhi
committed
Merge branch 'master' into develop
2 parents 0b7bfd4 + 81db8a6 commit 628ef00

File tree

15 files changed

+95
-144
lines changed

15 files changed

+95
-144
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ proguard/
8181
### Intellij ###
8282
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
8383

84-
/*.iml
84+
*.iml
8585

8686
## Directory-based project format:
8787
.idea/

FFmpegAndroid/build.gradle

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
apply plugin: 'com.android.library'
22

33
android {
4-
compileSdkVersion 16
5-
buildToolsVersion "20.0.0"
4+
compileSdkVersion rootProject.ext.compileSdkVersion as Integer
5+
buildToolsVersion rootProject.ext.buildToolsVersion as String
66

77
defaultConfig {
8-
applicationId "com.github.hiteshsondhi88.libffmpeg"
9-
minSdkVersion 16
10-
targetSdkVersion 16
11-
versionCode 25
12-
versionName "0.2.5"
8+
minSdkVersion rootProject.ext.minSdkVersion as Integer
9+
targetSdkVersion rootProject.ext.targetSdkVersion as Integer
10+
versionCode rootProject.ext.versionCode as Integer
11+
versionName rootProject.ext.versionName as String
1312
}
1413

1514
sourceSets.main {
@@ -20,7 +19,7 @@ android {
2019

2120
buildTypes {
2221
release {
23-
runProguard false
22+
minifyEnabled false
2423
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2524
}
2625
}

FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/CpuArchHelperTest.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
import static org.assertj.core.api.Assertions.assertThat;
88

99
public class CpuArchHelperTest extends TestCase {
10-
10+
1111
public void testGetCpuArch() throws Exception {
1212
CpuArch cpuArch = CpuArchHelper.getCpuArch();
1313
assertNotNull(cpuArch);
14-
if (Build.CPU_ABI.equals(CpuArchHelper.getx86CpuAbi())) {
14+
if (Build.CPU_ABI.equals(CpuArchHelper.getx86CpuAbi()) || Build.CPU_ABI.equals(CpuArchHelper.getx86_64CpuAbi())) {
1515
assertEquals(cpuArch, CpuArch.x86);
1616
} else if (Build.CPU_ABI.equals(CpuArchHelper.getArmeabiv7CpuAbi())) {
1717
assertThat(cpuArch == CpuArch.ARMv7 || cpuArch == CpuArch.ARMv7_NEON).isTrue();
18-
} else {
18+
} else if (Build.CPU_ABI.equals(CpuArchHelper.getArm64CpuAbi())) {
19+
assertEquals(cpuArch, CpuArch.ARMv7);
20+
}else {
1921
assertEquals(cpuArch, CpuArch.NONE);
2022
}
2123
}
22-
2324
}

FFmpegAndroid/src/androidTest/java/com/github/hiteshsondhi88/libffmpeg/ShellCommandTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public class ShellCommandTest extends CommonTestCase {
1414

1515
public void testRun() throws Exception {
1616
ShellCommand shellCommand = new ShellCommand();
17-
final Process process = shellCommand.run("logcat");
17+
final Process process = shellCommand.run(new String[] {"logcat"});
1818
assertNotNull(process);
1919
assertEquals(false, Util.isProcessCompleted(process));
2020

@@ -44,7 +44,7 @@ public void run() {
4444

4545
public void testRunWaitFor() throws Exception {
4646
ShellCommand shellCommand = new ShellCommand();
47-
CommandResult commandResult = shellCommand.runWaitFor("ls");
47+
CommandResult commandResult = shellCommand.runWaitFor(new String[] {"ls"});
4848
assertNotNull(commandResult);
4949
assertEquals(true, commandResult.success);
5050
assertThat(commandResult.output).isNotEmpty();

FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/CpuArchHelper.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
import android.os.Build;
44

55
class CpuArchHelper {
6-
6+
77
static CpuArch getCpuArch() {
8-
// check if device is x86
9-
if (Build.CPU_ABI.equals(getx86CpuAbi())) {
8+
Log.d("Build.CPU_ABI : " + Build.CPU_ABI);
9+
// check if device is x86 or x86_64
10+
if (Build.CPU_ABI.equals(getx86CpuAbi()) || Build.CPU_ABI.equals(getx86_64CpuAbi())) {
1011
return CpuArch.x86;
1112
} else {
1213
// check if device is armeabi
@@ -21,15 +22,26 @@ static CpuArch getCpuArch() {
2122
}
2223
return CpuArch.ARMv7;
2324
}
25+
// check if device is arm64 which is supported by ARMV7
26+
} else if (Build.CPU_ABI.equals(getArm64CpuAbi())) {
27+
return CpuArch.ARMv7;
2428
}
2529
}
2630
return CpuArch.NONE;
2731
}
28-
32+
2933
static String getx86CpuAbi() {
3034
return "x86";
3135
}
32-
36+
37+
static String getx86_64CpuAbi() {
38+
return "x86_64";
39+
}
40+
41+
static String getArm64CpuAbi() {
42+
return "arm64-v8a";
43+
}
44+
3345
static String getArmeabiv7CpuAbi() {
3446
return "armeabi-v7a";
3547
}

FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpeg.java

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.Context;
44
import android.text.TextUtils;
55

6+
import java.lang.reflect.Array;
67
import java.util.Map;
78

89
import com.github.hiteshsondhi88.libffmpeg.exceptions.FFmpegCommandAlreadyRunningException;
@@ -61,28 +62,41 @@ public void loadBinary(FFmpegLoadBinaryResponseHandler ffmpegLoadBinaryResponseH
6162
}
6263

6364
@Override
64-
public void execute(Map<String, String> environvenmentVars, String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
65+
public void execute(Map<String, String> environvenmentVars, String[] cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
6566
if (ffmpegExecuteAsyncTask != null && !ffmpegExecuteAsyncTask.isProcessCompleted()) {
6667
throw new FFmpegCommandAlreadyRunningException("FFmpeg command is already running, you are only allowed to run single command at a time");
6768
}
68-
if (!TextUtils.isEmpty(cmd)) {
69-
String ffmpegCmd = FileUtils.getFFmpeg(context, environvenmentVars) + " "+ cmd;
70-
ffmpegExecuteAsyncTask = new FFmpegExecuteAsyncTask(ffmpegCmd, timeout, ffmpegExecuteResponseHandler);
69+
if (cmd.length != 0) {
70+
String[] ffmpegBinary = new String[] { FileUtils.getFFmpeg(context, environvenmentVars) };
71+
String[] command = concatenate(ffmpegBinary, cmd);
72+
ffmpegExecuteAsyncTask = new FFmpegExecuteAsyncTask(command , timeout, ffmpegExecuteResponseHandler);
7173
ffmpegExecuteAsyncTask.execute();
7274
} else {
7375
throw new IllegalArgumentException("shell command cannot be empty");
7476
}
7577
}
7678

79+
public <T> T[] concatenate (T[] a, T[] b) {
80+
int aLen = a.length;
81+
int bLen = b.length;
82+
83+
@SuppressWarnings("unchecked")
84+
T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen + bLen);
85+
System.arraycopy(a, 0, c, 0, aLen);
86+
System.arraycopy(b, 0, c, aLen, bLen);
87+
88+
return c;
89+
}
90+
7791
@Override
78-
public void execute(String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
92+
public void execute(String[] cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
7993
execute(null, cmd, ffmpegExecuteResponseHandler);
8094
}
8195

8296
@Override
8397
public String getDeviceFFmpegVersion() throws FFmpegCommandAlreadyRunningException {
8498
ShellCommand shellCommand = new ShellCommand();
85-
CommandResult commandResult = shellCommand.runWaitFor(FileUtils.getFFmpeg(context) + " -version");
99+
CommandResult commandResult = shellCommand.runWaitFor(new String[] { FileUtils.getFFmpeg(context), "-version" });
86100
if (commandResult.success) {
87101
return commandResult.output.split(" ")[2];
88102
}

FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegExecuteAsyncTask.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
class FFmpegExecuteAsyncTask extends AsyncTask<Void, String, CommandResult> {
1111

12-
private final String cmd;
12+
private final String[] cmd;
1313
private final FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler;
1414
private final ShellCommand shellCommand;
1515
private final long timeout;
1616
private long startTime;
1717
private Process process;
1818
private String output = "";
1919

20-
FFmpegExecuteAsyncTask(String cmd, long timeout, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) {
20+
FFmpegExecuteAsyncTask(String[] cmd, long timeout, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) {
2121
this.cmd = cmd;
2222
this.timeout = timeout;
2323
this.ffmpegExecuteResponseHandler = ffmpegExecuteResponseHandler;

FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/FFmpegInterface.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ interface FFmpegInterface {
2222
* @param ffmpegExecuteResponseHandler {@link FFmpegExecuteResponseHandler}
2323
* @throws FFmpegCommandAlreadyRunningException
2424
*/
25-
public void execute(Map<String, String> environvenmentVars, String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException;
25+
public void execute(Map<String, String> environvenmentVars, String[] cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException;
2626

2727
/**
2828
* Executes a command
2929
* @param cmd command to execute
3030
* @param ffmpegExecuteResponseHandler {@link FFmpegExecuteResponseHandler}
3131
* @throws FFmpegCommandAlreadyRunningException
3232
*/
33-
public void execute(String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException;
33+
public void execute(String[] cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException;
3434

3535
/**
3636
* Tells FFmpeg version currently on device

FFmpegAndroid/src/main/java/com/github/hiteshsondhi88/libffmpeg/ShellCommand.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
class ShellCommand {
66

7-
Process run(String commandString) {
7+
Process run(String[] commandString) {
88
Process process = null;
99
try {
1010
process = Runtime.getRuntime().exec(commandString);
@@ -14,7 +14,7 @@ Process run(String commandString) {
1414
return process;
1515
}
1616

17-
CommandResult runWaitFor(String s) {
17+
CommandResult runWaitFor(String[] s) {
1818
Process process = run(s);
1919

2020
Integer exitValue = null;

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
[FFmpeg-Android-Java](http://hiteshsondhi88.github.io/ffmpeg-android-java/) [![Build Status](https://travis-ci.org/hiteshsondhi88/ffmpeg-android-java.svg?branch=master)](https://travis-ci.org/hiteshsondhi88/ffmpeg-android-java) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-FFmpeg--Android--Java-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/931)
1+
[FFmpeg-Android-Java](http://writingminds.github.io/ffmpeg-android-java/) [![Build Status](https://travis-ci.org/hiteshsondhi88/ffmpeg-android-java.svg?branch=master)](https://travis-ci.org/hiteshsondhi88/ffmpeg-android-java) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-FFmpeg--Android--Java-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/931)
22
==============
33

4+
[![Join the chat at https://gitter.im/hiteshsondhi88/ffmpeg-android-java](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/hiteshsondhi88/ffmpeg-android-java?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5+
46
## About
5-
[FFmpeg Android java](http://hiteshsondhi88.github.io/ffmpeg-android-java/) is a java library that simplifies your task of using ffmpeg in Android project which I've compiled using [FFmpeg-Android](http://hiteshsondhi88.github.io/ffmpeg-android/)
7+
[FFmpeg Android java](http://writingminds.github.io/ffmpeg-android-java/) is a java library that simplifies your task of using ffmpeg in Android project which I've compiled using [FFmpeg-Android](http://writingminds.github.io/ffmpeg-android/)
68

79
These are two basic methods of this library:
810

911
* `loadBinary(FFmpegLoadBinaryResponseHandler ffmpegLoadBinaryResponseHandler) throws FFmpegNotSupportedException`
1012
* `execute(String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException`
1113

1214
For examples and usage instructions head over to:
13-
* [hiteshsondhi88.github.io/ffmpeg-android-java] (http://hiteshsondhi88.github.io/ffmpeg-android-java/)
15+
* [writingminds.github.io/ffmpeg-android-java] (http://writingminds.github.io/ffmpeg-android-java/)
1416

1517
## Supported Architecture
1618
* armv7
@@ -19,10 +21,17 @@ For examples and usage instructions head over to:
1921

2022
## Sample
2123
![http://i.imgur.com/cP4WhLn.gif](http://i.imgur.com/cP4WhLn.gif)
22-
* [Download APK](https://github.com/hiteshsondhi88/ffmpeg-android-java/releases/download/v0.2.3/app-debug.apk)
24+
* [Download APK](https://github.com/writingminds/ffmpeg-android-java/releases/download/v0.2.3/app-debug.apk)
2325

2426
## JavaDoc
25-
* [Javadoc](http://hiteshsondhi88.github.io/ffmpeg-android-java/docs/)
27+
* [Javadoc](http://writingminds.github.io/ffmpeg-android-java/docs/)
2628

2729
## License
2830
* Check file LICENSE.GPLv3 and Make sure to follow the licensing terms and conditions of the project and the software used to build the project.
31+
32+
## HIRE US
33+
* Get in touch with us - http://www.writingminds.com
34+
35+
36+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/hiteshsondhi88/ffmpeg-android-java/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
37+

app/app.iml

Lines changed: 0 additions & 94 deletions
This file was deleted.

0 commit comments

Comments
 (0)