├── x264-codec ├── .gitignore ├── consumer-rules.pro ├── src │ ├── main │ │ ├── jni │ │ │ ├── Android.mk │ │ │ ├── Application.mk │ │ │ ├── fdkaac │ │ │ │ ├── lib │ │ │ │ │ ├── x86 │ │ │ │ │ │ └── libfdk-aac.a │ │ │ │ │ └── arm64-v8a │ │ │ │ │ │ └── libfdk-aac.a │ │ │ │ └── Android.mk │ │ │ ├── libx264 │ │ │ │ ├── libs │ │ │ │ │ ├── x86 │ │ │ │ │ │ └── libx264.a │ │ │ │ │ ├── x86_64 │ │ │ │ │ │ └── libx264.a │ │ │ │ │ └── arm64-v8a │ │ │ │ │ │ └── libx264.a │ │ │ │ ├── include │ │ │ │ │ └── x264_config.h │ │ │ │ └── Android.mk │ │ │ ├── libopenh264 │ │ │ │ ├── libs │ │ │ │ │ ├── x86 │ │ │ │ │ │ └── libopenh264.a │ │ │ │ │ └── arm64-v8a │ │ │ │ │ │ └── libopenh264.a │ │ │ │ └── include │ │ │ │ │ └── wels │ │ │ │ │ ├── codec_ver.h │ │ │ │ │ └── codec_def.h │ │ │ ├── librtmp │ │ │ │ ├── librtmp.pc.in │ │ │ │ ├── Android.mk │ │ │ │ ├── http.h │ │ │ │ ├── log.h │ │ │ │ ├── bytes.h │ │ │ │ ├── rtmp_sys.h │ │ │ │ ├── log.c │ │ │ │ ├── amf.h │ │ │ │ ├── parseurl.c │ │ │ │ └── librtmp.3 │ │ │ └── softcodec │ │ │ │ ├── rtmpManage.h │ │ │ │ ├── Android.mk │ │ │ │ ├── rtmpManage.c │ │ │ │ ├── h264_encoder_log.h │ │ │ │ ├── xiecc_rtmp.h │ │ │ │ ├── h264Encoder.h │ │ │ │ ├── aacEncode.h │ │ │ │ ├── aacEncode.c │ │ │ │ ├── h264Encoder.c │ │ │ │ └── xiecc_rtmp.c │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── io │ │ │ └── github │ │ │ └── brucewind │ │ │ └── softcodec │ │ │ ├── StreamHelper.java │ │ │ ├── RtmpHelper.java │ │ │ └── AudioRecorder.java │ └── test │ │ └── java │ │ └── io │ │ └── github │ │ └── brucewind │ │ └── x264_codec │ │ └── ExampleUnitTest.java ├── proguard-rules.pro └── build.gradle ├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── androidyuan │ │ │ └── ui │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── androidyuan │ │ │ └── softcodec │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── androidyuan │ │ └── softcodec │ │ └── ApplicationTest.java ├── proguard-rules.pro └── build.gradle ├── openh264-codec ├── .gitignore ├── consumer-rules.pro ├── src │ ├── main │ │ ├── jni │ │ │ ├── Android.mk │ │ │ ├── Application.mk │ │ │ ├── softcodec │ │ │ │ ├── Application.mk │ │ │ │ ├── print_hex.h │ │ │ │ ├── rtmpManage.h │ │ │ │ ├── print_hex.cc │ │ │ │ ├── Android.mk │ │ │ │ ├── stdint.h │ │ │ │ ├── rtmpManage.c │ │ │ │ ├── h264_encoder_log.h │ │ │ │ ├── h264Encoder.h │ │ │ │ ├── xiecc_rtmp.h │ │ │ │ ├── aacEncode.h │ │ │ │ └── aacEncode.c │ │ │ ├── fdkaac │ │ │ │ ├── lib │ │ │ │ │ ├── x86 │ │ │ │ │ │ └── libfdk-aac.a │ │ │ │ │ └── arm64-v8a │ │ │ │ │ │ └── libfdk-aac.a │ │ │ │ └── Android.mk │ │ │ ├── libopenh264 │ │ │ │ ├── libs │ │ │ │ │ ├── x86 │ │ │ │ │ │ └── libopenh264.a │ │ │ │ │ └── arm64-v8a │ │ │ │ │ │ └── libopenh264.a │ │ │ │ ├── Android.mk │ │ │ │ └── include │ │ │ │ │ └── wels │ │ │ │ │ ├── codec_ver.h │ │ │ │ │ └── codec_def.h │ │ │ ├── librtmp │ │ │ │ ├── librtmp.pc.in │ │ │ │ ├── Android.mk │ │ │ │ ├── http.h │ │ │ │ ├── log.h │ │ │ │ ├── bytes.h │ │ │ │ ├── rtmp_sys.h │ │ │ │ ├── log.c │ │ │ │ ├── amf.h │ │ │ │ ├── parseurl.c │ │ │ │ └── librtmp.3 │ │ │ └── CMakeLists.txt │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── io │ │ │ └── github │ │ │ └── brucewind │ │ │ └── softcodec │ │ │ ├── StreamHelper.java │ │ │ ├── YUVHelper.java │ │ │ ├── RtmpHelper.java │ │ │ └── AudioRecorder.java │ └── test │ │ └── java │ │ └── io │ │ └── github │ │ └── brucewind │ │ └── x264_codec │ │ └── ExampleUnitTest.java ├── README.md ├── proguard-rules.pro └── build.gradle ├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── .github └── workflows │ └── build.yml ├── gradle.properties ├── gradlew.bat ├── README_zh_cn.md ├── README.md ├── .gitignore └── gradlew /x264-codec/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /obj -------------------------------------------------------------------------------- /openh264-codec/.gitignore: -------------------------------------------------------------------------------- 1 | /build -------------------------------------------------------------------------------- /openh264-codec/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /x264-codec/consumer-rules.pro: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /x264-codec/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | include $(call all-subdir-makefiles) 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | //include ':x264-codec' 2 | include ':openh264-codec' 3 | include ':app' 4 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/Android.mk: -------------------------------------------------------------------------------- 1 | include $(call all-subdir-makefiles) 2 | 3 | LOCAL_CPPFLAGS += -O3 -std=c++11 -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /x264-codec/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := arm64-v8a 2 | # 3 | #APP_ABI := all 4 | APP_PLATFORM := android-9 5 | APP_STL := c++_static -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /openh264-codec/README.md: -------------------------------------------------------------------------------- 1 | ## Notes 2 | 3 | Openh264 only support [YUV420 format](https://github.com/cisco/openh264/wiki#encoder-features). 4 | 5 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := arm64-v8a 2 | APP_PLATFORM := android-16 3 | APP_STL := c++_static 4 | #APP_STL := c++_shared -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/Application.mk: -------------------------------------------------------------------------------- 1 | APP_ABI := arm64-v8a 2 | APP_PLATFORM := android-16 3 | APP_STL := c++_static 4 | #APP_STL := c++_shared -------------------------------------------------------------------------------- /x264-codec/src/main/jni/fdkaac/lib/x86/libfdk-aac.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/x264-codec/src/main/jni/fdkaac/lib/x86/libfdk-aac.a -------------------------------------------------------------------------------- /x264-codec/src/main/jni/libx264/libs/x86/libx264.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/x264-codec/src/main/jni/libx264/libs/x86/libx264.a -------------------------------------------------------------------------------- /x264-codec/src/main/jni/libx264/libs/x86_64/libx264.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/x264-codec/src/main/jni/libx264/libs/x86_64/libx264.a -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/fdkaac/lib/x86/libfdk-aac.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/openh264-codec/src/main/jni/fdkaac/lib/x86/libfdk-aac.a -------------------------------------------------------------------------------- /x264-codec/src/main/jni/libx264/libs/arm64-v8a/libx264.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/x264-codec/src/main/jni/libx264/libs/arm64-v8a/libx264.a -------------------------------------------------------------------------------- /x264-codec/src/main/jni/fdkaac/lib/arm64-v8a/libfdk-aac.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/x264-codec/src/main/jni/fdkaac/lib/arm64-v8a/libfdk-aac.a -------------------------------------------------------------------------------- /x264-codec/src/main/jni/libopenh264/libs/x86/libopenh264.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/x264-codec/src/main/jni/libopenh264/libs/x86/libopenh264.a -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/fdkaac/lib/arm64-v8a/libfdk-aac.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/openh264-codec/src/main/jni/fdkaac/lib/arm64-v8a/libfdk-aac.a -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/libopenh264/libs/x86/libopenh264.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/openh264-codec/src/main/jni/libopenh264/libs/x86/libopenh264.a -------------------------------------------------------------------------------- /x264-codec/src/main/jni/libopenh264/libs/arm64-v8a/libopenh264.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/x264-codec/src/main/jni/libopenh264/libs/arm64-v8a/libopenh264.a -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/libopenh264/libs/arm64-v8a/libopenh264.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BruceWind/SoftCodec/HEAD/openh264-codec/src/main/jni/libopenh264/libs/arm64-v8a/libopenh264.a -------------------------------------------------------------------------------- /x264-codec/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /openh264-codec/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | -------------------------------------------------------------------------------- /x264-codec/src/main/jni/libx264/include/x264_config.h: -------------------------------------------------------------------------------- 1 | #define X264_GPL 1 2 | #define X264_INTERLACED 1 3 | #define X264_BIT_DEPTH 0 4 | #define X264_CHROMA_FORMAT 0 5 | #define X264_VERSION "" 6 | #define X264_POINTVER "0.155.x" 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | SoftCodec 3 | Cannt connect to %s 4 | connected to %s. 5 | 6 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/print_hex.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by bruce on 21-6-14. 3 | // 4 | 5 | #ifndef SOFTCODEC_PRINT_HEX_H 6 | #define SOFTCODEC_PRINT_HEX_H 7 | 8 | void print_hex(char * tag, unsigned char* data,int len); 9 | #endif //SOFTCODEC_PRINT_HEX_H 10 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | on: [pull_request, push] 3 | jobs: 4 | build: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Checkout the code 8 | uses: actions/checkout@v2 9 | - name: Build the app 10 | run: ./gradlew build -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu May 20 23:04:35 CST 2021 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip 7 | -------------------------------------------------------------------------------- /x264-codec/src/main/jni/librtmp/librtmp.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=${prefix} 3 | libdir=@libdir@ 4 | incdir=${prefix}/include 5 | 6 | Name: librtmp 7 | Description: RTMP implementation 8 | Version: @VERSION@ 9 | Requires: @CRYPTO_REQ@ 10 | URL: http://rtmpdump.mplayerhq.hu 11 | Libs: -L${libdir} -lrtmp -lz @PUBLIC_LIBS@ 12 | Libs.private: @PRIVATE_LIBS@ 13 | Cflags: -I${incdir} 14 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/librtmp/librtmp.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=${prefix} 3 | libdir=@libdir@ 4 | incdir=${prefix}/include 5 | 6 | Name: librtmp 7 | Description: RTMP implementation 8 | Version: @VERSION@ 9 | Requires: @CRYPTO_REQ@ 10 | URL: http://rtmpdump.mplayerhq.hu 11 | Libs: -L${libdir} -lrtmp -lz @PUBLIC_LIBS@ 12 | Libs.private: @PRIVATE_LIBS@ 13 | Cflags: -I${incdir} 14 | -------------------------------------------------------------------------------- /x264-codec/src/main/jni/softcodec/rtmpManage.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xiecc_rtmp.h" 3 | 4 | 5 | /* 6 | *rtmp的连接 7 | */ 8 | JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_open(JNIEnv *env,jobject instance, jstring url_); 9 | 10 | 11 | /* 12 | *断开rtmp的 13 | */ 14 | 15 | JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_stop(JNIEnv *env,jobject instance); 16 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/rtmpManage.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | /* 5 | *rtmp的连接 6 | */ 7 | JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_open(JNIEnv *env,jobject instance, jstring url_); 8 | 9 | //TODO does it need to add pause function? 10 | 11 | /* 12 | *断开rtmp的 13 | */ 14 | 15 | JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_stop(JNIEnv *env,jobject instance); 16 | -------------------------------------------------------------------------------- /app/src/test/java/com/androidyuan/softcodec/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.androidyuan.softcodec; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/libopenh264/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | LOCAL_MODULE := libopenh264 5 | 6 | ifeq ($(TARGET_ARCH_ABI),arm64-v8a) 7 | LOCAL_SRC_FILES := libs/arm64-v8a/libopenh264.a 8 | endif 9 | 10 | ifeq ($(TARGET_ARCH_ABI),x86) 11 | LOCAL_SRC_FILES := libs/x86/libopenh264.a 12 | endif 13 | 14 | LOCAL_EXPORT_C_INCLUDES := include/wels 15 | include $(PREBUILT_STATIC_LIBRARY) 16 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/androidyuan/softcodec/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.androidyuan.softcodec; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /x264-codec/src/main/jni/librtmp/Android.mk: -------------------------------------------------------------------------------- 1 | ## depend librtmp with source code. 2 | LOCAL_PATH:= $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_MODULE := librtmp 7 | 8 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/include 9 | 10 | LOCAL_SRC_FILES := \ 11 | amf.c \ 12 | log.c \ 13 | parseurl.c \ 14 | rtmp.c \ 15 | hashswf.c 16 | 17 | LOCAL_CFLAGS := -DRTMPDUMP_VERSION=v2.4 -DNO_CRYPTO 18 | 19 | include $(BUILD_STATIC_LIBRARY) 20 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/fdkaac/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | include $(CLEAR_VARS) 5 | LOCAL_MODULE :=static_aac 6 | 7 | 8 | ifeq ($(TARGET_ARCH_ABI),arm64-v8a) 9 | LOCAL_SRC_FILES := lib/arm64-v8a/libfdk-aac.a 10 | endif 11 | 12 | ifeq ($(TARGET_ARCH_ABI),x86) 13 | LOCAL_SRC_FILES := lib/x86/libfdk-aac.a 14 | endif 15 | 16 | 17 | LOCAL_EXPORT_C_INCLUDES := include 18 | include $(PREBUILT_STATIC_LIBRARY) 19 | 20 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/librtmp/Android.mk: -------------------------------------------------------------------------------- 1 | ## depend librtmp with source code. 2 | LOCAL_PATH:= $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | 6 | LOCAL_MODULE := librtmp 7 | 8 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/include 9 | 10 | LOCAL_SRC_FILES := \ 11 | amf.c \ 12 | log.c \ 13 | parseurl.c \ 14 | rtmp.c \ 15 | hashswf.c 16 | 17 | LOCAL_CFLAGS := -DRTMPDUMP_VERSION=v2.4 -DNO_CRYPTO 18 | 19 | include $(BUILD_STATIC_LIBRARY) 20 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/print_hex.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "h264_encoder_log.h" 9 | 10 | void print_hex(char * tag, unsigned char* data,int len){ 11 | char buffer[len*2+1]; 12 | buffer[len*2]=0; 13 | 14 | for(auto j = 0; j < len; j++){ 15 | sprintf(&buffer[2*j], "%02X", data[j]); 16 | } 17 | ALOGI("%s hex:%s",tag,buffer); 18 | } -------------------------------------------------------------------------------- /x264-codec/src/main/jni/softcodec/Android.mk: -------------------------------------------------------------------------------- 1 | include $(call all-subdir-makefiles) 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | 5 | 6 | 7 | include $(CLEAR_VARS) 8 | LOCAL_MODULE := share_x264 9 | LOCAL_SHARED_LIBRARIES := libx264 10 | LOCAL_STATIC_LIBRARIES := librtmp \ 11 | static_aac 12 | LOCAL_LDLIBS := -ldl -lc -lz -lm -llog 13 | LOCAL_SRC_FILES := h264Encoder.c \ 14 | xiecc_rtmp.c \ 15 | aacEncode.c \ 16 | rtmpManage.c 17 | include $(BUILD_SHARED_LIBRARY) 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /openh264-codec/src/test/java/io/github/brucewind/x264_codec/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package io.github.brucewind.x264_codec; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | 14 | @Test 15 | public void addition_isCorrect() { 16 | assertEquals(4, 2 + 2); 17 | } 18 | } -------------------------------------------------------------------------------- /x264-codec/src/test/java/io/github/brucewind/x264_codec/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package io.github.brucewind.x264_codec; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * Example local unit test, which will execute on the development machine (host). 9 | * 10 | * @see Testing documentation 11 | */ 12 | public class ExampleUnitTest { 13 | 14 | @Test 15 | public void addition_isCorrect() { 16 | assertEquals(4, 2 + 2); 17 | } 18 | } -------------------------------------------------------------------------------- /x264-codec/src/main/jni/libopenh264/include/wels/codec_ver.h: -------------------------------------------------------------------------------- 1 | //The current file is auto-generated by script: generate_codec_ver.sh 2 | #ifndef CODEC_VER_H 3 | #define CODEC_VER_H 4 | 5 | #include "codec_app_def.h" 6 | 7 | static const OpenH264Version g_stCodecVersion = {2, 1, 1, 2005}; 8 | static const char* const g_strCodecVer = "OpenH264 version:2.1.1.2005"; 9 | 10 | #define OPENH264_MAJOR (2) 11 | #define OPENH264_MINOR (1) 12 | #define OPENH264_REVISION (1) 13 | #define OPENH264_RESERVED (2005) 14 | 15 | #endif // CODEC_VER_H 16 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/libopenh264/include/wels/codec_ver.h: -------------------------------------------------------------------------------- 1 | //The current file is auto-generated by script: generate_codec_ver.sh 2 | #ifndef CODEC_VER_H 3 | #define CODEC_VER_H 4 | 5 | #include "codec_app_def.h" 6 | 7 | static const OpenH264Version g_stCodecVersion = {2, 1, 1, 2005}; 8 | static const char* const g_strCodecVer = "OpenH264 version:2.1.1.2005"; 9 | 10 | #define OPENH264_MAJOR (2) 11 | #define OPENH264_MINOR (1) 12 | #define OPENH264_REVISION (1) 13 | #define OPENH264_RESERVED (2005) 14 | 15 | #endif // CODEC_VER_H 16 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/Android.mk: -------------------------------------------------------------------------------- 1 | include $(call all-subdir-makefiles) 2 | 3 | LOCAL_PATH := $(call my-dir) 4 | 5 | 6 | 7 | include $(CLEAR_VARS) 8 | 9 | LOCAL_CPPFLAGS += -O3 -std=c++11 10 | LOCAL_MODULE := softcodec 11 | LOCAL_SHARED_LIBRARIES := libopenh264 \ 12 | librtmp \ 13 | static_aac 14 | LOCAL_LDLIBS := -ldl -lc -lz -lm -llog 15 | LOCAL_SRC_FILES := h264Encoder.cc \ 16 | xiecc_rtmp.c \ 17 | aacEncode.c \ 18 | rtmpManage.c 19 | 20 | include $(BUILD_SHARED_LIBRARY) 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /x264-codec/src/main/jni/fdkaac/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | include $(CLEAR_VARS) 3 | 4 | include $(CLEAR_VARS) 5 | LOCAL_MODULE :=static_aac 6 | ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 7 | LOCAL_SRC_FILES := lib/armeabi-v7a/libfdk-aac.a 8 | endif 9 | 10 | ifeq ($(TARGET_ARCH_ABI),arm64-v8a) 11 | LOCAL_SRC_FILES := lib/arm64-v8a/libfdk-aac.a 12 | endif 13 | 14 | ifeq ($(TARGET_ARCH_ABI),x86) 15 | LOCAL_SRC_FILES := lib/x86/libfdk-aac.a 16 | endif 17 | 18 | 19 | LOCAL_EXPORT_C_INCLUDES := include 20 | include $(PREBUILT_STATIC_LIBRARY) 21 | 22 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/stdint.h: -------------------------------------------------------------------------------- 1 | #ifndef CODEC_STDINT_H 2 | #define CODEC_STDINT_H 3 | 4 | #ifndef _MSC_VER 5 | 6 | #include 7 | 8 | #else 9 | 10 | typedef signed char int8_t ; 11 | typedef unsigned char uint8_t ; 12 | typedef short int16_t ; 13 | typedef unsigned short uint16_t; 14 | typedef int int32_t ; 15 | typedef unsigned int uint32_t; 16 | typedef __int64 int64_t ; 17 | typedef unsigned __int64 uint64_t; 18 | typedef short int_least16_t; 19 | 20 | #endif 21 | 22 | #endif //CODEC_STDINT_H -------------------------------------------------------------------------------- /x264-codec/src/main/jni/libx264/Android.mk: -------------------------------------------------------------------------------- 1 | 2 | LOCAL_PATH := $(call my-dir) 3 | 4 | include $(CLEAR_VARS) 5 | LOCAL_MODULE := libx264 6 | 7 | ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) 8 | LOCAL_SRC_FILES := libs/armeabi-v7a/libx264.a 9 | endif 10 | 11 | ifeq ($(TARGET_ARCH_ABI),arm64-v8a) 12 | LOCAL_SRC_FILES := libs/arm64-v8a/libx264.a 13 | endif 14 | 15 | ifeq ($(TARGET_ARCH_ABI),x86) 16 | LOCAL_SRC_FILES := libs/x86/libx264.a 17 | endif 18 | 19 | ifeq ($(TARGET_ARCH_ABI),mips) 20 | LOCAL_SRC_FILES := libs/mips/libx264.a 21 | endif 22 | 23 | LOCAL_EXPORT_C_INCLUDES := include 24 | include $(PREBUILT_STATIC_LIBRARY) 25 | -------------------------------------------------------------------------------- /x264-codec/src/main/jni/softcodec/rtmpManage.c: -------------------------------------------------------------------------------- 1 | #include "rtmpManage.h" 2 | 3 | 4 | /* 5 | *rtmp的连接 6 | */ 7 | JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_rtmpOpen(JNIEnv *env, 8 | jobject instance, jstring url_) { 9 | 10 | const char *url = (*env)->GetStringUTFChars(env, url_, 0); 11 | 12 | int result = rtmp_open_for_write(url); 13 | 14 | (*env)->ReleaseStringUTFChars(env, url_, url); 15 | 16 | return result; 17 | } 18 | 19 | /* 20 | *断开rtmp的连接 21 | */ 22 | 23 | JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_rtmpStop(JNIEnv *env, 24 | jobject instance) { 25 | 26 | int result = stopRtmpConnect(); 27 | 28 | return result; 29 | } 30 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/rtmpManage.c: -------------------------------------------------------------------------------- 1 | #include "rtmpManage.h" 2 | #include "xiecc_rtmp.h" 3 | 4 | 5 | /* 6 | *rtmp的连接 7 | */ 8 | JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_rtmpOpen(JNIEnv *env, 9 | jobject instance, jstring url_) { 10 | 11 | const char *url = (*env)->GetStringUTFChars(env, url_, 0); 12 | 13 | int result = rtmp_open_for_write(url); 14 | 15 | (*env)->ReleaseStringUTFChars(env, url_, url); 16 | 17 | return result; 18 | } 19 | 20 | /* 21 | *断开rtmp的连接 22 | */ 23 | 24 | JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_rtmpStop(JNIEnv *env, 25 | jobject instance) { 26 | 27 | int result = stopRtmpConnect(); 28 | 29 | return result; 30 | } 31 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /home/wei/文档/tools/android-sdk-linux/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /x264-codec/src/main/jni/softcodec/h264_encoder_log.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by bruce on 5/1/21. 3 | // 4 | 5 | #ifndef SOFTCODEC_H264_ENCODER_LOG_H 6 | #define SOFTCODEC_H264_ENCODER_LOG_H 7 | 8 | 9 | #define LOGTAG "LiveCamera_encoder" 10 | #define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, LOGTAG, __VA_ARGS__) 11 | #define printf(...) LOGI(__VA_ARGS__) 12 | #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOGTAG, __VA_ARGS__) 13 | #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG , LOGTAG, __VA_ARGS__) 14 | #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO , LOGTAG, __VA_ARGS__) 15 | #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN , LOGTAG, __VA_ARGS__) 16 | #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR , LOGTAG, __VA_ARGS__) 17 | 18 | 19 | 20 | #endif //SOFTCODEC_H264_ENCODER_LOG_H 21 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/h264_encoder_log.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by bruce on 5/1/21. 3 | // 4 | 5 | #ifndef SOFTCODEC_H264_ENCODER_LOG_H 6 | #define SOFTCODEC_H264_ENCODER_LOG_H 7 | 8 | 9 | #define LOGTAG "LiveCamera_encoder" 10 | #define LOGI(...) __android_log_print(ANDROID_LOG_DEBUG, LOGTAG, __VA_ARGS__) 11 | #define printf(...) LOGI(__VA_ARGS__) 12 | #define ALOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOGTAG, __VA_ARGS__) 13 | #define ALOGD(...) __android_log_print(ANDROID_LOG_DEBUG , LOGTAG, __VA_ARGS__) 14 | #define ALOGI(...) __android_log_print(ANDROID_LOG_INFO , LOGTAG, __VA_ARGS__) 15 | #define ALOGW(...) __android_log_print(ANDROID_LOG_WARN , LOGTAG, __VA_ARGS__) 16 | #define ALOGE(...) __android_log_print(ANDROID_LOG_ERROR , LOGTAG, __VA_ARGS__) 17 | 18 | 19 | 20 | #endif //SOFTCODEC_H264_ENCODER_LOG_H 21 | -------------------------------------------------------------------------------- /x264-codec/proguard-rules.pro: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /openh264-codec/proguard-rules.pro: -------------------------------------------------------------------------------- 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 -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 10 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 11 | # When configured, Gradle will run in incubating parallel mode. 12 | # This option should only be used with decoupled projects. More details, visit 13 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 14 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /x264-codec/src/main/java/io/github/brucewind/softcodec/StreamHelper.java: -------------------------------------------------------------------------------- 1 | package io.github.brucewind.softcodec; 2 | 3 | /** 4 | * Created by bruce on 16-11-24. 5 | * It is used to connect server and push stream. 6 | */ 7 | class StreamHelper { 8 | 9 | 10 | static { 11 | System.loadLibrary("share_x264"); 12 | } 13 | 14 | /** 15 | * connect rtmp server 16 | */ 17 | public native int rtmpOpen(String url); 18 | 19 | public native int rtmpStop(); 20 | 21 | /** 22 | * x264 function 23 | * @param encoder 24 | * @param NV12 25 | * @param NV12size 26 | * @param H264 27 | * @return 28 | */ 29 | public native int compressBuffer(long encoder, byte[] NV12, int NV12size, byte[] H264); 30 | 31 | public native long compressBegin(int width, int height, int bitrate, int fps); 32 | 33 | public native int compressEnd(long encoder); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/h264Encoder.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "xiecc_rtmp.h" 8 | #include "../libopenh264/include/wels/codec_app_def.h" 9 | #include "../libopenh264/include/wels/codec_api.h" 10 | #include "h264_encoder_log.h" 11 | 12 | 13 | extern "C" JNIEXPORT jlong 14 | Java_io_github_brucewind_softcodec_StreamHelper_compressBegin(JNIEnv * env , 15 | jobject thiz, jint 16 | width , jint height, jint 17 | bitrate , jint fps); 18 | 19 | extern "C" JNIEXPORT jint 20 | Java_io_github_brucewind_softcodec_StreamHelper_compressEnd(JNIEnv * env , 21 | jobject thiz, jlong 22 | handle ); 23 | 24 | extern "C" JNIEXPORT jint 25 | Java_io_github_brucewind_softcodec_StreamHelper_compressBuffer(JNIEnv * env , 26 | jobject thiz, 27 | jlong 28 | handle , 29 | jbyteArray in, 30 | jint 31 | insize , 32 | jbyteArray out ); -------------------------------------------------------------------------------- /openh264-codec/src/main/java/io/github/brucewind/softcodec/StreamHelper.java: -------------------------------------------------------------------------------- 1 | package io.github.brucewind.softcodec; 2 | 3 | /** 4 | * Created by bruce on 16-11-24. 5 | * It is used to connect server and push stream. 6 | */ 7 | class StreamHelper { 8 | 9 | 10 | static { 11 | System.loadLibrary("softcodec"); 12 | } 13 | 14 | /** 15 | * connect rtmp server 16 | */ 17 | public native int rtmpOpen(String url); 18 | 19 | public native int rtmpStop(); 20 | 21 | /** 22 | * x264 function 23 | * @param encoder 24 | * @param I420 25 | * @param I420Size 26 | * @param H264, it is unused. 27 | * @return 28 | */ 29 | public native int compressBuffer(long encoder, byte[] I420, int I420Size, byte[] H264); 30 | 31 | public native long compressBegin(int width, int height, int bitrate, int fps); 32 | 33 | public native int compressEnd(long encoder); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /x264-codec/src/main/jni/softcodec/xiecc_rtmp.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by faraklit on 08.02.2016. 3 | // 4 | 5 | #ifndef _XIECC_RTMP_H_ 6 | #define _XIECC_RTMP_H_ 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C"{ 14 | #endif 15 | 16 | 17 | static int getSystemTime() { 18 | struct timeval tv; //获取一个时间结构 19 | gettimeofday(&tv, NULL); //获取当前时间 20 | int t = tv.tv_sec; 21 | t *= 1000; 22 | t += tv.tv_usec / 1000; 23 | return t; 24 | } 25 | 26 | int rtmp_open_for_write(const char * url); 27 | 28 | void send_video_sps_pps(uint8_t *sps,int sps_len,uint8_t *pps,int pps_len); 29 | 30 | void send_rtmp_video(uint8_t *data, int data_len,int timestamp) ; 31 | 32 | void send_rtmp_audio_spec(unsigned char *spec_buf, uint32_t spec_len); 33 | 34 | void send_rtmp_audio(unsigned char *buf, uint32_t len,int time) ; 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | #endif 39 | -------------------------------------------------------------------------------- /x264-codec/src/main/jni/softcodec/h264Encoder.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include <../libx264/include/x264.h> 7 | #include "xiecc_rtmp.h" 8 | 9 | /*compressBegin 10 | *初始化x264 11 | *width 宽度 12 | *height 高度 13 | *bitrate 码率 14 | *fps 幀率 15 | */ 16 | JNIEXPORT jlong Java_io_github_brucewind_softcodec_StreamHelper_compressBegin(JNIEnv* env, 17 | jobject thiz, jint width, jint height, jint bitrate, jint fps); 18 | 19 | /*compressEnd 20 | *結束x264编码 21 | *handle 22 | */ 23 | JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_compressEnd(JNIEnv* env, 24 | jobject thiz, jlong handle); 25 | 26 | /*compressBegin 27 | *编码x264 28 | *handle 29 | *in nv12 30 | *insize nv12 长度 31 | *out h264 32 | */ 33 | JNIEXPORT jint Java_io_github_brucewind_softcodec_StreamHelper_compressBuffer(JNIEnv* env, 34 | jobject thiz, 35 | jlong handle, 36 | jbyteArray in, 37 | jint insize, 38 | jbyteArray out); 39 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/xiecc_rtmp.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by faraklit on 08.02.2016. 3 | // 4 | 5 | #ifndef _XIECC_RTMP_H_ 6 | #define _XIECC_RTMP_H_ 7 | #include "../libopenh264/include/wels/codec_def.h" 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #ifdef __cplusplus 15 | extern "C"{ 16 | #endif 17 | 18 | 19 | static int getSystemTime() { 20 | struct timeval tv; //获取一个时间结构 21 | gettimeofday(&tv, NULL); //获取当前时间 22 | int t = tv.tv_sec; 23 | t *= 1000; 24 | t += tv.tv_usec / 1000; 25 | return t; 26 | } 27 | 28 | int isConnected(); 29 | 30 | int rtmp_open_for_write(const char * url); 31 | 32 | void send_video_sps_pps(uint8_t *sps,int sps_len,uint8_t *pps,int pps_len); 33 | 34 | void send_rtmp_video(uint8_t *data, uint32_t data_len,int timestamp) ; 35 | 36 | void send_rtmp_audio_spec(unsigned char *spec_buf, uint32_t spec_len); 37 | 38 | void send_rtmp_audio(unsigned char *buf, uint32_t len,int time) ; 39 | #ifdef __cplusplus 40 | } 41 | #endif 42 | #endif 43 | -------------------------------------------------------------------------------- /x264-codec/src/main/jni/softcodec/aacEncode.h: -------------------------------------------------------------------------------- 1 | #include "../fdkaac/include/aacenc_lib.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "xiecc_rtmp.h" 8 | #include "stdbool.h" 9 | 10 | 11 | 12 | typedef struct AudioOutput { 13 | int transMux; //TODO ?? 14 | int afterburner; //TODO ?? 15 | int channelLoader; //TODO ?? 16 | int aot ; //aot类型。 17 | int channels; 18 | int samplerate; 19 | int bitrate; 20 | CHANNEL_MODE mode; //通道模式。 21 | HANDLE_AACENCODER handle; //aac处理实例 22 | AACENC_InfoStruct info; 23 | int input_size; 24 | int first; 25 | }AACOutput; 26 | 27 | typedef struct EncodeAAC Encode; 28 | jint Java_io_github_brucewind_softcodec_AudioRecorder_initAAC(JNIEnv* env,jobject thiz, jint bitrate,jint samplerate,jint channels); 29 | jint Java_io_github_brucewind_softcodec_AudioRecorder_getbuffersize(JNIEnv* env, jobject thiz); 30 | jboolean Java_io_github_brucewind_softcodec_AudioRecorder_encodeFrame(JNIEnv *pEnv,jobject obj,jbyteArray pcmData); 31 | bool aacEncoderProcess(AACENC_BufDesc* in_buf,AACENC_BufDesc* out_buf,AACENC_InArgs* in_args,AACENC_OutArgs* out_args); 32 | -------------------------------------------------------------------------------- /openh264-codec/src/main/jni/softcodec/aacEncode.h: -------------------------------------------------------------------------------- 1 | #include "../fdkaac/include/aacenc_lib.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include "xiecc_rtmp.h" 8 | #include "stdbool.h" 9 | 10 | 11 | 12 | typedef struct AudioOutput { 13 | int transMux; //TODO ?? 14 | int afterburner; //TODO ?? 15 | int channelLoader; //TODO ?? 16 | int aot ; //aot类型。 17 | int channels; 18 | int samplerate; 19 | int bitrate; 20 | CHANNEL_MODE mode; //通道模式。 21 | HANDLE_AACENCODER handle; //aac处理实例 22 | AACENC_InfoStruct info; 23 | int input_size; 24 | int first; 25 | }AACOutput; 26 | 27 | typedef struct EncodeAAC Encode; 28 | jint Java_io_github_brucewind_softcodec_AudioRecorder_initAAC(JNIEnv* env,jobject thiz, jint bitrate,jint samplerate,jint channels); 29 | jint Java_io_github_brucewind_softcodec_AudioRecorder_getbuffersize(JNIEnv* env, jobject thiz); 30 | jboolean Java_io_github_brucewind_softcodec_AudioRecorder_encodeFrame(JNIEnv *pEnv,jobject obj,jbyteArray pcmData); 31 | bool aacEncoderProcess(AACENC_BufDesc* in_buf,AACENC_BufDesc* out_buf,AACENC_InArgs* in_args,AACENC_OutArgs* out_args); 32 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 17 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /x264-codec/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | } 4 | 5 | android { 6 | compileSdkVersion 24 7 | buildToolsVersion "24.0.3" 8 | 9 | ndkVersion "16.1.4479499" 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 21 14 | versionCode 1 15 | versionName "1.0" 16 | ndk { 17 | // Specifies the ABI configurations of your native 18 | // libraries Gradle should build and package with your APK. 19 | abiFilters 'arm64-v8a' 20 | } 21 | } 22 | 23 | buildTypes { 24 | release { 25 | minifyEnabled false 26 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 27 | } 28 | } 29 | 30 | externalNativeBuild { 31 | ndkBuild { 32 | path file('src/main/jni/Android.mk') 33 | } 34 | } 35 | compileOptions { 36 | sourceCompatibility JavaVersion.VERSION_1_7 37 | targetCompatibility JavaVersion.VERSION_1_7 38 | } 39 | 40 | lintOptions { 41 | abortOnError false 42 | } 43 | } 44 | 45 | dependencies { 46 | testImplementation 'junit:junit:4.+' 47 | } -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 24 5 | buildToolsVersion "24.0.3" 6 | 7 | //If I don't write this line, C codes will build with latest version of NDK. 8 | // ndkVersion "16.1.4479499" 9 | ndkVersion "21.4.7075529" 10 | 11 | defaultConfig { 12 | applicationId "com.androidyuan.softcodec" 13 | minSdkVersion 21 14 | targetSdkVersion 21 15 | versionCode 1 16 | versionName "1.0" 17 | 18 | //In the event that I have not written this line, so file won't packaged into apk. 19 | ndk { 20 | abiFilters 'arm64-v8a','x86' //setting only one abi make apk smaller. 21 | } 22 | } 23 | 24 | buildTypes { 25 | release { 26 | minifyEnabled false 27 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 28 | } 29 | } 30 | 31 | 32 | lintOptions { 33 | abortOnError false 34 | } 35 | } 36 | 37 | 38 | dependencies { 39 | testImplementation 'junit:junit:4.12' 40 | implementation 'com.android.support:appcompat-v7:24.0.0' 41 | // implementation "com.android.support.constraint:constraint-layout:2.0.4" 42 | implementation project(':openh264-codec') 43 | } 44 | -------------------------------------------------------------------------------- /openh264-codec/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'com.android.library' 3 | } 4 | 5 | android { 6 | compileSdkVersion 24 7 | buildToolsVersion "24.0.3" 8 | 9 | ndkVersion '21.1.6352462' 10 | // ndkVersion "16.1.4479499" 11 | 12 | defaultConfig { 13 | minSdkVersion 21 14 | targetSdkVersion 21 15 | versionCode 1 16 | versionName "1.0" 17 | 18 | externalNativeBuild { 19 | cmake { 20 | cppFlags "-std=c++11" 21 | abiFilters 'arm64-v8a', 'x86'// ,'armeabi-v7a', 22 | } 23 | 24 | // ndk { 25 | // abiFilters 'arm64-v8a' 26 | // } 27 | } 28 | } 29 | 30 | buildTypes { 31 | release { 32 | minifyEnabled false 33 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 34 | } 35 | } 36 | externalNativeBuild { 37 | cmake { 38 | path "src/main/jni/CMakeLists.txt" 39 | version "3.10.2" 40 | } 41 | // ndkBuild { 42 | // path file('src/main/jni/Android.mk') 43 | // } 44 | } 45 | compileOptions { 46 | sourceCompatibility JavaVersion.VERSION_1_7 47 | targetCompatibility JavaVersion.VERSION_1_7 48 | } 49 | 50 | lintOptions { 51 | abortOnError false 52 | } 53 | } 54 | 55 | dependencies { 56 | testImplementation 'junit:junit:4.+' 57 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 11 | 12 |