Skip to content

Commit

Permalink
Merge branch 'refs/heads/dev/4.5.0' into dev/4.5.0_android
Browse files Browse the repository at this point in the history
  • Loading branch information
weileifrank committed Oct 30, 2024
2 parents 7c987bb + 0fdc5f6 commit 04ae8a7
Show file tree
Hide file tree
Showing 67 changed files with 2,324 additions and 2,852 deletions.
2 changes: 2 additions & 0 deletions .github/ci/build/build_ios.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion .github/ci/build/modify_podfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ def modfiy(path):

if __name__ == '__main__':
path = sys.argv[1:][0]
modfiy(path.strip())
modfiy(path.strip())
96 changes: 54 additions & 42 deletions iOS/APIExample/APIExample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -34,13 +37,29 @@ @interface BeautyAPI ()<AgoraVideoFrameDelegate>

@implementation BeautyAPI

- (instancetype)init {
if (self == [super init]) {
_isFrontCamera = YES;
}
return self;
}

- (NSMutableArray *)statsArray {
if (_statsArray == nil) {
_statsArray = [NSMutableArray new];
}
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];
Expand All @@ -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;
Expand All @@ -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(<AgoraRtcKit/AgoraRtcKit.h>)
Expand All @@ -79,22 +98,25 @@ - (int)initialize:(BeautyConfig *)config {
}
};
[self rtcReportWithEvent:@"initialize" label:dict];
[self setupMirror];
#else
[LogUtil log:@"rtc 未导入" level:(LogLevelError)];
return -1;
#endif
} 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 {
Expand Down Expand Up @@ -190,6 +212,7 @@ - (int)destroy {
[self.config.beautyRender destroy];
self.config = nil;
[LogUtil log:@"destroy"];
[self.reporter endDurationEventWithName:@"initialize-release" ext:@{}];
return 0;
}

Expand All @@ -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(<AgoraRtcKit/AgoraRtcKit.h>)
- (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)];
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@
// Created by zhaoyongqiang on 2023/6/30.
//

#define BytesMoudle "bef_effect_ai_api.h"
#define BytesMoudle <effect-sdk/bef_effect_ai_api.h>

#import <Foundation/Foundation.h>

#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"

NS_ASSUME_NONNULL_BEGIN

@interface BytesBeautyRender : NSObject<BeautyRenderDelegate>

#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
Loading

0 comments on commit 04ae8a7

Please sign in to comment.