Skip to content

Commit b553ef1

Browse files
committed
add libpmp3 module which is independent
1 parent fbfe1ce commit b553ef1

19 files changed

Lines changed: 1500 additions & 52 deletions

File tree

‎app/CMakeLists.txt‎

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ add_library( # Sets the name of the library.
3232
src/main/cpp/AVpacket_queue.c
3333
src/main/cpp/media_player.c
3434
src/main/cpp/video_filter.c
35-
src/main/cpp/audio_lame.c
3635
src/main/cpp/fast_start.c
3736
src/main/cpp/ffprobe_cmd.c
3837
)
@@ -44,13 +43,6 @@ set_target_properties( ffmpeg
4443
PROPERTIES IMPORTED_LOCATION
4544
../../../../libs/${CMAKE_ANDROID_ARCH_ABI}/libffmpeg.so )
4645

47-
add_library( mp3lame
48-
SHARED
49-
IMPORTED )
50-
set_target_properties( mp3lame
51-
PROPERTIES IMPORTED_LOCATION
52-
../../../../libs/${CMAKE_ANDROID_ARCH_ABI}/libmp3lame.so )
53-
5446
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
5547

5648
include_directories(src/main/cpp)
@@ -69,7 +61,6 @@ find_library( # Sets the name of the path variable.
6961

7062
target_link_libraries( # Specifies the target library.
7163
media-handle
72-
mp3lame
7364
ffmpeg
7465
-landroid #native_window
7566
-ljnigraphics #bitmap

‎app/build.gradle‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,6 @@ dependencies {
6262
implementation "androidx.core:core-ktx:$rootProject.core_ktx"
6363
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycle_ktx"
6464
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
65+
//implementation "libmp3" if you need mp3-lite module
66+
implementation project(':libmp3')
6567
}

‎app/src/main/java/com/frank/ffmpeg/AudioPlayer.java‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,6 @@ public class AudioPlayer {
2222

2323
public native void stop();
2424

25-
public native static void lameInitDefault();
26-
27-
public native static void lameInit(int inSamplerate, int outChannel,
28-
int outSamplerate, int outBitrate, float scaleInput, int mode, int vbrMode,
29-
int quality, int vbrQuality, int abrMeanBitrate, int lowpassFreq, int highpassFreq, String id3tagTitle,
30-
String id3tagArtist, String id3tagAlbum, String id3tagYear,
31-
String id3tagComment);
32-
33-
public native static int lameEncode(short[] buffer_l, short[] buffer_r,
34-
int samples, byte[] mp3buf);
35-
36-
public native static int encodeBufferInterleaved(short[] pcm, int samples,
37-
byte[] mp3buf);
38-
39-
public native static int lameFlush(byte[] mp3buf);
40-
41-
public native static void lameClose();
42-
4325
/**
4426
* Create an AudioTrack instance for JNI calling
4527
*

‎app/src/main/java/com/frank/ffmpeg/activity/AudioHandleActivity.kt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import java.util.Locale
1616
import com.frank.ffmpeg.AudioPlayer
1717
import com.frank.ffmpeg.R
1818
import com.frank.ffmpeg.handler.FFmpegHandler
19-
import com.frank.ffmpeg.mp3.Mp3Converter
19+
import com.frank.mp3.Mp3Converter
2020
import com.frank.ffmpeg.util.FFmpegUtil
2121
import com.frank.ffmpeg.util.FileUtil
2222

‎libmp3/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

‎libmp3/CMakeLists.txt‎

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# For more information about using CMake with Android Studio, read the
2+
# documentation: https://d.android.com/studio/projects/add-native-code.html
3+
4+
# Sets the minimum version of CMake required to build the native library.
5+
6+
cmake_minimum_required(VERSION 3.4.1)
7+
8+
# Creates and names a library, sets it as either STATIC
9+
# or SHARED, and provides the relative paths to its source code.
10+
# You can define multiple libraries, and CMake builds them for you.
11+
# Gradle automatically packages shared libraries with your APK.
12+
13+
add_library( # Sets the name of the library.
14+
mp3-lite
15+
16+
# Sets the library as a shared library.
17+
SHARED
18+
19+
# Provides a relative path to your source file(s).
20+
src/main/cpp/audio_lame.c
21+
)
22+
23+
add_library( mp3lame
24+
SHARED
25+
IMPORTED )
26+
set_target_properties( mp3lame
27+
PROPERTIES IMPORTED_LOCATION
28+
../../../../libs/${CMAKE_ANDROID_ARCH_ABI}/libmp3lame.so )
29+
30+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
31+
32+
include_directories(src/main/cpp)
33+
34+
find_library( # Sets the name of the path variable.
35+
log-lib
36+
log )
37+
38+
target_link_libraries( # Specifies the target library.
39+
mp3-lite
40+
mp3lame
41+
# Links the target library to the log library
42+
# included in the NDK.
43+
${log-lib} )

‎libmp3/build.gradle‎

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
apply plugin: 'com.android.library'
2+
apply plugin: 'kotlin-android'
3+
apply plugin: 'kotlin-android-extensions'
4+
android {
5+
compileSdkVersion rootProject.ext.compileSdkVersion
6+
buildToolsVersion rootProject.ext.buildToolsVersion
7+
8+
9+
defaultConfig {
10+
minSdkVersion rootProject.ext.minSdkVersion
11+
targetSdkVersion rootProject.ext.targetSdkVersion
12+
versionCode rootProject.ext.versionCode
13+
versionName rootProject.ext.versionName
14+
15+
externalNativeBuild {
16+
cmake {
17+
cppFlags ""
18+
}
19+
}
20+
ndk {
21+
abiFilters "armeabi-v7a", "arm64-v8a"
22+
}
23+
}
24+
25+
buildTypes {
26+
release {
27+
minifyEnabled false
28+
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
29+
}
30+
}
31+
32+
externalNativeBuild {
33+
cmake {
34+
path "CMakeLists.txt"
35+
}
36+
}
37+
sourceSets {
38+
main {
39+
jniLibs.srcDirs = ['libs']
40+
jni.srcDirs = []
41+
}
42+
}
43+
}
44+
45+
dependencies {
46+
implementation fileTree(dir: 'libs', include: ['*.jar'])
47+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
48+
implementation "androidx.appcompat:appcompat:$rootProject.appcompatVersion"
49+
implementation "androidx.core:core-ktx:$rootProject.core_ktx"
50+
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$rootProject.lifecycle_ktx"
51+
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
52+
}

‎libmp3/proguard-rules.pro‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Add project specific ProGuard rules here.
2+
# You can control the set of applied configuration files using the
3+
# proguardFiles setting in build.gradle.
4+
#
5+
# For more details, see
6+
# http://developer.android.com/guide/developing/tools/proguard.html
7+
8+
# If your project uses WebView with JS, uncomment the following
9+
# and specify the fully qualified class name to the JavaScript interface
10+
# class:
11+
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12+
# public *;
13+
#}
14+
15+
# Uncomment this to preserve the line number information for
16+
# debugging stack traces.
17+
#-keepattributes SourceFile,LineNumberTable
18+
19+
# If you keep the line number information, uncomment this to
20+
# hide the original source file name.
21+
#-renamesourcefileattribute SourceFile

0 commit comments

Comments
 (0)