Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Android/APIExample/agora-simple-filter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -57,10 +53,36 @@ namespace agora {
return true;
}

bool WatermarkProcessor::makeCurrent() {
const std::lock_guard<std::mutex> 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<std::mutex> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ namespace agora {

bool releaseOpenGL();

bool makeCurrent();

bool detachCurrent();

int processFrame(agora::rtc::VideoFrameData &capturedFrame);

int setParameters(std::string parameter);
Expand Down