WICHTIG EDIT Die Bilder möglicherweise nicht auf dem neuesten Stand sein, aber die Arbeit wurde unter Versionen getestet:
Eine aktualisierte Version (funktioniert für opus-1.1.2) von @ praneetloke-Lösung. Eine Art anderer Ansatz mit einigen Extras. Zunächst einmal unten ist meine Struktur zu verwenden (ich sollte mehr Bibliotheken verwenden, so dass ich Opus in seinem eigenen Unterverzeichnis.)
Zweitens habe ich eine Wurzel Android.mk
Datei und sie in den Ordner opus -1.1.2. Hier
ist die Wurzel Android.mk
Datei:
LOCAL_PATH := $(call my-dir)
OPUS_DIR := opus-1.1.2
include $(OPUS_DIR)/Android.mk
include $(CLEAR_VARS)
LOCAL_MODULE := codec
LOCAL_SRC_FILES := Opus_jni.cpp
LOCAL_CFLAGS := -DNULL=0
LOCAL_LDLIBS := -lm -llog
LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(OPUS_DIR)/include
LOCAL_SHARED_LIBRARIES := opus
include $(BUILD_SHARED_LIBRARY)
Android.mk
Datei im opus-1.1.2 Ordner unter:
#Backing up previous LOCAL_PATH so it does not screw with the root Android.mk file
LOCAL_PATH_OLD := $(LOCAL_PATH)
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#include the .mk files
include $(LOCAL_PATH)/celt_sources.mk
include $(LOCAL_PATH)/silk_sources.mk
include $(LOCAL_PATH)/opus_sources.mk
LOCAL_MODULE := opus
#fixed point sources
SILK_SOURCES += $(SILK_SOURCES_FIXED)
#ARM build
CELT_SOURCES += $(CELT_SOURCES_ARM)
SILK_SOURCES += $(SILK_SOURCES_ARM)
LOCAL_SRC_FILES := \
$(CELT_SOURCES) $(SILK_SOURCES) $(OPUS_SOURCES)
LOCAL_LDLIBS := -lm -llog
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/silk \
$(LOCAL_PATH)/silk/fixed \
$(LOCAL_PATH)/celt
LOCAL_CFLAGS := -DNULL=0 -DSOCKLEN_T=socklen_t -DLOCALE_NOT_USED -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64
LOCAL_CFLAGS += -Drestrict='' -D__EMX__ -DOPUS_BUILD -DFIXED_POINT=1 -DDISABLE_FLOAT_API -DUSE_ALLOCA -DHAVE_LRINT -DHAVE_LRINTF -DAVOID_TABLES
LOCAL_CFLAGS += -w -std=gnu99 -O3 -fno-strict-aliasing -fprefetch-loop-arrays -fno-math-errno
LOCAL_CPPFLAGS := -DBSD=1
LOCAL_CPPFLAGS += -ffast-math -O3 -funroll-loops
include $(BUILD_SHARED_LIBRARY)
#Putting previous LOCAL_PATH back here
LOCAL_PATH := $(LOCAL_PATH_OLD)
Dies ist, wie es aussieht innen OPUS 1.1.2 Ordner:
Die einzige Berührung zu den Originalquellen ist das Hinzufügen einer Android.mk
Datei. Nichts entfernt.
Auf diese Weise kann ich Opus wie eine separate Bibliothek verwenden und aktualisieren.
Hier ist die Extras für diejenigen, die Opus in Android kompilieren und verwenden möchten; Wrapper Quelle, teilweise:
#include <jni.h>
#include <android/log.h>
#include <opus.h>
/* Header for class net_abcdefgh_opustrial_codec_Opus */
#ifndef _Included_net_abcdefgh_opustrial_codec_Opus
#define _Included_net_abcdefgh_opustrial_codec_Opus
#define TAG "Opus_JNI"
#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, TAG,__VA_ARGS__)
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG , TAG,__VA_ARGS__)
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO , TAG,__VA_ARGS__)
#define LOGW(...) __android_log_print(ANDROID_LOG_WARN , TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR , TAG,__VA_ARGS__)
#ifdef __cplusplus
extern "C" {
#endif
JNIEXPORT jint JNICALL Java_net_abcdefgh_opustrial_codec_Opus_open
(JNIEnv *env, jobject thiz){
...
return error;
}
JNIEXPORT jint JNICALL Java_net_abcdefgh_opustrial_codec_Opus_decode
(JNIEnv * env, jobject thiz, jbyteArray jencoded, jint jencodedOffset, jint jencodedLength, jbyteArray jpcm, jint jpcmOffset, jint jframeSize) {
...
return decodedSize;
}
JNIEXPORT jint JNICALL Java_net_abcdefgh_opustrial_codec_Opus_encode
(JNIEnv * env, jobject thiz, jbyteArray jpcm, jint jpcmOffset, jint jpcmLength, jbyteArray jencoded, jint jencodedOffset) {
...
return encodedSize;
}
JNIEXPORT void JNICALL Java_net_abcdefgh_opustrial_codec_Opus_close
(JNIEnv *env, jobject thiz){
...
}
#ifdef __cplusplus
}
#endif
#endif
Application.mk
Datei (optional)
APP_ABI := all # mips, armeabi, armeabi-v7a, x86 etc. builds
Warum es nicht zurück zu den Opus-Leuten beitragen? – Samveen
Gute Idee. Wird besorgt. – Stanley
Hey Stanley, Wurde dies jemals einer offiziellen Opus-Veröffentlichung hinzugefügt? Für welche Version von Opus wurde dieses Makefile erstellt? Haben Sie ein aktualisiertes Makefile für v1.1? –