Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitesh Sondhi committed Apr 19, 2016
2 parents 0b7bfd4 + 81db8a6 commit 628ef00
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 144 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ proguard/
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm

/*.iml
*.iml

## Directory-based project format:
.idea/
Expand Down
15 changes: 7 additions & 8 deletions FFmpegAndroid/build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 16
buildToolsVersion "20.0.0"
compileSdkVersion rootProject.ext.compileSdkVersion as Integer
buildToolsVersion rootProject.ext.buildToolsVersion as String

defaultConfig {
applicationId "com.github.hiteshsondhi88.libffmpeg"
minSdkVersion 16
targetSdkVersion 16
versionCode 25
versionName "0.2.5"
minSdkVersion rootProject.ext.minSdkVersion as Integer
targetSdkVersion rootProject.ext.targetSdkVersion as Integer
versionCode rootProject.ext.versionCode as Integer
versionName rootProject.ext.versionName as String
}

sourceSets.main {
Expand All @@ -20,7 +19,7 @@ android {

buildTypes {
release {
runProguard false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@
import static org.assertj.core.api.Assertions.assertThat;

public class CpuArchHelperTest extends TestCase {

public void testGetCpuArch() throws Exception {
CpuArch cpuArch = CpuArchHelper.getCpuArch();
assertNotNull(cpuArch);
if (Build.CPU_ABI.equals(CpuArchHelper.getx86CpuAbi())) {
if (Build.CPU_ABI.equals(CpuArchHelper.getx86CpuAbi()) || Build.CPU_ABI.equals(CpuArchHelper.getx86_64CpuAbi())) {
assertEquals(cpuArch, CpuArch.x86);
} else if (Build.CPU_ABI.equals(CpuArchHelper.getArmeabiv7CpuAbi())) {
assertThat(cpuArch == CpuArch.ARMv7 || cpuArch == CpuArch.ARMv7_NEON).isTrue();
} else {
} else if (Build.CPU_ABI.equals(CpuArchHelper.getArm64CpuAbi())) {
assertEquals(cpuArch, CpuArch.ARMv7);
}else {
assertEquals(cpuArch, CpuArch.NONE);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class ShellCommandTest extends CommonTestCase {

public void testRun() throws Exception {
ShellCommand shellCommand = new ShellCommand();
final Process process = shellCommand.run("logcat");
final Process process = shellCommand.run(new String[] {"logcat"});
assertNotNull(process);
assertEquals(false, Util.isProcessCompleted(process));

Expand Down Expand Up @@ -44,7 +44,7 @@ public void run() {

public void testRunWaitFor() throws Exception {
ShellCommand shellCommand = new ShellCommand();
CommandResult commandResult = shellCommand.runWaitFor("ls");
CommandResult commandResult = shellCommand.runWaitFor(new String[] {"ls"});
assertNotNull(commandResult);
assertEquals(true, commandResult.success);
assertThat(commandResult.output).isNotEmpty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
import android.os.Build;

class CpuArchHelper {

static CpuArch getCpuArch() {
// check if device is x86
if (Build.CPU_ABI.equals(getx86CpuAbi())) {
Log.d("Build.CPU_ABI : " + Build.CPU_ABI);
// check if device is x86 or x86_64
if (Build.CPU_ABI.equals(getx86CpuAbi()) || Build.CPU_ABI.equals(getx86_64CpuAbi())) {
return CpuArch.x86;
} else {
// check if device is armeabi
Expand All @@ -21,15 +22,26 @@ static CpuArch getCpuArch() {
}
return CpuArch.ARMv7;
}
// check if device is arm64 which is supported by ARMV7
} else if (Build.CPU_ABI.equals(getArm64CpuAbi())) {
return CpuArch.ARMv7;
}
}
return CpuArch.NONE;
}

static String getx86CpuAbi() {
return "x86";
}


static String getx86_64CpuAbi() {
return "x86_64";
}

static String getArm64CpuAbi() {
return "arm64-v8a";
}

static String getArmeabiv7CpuAbi() {
return "armeabi-v7a";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.content.Context;
import android.text.TextUtils;

import java.lang.reflect.Array;
import java.util.Map;

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

@Override
public void execute(Map<String, String> environvenmentVars, String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
public void execute(Map<String, String> environvenmentVars, String[] cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
if (ffmpegExecuteAsyncTask != null && !ffmpegExecuteAsyncTask.isProcessCompleted()) {
throw new FFmpegCommandAlreadyRunningException("FFmpeg command is already running, you are only allowed to run single command at a time");
}
if (!TextUtils.isEmpty(cmd)) {
String ffmpegCmd = FileUtils.getFFmpeg(context, environvenmentVars) + " "+ cmd;
ffmpegExecuteAsyncTask = new FFmpegExecuteAsyncTask(ffmpegCmd, timeout, ffmpegExecuteResponseHandler);
if (cmd.length != 0) {
String[] ffmpegBinary = new String[] { FileUtils.getFFmpeg(context, environvenmentVars) };
String[] command = concatenate(ffmpegBinary, cmd);
ffmpegExecuteAsyncTask = new FFmpegExecuteAsyncTask(command , timeout, ffmpegExecuteResponseHandler);
ffmpegExecuteAsyncTask.execute();
} else {
throw new IllegalArgumentException("shell command cannot be empty");
}
}

public <T> T[] concatenate (T[] a, T[] b) {
int aLen = a.length;
int bLen = b.length;

@SuppressWarnings("unchecked")
T[] c = (T[]) Array.newInstance(a.getClass().getComponentType(), aLen + bLen);
System.arraycopy(a, 0, c, 0, aLen);
System.arraycopy(b, 0, c, aLen, bLen);

return c;
}

@Override
public void execute(String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
public void execute(String[] cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException {
execute(null, cmd, ffmpegExecuteResponseHandler);
}

@Override
public String getDeviceFFmpegVersion() throws FFmpegCommandAlreadyRunningException {
ShellCommand shellCommand = new ShellCommand();
CommandResult commandResult = shellCommand.runWaitFor(FileUtils.getFFmpeg(context) + " -version");
CommandResult commandResult = shellCommand.runWaitFor(new String[] { FileUtils.getFFmpeg(context), "-version" });
if (commandResult.success) {
return commandResult.output.split(" ")[2];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@

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

private final String cmd;
private final String[] cmd;
private final FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler;
private final ShellCommand shellCommand;
private final long timeout;
private long startTime;
private Process process;
private String output = "";

FFmpegExecuteAsyncTask(String cmd, long timeout, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) {
FFmpegExecuteAsyncTask(String[] cmd, long timeout, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) {
this.cmd = cmd;
this.timeout = timeout;
this.ffmpegExecuteResponseHandler = ffmpegExecuteResponseHandler;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ interface FFmpegInterface {
* @param ffmpegExecuteResponseHandler {@link FFmpegExecuteResponseHandler}
* @throws FFmpegCommandAlreadyRunningException
*/
public void execute(Map<String, String> environvenmentVars, String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException;
public void execute(Map<String, String> environvenmentVars, String[] cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException;

/**
* Executes a command
* @param cmd command to execute
* @param ffmpegExecuteResponseHandler {@link FFmpegExecuteResponseHandler}
* @throws FFmpegCommandAlreadyRunningException
*/
public void execute(String cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException;
public void execute(String[] cmd, FFmpegExecuteResponseHandler ffmpegExecuteResponseHandler) throws FFmpegCommandAlreadyRunningException;

/**
* Tells FFmpeg version currently on device
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class ShellCommand {

Process run(String commandString) {
Process run(String[] commandString) {
Process process = null;
try {
process = Runtime.getRuntime().exec(commandString);
Expand All @@ -14,7 +14,7 @@ Process run(String commandString) {
return process;
}

CommandResult runWaitFor(String s) {
CommandResult runWaitFor(String[] s) {
Process process = run(s);

Integer exitValue = null;
Expand Down
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
[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)
[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)
==============

[![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)

## About
[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/)
[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/)

These are two basic methods of this library:

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

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

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

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

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

## License
* 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.

## HIRE US
* Get in touch with us - http://www.writingminds.com


[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/hiteshsondhi88/ffmpeg-android-java/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

94 changes: 0 additions & 94 deletions app/app.iml

This file was deleted.

Loading

0 comments on commit 628ef00

Please sign in to comment.