Kandy-IO / kandy-link-ios-sdk

Kandy Link iOS SDK release repository
Other
7 stars 1 forks source link

Problem with switching camera #1

Closed evermeer closed 4 years ago

evermeer commented 4 years ago

Hi,

In our iOS application there is a bug with switching the camera from front to back (and the other way around). What happens is that when we execute the setCaptureDevice code, the local view mirrors the users video (so it does not go to the back camera) and then freezes the video. As we haven’t updated the switching code, it might be a problem in the Kandy library. We use the KandyLinkMobileSDK v 5.6.0 in the production application. Below is the code we use to switch the camera. We can confirm that activeCamera and the self (SMIncomingCallDelegate) are not nil. We also tried running the code on the main thread but without any luck. Using the default resolution (empty string) also did not resolve the issue.

We successfully replicated the bug using the KandyLinkMobileSDK 5.7.0 on an iPhone 8 with iOS 13.5.1.

extension SMIncomingCallDelegate {
    func switchCamera() {
        let activeCamera = self.getActiveCamera()

        let hd = AVCaptureSession.Preset.hd1920x1080.rawValue
        if activeCamera == .front {
            self.setCaptureDevice(.back, withVideoResolution: hd, completionHandler: { (error) in
                print(error as Any)
            })
        } else if activeCamera == .back {
            self.setCaptureDevice(.front, withVideoResolution: hd, completionHandler: { (error) in
                print(error as Any)
            })
        } else {
            self.setCaptureDevice(.front, withVideoResolution: hd, completionHandler: { (error) in
                print(error as Any)
            })
        }
    }
}

Log:

✳️ .debug ⏱ 06/23/2020 14:03:02:102 📱 MyApp [14326:] 📂 VideoChatViewController.swift(148) ⚙️ switchCamera() ➡️
    Switch camera

✳️ .debug ⏱ 06/23/2020 14:03:02:105 📱 MyApp [14326:] 📂 KandyManager.swift(22) ⚙️ switchCamera() ➡️
    HD: AVCaptureSessionPreset1920x1080
4 CallService.Call setCaptureDevice:withVideoResolution:completionHandler: started
3 CallService.Call setCaptureDevice:withVideoResolution:completionHandler: setCaptureDevice is triggered from call (58522152_0efbfc5e_464ec74e-89e2-4e77-b8e7-bc016b5ebf82:18d3f01e27fce7d51747da9684a9db90c148efddf@185.70.193.26:73d4c9a0-920b-4fac-8d77-1a3afd8dad71:wae-base-sipt)$(73d4c9a0-920b-4fac-8d77-1a3afd8dad71:wae-base-sipt)$ZW1lYXNwZHIxLWFzaXBjLTM%3D%0A
4 CallService.Call setCaptureDevice:withVideoResolution:completionHandler: finished
4 WebRTC.WebRTCCall setCaptureDevice:withVideoResolution:withVideoState:completionHandler: started
3 WebRTC.WebRTCCall setCaptureDevice:withVideoResolution:withVideoState:completionHandler: Camera position is changed - Capturer will be restarted in new position 1
4 WebRTC.WebRTCCallManager startCapturerWithCameraPosition:preset: started
2 WebRTC.WebRTCCallManager stopVideoSources videoCapturer and videoSource disposed
4 WebRTC.WebRTCCallManager getCapturer started
5 WEBRTC startLogger (RTCLogging.mm:33): (RTCCameraVideoCapturer.m:196 -[RTCCameraVideoCapturer stopCaptureWithCompletionHandler:]_block_invoke): Stop

4 WebRTC.WebRTCCallManager getCapturer finished
nil
3 WebRTC.WebRTCCallManager selectFpsForFormat: Max supported frame rate: 60.000000 - FPS in the configuration: 0
4 WebRTC.WebRTCCallManager startCapturerWithCameraPosition:preset: finished
5 WEBRTC startLogger (stream_synchronization.cc:72): Audio delay: 143 current diff: 19 for stream 72936480

5 WEBRTC startLogger (connection.cc:627): Conn[160b5e00:audio:Net[en0:192.168.178.x/24:Wifi:id=1]:OC/WO8zx:1:0:local:udp:192.168.178.x:58723->bxWMrnA0:1:2122260223:local:udp:192.168.178.x:40979|CRWS|S|1|0|9115038255631187454|59]: UpdateState(), ms since last received response=1681, ms since last received data=1, rtt=118, pings_since_last_response=

5 WEBRTC startLogger (connection.cc:627): Conn[1609d400:audio:Net[pdp_ip0:100.82.213.x/32:Cellular:id=7]:RmdcyrFA:1:0:stun:udp:188.206.70.x:64555->eYowdZvY:1:8331263:relay:udp:185.70.192.x:34603|CRWS|-|0|0|35782505491086846|69]: UpdateState(), ms since last received response=1601, ms since last received data=54832503, rtt=138, pings_since_last_response=

5 WEBRTC startLogger (connection.cc:627): Conn[16858000:audio:Net[en0:192.168.178.x/24:Wifi:id=1]:OC/WO8zx:1:0:local:udp:192.168.178.x:58723->rC+PTaV3:1:2122129151:local:udp:127.0.0.x:42223|C--I|-|0|0|9114475305677766142|-]: UpdateState(), ms since last received response=54832503, ms since last received data=54832503, rtt=6000, pings_since_last_response=4b666951514b2f6d41564854 545531515974566746442f59 78476d462b43523734383466 466c4f6e504b6b662b785141 6c454f4162394d5857416442 ... 8 more
mobilesdk35 commented 4 years ago

Thanks for reporting, We will investigate issue.

mobilesdk35 commented 4 years ago

Please check version 5.8.0.