diff --git a/.github/ci/build/build_ios.sh b/.github/ci/build/build_ios.sh index f8491ac4c..07517f9eb 100644 --- a/.github/ci/build/build_ios.sh +++ b/.github/ci/build/build_ios.sh @@ -70,6 +70,8 @@ mkdir ./$unzip_name/samples cp -rf ./iOS/${ios_direction} ./$unzip_name/samples/API-Example || exit 1 ls -al ./$unzip_name/samples/API-Example/ mv ./$unzip_name/samples/API-Example/sdk.podspec ./$unzip_name/ || exit 1 + +echo "work space1: $WORKSPACE" python3 ./.github/ci/build/modify_podfile.py ./$unzip_name/samples/API-Example/Podfile || exit 1 diff --git a/.github/ci/build/modify_podfile.py b/.github/ci/build/modify_podfile.py index 3cf89c2bd..c9ad317ec 100644 --- a/.github/ci/build/modify_podfile.py +++ b/.github/ci/build/modify_podfile.py @@ -21,4 +21,4 @@ def modfiy(path): if __name__ == '__main__': path = sys.argv[1:][0] - modfiy(path.strip()) \ No newline at end of file + modfiy(path.strip()) diff --git a/iOS/APIExample/APIExample.xcodeproj/project.pbxproj b/iOS/APIExample/APIExample.xcodeproj/project.pbxproj index d7ea617d5..44f29c857 100644 --- a/iOS/APIExample/APIExample.xcodeproj/project.pbxproj +++ b/iOS/APIExample/APIExample.xcodeproj/project.pbxproj @@ -214,22 +214,15 @@ E7A49D282907DDFF00F06DD4 /* EffectsDetector.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D262907DDFE00F06DD4 /* EffectsDetector.m */; }; E7A49D2B2907DEE600F06DD4 /* EFMotionManager.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D292907DEE600F06DD4 /* EFMotionManager.m */; }; E7A49D342907E74A00F06DD4 /* BundleUtil.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D332907E74A00F06DD4 /* BundleUtil.m */; }; - E7A49D362907EB6000F06DD4 /* SENSEME.lic in Resources */ = {isa = PBXBuildFile; fileRef = E7A49D352907EB6000F06DD4 /* SENSEME.lic */; }; E7A49D40290907E200F06DD4 /* BytedEffect.strings in Resources */ = {isa = PBXBuildFile; fileRef = E7A49D39290907E200F06DD4 /* BytedEffect.strings */; }; E7A49D41290907E200F06DD4 /* BytedEffectVC.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D3B290907E200F06DD4 /* BytedEffectVC.m */; }; E7A49D42290907E200F06DD4 /* BytedEffect.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E7A49D3C290907E200F06DD4 /* BytedEffect.storyboard */; }; - E7A49D4529090F3C00F06DD4 /* ByteDanceFilter.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D4429090F3C00F06DD4 /* ByteDanceFilter.m */; }; - E7A49D4829090F8000F06DD4 /* BEFrameProcessor.mm in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D4729090F8000F06DD4 /* BEFrameProcessor.mm */; }; - E7A49D4B29090FA000F06DD4 /* BERenderHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D4929090FA000F06DD4 /* BERenderHelper.m */; }; - E7A49D4E29090FB800F06DD4 /* BEResourceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D4C29090FB800F06DD4 /* BEResourceHelper.m */; }; E7A49D5129090FCC00F06DD4 /* BEEffectManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D5029090FCC00F06DD4 /* BEEffectManager.mm */; }; E7A49D5429090FF500F06DD4 /* BELicenseHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D5329090FF500F06DD4 /* BELicenseHelper.mm */; }; E7A49D572909101D00F06DD4 /* BEImageUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D562909101D00F06DD4 /* BEImageUtils.m */; }; E7A49D5A2909103600F06DD4 /* BEGLTexture.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D592909103500F06DD4 /* BEGLTexture.m */; }; - E7A49D5D2909105000F06DD4 /* BEPixelBufferInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D5C2909105000F06DD4 /* BEPixelBufferInfo.m */; }; E7A49D62290910FD00F06DD4 /* BEOpenGLRenderHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D60290910FD00F06DD4 /* BEOpenGLRenderHelper.m */; }; E7A49D652909111400F06DD4 /* BEHttpRequestProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D642909111400F06DD4 /* BEHttpRequestProvider.mm */; }; - E7A49D682909113200F06DD4 /* BERender.mm in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D672909113200F06DD4 /* BERender.mm */; }; E7A49D6B2909115200F06DD4 /* BEEffectResourceHelper.m in Sources */ = {isa = PBXBuildFile; fileRef = E7A49D6A2909115100F06DD4 /* BEEffectResourceHelper.m */; }; E7AD0DE129C85FFB00C9A4B0 /* sample.mov in Resources */ = {isa = PBXBuildFile; fileRef = E7AD0DE029C85FFB00C9A4B0 /* sample.mov */; }; E7AD0DE329C95EB500C9A4B0 /* PickerView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E7AD0DE229C95EB500C9A4B0 /* PickerView.swift */; }; @@ -242,6 +235,10 @@ F728B9DD2CA295D7007813BB /* PixelBufferPIPViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = F728B9D42CA295D7007813BB /* PixelBufferPIPViewController.swift */; }; F728B9DE2CA295D7007813BB /* PixelBufferRenderView.swift in Sources */ = {isa = PBXBuildFile; fileRef = F728B9D52CA295D7007813BB /* PixelBufferRenderView.swift */; }; F728B9E02CA29625007813BB /* PictureInPicture.strings in Resources */ = {isa = PBXBuildFile; fileRef = F728B9DF2CA29625007813BB /* PictureInPicture.strings */; }; + F73B01CE2CCB7E730077B7D2 /* BETimeRecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = F73B01C82CCB7E720077B7D2 /* BETimeRecoder.m */; }; + F73B01CF2CCB7E730077B7D2 /* BEGLUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = F73B01CC2CCB7E730077B7D2 /* BEGLUtils.m */; }; + F73B01D52CCB84590077B7D2 /* APIReporter.m in Sources */ = {isa = PBXBuildFile; fileRef = F73B01D32CCB84590077B7D2 /* APIReporter.m */; }; + F73B01D82CCB862A0077B7D2 /* EFGlobalSingleton.m in Sources */ = {isa = PBXBuildFile; fileRef = F73B01D72CCB862A0077B7D2 /* EFGlobalSingleton.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -537,7 +534,6 @@ E7A49CEE29029E0000F06DD4 /* ThirdBeautify.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ThirdBeautify.swift; sourceTree = ""; }; E7A49CF129029E0000F06DD4 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/FUBeautify.strings"; sourceTree = ""; }; E7A49CF229029E0000F06DD4 /* FUBeautifyVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUBeautifyVC.h; sourceTree = ""; }; - E7A49CF329029E0000F06DD4 /* authpack.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = authpack.h; sourceTree = ""; }; E7A49CF529029E0000F06DD4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/FUBeautify.storyboard; sourceTree = ""; }; E7A49CF629029E0000F06DD4 /* FUManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FUManager.h; sourceTree = ""; }; E7A49CF729029E0000F06DD4 /* FUBeautifyVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FUBeautifyVC.m; sourceTree = ""; }; @@ -567,19 +563,10 @@ E7A49D2E2907E68800F06DD4 /* libz.1.1.3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.1.1.3.tbd; path = usr/lib/libz.1.1.3.tbd; sourceTree = SDKROOT; }; E7A49D322907E74A00F06DD4 /* BundleUtil.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BundleUtil.h; sourceTree = ""; }; E7A49D332907E74A00F06DD4 /* BundleUtil.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BundleUtil.m; sourceTree = ""; }; - E7A49D352907EB6000F06DD4 /* SENSEME.lic */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = SENSEME.lic; sourceTree = ""; }; E7A49D3A290907E200F06DD4 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/BytedEffect.strings"; sourceTree = ""; }; E7A49D3B290907E200F06DD4 /* BytedEffectVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BytedEffectVC.m; sourceTree = ""; }; E7A49D3D290907E200F06DD4 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/BytedEffect.storyboard; sourceTree = ""; }; E7A49D3F290907E200F06DD4 /* BytedEffectVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BytedEffectVC.h; sourceTree = ""; }; - E7A49D4329090F3B00F06DD4 /* ByteDanceFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ByteDanceFilter.h; sourceTree = ""; }; - E7A49D4429090F3C00F06DD4 /* ByteDanceFilter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ByteDanceFilter.m; sourceTree = ""; }; - E7A49D4629090F7F00F06DD4 /* BEFrameProcessor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BEFrameProcessor.h; sourceTree = ""; }; - E7A49D4729090F8000F06DD4 /* BEFrameProcessor.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BEFrameProcessor.mm; sourceTree = ""; }; - E7A49D4929090FA000F06DD4 /* BERenderHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BERenderHelper.m; sourceTree = ""; }; - E7A49D4A29090FA000F06DD4 /* BERenderHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BERenderHelper.h; sourceTree = ""; }; - E7A49D4C29090FB800F06DD4 /* BEResourceHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BEResourceHelper.m; sourceTree = ""; }; - E7A49D4D29090FB800F06DD4 /* BEResourceHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BEResourceHelper.h; sourceTree = ""; }; E7A49D4F29090FCC00F06DD4 /* BEEffectManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BEEffectManager.h; sourceTree = ""; }; E7A49D5029090FCC00F06DD4 /* BEEffectManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BEEffectManager.mm; sourceTree = ""; }; E7A49D5229090FF400F06DD4 /* BELicenseHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BELicenseHelper.h; sourceTree = ""; }; @@ -588,16 +575,12 @@ E7A49D562909101D00F06DD4 /* BEImageUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BEImageUtils.m; sourceTree = ""; }; E7A49D582909103500F06DD4 /* BEGLTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BEGLTexture.h; sourceTree = ""; }; E7A49D592909103500F06DD4 /* BEGLTexture.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BEGLTexture.m; sourceTree = ""; }; - E7A49D5B2909105000F06DD4 /* BEPixelBufferInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BEPixelBufferInfo.h; sourceTree = ""; }; - E7A49D5C2909105000F06DD4 /* BEPixelBufferInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BEPixelBufferInfo.m; sourceTree = ""; }; E7A49D5E290910A000F06DD4 /* Core.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Core.h; sourceTree = ""; }; E7A49D5F290910A100F06DD4 /* macro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = macro.h; sourceTree = ""; }; E7A49D60290910FD00F06DD4 /* BEOpenGLRenderHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BEOpenGLRenderHelper.m; sourceTree = ""; }; E7A49D61290910FD00F06DD4 /* BEOpenGLRenderHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BEOpenGLRenderHelper.h; sourceTree = ""; }; E7A49D632909111300F06DD4 /* BEHttpRequestProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BEHttpRequestProvider.h; sourceTree = ""; }; E7A49D642909111400F06DD4 /* BEHttpRequestProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BEHttpRequestProvider.mm; sourceTree = ""; }; - E7A49D662909113200F06DD4 /* BERender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BERender.h; sourceTree = ""; }; - E7A49D672909113200F06DD4 /* BERender.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BERender.mm; sourceTree = ""; }; E7A49D692909115100F06DD4 /* BEEffectResourceHelper.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BEEffectResourceHelper.h; sourceTree = ""; }; E7A49D6A2909115100F06DD4 /* BEEffectResourceHelper.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BEEffectResourceHelper.m; sourceTree = ""; }; E7A49D6E290A744400F06DD4 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/ThirdBeautify.strings"; sourceTree = ""; }; @@ -614,6 +597,16 @@ F728B9D42CA295D7007813BB /* PixelBufferPIPViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PixelBufferPIPViewController.swift; sourceTree = ""; }; F728B9D52CA295D7007813BB /* PixelBufferRenderView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PixelBufferRenderView.swift; sourceTree = ""; }; F728B9DF2CA29625007813BB /* PictureInPicture.strings */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; path = PictureInPicture.strings; sourceTree = ""; }; + F73B01C82CCB7E720077B7D2 /* BETimeRecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BETimeRecoder.m; sourceTree = ""; }; + F73B01C92CCB7E720077B7D2 /* Config.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Config.h; sourceTree = ""; }; + F73B01CA2CCB7E720077B7D2 /* BETimeRecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BETimeRecoder.h; sourceTree = ""; }; + F73B01CC2CCB7E730077B7D2 /* BEGLUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BEGLUtils.m; sourceTree = ""; }; + F73B01CD2CCB7E730077B7D2 /* BEGLUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BEGLUtils.h; sourceTree = ""; }; + F73B01D12CCB7EE20077B7D2 /* EffectMacro.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EffectMacro.h; sourceTree = ""; }; + F73B01D22CCB84590077B7D2 /* APIReporter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIReporter.h; sourceTree = ""; }; + F73B01D32CCB84590077B7D2 /* APIReporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = APIReporter.m; sourceTree = ""; }; + F73B01D62CCB862A0077B7D2 /* EFGlobalSingleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EFGlobalSingleton.h; sourceTree = ""; }; + F73B01D72CCB862A0077B7D2 /* EFGlobalSingleton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = EFGlobalSingleton.m; sourceTree = ""; }; FAAC2AEE355D103B9E8527B5 /* Pods-Agora-ScreenShare-Extension.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Agora-ScreenShare-Extension.debug.xcconfig"; path = "Target Support Files/Pods-Agora-ScreenShare-Extension/Pods-Agora-ScreenShare-Extension.debug.xcconfig"; sourceTree = ""; }; /* End PBXFileReference section */ @@ -1324,6 +1317,7 @@ E76347B62AAEF4AF005D130F /* BeautyAPI */ = { isa = PBXGroup; children = ( + F73B01D42CCB84590077B7D2 /* Report */, E76347B82AAEF4AF005D130F /* BeautyAPI.h */, E76347C72AAEF4AF005D130F /* BeautyAPI.m */, E76347BC2AAEF4AF005D130F /* Render */, @@ -1436,7 +1430,6 @@ E7A49D0029029E1900F06DD4 /* Manager */ = { isa = PBXGroup; children = ( - E7A49CF329029E0000F06DD4 /* authpack.h */, E7A49CF629029E0000F06DD4 /* FUManager.h */, E7A49CF829029E0000F06DD4 /* FUManager.m */, ); @@ -1458,12 +1451,14 @@ E7A49D0729067F8300F06DD4 /* Manager */ = { isa = PBXGroup; children = ( - E7A49D352907EB6000F06DD4 /* SENSEME.lic */, E7A49D192907DD7800F06DD4 /* Effects.h */, E7A49D182907DD7800F06DD4 /* Effects.m */, E7A49D2A2907DEE600F06DD4 /* EFMotionManager.h */, E7A49D292907DEE600F06DD4 /* EFMotionManager.m */, + F73B01D62CCB862A0077B7D2 /* EFGlobalSingleton.h */, + F73B01D72CCB862A0077B7D2 /* EFGlobalSingleton.m */, E7A49D1B2907DD8400F06DD4 /* EffectsAnimal.h */, + F73B01D12CCB7EE20077B7D2 /* EffectMacro.h */, E7A49D1C2907DD8400F06DD4 /* EffectsAnimal.m */, E7A49D162907DD2600F06DD4 /* EffectsLicense.h */, E7A49D152907DD2600F06DD4 /* EffectsLicense.m */, @@ -1498,32 +1493,25 @@ children = ( E7A49D5E290910A000F06DD4 /* Core.h */, E7A49D5F290910A100F06DD4 /* macro.h */, - E7A49D662909113200F06DD4 /* BERender.h */, - E7A49D672909113200F06DD4 /* BERender.mm */, E7A49D692909115100F06DD4 /* BEEffectResourceHelper.h */, E7A49D6A2909115100F06DD4 /* BEEffectResourceHelper.m */, + F73B01CD2CCB7E730077B7D2 /* BEGLUtils.h */, + F73B01CC2CCB7E730077B7D2 /* BEGLUtils.m */, + F73B01CA2CCB7E720077B7D2 /* BETimeRecoder.h */, + F73B01C82CCB7E720077B7D2 /* BETimeRecoder.m */, + F73B01C92CCB7E720077B7D2 /* Config.h */, E7A49D632909111300F06DD4 /* BEHttpRequestProvider.h */, E7A49D642909111400F06DD4 /* BEHttpRequestProvider.mm */, E7A49D61290910FD00F06DD4 /* BEOpenGLRenderHelper.h */, E7A49D60290910FD00F06DD4 /* BEOpenGLRenderHelper.m */, - E7A49D5B2909105000F06DD4 /* BEPixelBufferInfo.h */, - E7A49D5C2909105000F06DD4 /* BEPixelBufferInfo.m */, E7A49D582909103500F06DD4 /* BEGLTexture.h */, E7A49D592909103500F06DD4 /* BEGLTexture.m */, E7A49D552909101D00F06DD4 /* BEImageUtils.h */, E7A49D562909101D00F06DD4 /* BEImageUtils.m */, E7A49D5229090FF400F06DD4 /* BELicenseHelper.h */, E7A49D5329090FF500F06DD4 /* BELicenseHelper.mm */, - E7A49D4D29090FB800F06DD4 /* BEResourceHelper.h */, - E7A49D4C29090FB800F06DD4 /* BEResourceHelper.m */, E7A49D4F29090FCC00F06DD4 /* BEEffectManager.h */, E7A49D5029090FCC00F06DD4 /* BEEffectManager.mm */, - E7A49D4A29090FA000F06DD4 /* BERenderHelper.h */, - E7A49D4929090FA000F06DD4 /* BERenderHelper.m */, - E7A49D4629090F7F00F06DD4 /* BEFrameProcessor.h */, - E7A49D4729090F8000F06DD4 /* BEFrameProcessor.mm */, - E7A49D4329090F3B00F06DD4 /* ByteDanceFilter.h */, - E7A49D4429090F3C00F06DD4 /* ByteDanceFilter.m */, ); path = Manager; sourceTree = ""; @@ -1547,6 +1535,15 @@ path = PixelBufferPIPViewController; sourceTree = ""; }; + F73B01D42CCB84590077B7D2 /* Report */ = { + isa = PBXGroup; + children = ( + F73B01D22CCB84590077B7D2 /* APIReporter.h */, + F73B01D32CCB84590077B7D2 /* APIReporter.m */, + ); + path = Report; + sourceTree = ""; + }; FD17F473C6A05604A44BDDDE /* Pods */ = { isa = PBXGroup; children = ( @@ -1616,6 +1613,7 @@ 1B6F6CF9B678035E221EAFDE /* [CP] Embed Pods Frameworks */, 0339BEBA25205B80007D4FDD /* Embed App Extensions */, E76F80122AF0A7A200CCB9D6 /* ShellScript */, + EA59815E58120166C6FD72B5 /* [CP] Copy Pods Resources */, ); buildRules = ( ); @@ -1785,7 +1783,6 @@ 033A9F6B252D8B3500BC26E1 /* MediaChannelRelay.storyboard in Resources */, 671BD6B927E1DB2D0076D5E1 /* CustomAudioRender.storyboard in Resources */, E728B85128B60D5B00674A4A /* VideoViewSampleBufferDisplayView.xib in Resources */, - E7A49D362907EB6000F06DD4 /* SENSEME.lic in Resources */, 03D13BD72448758900B599B3 /* Main.storyboard in Resources */, F728B9D72CA295D7007813BB /* PictureInPicture.storyboard in Resources */, ); @@ -1901,6 +1898,23 @@ shellPath = /bin/sh; shellScript = "\"${PODS_ROOT}/SwiftLint/swiftlint\" \n"; }; + EA59815E58120166C6FD72B5 /* [CP] Copy Pods Resources */ = { + isa = PBXShellScriptBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + inputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-APIExample/Pods-APIExample-resources-${CONFIGURATION}-input-files.xcfilelist", + ); + name = "[CP] Copy Pods Resources"; + outputFileListPaths = ( + "${PODS_ROOT}/Target Support Files/Pods-APIExample/Pods-APIExample-resources-${CONFIGURATION}-output-files.xcfilelist", + ); + runOnlyForDeploymentPostprocessing = 0; + shellPath = /bin/sh; + shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-APIExample/Pods-APIExample-resources.sh\"\n"; + showEnvVarsInLog = 0; + }; /* End PBXShellScriptBuildPhase section */ /* Begin PBXSourcesBuildPhase section */ @@ -1923,7 +1937,6 @@ 8BA5459626AFEC8D00ED4295 /* SimpleFilter.swift in Sources */, 036CBA47251990B400D74FAD /* AgoraCustomEncryption.h in Sources */, E726BFFB2A949F70006870E2 /* AudioRouterPlayer.swift in Sources */, - E7A49D4E29090FB800F06DD4 /* BEResourceHelper.m in Sources */, E7A49D232907DD9A00F06DD4 /* EffectsCommonObject.m in Sources */, E7A49D652909111400F06DD4 /* BEHttpRequestProvider.mm in Sources */, E7A49CFB29029E0000F06DD4 /* ThirdBeautify.swift in Sources */, @@ -1933,7 +1946,6 @@ E76347D32AAEF4AF005D130F /* BeautyAPI.m in Sources */, 0339BE9625203293007D4FDD /* ScreenShare.swift in Sources */, 033A9F00252D61E200BC26E1 /* CustomAudioSource.swift in Sources */, - E7A49D682909113200F06DD4 /* BERender.mm in Sources */, 03DF1D9224CFC29700DF7151 /* UIView+CSshortFrame.m in Sources */, E7A49D1A2907DD7800F06DD4 /* Effects.m in Sources */, 671BD6BA27E1DB2D0076D5E1 /* CustomAudioRender.swift in Sources */, @@ -1945,13 +1957,10 @@ E77D54C928F55E9100D51C1E /* JoinChannelVideoToken.swift in Sources */, 0371D8AE250B4A2C00C0DD61 /* JoinChannelAudio.swift in Sources */, E726C0052A96FD3A006870E2 /* AudioWaveform.swift in Sources */, - E7A49D4529090F3C00F06DD4 /* ByteDanceFilter.m in Sources */, E7A49D5429090FF500F06DD4 /* BELicenseHelper.mm in Sources */, - E7A49D4B29090FA000F06DD4 /* BERenderHelper.m in Sources */, E7A49D172907DD2600F06DD4 /* EffectsLicense.m in Sources */, E728B84F28B601A300674A4A /* AgoraSampleBufferRender.m in Sources */, 8B333DA9267B4BC3002A3785 /* SettingsCells.swift in Sources */, - E7A49D4829090F8000F06DD4 /* BEFrameProcessor.mm in Sources */, 033A9EFC252D61E200BC26E1 /* CustomVideoRender.swift in Sources */, E76347D22AAEF4AF005D130F /* BytesBeautyRender.m in Sources */, 576EA59025AEDD3C000B3D79 /* (null) in Sources */, @@ -1999,8 +2008,10 @@ 0318857924CD667A00C699EB /* SettingsViewController.swift in Sources */, E726C0082A96FF15006870E2 /* ZSNBoxingView.m in Sources */, 033A9EFB252D61E200BC26E1 /* CustomVideoSourcePush.swift in Sources */, + F73B01D82CCB862A0077B7D2 /* EFGlobalSingleton.m in Sources */, 576CA80C25AA0FA90091520B /* AgoraPcmSourcePush.swift in Sources */, E7A49D62290910FD00F06DD4 /* BEOpenGLRenderHelper.m in Sources */, + F73B01D52CCB84590077B7D2 /* APIReporter.m in Sources */, A7BD7660247CC6920062A6B3 /* UITypeAlias.swift in Sources */, 8BE7ABC4279E065000DFBCEF /* FusionCDN.swift in Sources */, 57FE7C4B26B2D103002D9043 /* CircularBuffer.c in Sources */, @@ -2023,12 +2034,13 @@ 034C625E2524A06800296ECF /* VoiceChanger.swift in Sources */, E7A49D2B2907DEE600F06DD4 /* EFMotionManager.m in Sources */, 03D13BD02448758900B599B3 /* AppDelegate.swift in Sources */, + F73B01CE2CCB7E730077B7D2 /* BETimeRecoder.m in Sources */, 0385768225224A88003C369A /* JoinChannelVideo.swift in Sources */, A7847F922458062900469187 /* StatisticsInfo.swift in Sources */, - E7A49D5D2909105000F06DD4 /* BEPixelBufferInfo.m in Sources */, E7163F88296414F700EBBD55 /* ARVideoRenderer.swift in Sources */, 0339BE72251EF075007D4FDD /* MediaPlayer.swift in Sources */, E76347D02AAEF4AF005D130F /* FUBeautyRender.m in Sources */, + F73B01CF2CCB7E730077B7D2 /* BEGLUtils.m in Sources */, E7A49CFE29029E0000F06DD4 /* FUBeautifyVC.m in Sources */, E77902672A484A8A008791AD /* KFMP4Demuxer.m in Sources */, 0385767E2521E5A0003C369A /* MediaChannelRelay.swift in Sources */, diff --git a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/BeautyAPI.m b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/BeautyAPI.m index 844870bc9..ece43cc0d 100644 --- a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/BeautyAPI.m +++ b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/BeautyAPI.m @@ -6,8 +6,9 @@ // #import "BeautyAPI.h" +#import "APIReporter.h" -static NSString *const beautyAPIVnersio = @"1.0.3"; +static NSString *const beautyAPIVersion = @"1.0.7"; @implementation BeautyStats @end @@ -24,6 +25,8 @@ @interface BeautyAPI () @property (nonatomic, assign) CFTimeInterval preTime; @property (nonatomic, strong) NSMutableArray *statsArray; @property (nonatomic, assign) AgoraVideoRenderMode renderMode; +@property (nonatomic, strong) APIReporter *reporter; +@property (nonatomic, assign) BOOL isFirstFrame; @end @@ -34,6 +37,13 @@ @interface BeautyAPI () @implementation BeautyAPI +- (instancetype)init { + if (self == [super init]) { + _isFrontCamera = YES; + } + return self; +} + - (NSMutableArray *)statsArray { if (_statsArray == nil) { _statsArray = [NSMutableArray new]; @@ -41,6 +51,15 @@ - (NSMutableArray *)statsArray { return _statsArray; } +- (APIReporter *)reporter { + if (_reporter == nil) { + _reporter = [[APIReporter alloc] initWithType:(APITypeBeauty) + version:beautyAPIVersion + engine:self.config.rtcEngine]; + } + return _reporter; +} + - (int)initialize:(BeautyConfig *)config { if (config.cameraConfig == nil) { CameraConfig *cameraConfig = [[CameraConfig alloc] init]; @@ -50,7 +69,6 @@ - (int)initialize:(BeautyConfig *)config { } [LogUtil log:[NSString stringWithFormat:@"RTC Version == %@", [AgoraRtcEngineKit getSdkVersion]]]; [LogUtil log:[NSString stringWithFormat:@"BeautyAPI Version == %@", [self getVersion]]]; - _isFrontCamera = YES; self.config = config; if (self.config.statsDuration <= 0) { self.config.statsDuration = 1; @@ -64,6 +82,7 @@ - (int)initialize:(BeautyConfig *)config { return -1; } [LogUtil log:[NSString stringWithFormat:@"beautyRender == %@", config.beautyRender.description]]; + [self.reporter startDurationEventWithName:@"initialize-release"]; self.beautyRender = config.beautyRender; if (config.captureMode == CaptureModeAgora) { #if __has_include() @@ -79,6 +98,7 @@ - (int)initialize:(BeautyConfig *)config { } }; [self rtcReportWithEvent:@"initialize" label:dict]; + [self setupMirror]; #else [LogUtil log:@"rtc 未导入" level:(LogLevelError)]; return -1; @@ -86,15 +106,17 @@ - (int)initialize:(BeautyConfig *)config { } else { [LogUtil log:@"captureMode == Custom"]; } + [self setupMirror]; return 0; } - (int)switchCamera { _isFrontCamera = !_isFrontCamera; - [self setupMirror]; NSDictionary *dict = @{ @"cameraPosition": @(_isFrontCamera) }; [self rtcReportWithEvent:@"cameraPosition" label:dict]; - return [self.config.rtcEngine switchCamera]; + int res = [self.config.rtcEngine switchCamera]; + [self setupMirror]; + return res; } - (AgoraVideoMirrorMode)setupMirror { @@ -190,6 +212,7 @@ - (int)destroy { [self.config.beautyRender destroy]; self.config = nil; [LogUtil log:@"destroy"]; + [self.reporter endDurationEventWithName:@"initialize-release" ext:@{}]; return 0; } @@ -198,39 +221,34 @@ - (void)rtcReportWithEvent: (NSString *)event label: (NSDictionary *)label { [LogUtil log:@"rtc 不能为空" level:(LogLevelError)]; return; } - NSString *jsonString = [self convertToJson:label]; - [self.config.rtcEngine sendCustomReportMessage:@"scenarioAPI" - category:[NSString stringWithFormat:@"beauty_iOS_%@",[self getVersion]] - event:event - label:jsonString - value:0]; -} - -- (NSString *)convertToJson: (NSDictionary *)object { - NSError *error = nil; - NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object - options:0 - error:&error]; - if (error) { - // 转换失败 - NSLog(@"Error: %@", error.localizedDescription); - return nil; - } - NSString *jsonString = [[NSString alloc] initWithData:jsonData - encoding:NSUTF8StringEncoding]; - return jsonString; + [self.reporter reportFuncEventWithName:event value:label ext:@{}]; } - (NSString *)getVersion { - return beautyAPIVnersio; + return beautyAPIVersion; } #pragma mark - VideoFrameDelegate #if __has_include() +- (BOOL)onCaptureVideoFrame:(AgoraOutputVideoFrame *)videoFrame { + return [self onCaptureVideoFrame:videoFrame sourceType:(AgoraVideoSourceTypeCamera)]; +} - (BOOL)onCaptureVideoFrame:(AgoraOutputVideoFrame *)videoFrame sourceType:(AgoraVideoSourceType)sourceType { if (!self.isEnable) { return YES; } CFTimeInterval startTime = CACurrentMediaTime(); + if (!self.isFirstFrame) { + [self.reporter startDurationEventWithName:@"first_beauty_frame"]; + } CVPixelBufferRef pixelBuffer = [self.config.beautyRender onCapture:videoFrame.pixelBuffer]; + if (!self.isFirstFrame) { + [self.reporter endDurationEventWithName:@"first_beauty_frame" ext:@{ + @"width": @(CVPixelBufferGetWidth(pixelBuffer)), + @"height": @(CVPixelBufferGetHeight(pixelBuffer)), + @"camera_facing": _isFrontCamera ? @"front" : @"back", + @"buffer_type": @"pixelbuffer" + }]; + self.isFirstFrame = YES; + } CFTimeInterval endTime = CACurrentMediaTime(); if (self.config.statsEnable) { [self.statsArray addObject:@(endTime - startTime)]; @@ -239,7 +257,7 @@ - (BOOL)onCaptureVideoFrame:(AgoraOutputVideoFrame *)videoFrame sourceType:(Agor if (self.config.eventCallback && self.preTime > 0 && self.config.statsEnable) { CFTimeInterval time = startTime - self.preTime; if (time > self.config.statsDuration && self.statsArray.count > 0) { - NSArray *sortArray = [self.statsArray sortedArrayUsingComparator:^NSComparisonResult(NSNumber * _Nonnull obj1, NSNumber * _Nonnull obj2) { + NSArray *sortArray = [self.statsArray sortedArrayUsingComparator:^NSComparisonResult(NSNumber * _Nonnull obj1, NSNumber * _Nonnull obj2) { return obj1.doubleValue > obj2.doubleValue; }]; double totalValue = 0; diff --git a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/BytesRender/BytesBeautyRender.h b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/BytesRender/BytesBeautyRender.h index bbe434af1..d9b637a5e 100644 --- a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/BytesRender/BytesBeautyRender.h +++ b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/BytesRender/BytesBeautyRender.h @@ -5,13 +5,14 @@ // Created by zhaoyongqiang on 2023/6/30. // -#define BytesMoudle "bef_effect_ai_api.h" +#define BytesMoudle #import -#if __has_include("BEImageUtils.h") && __has_include("BEFrameProcessor.h") +#if __has_include("BEImageUtils.h") && __has_include("BEEffectManager.h") #import "BEImageUtils.h" -#import "BEFrameProcessor.h" +#import "BEEffectManager.h" +#import "BEEffectResourceHelper.h" #endif #import "BeautyAPI.h" @@ -19,11 +20,11 @@ NS_ASSUME_NONNULL_BEGIN @interface BytesBeautyRender : NSObject -#if __has_include("BEImageUtils.h") && __has_include("BEFrameProcessor.h") -@property (nonatomic, strong) BEFrameProcessor *frameProcessor; +#if __has_include("BEImageUtils.h") && __has_include("BEEffectManager.h") +@property (nonatomic, strong) BEEffectManager *effectManager; @property (nonatomic, strong) BEImageUtils *imageUtils; #endif - +- (BOOL)checkLicense; @end NS_ASSUME_NONNULL_END diff --git a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/BytesRender/BytesBeautyRender.m b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/BytesRender/BytesBeautyRender.m index 645b31a3c..cce26dd58 100644 --- a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/BytesRender/BytesBeautyRender.m +++ b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/BytesRender/BytesBeautyRender.m @@ -7,26 +7,30 @@ #import "BytesBeautyRender.h" + @interface BytesBeautyRender () @property (nonatomic, strong) NSMutableArray *bytesNodes; +@property (nonatomic, weak) BEPixelBufferGLTexture *outTexture; @end @implementation BytesBeautyRender -#if __has_include("BEImageUtils.h") && __has_include("BEFrameProcessor.h") -- (BEFrameProcessor *)frameProcessor { - if (_frameProcessor == nil) { - EAGLContext *context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; - [EAGLContext setCurrentContext:context]; - _frameProcessor = [[BEFrameProcessor alloc]initWithContext:context resourceDelegate:nil]; - _frameProcessor.processorResult = BECVPixelBuffer; - [_frameProcessor setEffectOn:YES]; - [_frameProcessor updateComposerNodes:self.bytesNodes]; +#if __has_include("BEImageUtils.h") && __has_include("BEEffectManager.h") +- (BEEffectManager *)effectManager { + if (_effectManager == nil) { + _effectManager = [[BEEffectManager alloc] initWithResourceProvider:[BEEffectResourceHelper new] licenseProvider:[BELicenseHelper shareInstance]]; +#if __has_include(BytesMoudle) + int ret = [_effectManager initTask]; + if (ret == BEF_RESULT_SUC){ + [_effectManager updateComposerNodes:self.bytesNodes]; + } +#endif } - return _frameProcessor; + return _effectManager; } + - (BEImageUtils *)imageUtils { if (_imageUtils == nil) { _imageUtils = [[BEImageUtils alloc] init]; @@ -42,84 +46,150 @@ - (NSMutableArray *)bytesNodes { return _bytesNodes; } -- (void)destroy { +- (BOOL)checkLicense { +#if __has_include(BytesMoudle) + return [[BELicenseHelper shareInstance] checkLicense]; +#else + return NO; +#endif +} + +- (void)destroy { #if __has_include(BytesMoudle) - _frameProcessor = nil; + [_effectManager cleanPipeline]; + [_effectManager destroyTask]; + _effectManager = nil; _imageUtils = nil; + [self.outTexture destroy]; + self.outTexture = nil; #endif } -- (nonnull CVPixelBufferRef)onCapture:(nonnull CVPixelBufferRef)pixelBuffer { +- (nonnull CVPixelBufferRef)onCapture:(nonnull CVPixelBufferRef)pixelBuffer { #if __has_include(BytesMoudle) - pixelBuffer = [self.imageUtils transforCVPixelBufferToCVPixelBuffer:pixelBuffer outputFormat:BE_BGRA]; - CVPixelBufferRef px = [self.frameProcessor process: pixelBuffer - timeStamp: [NSDate date].timeIntervalSince1970].pixelBuffer; - return px; + double timeStamp = [[NSDate date] timeIntervalSince1970]; + BEPixelBufferInfo *pixelBufferInfo = [self.imageUtils getCVPixelBufferInfo:pixelBuffer]; + if (pixelBufferInfo.format != BE_BGRA) { + pixelBuffer = [self.imageUtils transforCVPixelBufferToCVPixelBuffer:pixelBuffer + outputFormat:pixelBufferInfo.format]; + } + + if ([self getDeviceOrientation] != BEF_AI_CLOCKWISE_ROTATE_0) { + pixelBuffer = [self.imageUtils rotateCVPixelBuffer:pixelBuffer rotation:BEF_AI_CLOCKWISE_ROTATE_0]; + } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + if ([EAGLContext currentContext] != self.effectManager.glContext) { + [EAGLContext setCurrentContext: self.effectManager.glContext]; + } +#pragma clang diagnostic pop + id texture = [self.imageUtils transforCVPixelBufferToTexture:pixelBuffer]; + BEPixelBufferGLTexture *outTexture = nil; + + outTexture = [self.imageUtils getOutputPixelBufferGLTextureWithWidth:texture.width + height:texture.height + format:pixelBufferInfo.format + withPipeline:self.effectManager.usePipeline]; + self.outTexture = outTexture; + int ret = [self.effectManager processTexture:texture.texture + outputTexture:outTexture.texture + width:pixelBufferInfo.width + height:pixelBufferInfo.height + rotate:[self getDeviceOrientation] + timeStamp:timeStamp]; + if (ret != BEF_RESULT_SUC) { + outTexture = texture; + } + return [(BEPixelBufferGLTexture *)outTexture pixelBuffer]; +#else + return pixelBuffer; #endif - return nil; } + +#if __has_include(BytesMoudle) +- (bef_ai_rotate_type)getDeviceOrientation { + UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation]; + switch (orientation) { + case UIDeviceOrientationPortrait: + return BEF_AI_CLOCKWISE_ROTATE_0; + + case UIDeviceOrientationPortraitUpsideDown: + return BEF_AI_CLOCKWISE_ROTATE_180; + + case UIDeviceOrientationLandscapeLeft: + return BEF_AI_CLOCKWISE_ROTATE_270; + + case UIDeviceOrientationLandscapeRight: + return BEF_AI_CLOCKWISE_ROTATE_90; + + default: + return BEF_AI_CLOCKWISE_ROTATE_0; + } +} +#endif + #if __has_include() - (AgoraVideoFormat)getVideoFormatPreference { return AgoraVideoFormatCVPixelBGRA; } #endif -- (void)reset { +- (void)reset { #if __has_include(BytesMoudle) - [self.frameProcessor updateComposerNodeIntensity:@"/beauty_IOS_lite" key:@"whiten" intensity:0]; - [self.frameProcessor updateComposerNodeIntensity:@"/beauty_IOS_lite" key:@"smooth" intensity:0]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Overall" intensity:0]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Zoom_Cheekbone" intensity:0]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Eye" intensity:0]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Nose" intensity:0]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Chin" intensity:0]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Zoom_Jawbone" intensity:0]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Forehead" intensity:0]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_ZoomMouth" intensity:0]; - [self.frameProcessor updateComposerNodeIntensity:@"/beauty_4Items" key:@"BEF_BEAUTY_WHITEN_TEETH" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/beauty_IOS_lite" key:@"whiten" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/beauty_IOS_lite" key:@"smooth" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Overall" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Zoom_Cheekbone" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Eye" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Nose" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Chin" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Zoom_Jawbone" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Forehead" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_ZoomMouth" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/beauty_4Items" key:@"BEF_BEAUTY_WHITEN_TEETH" intensity:0]; #endif } -- (void)setBeautyPreset { +- (void)setBeautyPreset { #if __has_include(BytesMoudle) - [self.frameProcessor updateComposerNodeIntensity:@"/beauty_IOS_lite" key:@"whiten" intensity:0.2]; - [self.frameProcessor updateComposerNodeIntensity:@"/beauty_IOS_lite" key:@"smooth" intensity:0.3]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Overall" intensity:0.15]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Zoom_Cheekbone" intensity:0.3]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Eye" intensity:0.15]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Nose" intensity:0.15]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Chin" intensity:0.46]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Zoom_Jawbone" intensity:0.46]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Forehead" intensity:0.4]; - [self.frameProcessor updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_ZoomMouth" intensity:0.16]; - [self.frameProcessor updateComposerNodeIntensity:@"/beauty_4Items" key:@"BEF_BEAUTY_WHITEN_TEETH" intensity:0.2]; + [self.effectManager updateComposerNodeIntensity:@"/beauty_IOS_lite" key:@"whiten" intensity:0.2]; + [self.effectManager updateComposerNodeIntensity:@"/beauty_IOS_lite" key:@"smooth" intensity:0.3]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Overall" intensity:0.15]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Zoom_Cheekbone" intensity:0.3]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Eye" intensity:0.15]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Nose" intensity:0.15]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Chin" intensity:0.46]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Zoom_Jawbone" intensity:0.46]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_Forehead" intensity:0.4]; + [self.effectManager updateComposerNodeIntensity:@"/reshape_lite" key:@"Internal_Deform_ZoomMouth" intensity:0.16]; + [self.effectManager updateComposerNodeIntensity:@"/beauty_4Items" key:@"BEF_BEAUTY_WHITEN_TEETH" intensity:0.2]; #endif } -- (void)setMakeup:(BOOL)isSelected { +- (void)setMakeup:(BOOL)isSelected { #if __has_include(BytesMoudle) if (isSelected) { if (![self.bytesNodes containsObject:@"/style_makeup/qise"]) { [self.bytesNodes addObject:@"/style_makeup/qise"]; - [self.frameProcessor updateComposerNodes:self.bytesNodes]; + [self.effectManager updateComposerNodes:self.bytesNodes]; } - [self.frameProcessor updateComposerNodeIntensity:@"/style_makeup/qise" key:@"Makeup_ALL" intensity:0.6]; + [self.effectManager updateComposerNodeIntensity:@"/style_makeup/qise" key:@"Makeup_ALL" intensity:0.6]; } else { if ([self.bytesNodes containsObject:@"/style_makeup/qise"]) { [self.bytesNodes removeObject:@"/style_makeup/qise"]; - [self.frameProcessor updateComposerNodes:self.bytesNodes]; + [self.effectManager updateComposerNodes:self.bytesNodes]; } - [self.frameProcessor updateComposerNodeIntensity:@"/style_makeup/qise" key:@"Makeup_ALL" intensity:0]; + [self.effectManager updateComposerNodeIntensity:@"/style_makeup/qise" key:@"Makeup_ALL" intensity:0]; } #endif } -- (void)setSticker:(BOOL)isSelected { +- (void)setSticker:(BOOL)isSelected { #if __has_include(BytesMoudle) if (isSelected) { - [self.frameProcessor setStickerPath:@"matting_bg"]; + [self.effectManager setStickerPath:@"stickers_zhaocaimao"]; } else { - [self.frameProcessor setStickerPath:@""]; + [self.effectManager setStickerPath:@""]; } #endif } diff --git a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/FURender/FUBeautyRender.h b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/FURender/FUBeautyRender.h index daa31195b..a37bd6db7 100644 --- a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/FURender/FUBeautyRender.h +++ b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/FURender/FUBeautyRender.h @@ -25,11 +25,13 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, strong) FUManager *fuManager; #endif -- (void)setBeautyWithPath: (NSString *)path key: (NSString *)key value: (float)value; ++ (BOOL)checkLicense; -- (void)setStyleWithPath: (NSString *)path key: (NSString *)key value: (float)value; +- (void)setBeautyWithPath:(NSString *)path key:(NSString *)key value:(float)value; -- (void)setStickerWithPath: (NSString *)path; +- (void)setStyleWithPath:(NSString *)path key:(NSString *)key value:(float)value isCombined:(BOOL)isCombined; + +- (void)setStickerWithPath:(NSString *)path; - (void)reset; @@ -39,6 +41,8 @@ NS_ASSUME_NONNULL_BEGIN - (void)destroy; + + @end NS_ASSUME_NONNULL_END diff --git a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/FURender/FUBeautyRender.m b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/FURender/FUBeautyRender.m index 662529ef6..e312eb363 100644 --- a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/FURender/FUBeautyRender.m +++ b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/FURender/FUBeautyRender.m @@ -8,6 +8,10 @@ #import "FUBeautyRender.h" #import "BundleUtil.h" +#if __has_include(FURenderMoudle) +#import "authpack.h" +#endif + @interface FUBeautyRender () #if __has_include(FURenderMoudle) @@ -15,6 +19,7 @@ @interface FUBeautyRender () @property (nonatomic, strong) FUSticker *currentSticker; @property (nonatomic, strong) FUAnimoji *currentAnimoji; #endif +@property (nonatomic, copy) NSString *makeupKey; @end @@ -29,12 +34,27 @@ - (instancetype)init { return self; } ++ (BOOL)checkLicense { + BOOL success = NO; +#if __has_include(FURenderMoudle) + FUSetupConfig *setupConfig = [[FUSetupConfig alloc] init]; + setupConfig.authPack = FUAuthPackMake(g_auth_package, sizeof(g_auth_package)); + + // 初始化 FURenderKit + success = [FURenderKit setupWithSetupConfig:setupConfig]; +#endif + return success; +} + - (void)destroy { #if __has_include(FURenderMoudle) - [FURenderKit shareRenderKit].beauty = nil; - [FURenderKit shareRenderKit].makeup = nil; - [[FURenderKit shareRenderKit].stickerContainer removeAllSticks]; - [FURenderKit destroy]; + dispatch_queue_t referQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0); + dispatch_async(referQueue, ^{ + [FURenderKit shareRenderKit].beauty = nil; + [FURenderKit shareRenderKit].makeup = nil; + [[FURenderKit shareRenderKit].stickerContainer removeAllSticks]; + [FURenderKit destroy]; + }); _fuManager = nil; #endif } @@ -55,8 +75,7 @@ - (void)setBeautyWithPath:(NSString *)path key:(NSString *)key value:(float)valu #if __has_include(FURenderMoudle) FUBeauty *beauty = [FURenderKit shareRenderKit].beauty; if (beauty == nil) { - NSBundle *bundle = [BundleUtil bundleWithBundleName:@"FURenderKit" podName:@"fuLib"]; - NSString *faceAIPath = [bundle pathForResource:[NSString stringWithFormat:@"graphics/%@", path] ofType:@"bundle"]; + NSString *faceAIPath = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@", path] ofType:@"bundle"]; beauty = [[FUBeauty alloc] initWithPath:faceAIPath name:@"FUBeauty"]; beauty.heavyBlur = 0; } @@ -129,21 +148,46 @@ - (void)setBeautyWithPath:(NSString *)path key:(NSString *)key value:(float)valu } else if ([key isEqualToString:@"sharpen"]) { beauty.sharpen = value; } + beauty.enable = YES; [FURenderKit shareRenderKit].beauty = beauty; #endif } -- (void)setStyleWithPath:(NSString *)path key:(NSString *)key value:(float)value { +- (void)setStyleWithPath:(NSString *)path key:(NSString *)key value:(float)value isCombined:(BOOL)isCombined { #if __has_include(FURenderMoudle) - NSBundle *bundle = [BundleUtil bundleWithBundleName:@"FURenderKit" podName:@"fuLib"]; - NSString *makeupPath = [bundle pathForResource:path ofType:@"bundle"]; + [self setupBeauty]; FUMakeup *makeup = [FURenderKit shareRenderKit].makeup; - if (makeup == nil) { - makeup = [[FUMakeup alloc] initWithPath:makeupPath name:@"face_makeup"]; - makeup.isMakeupOn = YES; - [FURenderKit shareRenderKit].makeup = makeup; - [FURenderKit shareRenderKit].makeup.enable = YES; + if (isCombined) { + if (makeup == nil || self.makeupKey != key) { + NSBundle *bundle = [BundleUtil bundleWithBundleName:@"FURenderKit" podName:@"fuLib"]; + NSString *stylePath = [bundle pathForResource:key ofType:@"bundle"]; + makeup = [[FUMakeup alloc] initWithPath:stylePath name:@"makeup"]; + makeup.isMakeupOn = YES; + dispatch_queue_t referQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0); + dispatch_async(referQueue, ^{ + [FURenderKit shareRenderKit].makeup = makeup; + [FURenderKit shareRenderKit].makeup.intensity = value; + [FURenderKit shareRenderKit].makeup.enable = YES; + }); + } + [FURenderKit shareRenderKit].makeup.intensity = value; + self.makeupKey = key; + } else { + NSString *makeupPath = [[NSBundle mainBundle] pathForResource:path ofType:@"bundle"]; + if (makeup == nil || self.makeupKey != path) { + makeup = [[FUMakeup alloc] initWithPath:makeupPath name:@"face_makeup"]; + makeup.isMakeupOn = YES; + [FURenderKit shareRenderKit].makeup = makeup; + [FURenderKit shareRenderKit].makeup.enable = YES; + } + NSBundle *bundle = [BundleUtil bundleWithBundleName:@"FURenderKit" podName:@"fuLib"]; + NSString *stylePath = [bundle pathForResource:key ofType:@"bundle"]; + FUItem *makupItem = [[FUItem alloc] initWithPath:stylePath name:key]; + [makeup updateMakeupPackage:makupItem needCleanSubItem:NO]; + makeup.intensity = value; + self.makeupKey = path; } + NSBundle *bundle = [BundleUtil bundleWithBundleName:@"FURenderKit" podName:@"fuLib"]; NSString *stylePath = [bundle pathForResource:key ofType:@"bundle"]; FUItem *makupItem = [[FUItem alloc] initWithPath:stylePath name:key]; [makeup updateMakeupPackage:makupItem needCleanSubItem:NO]; @@ -153,6 +197,7 @@ - (void)setStyleWithPath:(NSString *)path key:(NSString *)key value:(float)value - (void)setAnimojiWithPath:(NSString *)path { #if __has_include(FURenderMoudle) + [self setupBeauty]; if (self.currentSticker) { [[FURenderKit shareRenderKit].stickerContainer removeSticker:self.currentSticker completion:nil]; self.currentSticker = nil; @@ -173,10 +218,15 @@ - (void)setAnimojiWithPath:(NSString *)path { } - (void)setStickerWithPath:(NSString *)path { +#if __has_include(FURenderMoudle) + [self setupBeauty]; NSBundle *bundle = [BundleUtil bundleWithBundleName:@"FURenderKit" podName:@"fuLib"]; NSString *stickerPath = [bundle pathForResource:[NSString stringWithFormat:@"sticker/%@", path] ofType:@"bundle"]; -#if __has_include(FURenderMoudle) - FUSticker *sticker = [[FUSticker alloc] initWithPath:stickerPath name:@"sticker"]; + if (stickerPath == nil && self.currentSticker == nil) { + return; + } + FUSticker *sticker = [[FUSticker alloc] initWithPath:stickerPath + name:path]; if (self.currentAnimoji) { [[FURenderKit shareRenderKit].stickerContainer removeSticker:self.currentAnimoji completion:nil]; self.currentAnimoji = nil; @@ -192,15 +242,15 @@ - (void)setStickerWithPath:(NSString *)path { - (void)reset { #if __has_include(FURenderMoudle) - [FURenderKit shareRenderKit].beauty = nil; + [FURenderKit shareRenderKit].beauty.enable = NO; #endif } - (void)resetStyle { #if __has_include(FURenderMoudle) [FURenderKit shareRenderKit].makeup.enable = NO; - [FURenderKit shareRenderKit].makeup = nil; #endif + self.makeupKey = nil; } - (void)resetSticker { @@ -213,19 +263,31 @@ - (void)resetSticker { - (void)setBeautyPreset { #if __has_include(FURenderMoudle) - NSBundle *bundle = [BundleUtil bundleWithBundleName:@"FURenderKit" podName:@"fuLib"]; - NSString *faceAIPath = [bundle pathForResource:@"graphics/face_beautification" ofType:@"bundle"]; - FUBeauty *beauty = [[FUBeauty alloc] initWithPath:faceAIPath name:@"FUBeauty"]; - [FURenderKit shareRenderKit].beauty = beauty; + dispatch_queue_t referQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0); + dispatch_async(referQueue, ^{ + NSString *faceAIPath = [[NSBundle mainBundle] pathForResource:@"face_beautification" ofType:@"bundle"]; + FUBeauty *beauty = [[FUBeauty alloc] initWithPath:faceAIPath name:@"FUBeauty"]; + [FURenderKit shareRenderKit].beauty = beauty; + }); +#endif +} + +- (void)setupBeauty { +#if __has_include(FURenderMoudle) + if ([FURenderKit shareRenderKit].beauty == nil) { + NSString *faceAIPath = [[NSBundle mainBundle] pathForResource:@"face_beautification" ofType:@"bundle"]; + FUBeauty *beauty = [[FUBeauty alloc] initWithPath:faceAIPath name:@"FUBeauty"]; + [FURenderKit shareRenderKit].beauty = beauty; + } #endif } - (void)setMakeup:(BOOL)isSelected { #if __has_include(FURenderMoudle) if (isSelected) { - NSBundle *bundle = [BundleUtil bundleWithBundleName:@"FURenderKit" podName:@"fuLib"]; - NSString *makeupPath = [bundle pathForResource:@"graphics/face_makeup" ofType:@"bundle"]; + NSString *makeupPath = [[NSBundle mainBundle] pathForResource:@"face_makeup" ofType:@"bundle"]; FUMakeup *makeup = [[FUMakeup alloc] initWithPath:makeupPath name:@"face_makeup"]; + NSBundle *bundle = [BundleUtil bundleWithBundleName:@"FURenderKit" podName:@"fuLib"]; NSString *path = [bundle pathForResource:@"makeup/ziyun" ofType:@"bundle"]; FUItem *makupItem = [[FUItem alloc] initWithPath:path name:@"ziyun"]; makeup.isMakeupOn = YES; @@ -235,7 +297,6 @@ - (void)setMakeup:(BOOL)isSelected { makeup.intensity = 0.7; } else { [FURenderKit shareRenderKit].makeup.enable = NO; - [FURenderKit shareRenderKit].makeup = nil; } #endif } diff --git a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/SenseRender/SenseBeautyRender.m b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/SenseRender/SenseBeautyRender.m index 323e32f87..52fba49ef 100644 --- a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/SenseRender/SenseBeautyRender.m +++ b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/SenseRender/SenseBeautyRender.m @@ -61,10 +61,11 @@ - (void)checkSensetimeLicense { self.isSuccessLicense = [EffectsProcess authorizeWithLicensePath:licensePath]; __weak SenseBeautyRender *weakSelf = self; self.timer = [NSTimer timerWithTimeInterval:1 repeats:YES block:^(NSTimer * _Nonnull timer) { - weakSelf.isSuccessLicense = weakSelf.videoProcessing.effectsProcess.isAuthrized; if (weakSelf.isSuccessLicense) { [weakSelf.timer invalidate]; weakSelf.timer = nil; + } else { + weakSelf.isSuccessLicense = weakSelf.videoProcessing.effectsProcess.isAuthrized; } if (weakSelf.licenseEventCallback) { weakSelf.licenseEventCallback(weakSelf.isSuccessLicense); @@ -86,7 +87,7 @@ - (nonnull CVPixelBufferRef)onCapture:(nonnull CVPixelBufferRef)pixelBuffer { if (self.isSuccessLicense) { return [self.videoProcessing videoProcessHandler:pixelBuffer]; } - return nil; + return pixelBuffer; #endif return pixelBuffer; } @@ -134,14 +135,12 @@ - (void)setBeautyDefault { - (void)setMakeup:(BOOL)isSelected { #if __has_include(Sensetime) if (isSelected) { - NSString *path = [[NSBundle mainBundle] pathForResource:@"qise.zip" ofType:nil]; __weak SenseBeautyRender *weakself = self; - [self.videoProcessing.effectsProcess addStickerWithPath:path callBack:^(st_result_t state, int sticker, uint64_t action) { - [weakself.videoProcessing.effectsProcess setPackageId:sticker groupType:EFFECT_BEAUTY_GROUP_MAKEUP strength:0.5]; + [self.videoProcessing addStylePath:@"hunxue.zip" groupId:0 strength:0.5 callBack:^(int sticker) { weakself.stickerId = sticker; }]; } else { - [self.videoProcessing.effectsProcess removeSticker:self.stickerId]; + [self.videoProcessing removeStickerId:self.stickerId]; self.stickerId = 0; } #endif @@ -150,7 +149,7 @@ - (void)setMakeup:(BOOL)isSelected { - (void)setSticker:(BOOL)isSelected { #if __has_include(Sensetime) if (isSelected) { - NSString *path = [[NSBundle mainBundle] pathForResource:@"lianxingface.zip" ofType:nil]; + NSString *path = [[NSBundle mainBundle] pathForResource:@"ShangBanLe.zip" ofType:nil]; [self.videoProcessing.effectsProcess setStickerWithPath:path callBack:^(st_result_t state, int stickerId, uint64_t action) { }]; diff --git a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Report/APIReporter.h b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Report/APIReporter.h new file mode 100644 index 000000000..fe85201a1 --- /dev/null +++ b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Report/APIReporter.h @@ -0,0 +1,49 @@ +// +// APIReporter.h +// BeautyAPi +// +// Created by zhaoyongqiang on 2024/4/17. +// + +#import +#import + +typedef NS_ENUM(NSInteger, APIType) { + APITypeKTV = 1, //K歌 + APITypeCall = 2, //呼叫 + APITypeBeauty = 3, //美颜 + APITypeVideoLoader = 4, //秒开/秒切 + APITypePK = 5, //团战 + APITypeVitualSpace = 6, + APITypeScreenSpace = 7, //屏幕共享 + APITypeAudioScenario = 8 //音频scenario +}; + +typedef NS_ENUM(NSInteger, APIEventType) { + APIEventTypeAPI = 0, //api事件 + APIEventTypeCost, //耗时事件 + APIEventTypeCustom //自定义事件 +}; + +typedef NS_ENUM(NSInteger, APICostEvent) { + APICostEventChannelUsage = 0, //频道使用耗时 + APICostEventFirstFrameActual, //首帧实际耗时 + APICostEventFirstFramePerceived //首帧感官耗时 +}; + +NS_ASSUME_NONNULL_BEGIN + +@interface APIReporter : NSObject + +- (instancetype)initWithType:(APIType)type version:(NSString *)version engine:(AgoraRtcEngineKit *)engine; +- (void)reportFuncEventWithName:(NSString *)name value:(NSDictionary *)value ext:(NSDictionary *)ext; +- (void)startDurationEventWithName:(NSString *)name; +- (void)endDurationEventWithName:(NSString *)name ext:(NSDictionary *)ext; +- (void)reportCostEventWithName:(APICostEvent)name cost:(NSInteger)cost ext:(NSDictionary *)ext; +- (void)reportCustomEventWithName:(NSString *)name ext:(NSDictionary *)ext; +- (void)writeLogWithContent:(NSString *)content level:(AgoraLogLevel)level; +- (void)cleanCache; + +@end + +NS_ASSUME_NONNULL_END diff --git a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Report/APIReporter.m b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Report/APIReporter.m new file mode 100644 index 000000000..cb4ca73f1 --- /dev/null +++ b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Report/APIReporter.m @@ -0,0 +1,143 @@ +// +// APIReporter.m +// BeautyAPi +// +// Created by zhaoyongqiang on 2024/4/17. +// + +#import "APIReporter.h" + +@interface APIReporter () + +@property (nonatomic, strong) AgoraRtcEngineKit *engine; +@property (nonatomic, copy) NSString *category; +@property (nonatomic, strong) NSMutableDictionary *durationEventStartMap; +@property (nonatomic, copy) NSString *messsageId; + +@end + +@implementation APIReporter + +- (NSString *)messsageId { + return @"agora:scenarioAPI"; +} + +- (instancetype)initWithType:(APIType)type version:(NSString *)version engine:(AgoraRtcEngineKit *)engine { + self = [super init]; + if (self) { + _category = [NSString stringWithFormat:@"%ld_iOS%@", (long)type, version]; + _engine = engine; + [self configParameters]; + } + return self; +} + +- (void)reportFuncEventWithName:(NSString *)name value:(NSDictionary *)value ext:(NSDictionary *)ext { + NSString *content = [NSString stringWithFormat:@"[APIReporter]reportFuncEvent: %@ value: %@ ext: %@", name, value, ext]; + [self debugApiPrint:content]; + + NSDictionary *eventMap = @{ @"type": @(APIEventTypeAPI), @"desc": name }; + NSDictionary *labelMap = @{ @"apiValue": value, @"ts": @([self getCurrentTs]), @"ext": ext}; + + NSString *event = [self convertToJSONString:eventMap]; + NSString *label = [self convertToJSONString:labelMap]; + + [self.engine sendCustomReportMessage:self.messsageId category:self.category event:event label:label value:0]; +} + +- (void)startDurationEventWithName:(NSString *)name { + self.durationEventStartMap[name] = @([self getCurrentTs]); +} + +- (void)endDurationEventWithName:(NSString *)name ext:(NSDictionary *)ext { + NSNumber *beginTs = self.durationEventStartMap[name]; + if (!beginTs) { + return; + } + [self.durationEventStartMap removeObjectForKey:name]; + + NSInteger ts = [self getCurrentTs]; + NSInteger cost = ts - beginTs.integerValue; + + [self reportCostEventWithTs:ts name:name cost:cost ext:ext]; +} + +- (void)reportCostEventWithName:(APICostEvent)name cost:(NSInteger)cost ext:(NSDictionary *)ext { [self.durationEventStartMap removeObjectForKey: [self getCostEventWithName:name]]; + + [self reportCostEventWithTs:[self getCurrentTs] name:[self getCostEventWithName:name] cost:cost ext:ext]; +} + +- (void)reportCustomEventWithName:(NSString *)name ext:(NSDictionary *)ext { + NSString *content = [NSString stringWithFormat:@"[APIReporter]reportCustomEvent: %@ ext: %@", name, ext]; + [self debugApiPrint:content]; + + NSDictionary *eventMap = @{ @"type": @(APIEventTypeCustom), @"desc": name }; + NSDictionary *labelMap = @{ @"ts": @([self getCurrentTs]), @"ext": ext }; + + NSString *event = [self convertToJSONString:eventMap]; + NSString *label = [self convertToJSONString:labelMap]; + + [self.engine sendCustomReportMessage:self.messsageId category:self.category event:event label:label value:0]; +} + +- (NSString *)getCostEventWithName:(APICostEvent)name { + switch (name) { + case APICostEventChannelUsage: return @"channelUsage"; + case APICostEventFirstFrameActual: return @"firstFrameActual"; + case APICostEventFirstFramePerceived: return @"firstFramePerceived"; + } +} + +- (void)writeLogWithContent:(NSString *)content level:(AgoraLogLevel)level { + [self.engine writeLog:level content:content]; +} + +- (void)cleanCache { + [self.durationEventStartMap removeAllObjects]; +} + +#pragma mark - Private Methods +- (void)reportCostEventWithTs:(NSInteger)ts name:(NSString *)name cost:(NSInteger)cost ext:(NSDictionary *)ext { + NSString *content = [NSString stringWithFormat:@"[APIReporter]reportCostEvent: %@ cost: %ld ms ext: %@", name, (long)cost, ext]; + [self debugApiPrint:content]; + [self writeLogWithContent:content level:AgoraLogLevelInfo]; + + NSDictionary *eventMap = @{ @"type": @(APIEventTypeCost), @"desc": name }; + NSDictionary *labelMap = @{ @"ts": @(ts), @"ext": ext }; + + NSString *event = [self convertToJSONString:eventMap]; + NSString *label = [self convertToJSONString:labelMap]; + + [self.engine sendCustomReportMessage:self.messsageId category:self.category event:event label:label value:cost]; +} + +- (void)configParameters { + [self.engine setParameters:@"{\"rtc.direct_send_custom_event\": true}"]; + [self.engine setParameters:@"{\"rtc.log_external_input\": true}"]; +} + +- (NSInteger)getCurrentTs { + return (NSInteger)([[NSDate date] timeIntervalSince1970] * 1000.0); +} + +- (NSString *)convertToJSONString:(NSDictionary *)dictionary { + NSError *error; + NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:&error]; + if (!jsonData) { + [self writeLogWithContent:[NSString stringWithFormat:@"[APIReporter]convert to json fail: %@ dictionary: %@", error, dictionary] level:AgoraLogLevelWarn]; + return nil; + } + NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + return jsonString; +} + +- (void)debugApiPrint:(NSString *)message { +#if DEBUG + NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; + formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss.SSS"; + NSString *timeString = [formatter stringFromDate:[NSDate date]]; + NSLog(@"%@ %@", timeString, message); +#endif +} + +@end diff --git a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/ByteBeautify/Base.lproj/BytedEffect.storyboard b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/ByteBeautify/Base.lproj/BytedEffect.storyboard index f4fcda5fc..078ebc6c2 100644 --- a/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/ByteBeautify/Base.lproj/BytedEffect.storyboard +++ b/iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/ByteBeautify/Base.lproj/BytedEffect.storyboard @@ -1,9 +1,9 @@ - + - + @@ -105,14 +105,12 @@