AgoraIO / API-Examples

Play with AgoraSDK and have fun! Everything you need to start learning Agora.
292 stars 217 forks source link

In Swift, it's unable to set the local video. #395

Open chsunwoo1002 opened 1 month ago

chsunwoo1002 commented 1 month ago

Hi,

We are currently developing a video call feature using Agora on our React Native app. We chose Agora's Swift SDK because it supports pushing a custom video source. Although I managed to run the custom and camera sources successfully on the example app, I'm encountering an issue where the self.agoraKit!.enableVideo() or self.agoraKit!.enableLocalVideo(true) functions return 7, despite the audio working correctly.

I have ensured the engine initialization and video setup are executed on the main thread, and I have obtained the necessary camera permissions on iOS. Below is the relevant code snippet:

Podfile

  pod 'AgoraAudio_iOS', '4.3.2'
@objc func startCall(_ resolve: @escaping RCTPromiseResolveBlock,
                     reject reject: @escaping RCTPromiseRejectBlock) {
    AVCaptureDevice.requestAccess(for: .video) { granted in
        if granted {
            DispatchQueue.main.async {
                self.setupEngine()
                self.setupVideo()
                self.setupAudio()
                self.joinChannel()
                resolve(nil)
            }
        } else {
            let error = NSError(domain: "VideoCall", code: 1, userInfo: [NSLocalizedDescriptionKey: "Camera access denied"])
            reject("CAMERA_ACCESS_DENIED", "Camera access denied", error)
        }
    }
}

private func setupVideo() {
    let success = self.agoraKit!.enableVideo()
    print("<Video-Call> is success to enable video: \(success)") // this return -7
}

Is there anything I might be missing during the initialization stage that could be causing this issue?

Thank you for your assistance.

Here are some api log from agora agoraapi.log

plutoless commented 1 month ago

api returns 7 means the engine is not properly initialized. please kindly check all these.

plutoless commented 1 month ago

if you want to learn how custom video source works on native iOS, you may also refer to the examples here