Skip to content

Commit 5b49ec4

Browse files
committed
fix: canvas minor change
1 parent a2c717e commit 5b49ec4

2 files changed

Lines changed: 7 additions & 10 deletions

File tree

iOS/APIExample/APIExample/Examples/Advanced/CustomVideoSourcePush/CustomVideoSourcePush.swift

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ class CustomVideoSourcePushMain: BaseViewController {
7373
// layout render view
7474
remoteVideo.setPlaceholder(text: "Remote Host".localized)
7575
container.layoutStream(views: [localVideo, remoteVideo])
76+
localVideo.backgroundColor = .black
7677

7778
// set up agora instance when view loaded
7879
let config = AgoraRtcEngineConfig()
@@ -113,7 +114,8 @@ class CustomVideoSourcePushMain: BaseViewController {
113114
// setup my own camera as custom video source
114115
// note setupLocalVideo is not working when using pushExternalVideoFrame
115116
// so you will have to prepare the preview yourself
116-
customCamera = AgoraYUVImageSourcePush(size: isHDR ? CGSize(width: 1280, height: 720) : CGSize(width: 320, height: 180),
117+
let size = isHDR ? CGSize(width: 1280, height: 720) : CGSize(width: 320, height: 180)
118+
customCamera = AgoraYUVImageSourcePush(size: size,
117119
fileName: isHDR ? "hlg-hdr" : "sample",
118120
frameRate: 15,
119121
isHDR: isHDR)
@@ -122,7 +124,7 @@ class CustomVideoSourcePushMain: BaseViewController {
122124
customCamera?.trackId = 0
123125
agoraKit.setExternalVideoSource(true, useTexture: true, sourceType: .videoFrame)
124126

125-
let resolution = (GlobalSettings.shared.getSetting(key: "resolution")?.selectedOption().value as? CGSize) ?? .zero
127+
let resolution = size //(GlobalSettings.shared.getSetting(key: "resolution")?.selectedOption().value as? CGSize) ?? .zero
126128
let fps = (GlobalSettings.shared.getSetting(key: "fps")?.selectedOption().value as? AgoraVideoFrameRate) ?? .fps15
127129
let orientation = (GlobalSettings.shared.getSetting(key: "orientation")?
128130
.selectedOption().value as? AgoraVideoOutputOrientationMode) ?? .fixedPortrait
@@ -221,7 +223,7 @@ extension CustomVideoSourcePushMain: AgoraRtcEngineDelegate {
221223
videoCanvas.uid = uid
222224
// the view to be binded
223225
videoCanvas.view = remoteVideo.videoView
224-
videoCanvas.renderMode = .hidden
226+
videoCanvas.renderMode = .fit
225227
agoraKit?.setupRemoteVideo(videoCanvas)
226228
}
227229

@@ -237,9 +239,6 @@ extension CustomVideoSourcePushMain: AgoraRtcEngineDelegate {
237239
// you will need to remove the EAGL sublayer from your binded view
238240
let videoCanvas = AgoraRtcVideoCanvas()
239241
videoCanvas.uid = uid
240-
// the view to be binded
241-
videoCanvas.view = nil
242-
videoCanvas.renderMode = .hidden
243242
agoraKit?.setupRemoteVideo(videoCanvas)
244243
}
245244
}

macOS/APIExample/Examples/Advanced/CustomVideoSourcePush/CustomVideoSourcePush.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ extension CustomVideoSourcePush: AgoraRtcEngineDelegate {
363363
videoCanvas.uid = uid
364364
// the view to be binded
365365
videoCanvas.view = remoteVideo.videocanvas
366-
videoCanvas.renderMode = .hidden
366+
videoCanvas.renderMode = .fit
367367
agoraKit?.setupRemoteVideo(videoCanvas)
368368
remoteVideo.uid = uid
369369
} else {
@@ -382,11 +382,9 @@ extension CustomVideoSourcePush: AgoraRtcEngineDelegate {
382382
// note the video will stay at its last frame, to completely remove it
383383
// you will need to remove the EAGL sublayer from your binded view
384384
if let remoteVideo = remoteVideos.first(where: { $0.uid == uid }) {
385+
// the view to be binded
385386
let videoCanvas = AgoraRtcVideoCanvas()
386387
videoCanvas.uid = uid
387-
// the view to be binded
388-
videoCanvas.view = nil
389-
videoCanvas.renderMode = .hidden
390388
agoraKit?.setupRemoteVideo(videoCanvas)
391389
remoteVideo.uid = nil
392390
} else {

0 commit comments

Comments
 (0)