From b5c0b5e79c8da744900356a1e7b86d306f52713f Mon Sep 17 00:00:00 2001 From: Qiming Deng Date: Thu, 25 Jan 2024 19:52:27 +0800 Subject: [PATCH] adapter video extension for v430 --- .../agora-simple-filter/build.gradle | 4 +-- .../src/main/cpp/CMakeLists.txt | 9 ------ .../cpp/plugin_source_code/VideoProcessor.cpp | 30 ++++++++++++++++--- .../cpp/plugin_source_code/VideoProcessor.h | 4 +++ 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/Android/APIExample/agora-simple-filter/build.gradle b/Android/APIExample/agora-simple-filter/build.gradle index c54d70f49..560e7feda 100644 --- a/Android/APIExample/agora-simple-filter/build.gradle +++ b/Android/APIExample/agora-simple-filter/build.gradle @@ -43,6 +43,6 @@ dependencies { api fileTree(dir: "libs", include: ["*.jar", "*.aar"]) implementation 'androidx.appcompat:appcompat:1.1.0' testImplementation 'junit:junit:4.12' - androidTestImplementation 'androidx.test.ext:junit:1.1.1' - androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' + androidTestImplementation 'androidx.test.ext:junit:1.1.3' + androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0' } diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/CMakeLists.txt b/Android/APIExample/agora-simple-filter/src/main/cpp/CMakeLists.txt index 977ea6581..b052242a5 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/CMakeLists.txt +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/CMakeLists.txt @@ -11,15 +11,6 @@ project(agora-simple-filter) set(agora-lib-so ${PROJECT_SOURCE_DIR}/../agoraLibs/${CMAKE_ANDROID_ARCH_ABI}/libagora-rtc-sdk.so) link_libraries(${agora-lib-so}) -set(agora-ffmpeg-so ${PROJECT_SOURCE_DIR}/../agoraLibs/${CMAKE_ANDROID_ARCH_ABI}/libagora-ffmpeg.so) -link_libraries(${agora-ffmpeg-so}) - -set(agora-soundtouch-so ${PROJECT_SOURCE_DIR}/../agoraLibs/${CMAKE_ANDROID_ARCH_ABI}/libagora-soundtouch.so) -link_libraries(${agora-soundtouch-so}) - -set(agora-fdkaac-so ${PROJECT_SOURCE_DIR}/../agoraLibs/${CMAKE_ANDROID_ARCH_ABI}/libagora-fdkaac.so) -link_libraries(${agora-fdkaac-so}) - #link opencv so set(opencv-lib-so ${PROJECT_SOURCE_DIR}/../jniLibs/${CMAKE_ANDROID_ARCH_ABI}/libopencv_java4.so) link_libraries(${opencv-lib-so}) diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/plugin_source_code/VideoProcessor.cpp b/Android/APIExample/agora-simple-filter/src/main/cpp/plugin_source_code/VideoProcessor.cpp index 387c1324d..17fd83d42 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/plugin_source_code/VideoProcessor.cpp +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/plugin_source_code/VideoProcessor.cpp @@ -33,10 +33,6 @@ namespace agora { if (!eglCore_) { eglCore_ = new EglCore(); offscreenSurface_ = eglCore_->createOffscreenSurface(640, 320); - - } - if (!eglCore_->isCurrent(offscreenSurface_)) { - eglCore_->makeCurrent(offscreenSurface_); } #endif return true; @@ -57,10 +53,36 @@ namespace agora { return true; } + bool WatermarkProcessor::makeCurrent() { + const std::lock_guard lock(mutex_); +#if defined(__ANDROID__) || defined(TARGET_OS_ANDROID) + if (eglCore_ && offscreenSurface_) { + if (!eglCore_->isCurrent(offscreenSurface_)) { + eglCore_->makeCurrent(offscreenSurface_); + } + return true; + } +#endif + return false; + } + + bool WatermarkProcessor::detachCurrent() { + const std::lock_guard lock(mutex_); +#if defined(__ANDROID__) || defined(TARGET_OS_ANDROID) + if (eglCore_) { + eglCore_->makeNothingCurrent(); + return true; + } +#endif + return false; + } + int WatermarkProcessor::processFrame(agora::rtc::VideoFrameData &capturedFrame) { // PRINTF_INFO("processFrame: w: %d, h: %d, r: %d, enable: %d", capturedFrame.width, capturedFrame.height, capturedFrame.rotation, wmEffectEnabled_); if (wmEffectEnabled_) { + makeCurrent(); addWatermark(capturedFrame); + detachCurrent(); } return 0; } diff --git a/Android/APIExample/agora-simple-filter/src/main/cpp/plugin_source_code/VideoProcessor.h b/Android/APIExample/agora-simple-filter/src/main/cpp/plugin_source_code/VideoProcessor.h index 01d85957e..75fc57ce2 100644 --- a/Android/APIExample/agora-simple-filter/src/main/cpp/plugin_source_code/VideoProcessor.h +++ b/Android/APIExample/agora-simple-filter/src/main/cpp/plugin_source_code/VideoProcessor.h @@ -26,6 +26,10 @@ namespace agora { bool releaseOpenGL(); + bool makeCurrent(); + + bool detachCurrent(); + int processFrame(agora::rtc::VideoFrameData &capturedFrame); int setParameters(std::string parameter);