diff --git a/VideoObserverPlugin/VideoObserverPlugin.cpp b/VideoObserverPlugin/VideoObserverPlugin.cpp index 4e16f19..cf8f383 100644 --- a/VideoObserverPlugin/VideoObserverPlugin.cpp +++ b/VideoObserverPlugin/VideoObserverPlugin.cpp @@ -3,6 +3,12 @@ #include "spdlog/sinks/stdout_sinks.h" #include "spdlog/spdlog.h" +#if defined(__ANDROID__) + +#include "spdlog/sinks/android_sink.h" + +#endif + #define IRIS_LOG_PLUGIN_D(...) \ SPDLOG_LOGGER_CALL(spdlog::default_logger(), spdlog::level::debug, \ __VA_ARGS__) diff --git a/VideoObserverPlugin/VideoObserverPlugin.h b/VideoObserverPlugin/VideoObserverPlugin.h index edaae8a..1c2ef26 100644 --- a/VideoObserverPlugin/VideoObserverPlugin.h +++ b/VideoObserverPlugin/VideoObserverPlugin.h @@ -1,5 +1,6 @@ #ifndef __IRIS_PLUGIN_CPP_API_H__ #define __IRIS_PLUGIN_CPP_API_H__ + #include "iris_plugin_platform.h" #include #include @@ -8,12 +9,15 @@ class IRIS_PLUGIN_CPP_API VideoObserverPlugin : public agora::media::IVideoFrameObserver { public: VideoObserverPlugin(agora::rtc::IRtcEngine *rtc_engine); + ~VideoObserverPlugin(); + bool onCaptureVideoFrame(VideoFrame &videoFrame) override; bool onSecondaryCameraCaptureVideoFrame(VideoFrame &videoFrame) override; bool onScreenCaptureVideoFrame(VideoFrame &videoFrame) override; + bool onSecondaryScreenCaptureVideoFrame(VideoFrame &videoFrame) override; bool onMediaPlayerVideoFrame(VideoFrame &videoFrame, @@ -39,15 +43,19 @@ class IRIS_PLUGIN_CPP_API VideoObserverPlugin getVideoFrameProcessMode() override; agora::media::base::VIDEO_PIXEL_FORMAT getVideoFormatPreference() override; + bool getRotationApplied() override { return true; } bool getMirrorApplied() override { return IVideoFrameObserver::getMirrorApplied(); } + bool EnablePlugin(); + bool DisablePlugin(); - + private: agora::rtc::IRtcEngine *rtc_engine_ = nullptr; }; + #endif diff --git a/VideoObserverPlugin/plugin_c_api.cpp b/VideoObserverPlugin/plugin_c_api.cpp index f4292af..c3e6586 100644 --- a/VideoObserverPlugin/plugin_c_api.cpp +++ b/VideoObserverPlugin/plugin_c_api.cpp @@ -1,5 +1,9 @@ -#include "Plugin_c_api.h" +#include "plugin_c_api.h" #include "VideoObserverPlugin.h" +#if defined(__ANDROID__) +#include +#endif + bool EnablePlugin(PluginSamplePtr plugin) { if (plugin) { return ((VideoObserverPlugin *) plugin)->EnablePlugin(); @@ -16,7 +20,7 @@ bool DisablePlugin(PluginSamplePtr plugin) { } } -PluginSamplePtr CreateSampePlugin(void *rtcEnginePtr) { +PluginSamplePtr CreateSamplePlugin(void *rtcEnginePtr) { auto *plugin = new VideoObserverPlugin((agora::rtc::IRtcEngine *) rtcEnginePtr); return (void *) plugin; @@ -24,4 +28,33 @@ PluginSamplePtr CreateSampePlugin(void *rtcEnginePtr) { void DestroySamplePlugin(PluginSamplePtr plugin) { delete (VideoObserverPlugin *) plugin; -} \ No newline at end of file +} + +#if defined(__ANDROID__) +extern "C" JNIEXPORT jlong JNICALL +Java_io_agora_iris_plugin_IrisVideoPlugin_createSamplePlugin( + JNIEnv *env, jobject thiz, jlong native_handle) { + return (jlong) CreateSamplePlugin((void *) native_handle); +} + +extern "C" JNIEXPORT void JNICALL +Java_io_agora_iris_plugin_IrisVideoPlugin_destroySamplePlugin(JNIEnv *env, + jobject thiz, + jlong handle) { + DestroySamplePlugin((PluginSamplePtr) handle); +} + +extern "C" JNIEXPORT jboolean JNICALL +Java_io_agora_iris_plugin_IrisVideoPlugin_enablePlugin(JNIEnv *env, + jobject thiz, + jlong handle) { + EnablePlugin((PluginSamplePtr) handle); +} + +extern "C" JNIEXPORT jboolean JNICALL +Java_io_agora_iris_plugin_IrisVideoPlugin_disablePlugin(JNIEnv *env, + jobject thiz, + jlong handle) { + DisablePlugin((PluginSamplePtr) handle); +} +#endif diff --git a/VideoObserverPlugin/plugin_c_api.h b/VideoObserverPlugin/plugin_c_api.h index 95b4304..2191847 100644 --- a/VideoObserverPlugin/plugin_c_api.h +++ b/VideoObserverPlugin/plugin_c_api.h @@ -1,9 +1,12 @@ #ifndef __IRIS_PLUGIN_C_API_H__ #define __IRIS_PLUGIN_C_API_H__ + #include "iris_plugin_platform.h" + typedef void *PluginSamplePtr; IRIS_PLUGIN_API bool EnablePlugin(PluginSamplePtr plugin); IRIS_PLUGIN_API bool DisablePlugin(PluginSamplePtr plugin); -IRIS_PLUGIN_API PluginSamplePtr CreateSampePlugin(void *rtcEnginePtr); +IRIS_PLUGIN_API PluginSamplePtr CreateSamplePlugin(void *rtcEnginePtr); IRIS_PLUGIN_API void DestroySamplePlugin(PluginSamplePtr plugin); + #endif \ No newline at end of file diff --git a/dcg/android/app/src/main/java/io/agora/iris/IrisEventHandler.java b/dcg/android/app/src/main/java/io/agora/iris/IrisEventHandler.java deleted file mode 100644 index 6ced148..0000000 --- a/dcg/android/app/src/main/java/io/agora/iris/IrisEventHandler.java +++ /dev/null @@ -1,7 +0,0 @@ -package io.agora.iris; - -import java.util.List; - -public interface IrisEventHandler { - void OnEvent(String event, String data, List buffers); -} diff --git a/dcg/android/app/src/main/java/io/agora/iris/IrisVIdeoPlugin.java b/dcg/android/app/src/main/java/io/agora/iris/IrisVIdeoPlugin.java deleted file mode 100644 index 8bf87a3..0000000 --- a/dcg/android/app/src/main/java/io/agora/iris/IrisVIdeoPlugin.java +++ /dev/null @@ -1,128 +0,0 @@ -package io.agora.iris.plugin; - -import android.content.Context; -import java.util.Arrays; -import java.util.List; - -public class IrisPlugin { - static { System.loadLibrary("VideoObserverPlugin"); } - - private long plugin; - private VideoFrameObserver videoObserver; - - public IrisPlugin(long nativeHandle) { - plugin = - createSampePlugin(nativeHandle); - } - - public void setObsever(VideoFrameObserver observer) { - synchronized (this) { this.videoObserver = observer; } - } - - public void destroy() { - destroySampePlugin(this.plugin); - this.plugin = 0; - } - - public long getPlugin() { return plugin; } - - boolean enable(){ - return enablePlugin(this.plugin); - } - - boolean disable(){ - return disablePlugin(this.plugin); - } - - protected boolean onCaptureVideoFrame(VideoFrame videoFrame){ - synchronized (this) { - if (this.observer != null) { - this.observer.onCaptureVideoFrame(videoFrame); - } - } - } - - protected boolean onSecondaryCameraCaptureVideoFrame(VideoFrame videoFrame){ - synchronized (this) { - if (this.observer != null) { - this.observer.onSecondaryCameraCaptureVideoFrame(videoFrame); - } - } - } - protected boolean onScreenCaptureVideoFrame(VideoFrame videoFrame){ - synchronized (this) { - if (this.observer != null) { - this.observer.onScreenCaptureVideoFrame(videoFrame); - } - } - } - protected boolean onSecondaryScreenCaptureVideoFrame(VideoFrame videoFrame){ - synchronized (this) { - if (this.observer != null) { - this.observer.onSecondaryScreenCaptureVideoFrame(videoFrame); - } - } - } - - protected boolean onMediaPlayerVideoFrame(VideoFrame videoFrame, int mediaPlayerId){ - synchronized (this) { - if (this.observer != null) { - this.observer.onMediaPlayerVideoFrame(videoFrame, mediaPlayerId); - } - } - } - - protected boolean onMediaPlayerVideoFrameString channelId, int uid, VideoFrame videoFrame){ - synchronized (this) { - if (this.observer != null) { - this.observer.onMediaPlayerVideoFrameString(channelId, uid, videoFrame); - } - } - } - - protected boolean onTranscodedVideoFrame(VideoFrame videoFrame){ - synchronized (this) { - if (this.observer != null) { - this.observer.onTranscodedVideoFrame(videoFrame); - } - } - } - protected boolean onPreEncodeVideoFrame(VideoFrame videoFrame){ - synchronized (this) { - if (this.observer != null) { - this.observer.onPreEncodeVideoFrame(videoFrame); - } - } - } - protected boolean onSecondaryPreEncodeCameraVideoFrame(VideoFrame videoFrame){ - synchronized (this) { - if (this.observer != null) { - this.observer.onSecondaryPreEncodeCameraVideoFrame(videoFrame); - } - } - } - - protected boolean onPreEncodeScreenVideoFrame(VideoFrame videoFrame){ - synchronized (this) { - if (this.observer != null) { - this.observer.onPreEncodeScreenVideoFrame(videoFrame); - } - } - } - - protected boolean onSecondaryPreEncodeScreenVideoFrame(VideoFrame videoFrame){ - synchronized (this) { - if (this.observer != null) { - this.observer.onSecondaryPreEncodeScreenVideoFrame(videoFrame); - } - } - } - - private native long createSampePlugin(long nativeHandle); - - private native void destroySampePlugin(long plugin); - - private native boolean enablePlugin(long plugin); - - private native boolean disablePlugin(long plugin); -} diff --git a/dcg/android/app/src/main/java/io/agora/iris/IrisVideoFrameObserver.java b/dcg/android/app/src/main/java/io/agora/iris/IrisVideoFrameObserver.java deleted file mode 100644 index 4a462f5..0000000 --- a/dcg/android/app/src/main/java/io/agora/iris/IrisVideoFrameObserver.java +++ /dev/null @@ -1,25 +0,0 @@ -import package io.agora.base; - -public interface VideoFrameObserver { - boolean OnCaptureVideoFrame(VideoFrame videoFrame); - - boolean onSecondaryCameraCaptureVideoFrame(VideoFrame videoFrame); - - boolean onScreenCaptureVideoFrame(VideoFrame videoFrame); - - boolean onSecondaryScreenCaptureVideoFrame(VideoFrame videoFrame); - - boolean onMediaPlayerVideoFrame(VideoFrame videoFrame, int mediaPlayerId); - - boolean onRenderVideoFrame(String channelId, int uid, VideoFrame videoFrame); - - boolean onTranscodedVideoFrame(VideoFrame videoFrame); - - boolean onPreEncodeVideoFrame(VideoFrame videoFrame); - - boolean onSecondaryPreEncodeCameraVideoFrame(VideoFrame videoFrame); - - boolean onPreEncodeScreenVideoFrame(VideoFrame videoFrame); - - boolean onSecondaryPreEncodeScreenVideoFrame(VideoFrame videoFrame); -} diff --git a/dcg/android/app/src/main/java/io/agora/iris/plugin/IrisVideoPlugin.java b/dcg/android/app/src/main/java/io/agora/iris/plugin/IrisVideoPlugin.java new file mode 100644 index 0000000..865cc3a --- /dev/null +++ b/dcg/android/app/src/main/java/io/agora/iris/plugin/IrisVideoPlugin.java @@ -0,0 +1,28 @@ +package io.agora.iris.plugin; + +public class IrisVideoPlugin { + static { System.loadLibrary("VideoObserverPlugin"); } + + private long handle; + + public IrisVideoPlugin(long nativeHandle) { + handle = createSamplePlugin(nativeHandle); + } + + public void destroy() { + destroySamplePlugin(this.handle); + this.handle = 0; + } + + boolean enable() { return enablePlugin(this.handle); } + + boolean disable() { return disablePlugin(this.handle); } + + private native long createSamplePlugin(long nativeHandle); + + private native void destroySamplePlugin(long handle); + + private native boolean enablePlugin(long handle); + + private native boolean disablePlugin(long handle); +} diff --git a/dcg/ci/build-android.sh b/dcg/ci/build-android.sh index a298ad8..e3c4c07 100644 --- a/dcg/ci/build-android.sh +++ b/dcg/ci/build-android.sh @@ -33,16 +33,21 @@ buildALL() { echo "start build aar ----------" sh ./gradlew assemble"$buildType" -P"$sdkType" -Dhttps.proxyHost=10.80.1.174 -Dhttps.proxyPort=1080 echo "start copy outputs ----------" - output_dir="$root_path/build/android/ALL_ARCHITECTURE/output/dcg/$buildType" + output_dir="$root_path/build/android/ALL_ARCHITECTURE/output/$buildType" output_name="VideoObserverPlugin" mkdir -p "$output_dir" cp app/build/outputs/aar/app-"$buildTypeLower".aar "$output_dir/$output_name.aar" cp app/build/intermediates/aar_main_jar/"$buildTypeLower"/classes.jar "$output_dir/$output_name.jar" - cp -rp app/.cxx/cmake/"$buildTypeLower"/arm64-v8a/output/dcg/include/ "$output_dir/include/" - cp -rp app/.cxx/cmake/"$buildTypeLower"/arm64-v8a/output/dcg/"$buildType"/ "$output_dir/arm64-v8a/" - cp -rp app/.cxx/cmake/"$buildTypeLower"/armeabi-v7a/output/dcg/"$buildType"/ "$output_dir/armeabi-v7a/" - cp -rp app/.cxx/cmake/"$buildTypeLower"/x86/output/dcg/"$buildType"/ "$output_dir/x86/" - cp -rp app/.cxx/cmake/"$buildTypeLower"/x86_64/output/dcg/"$buildType"/ "$output_dir/x86_64/" + mkdir -p "$output_dir/include" + cp -rp app/.cxx/cmake/"$buildTypeLower"/arm64-v8a/output/include/ "$output_dir/include/" + mkdir -p "$output_dir/arm64-v8a" + cp -rp app/.cxx/cmake/"$buildTypeLower"/arm64-v8a/output/"$buildType"/ "$output_dir/arm64-v8a/" + mkdir -p "$output_dir/armeabi-v7a" + cp -rp app/.cxx/cmake/"$buildTypeLower"/armeabi-v7a/output/"$buildType"/ "$output_dir/armeabi-v7a/" + mkdir -p "$output_dir/x86" + cp -rp app/.cxx/cmake/"$buildTypeLower"/x86/output/"$buildType"/ "$output_dir/x86/" + mkdir -p "$output_dir/x86_64" + cp -rp app/.cxx/cmake/"$buildTypeLower"/x86_64/output/"$buildType"/ "$output_dir/x86_64/" } if [ "$1" = "build" ]; then