forked from media-kit/libmpv-android-video-build
-
Notifications
You must be signed in to change notification settings - Fork 2
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
0 parents
commit cc33914
Showing
48 changed files
with
5,190 additions
and
0 deletions.
There are no files selected for viewing
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,11 @@ | ||
.gdb_history | ||
bin | ||
gen | ||
libs | ||
obj | ||
.gradle | ||
.idea | ||
**/*.iml | ||
build | ||
local.properties | ||
*~ |
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,8 @@ | ||
Copyright (c) 2016 Ilya Zhuravlev | ||
Copyright (c) 2016 sfan5 <[email protected]> | ||
|
||
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,5 @@ | ||
# mpvlib for Android | ||
|
||
## Building from source | ||
|
||
Take a look at [README.md](buildscripts/README.md) inside the `buildscripts` directory. |
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 @@ | ||
apply plugin: 'com.android.library' | ||
|
||
android { | ||
compileSdkVersion 33 | ||
|
||
defaultConfig { | ||
minSdkVersion 26 | ||
targetSdkVersion 33 | ||
consumerProguardFiles("proguard-rules.pro") | ||
} | ||
|
||
sourceSets { | ||
main { | ||
java.srcDirs = ["src/main/java"] | ||
jni.srcDirs = ["src/main/jni"] | ||
} | ||
} | ||
} | ||
|
||
// build a jar with source files | ||
task sourcesArtifact(type: Jar) { | ||
archiveClassifier.set("sources") | ||
from(android.sourceSets["main"].java.srcDirs) | ||
} | ||
|
||
task javadoc(type: Javadoc) { | ||
mustRunAfter "generateDebugRFile" | ||
mustRunAfter "generateReleaseRFile" | ||
failOnError false | ||
source = android.sourceSets["main"].java.sourceFiles | ||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator)) | ||
configurations.implementation.setCanBeResolved(true) | ||
classpath += configurations.implementation | ||
} | ||
|
||
// build a jar with javadoc | ||
task javadocJar(type: Jar, dependsOn: javadoc) { | ||
archiveClassifier.set("javadoc") | ||
from javadoc.destinationDir | ||
} | ||
|
||
artifacts { | ||
archives sourcesArtifact | ||
archives javadocJar | ||
} | ||
|
||
afterEvaluate { | ||
javadoc.classpath += files(android.libraryVariants.collect { variant -> | ||
variant.javaCompileProvider.get().classpath.files | ||
}) | ||
} | ||
|
||
dependencies { | ||
implementation 'androidx.annotation:annotation:1.5.0' | ||
} |
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 @@ | ||
-keep class dev.jdtech.mpv.MPVLib { *; } |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest package="dev.jdtech.mpvlib" /> |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
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,241 @@ | ||
package dev.jdtech.mpv; | ||
|
||
// Wrapper for native library | ||
|
||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import android.content.Context; | ||
import android.view.Surface; | ||
|
||
import androidx.annotation.IntDef; | ||
import androidx.annotation.NonNull; | ||
|
||
@SuppressWarnings("unused") | ||
public class MPVLib { | ||
|
||
static { | ||
String[] libs = {"mpv", "player"}; | ||
for (String lib : libs) { | ||
System.loadLibrary(lib); | ||
} | ||
} | ||
|
||
public static native void create(Context appctx); | ||
|
||
public static native void init(); | ||
|
||
public static native void destroy(); | ||
|
||
public static native void attachSurface(Surface surface); | ||
|
||
public static native void detachSurface(); | ||
|
||
public static native void command(@NonNull String[] cmd); | ||
|
||
public static native int setOptionString(@NonNull String name, @NonNull String value); | ||
|
||
public static native Integer getPropertyInt(@NonNull String property); | ||
|
||
public static native void setPropertyInt(@NonNull String property, @NonNull Integer value); | ||
|
||
public static native Double getPropertyDouble(@NonNull String property); | ||
|
||
public static native void setPropertyDouble(@NonNull String property, @NonNull Double value); | ||
|
||
public static native Boolean getPropertyBoolean(@NonNull String property); | ||
|
||
public static native void setPropertyBoolean(@NonNull String property, @NonNull Boolean value); | ||
|
||
public static native String getPropertyString(@NonNull String property); | ||
|
||
public static native void setPropertyString(@NonNull String property, @NonNull String value); | ||
|
||
public static native void observeProperty(@NonNull String property, @Format int format); | ||
|
||
private static final List<EventObserver> observers = new ArrayList<>(); | ||
|
||
public static void addObserver(EventObserver o) { | ||
synchronized (observers) { | ||
observers.add(o); | ||
} | ||
} | ||
|
||
public static void removeObserver(EventObserver o) { | ||
synchronized (observers) { | ||
observers.remove(o); | ||
} | ||
} | ||
|
||
public static void eventProperty(String property, long value) { | ||
synchronized (observers) { | ||
for (EventObserver o : observers) | ||
o.eventProperty(property, value); | ||
} | ||
} | ||
|
||
public static void eventProperty(String property, double value) { | ||
synchronized (observers) { | ||
for (EventObserver o : observers) | ||
o.eventProperty(property, value); | ||
} | ||
} | ||
|
||
public static void eventProperty(String property, boolean value) { | ||
synchronized (observers) { | ||
for (EventObserver o : observers) | ||
o.eventProperty(property, value); | ||
} | ||
} | ||
|
||
public static void eventProperty(String property, String value) { | ||
synchronized (observers) { | ||
for (EventObserver o : observers) | ||
o.eventProperty(property, value); | ||
} | ||
} | ||
|
||
public static void eventProperty(String property) { | ||
synchronized (observers) { | ||
for (EventObserver o : observers) | ||
o.eventProperty(property); | ||
} | ||
} | ||
|
||
public static void event(@Event int eventId) { | ||
synchronized (observers) { | ||
for (EventObserver o : observers) | ||
o.event(eventId); | ||
} | ||
} | ||
|
||
private static final List<LogObserver> log_observers = new ArrayList<>(); | ||
|
||
public static void addLogObserver(LogObserver o) { | ||
synchronized (log_observers) { | ||
log_observers.add(o); | ||
} | ||
} | ||
|
||
public static void removeLogObserver(LogObserver o) { | ||
synchronized (log_observers) { | ||
log_observers.remove(o); | ||
} | ||
} | ||
|
||
public static void logMessage(String prefix, @LogLevel int level, String text) { | ||
synchronized (log_observers) { | ||
for (LogObserver o : log_observers) | ||
o.logMessage(prefix, level, text); | ||
} | ||
} | ||
|
||
public interface EventObserver { | ||
void eventProperty(@NonNull String property); | ||
|
||
void eventProperty(@NonNull String property, long value); | ||
|
||
void eventProperty(@NonNull String property, double value); | ||
|
||
void eventProperty(@NonNull String property, boolean value); | ||
|
||
void eventProperty(@NonNull String property, @NonNull String value); | ||
|
||
void event(@Event int eventId); | ||
} | ||
|
||
public interface LogObserver { | ||
void logMessage(@NonNull String prefix, @LogLevel int level, @NonNull String text); | ||
} | ||
|
||
@Retention(RetentionPolicy.SOURCE) | ||
@IntDef({ | ||
MPV_FORMAT_NONE, | ||
MPV_FORMAT_STRING, | ||
MPV_FORMAT_OSD_STRING, | ||
MPV_FORMAT_FLAG, | ||
MPV_FORMAT_INT64, | ||
MPV_FORMAT_DOUBLE, | ||
MPV_FORMAT_NODE, | ||
MPV_FORMAT_NODE_ARRAY, | ||
MPV_FORMAT_NODE_MAP, | ||
MPV_FORMAT_BYTE_ARRAY | ||
}) | ||
public @interface Format {} | ||
|
||
public static final int MPV_FORMAT_NONE = 0; | ||
public static final int MPV_FORMAT_STRING = 1; | ||
public static final int MPV_FORMAT_OSD_STRING = 2; | ||
public static final int MPV_FORMAT_FLAG = 3; | ||
public static final int MPV_FORMAT_INT64 = 4; | ||
public static final int MPV_FORMAT_DOUBLE = 5; | ||
public static final int MPV_FORMAT_NODE = 6; | ||
public static final int MPV_FORMAT_NODE_ARRAY = 7; | ||
public static final int MPV_FORMAT_NODE_MAP = 8; | ||
public static final int MPV_FORMAT_BYTE_ARRAY = 9; | ||
|
||
|
||
@Retention(RetentionPolicy.SOURCE) | ||
@IntDef({ | ||
MPV_EVENT_NONE, | ||
MPV_EVENT_SHUTDOWN, | ||
MPV_EVENT_LOG_MESSAGE, | ||
MPV_EVENT_GET_PROPERTY_REPLY, | ||
MPV_EVENT_SET_PROPERTY_REPLY, | ||
MPV_EVENT_COMMAND_REPLY, | ||
MPV_EVENT_START_FILE, | ||
MPV_EVENT_END_FILE, | ||
MPV_EVENT_FILE_LOADED, | ||
MPV_EVENT_CLIENT_MESSAGE, | ||
MPV_EVENT_VIDEO_RECONFIG, | ||
MPV_EVENT_AUDIO_RECONFIG, | ||
MPV_EVENT_SEEK, | ||
MPV_EVENT_PLAYBACK_RESTART, | ||
MPV_EVENT_PROPERTY_CHANGE, | ||
MPV_EVENT_QUEUE_OVERFLOW, | ||
MPV_EVENT_HOOK | ||
}) | ||
public @interface Event {} | ||
|
||
public static final int MPV_EVENT_NONE = 0; | ||
public static final int MPV_EVENT_SHUTDOWN = 1; | ||
public static final int MPV_EVENT_LOG_MESSAGE = 2; | ||
public static final int MPV_EVENT_GET_PROPERTY_REPLY = 3; | ||
public static final int MPV_EVENT_SET_PROPERTY_REPLY = 4; | ||
public static final int MPV_EVENT_COMMAND_REPLY = 5; | ||
public static final int MPV_EVENT_START_FILE = 6; | ||
public static final int MPV_EVENT_END_FILE = 7; | ||
public static final int MPV_EVENT_FILE_LOADED = 8; | ||
public static final int MPV_EVENT_CLIENT_MESSAGE = 16; | ||
public static final int MPV_EVENT_VIDEO_RECONFIG = 17; | ||
public static final int MPV_EVENT_AUDIO_RECONFIG = 18; | ||
public static final int MPV_EVENT_SEEK = 20; | ||
public static final int MPV_EVENT_PLAYBACK_RESTART = 21; | ||
public static final int MPV_EVENT_PROPERTY_CHANGE = 22; | ||
public static final int MPV_EVENT_QUEUE_OVERFLOW = 24; | ||
public static final int MPV_EVENT_HOOK = 25; | ||
|
||
@Retention(RetentionPolicy.SOURCE) | ||
@IntDef({ | ||
MPV_LOG_LEVEL_NONE, | ||
MPV_LOG_LEVEL_FATAL, | ||
MPV_LOG_LEVEL_ERROR, | ||
MPV_LOG_LEVEL_WARN, | ||
MPV_LOG_LEVEL_INFO, | ||
MPV_LOG_LEVEL_V, | ||
MPV_LOG_LEVEL_DEBUG, | ||
MPV_LOG_LEVEL_TRACE | ||
}) | ||
public @interface LogLevel {} | ||
|
||
public static final int MPV_LOG_LEVEL_NONE = 0; | ||
public static final int MPV_LOG_LEVEL_FATAL = 10; | ||
public static final int MPV_LOG_LEVEL_ERROR = 20; | ||
public static final int MPV_LOG_LEVEL_WARN = 30; | ||
public static final int MPV_LOG_LEVEL_INFO = 40; | ||
public static final int MPV_LOG_LEVEL_V = 50; | ||
public static final int MPV_LOG_LEVEL_DEBUG = 60; | ||
public static final int MPV_LOG_LEVEL_TRACE = 70; | ||
} |
Oops, something went wrong.