-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
51 changed files
with
5,050 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Masayuki Suda | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android-extensions' | ||
apply plugin: 'kotlin-android' | ||
|
||
android { | ||
compileSdkVersion 29 | ||
|
||
defaultConfig { | ||
minSdkVersion 21 | ||
targetSdkVersion 29 | ||
versionCode 1 | ||
versionName "0.2.0" | ||
} | ||
|
||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
lintOptions { | ||
abortOnError false | ||
} | ||
|
||
} | ||
|
||
dependencies { | ||
implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" | ||
|
||
} | ||
repositories { | ||
mavenCentral() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.daasuu.mp4compose" /> |
55 changes: 55 additions & 0 deletions
55
mp4compose/src/main/java/com/daasuu/mp4compose/FillMode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.daasuu.mp4compose; | ||
|
||
/** | ||
* Created by sudamasayuki on 2018/01/01. | ||
*/ | ||
|
||
public enum FillMode { | ||
PRESERVE_ASPECT_FIT, | ||
PRESERVE_ASPECT_CROP, | ||
CUSTOM; | ||
|
||
public static float[] getScaleAspectFit(int angle, int widthIn, int heightIn, int widthOut, int heightOut) { | ||
final float[] scale = {1, 1}; | ||
scale[0] = scale[1] = 1; | ||
if (angle == 90 || angle == 270) { | ||
int cx = widthIn; | ||
widthIn = heightIn; | ||
heightIn = cx; | ||
} | ||
|
||
float aspectRatioIn = (float) widthIn / (float) heightIn; | ||
float heightOutCalculated = (float) widthOut / aspectRatioIn; | ||
|
||
if (heightOutCalculated < heightOut) { | ||
scale[1] = heightOutCalculated / heightOut; | ||
} else { | ||
scale[0] = heightOut * aspectRatioIn / widthOut; | ||
} | ||
|
||
return scale; | ||
} | ||
|
||
public static float[] getScaleAspectCrop(int angle, int widthIn, int heightIn, int widthOut, int heightOut) { | ||
final float[] scale = {1, 1}; | ||
scale[0] = scale[1] = 1; | ||
if (angle == 90 || angle == 270) { | ||
int cx = widthIn; | ||
widthIn = heightIn; | ||
heightIn = cx; | ||
} | ||
|
||
float aspectRatioIn = (float) widthIn / (float) heightIn; | ||
float aspectRatioOut = (float) widthOut / (float) heightOut; | ||
|
||
if (aspectRatioIn > aspectRatioOut) { | ||
float widthOutCalculated = (float) heightOut * aspectRatioIn; | ||
scale[0] = widthOutCalculated / widthOut; | ||
} else { | ||
float heightOutCalculated = (float) widthOut / aspectRatioIn; | ||
scale[1] = heightOutCalculated / heightOut; | ||
} | ||
|
||
return scale; | ||
} | ||
} |
86 changes: 86 additions & 0 deletions
86
mp4compose/src/main/java/com/daasuu/mp4compose/FillModeCustomItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.daasuu.mp4compose; | ||
|
||
import android.os.Parcel; | ||
import android.os.Parcelable; | ||
|
||
/** | ||
* Created by sudamasayuki2 on 2018/01/08. | ||
*/ | ||
|
||
public class FillModeCustomItem implements Parcelable { | ||
private final float scale; | ||
private final float rotate; | ||
private final float translateX; | ||
private final float translateY; | ||
private final float videoWidth; | ||
private final float videoHeight; | ||
|
||
public FillModeCustomItem(float scale, float rotate, float translateX, float translateY, float videoWidth, float videoHeight) { | ||
this.scale = scale; | ||
this.rotate = rotate; | ||
this.translateX = translateX; | ||
this.translateY = translateY; | ||
this.videoWidth = videoWidth; | ||
this.videoHeight = videoHeight; | ||
} | ||
|
||
public float getScale() { | ||
return scale; | ||
} | ||
|
||
public float getRotate() { | ||
return rotate; | ||
} | ||
|
||
public float getTranslateX() { | ||
return translateX; | ||
} | ||
|
||
public float getTranslateY() { | ||
return translateY; | ||
} | ||
|
||
public float getVideoWidth() { | ||
return videoWidth; | ||
} | ||
|
||
public float getVideoHeight() { | ||
return videoHeight; | ||
} | ||
|
||
@Override | ||
public int describeContents() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void writeToParcel(Parcel dest, int flags) { | ||
dest.writeFloat(this.scale); | ||
dest.writeFloat(this.rotate); | ||
dest.writeFloat(this.translateX); | ||
dest.writeFloat(this.translateY); | ||
dest.writeFloat(this.videoWidth); | ||
dest.writeFloat(this.videoHeight); | ||
} | ||
|
||
protected FillModeCustomItem(Parcel in) { | ||
this.scale = in.readFloat(); | ||
this.rotate = in.readFloat(); | ||
this.translateX = in.readFloat(); | ||
this.translateY = in.readFloat(); | ||
this.videoWidth = in.readFloat(); | ||
this.videoHeight = in.readFloat(); | ||
} | ||
|
||
public static final Parcelable.Creator<FillModeCustomItem> CREATOR = new Parcelable.Creator<FillModeCustomItem>() { | ||
@Override | ||
public FillModeCustomItem createFromParcel(Parcel source) { | ||
return new FillModeCustomItem(source); | ||
} | ||
|
||
@Override | ||
public FillModeCustomItem[] newArray(int size) { | ||
return new FillModeCustomItem[size]; | ||
} | ||
}; | ||
} |
31 changes: 31 additions & 0 deletions
31
mp4compose/src/main/java/com/daasuu/mp4compose/Rotation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.daasuu.mp4compose; | ||
|
||
/** | ||
* Created by sudamasayuki on 2017/11/15. | ||
*/ | ||
|
||
public enum Rotation { | ||
NORMAL(0), | ||
ROTATION_90(90), | ||
ROTATION_180(180), | ||
ROTATION_270(270); | ||
|
||
private final int rotation; | ||
|
||
Rotation(int rotation) { | ||
this.rotation = rotation; | ||
} | ||
|
||
public int getRotation() { | ||
return rotation; | ||
} | ||
|
||
public static Rotation fromInt(int rotate) { | ||
for (Rotation rotation : Rotation.values()) { | ||
if (rotate == rotation.getRotation()) return rotation; | ||
} | ||
|
||
return NORMAL; | ||
} | ||
|
||
} |
Oops, something went wrong.