Skip to content

Commit 28aded3

Browse files
committed
2 parents 5c2c59b + deecea4 commit 28aded3

File tree

7 files changed

+42
-18
lines changed

7 files changed

+42
-18
lines changed

Prj-iOS/ARLiveKit/ARLiveEngineKit.mm

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ - (instancetype)initWithDelegate:(id<ARLiveEngineDelegate>)delegate {
5555
if (liveEngine == NULL) {
5656
liveEngine = anyrtc::createArLive2Engine();
5757
liveEngine->initialize(nil);
58+
59+
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(enterBackground:) name:UIApplicationDidEnterBackgroundNotification object:nil];
60+
[NSNotificationCenter.defaultCenter addObserver:self selector:@selector(becomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
5861
} else {
5962
return nil;
6063
}
@@ -100,4 +103,18 @@ - (void)releaseArLivePlayer: (ARLivePlayer *)player {
100103
}
101104
}
102105

106+
// MARK: - private
107+
108+
- (void)enterBackground:(NSNotification *)notification {
109+
if (liveEngine) {
110+
liveEngine->setAppInBackground(true);
111+
}
112+
}
113+
114+
- (void)becomeActive:(NSNotification *)notification {
115+
if (liveEngine) {
116+
liveEngine->setAppInBackground(false);
117+
}
118+
}
119+
103120
@end

Prj-iOS/ARLiveKit/ARLivePlayer.mm

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,17 +122,16 @@ void onVodPlaybackProcess(anyrtc::IArLivePlayer *player, int allDuration, int cu
122122

123123
void onStatisticsUpdate(anyrtc::IArLivePlayer *player, anyrtc::ArLivePlayerStatistics statistics) override {
124124
/// 直播播放器统计数据回调
125+
ARLivePlayerStatistics *playerStatistics = [[ARLivePlayerStatistics alloc] init];
126+
playerStatistics.width = statistics.width;
127+
playerStatistics.height = statistics.height;
128+
playerStatistics.fps = statistics.fps;
129+
playerStatistics.videoBitrate = statistics.videoBitrate;
130+
playerStatistics.audioBitrate = statistics.audioBitrate;
131+
125132
void(^functionBlock)() = ^(){
126133
if (!isDestroy()) {
127134
if ([play_delegate_ respondsToSelector:@selector(onStatisticsUpdate:statistics:)]) {
128-
ARLivePlayerStatistics *playerStatistics = [[ARLivePlayerStatistics alloc] init];
129-
playerStatistics.appCpu = statistics.appCpu;
130-
playerStatistics.systemCpu = statistics.systemCpu;
131-
playerStatistics.width = statistics.width;
132-
playerStatistics.height = statistics.height;
133-
playerStatistics.fps = statistics.fps;
134-
playerStatistics.videoBitrate = statistics.videoBitrate;
135-
playerStatistics.audioBitrate = statistics.audioBitrate;
136135
[play_delegate_ onStatisticsUpdate:playerKit_ statistics:playerStatistics];
137136
}
138137
}
@@ -161,10 +160,10 @@ void onRenderVideoFrame(anyrtc::IArLivePlayer *player, const anyrtc::ArLiveVideo
161160

162161
void onReceiveSeiMessage(anyrtc::IArLivePlayer *player, int payloadType, const uint8_t *data, uint32_t dataSize) override {
163162
/// 收到 SEI 消息的回调,发送端通过 {@link ArLivePusher} 中的 `sendSeiMessage` 来发送 SEI 消息
163+
NSData *seiData = [NSData dataWithBytes:data length:dataSize];
164164
void(^functionBlock)() = ^(){
165165
if (!isDestroy()) {
166166
if ([play_delegate_ respondsToSelector:@selector(onReceiveSeiMessage:payloadType:data:)]) {
167-
NSData *seiData = [NSData dataWithBytes:data length:dataSize];
168167
[play_delegate_ onReceiveSeiMessage:playerKit_ payloadType:payloadType data:seiData];
169168
}
170169
}
@@ -303,16 +302,25 @@ - (int)isPlaying {
303302

304303
- (int)seekTo:(int)seekTimeS {
305304
/// 跳转进度
305+
if (_livePlayer) {
306+
return _livePlayer->seekTo(seekTimeS);
307+
}
306308
return -1;
307309
}
308310

309311
- (int)setSpeed:(CGFloat)speed {
310312
/// 倍速播放
313+
if (_livePlayer) {
314+
return _livePlayer->setSpeed(speed);
315+
}
311316
return -1;
312317
}
313318

314319
- (int)replay {
315320
/// 重新开始播放。一般用于点播场景
321+
if (_livePlayer) {
322+
_livePlayer->rePlay();
323+
}
316324
return -1;
317325
}
318326

Prj-iOS/ARLiveKit/ARLivePusher.mm

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,16 +94,15 @@ virtual void onPushStatusUpdate(anyrtc::ArLivePushStatus state, const char* msg,
9494

9595
virtual void onStatisticsUpdate(anyrtc::ArLivePusherStatistics statistics) {
9696
/// 直播推流器统计数据回调
97+
ARLivePusherStatistics *playerStatistics = [[ARLivePusherStatistics alloc] init];
98+
playerStatistics.width = statistics.width;
99+
playerStatistics.height = statistics.height;
100+
playerStatistics.fps = statistics.fps;
101+
playerStatistics.videoBitrate = statistics.videoBitrate;
102+
playerStatistics.audioBitrate = statistics.audioBitrate;
103+
97104
void(^functionBlock)() = ^(){
98105
if ([push_delegate_ respondsToSelector:@selector(onStatisticsUpdate:)]) {
99-
ARLivePusherStatistics *playerStatistics = [[ARLivePusherStatistics alloc] init];
100-
playerStatistics.appCpu = statistics.appCpu;
101-
playerStatistics.systemCpu = statistics.systemCpu;
102-
playerStatistics.width = statistics.width;
103-
playerStatistics.height = statistics.height;
104-
playerStatistics.fps = statistics.fps;
105-
playerStatistics.videoBitrate = statistics.videoBitrate;
106-
playerStatistics.audioBitrate = statistics.audioBitrate;
107106
[push_delegate_ onStatisticsUpdate:playerStatistics];
108107
}
109108
};
Binary file not shown.

Prj-iOS/WebRTC.framework/Headers/WebRTC.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2022 The WebRTC project authors. All Rights Reserved.
2+
* Copyright 2023 The WebRTC project authors. All Rights Reserved.
33
*
44
* Use of this source code is governed by a BSD-style license
55
* that can be found in the LICENSE file in the root of the source
-2 Bytes
Binary file not shown.

Prj-iOS/WebRTC.framework/WebRTC

-33.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)