Skip to content

Commit 3b57b5a

Browse files
committed
Merge branch 'refs/heads/dev/4.5.0' into dev/4.5.0_android
2 parents 38ceb9e + 0aab9dd commit 3b57b5a

67 files changed

Lines changed: 2324 additions & 2852 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/ci/build/build_ios.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ mkdir ./$unzip_name/samples
7070
cp -rf ./iOS/${ios_direction} ./$unzip_name/samples/API-Example || exit 1
7171
ls -al ./$unzip_name/samples/API-Example/
7272
mv ./$unzip_name/samples/API-Example/sdk.podspec ./$unzip_name/ || exit 1
73+
74+
echo "work space1: $WORKSPACE"
7375
python3 ./.github/ci/build/modify_podfile.py ./$unzip_name/samples/API-Example/Podfile || exit 1
7476

7577

.github/ci/build/modify_podfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ def modfiy(path):
2121

2222
if __name__ == '__main__':
2323
path = sys.argv[1:][0]
24-
modfiy(path.strip())
24+
modfiy(path.strip())

iOS/APIExample/APIExample.xcodeproj/project.pbxproj

Lines changed: 54 additions & 42 deletions
Large diffs are not rendered by default.

iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/BeautyAPI.m

Lines changed: 45 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
//
77

88
#import "BeautyAPI.h"
9+
#import "APIReporter.h"
910

10-
static NSString *const beautyAPIVnersio = @"1.0.3";
11+
static NSString *const beautyAPIVersion = @"1.0.7";
1112

1213
@implementation BeautyStats
1314
@end
@@ -24,6 +25,8 @@ @interface BeautyAPI ()
2425
@property (nonatomic, assign) CFTimeInterval preTime;
2526
@property (nonatomic, strong) NSMutableArray *statsArray;
2627
@property (nonatomic, assign) AgoraVideoRenderMode renderMode;
28+
@property (nonatomic, strong) APIReporter *reporter;
29+
@property (nonatomic, assign) BOOL isFirstFrame;
2730

2831
@end
2932

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

3538
@implementation BeautyAPI
3639

40+
- (instancetype)init {
41+
if (self == [super init]) {
42+
_isFrontCamera = YES;
43+
}
44+
return self;
45+
}
46+
3747
- (NSMutableArray *)statsArray {
3848
if (_statsArray == nil) {
3949
_statsArray = [NSMutableArray new];
4050
}
4151
return _statsArray;
4252
}
4353

54+
- (APIReporter *)reporter {
55+
if (_reporter == nil) {
56+
_reporter = [[APIReporter alloc] initWithType:(APITypeBeauty)
57+
version:beautyAPIVersion
58+
engine:self.config.rtcEngine];
59+
}
60+
return _reporter;
61+
}
62+
4463
- (int)initialize:(BeautyConfig *)config {
4564
if (config.cameraConfig == nil) {
4665
CameraConfig *cameraConfig = [[CameraConfig alloc] init];
@@ -50,7 +69,6 @@ - (int)initialize:(BeautyConfig *)config {
5069
}
5170
[LogUtil log:[NSString stringWithFormat:@"RTC Version == %@", [AgoraRtcEngineKit getSdkVersion]]];
5271
[LogUtil log:[NSString stringWithFormat:@"BeautyAPI Version == %@", [self getVersion]]];
53-
_isFrontCamera = YES;
5472
self.config = config;
5573
if (self.config.statsDuration <= 0) {
5674
self.config.statsDuration = 1;
@@ -64,6 +82,7 @@ - (int)initialize:(BeautyConfig *)config {
6482
return -1;
6583
}
6684
[LogUtil log:[NSString stringWithFormat:@"beautyRender == %@", config.beautyRender.description]];
85+
[self.reporter startDurationEventWithName:@"initialize-release"];
6786
self.beautyRender = config.beautyRender;
6887
if (config.captureMode == CaptureModeAgora) {
6988
#if __has_include(<AgoraRtcKit/AgoraRtcKit.h>)
@@ -79,22 +98,25 @@ - (int)initialize:(BeautyConfig *)config {
7998
}
8099
};
81100
[self rtcReportWithEvent:@"initialize" label:dict];
101+
[self setupMirror];
82102
#else
83103
[LogUtil log:@"rtc 未导入" level:(LogLevelError)];
84104
return -1;
85105
#endif
86106
} else {
87107
[LogUtil log:@"captureMode == Custom"];
88108
}
109+
[self setupMirror];
89110
return 0;
90111
}
91112

92113
- (int)switchCamera {
93114
_isFrontCamera = !_isFrontCamera;
94-
[self setupMirror];
95115
NSDictionary *dict = @{ @"cameraPosition": @(_isFrontCamera) };
96116
[self rtcReportWithEvent:@"cameraPosition" label:dict];
97-
return [self.config.rtcEngine switchCamera];
117+
int res = [self.config.rtcEngine switchCamera];
118+
[self setupMirror];
119+
return res;
98120
}
99121

100122
- (AgoraVideoMirrorMode)setupMirror {
@@ -190,6 +212,7 @@ - (int)destroy {
190212
[self.config.beautyRender destroy];
191213
self.config = nil;
192214
[LogUtil log:@"destroy"];
215+
[self.reporter endDurationEventWithName:@"initialize-release" ext:@{}];
193216
return 0;
194217
}
195218

@@ -198,39 +221,34 @@ - (void)rtcReportWithEvent: (NSString *)event label: (NSDictionary *)label {
198221
[LogUtil log:@"rtc 不能为空" level:(LogLevelError)];
199222
return;
200223
}
201-
NSString *jsonString = [self convertToJson:label];
202-
[self.config.rtcEngine sendCustomReportMessage:@"scenarioAPI"
203-
category:[NSString stringWithFormat:@"beauty_iOS_%@",[self getVersion]]
204-
event:event
205-
label:jsonString
206-
value:0];
207-
}
208-
209-
- (NSString *)convertToJson: (NSDictionary *)object {
210-
NSError *error = nil;
211-
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:object
212-
options:0
213-
error:&error];
214-
if (error) {
215-
// 转换失败
216-
NSLog(@"Error: %@", error.localizedDescription);
217-
return nil;
218-
}
219-
NSString *jsonString = [[NSString alloc] initWithData:jsonData
220-
encoding:NSUTF8StringEncoding];
221-
return jsonString;
224+
[self.reporter reportFuncEventWithName:event value:label ext:@{}];
222225
}
223226

224227
- (NSString *)getVersion {
225-
return beautyAPIVnersio;
228+
return beautyAPIVersion;
226229
}
227230

228231
#pragma mark - VideoFrameDelegate
229232
#if __has_include(<AgoraRtcKit/AgoraRtcKit.h>)
233+
- (BOOL)onCaptureVideoFrame:(AgoraOutputVideoFrame *)videoFrame {
234+
return [self onCaptureVideoFrame:videoFrame sourceType:(AgoraVideoSourceTypeCamera)];
235+
}
230236
- (BOOL)onCaptureVideoFrame:(AgoraOutputVideoFrame *)videoFrame sourceType:(AgoraVideoSourceType)sourceType {
231237
if (!self.isEnable) { return YES; }
232238
CFTimeInterval startTime = CACurrentMediaTime();
239+
if (!self.isFirstFrame) {
240+
[self.reporter startDurationEventWithName:@"first_beauty_frame"];
241+
}
233242
CVPixelBufferRef pixelBuffer = [self.config.beautyRender onCapture:videoFrame.pixelBuffer];
243+
if (!self.isFirstFrame) {
244+
[self.reporter endDurationEventWithName:@"first_beauty_frame" ext:@{
245+
@"width": @(CVPixelBufferGetWidth(pixelBuffer)),
246+
@"height": @(CVPixelBufferGetHeight(pixelBuffer)),
247+
@"camera_facing": _isFrontCamera ? @"front" : @"back",
248+
@"buffer_type": @"pixelbuffer"
249+
}];
250+
self.isFirstFrame = YES;
251+
}
234252
CFTimeInterval endTime = CACurrentMediaTime();
235253
if (self.config.statsEnable) {
236254
[self.statsArray addObject:@(endTime - startTime)];
@@ -239,7 +257,7 @@ - (BOOL)onCaptureVideoFrame:(AgoraOutputVideoFrame *)videoFrame sourceType:(Agor
239257
if (self.config.eventCallback && self.preTime > 0 && self.config.statsEnable) {
240258
CFTimeInterval time = startTime - self.preTime;
241259
if (time > self.config.statsDuration && self.statsArray.count > 0) {
242-
NSArray *sortArray = [self.statsArray sortedArrayUsingComparator:^NSComparisonResult(NSNumber * _Nonnull obj1, NSNumber * _Nonnull obj2) {
260+
NSArray *sortArray = [self.statsArray sortedArrayUsingComparator:^NSComparisonResult(NSNumber * _Nonnull obj1, NSNumber * _Nonnull obj2) {
243261
return obj1.doubleValue > obj2.doubleValue;
244262
}];
245263
double totalValue = 0;

iOS/APIExample/APIExample/Examples/Advanced/ThirdBeautify/BeautyAPI/Render/BytesRender/BytesBeautyRender.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,26 @@
55
// Created by zhaoyongqiang on 2023/6/30.
66
//
77

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

1010
#import <Foundation/Foundation.h>
1111

12-
#if __has_include("BEImageUtils.h") && __has_include("BEFrameProcessor.h")
12+
#if __has_include("BEImageUtils.h") && __has_include("BEEffectManager.h")
1313
#import "BEImageUtils.h"
14-
#import "BEFrameProcessor.h"
14+
#import "BEEffectManager.h"
15+
#import "BEEffectResourceHelper.h"
1516
#endif
1617
#import "BeautyAPI.h"
1718

1819
NS_ASSUME_NONNULL_BEGIN
1920

2021
@interface BytesBeautyRender : NSObject<BeautyRenderDelegate>
2122

22-
#if __has_include("BEImageUtils.h") && __has_include("BEFrameProcessor.h")
23-
@property (nonatomic, strong) BEFrameProcessor *frameProcessor;
23+
#if __has_include("BEImageUtils.h") && __has_include("BEEffectManager.h")
24+
@property (nonatomic, strong) BEEffectManager *effectManager;
2425
@property (nonatomic, strong) BEImageUtils *imageUtils;
2526
#endif
26-
27+
- (BOOL)checkLicense;
2728
@end
2829

2930
NS_ASSUME_NONNULL_END

0 commit comments

Comments
 (0)