Twillio视频通话中没有声音

时间:2020-05-16 18:38:20

标签: ios swift

我正在Twillio Video SDK的帮助下创建一个有两个参与者的房间。要使用音频和视频连接到房间,我正在使用此功能:

func performRoomConnect(uuid: UUID, roomName: String?, completionHandler: @escaping (Bool) -> Swift.Void) {
    logMessage(messageText: "Attempting to connect to room with token and name \(String(describing: accessToken)), \(String(describing: self.roomName))")

    // Prepare local media which we will share with Room Participants.

    if (localAudioTrack == nil) {
        // Here i am assigning AudioTrack to Twillio Audio Track 
        localAudioTrack = LocalAudioTrack()
        if (localAudioTrack == nil) {
            logMessage(messageText: "Failed to create audio track")
        }
    }

    // Create a video track which captures from the camera.
    if (localVideoTrack == nil) {
        self.startPreview()  
    }

    // Preparing the connect options with the access token that we fetched (or hardcoded).
    let connectOptions = ConnectOptions(token: accessToken) { (builder) in

        // Use the local media that we prepared earlier.
        builder.audioTracks = self.localAudioTrack != nil ? [self.localAudioTrack!] : [LocalAudioTrack]()
        builder.videoTracks = self.localVideoTrack != nil ? [self.localVideoTrack!] : [LocalVideoTrack]()

        // Use the preferred audio codec
        if let preferredAudioCodec = Settings.shared.audioCodec {
            builder.preferredAudioCodecs = [preferredAudioCodec]
        }

        // Use the preferred video codec
        if let preferredVideoCodec = Settings.shared.videoCodec {
            builder.preferredVideoCodecs = [preferredVideoCodec]
        }

        // Use the preferred encoding parameters
        if let encodingParameters = Settings.shared.getEncodingParameters() {
            builder.encodingParameters = encodingParameters
        }

        // Use the preferred signaling region
        if let signalingRegion = Settings.shared.signalingRegion {
            builder.region = signalingRegion
        }

        // The name of the Room where the Client will attempt to connect to. Please note that if you pass an empty
        // Room `name`, the Client will create one for you. You can get the name or sid from any connected Room.
        builder.roomName = roomName

        // The CallKit UUID to assoicate with this Room.
        builder.uuid = uuid
    }

    // Connect to the Room using the options we provided.
    room = TwilioVideoSDK.connect(options: connectOptions, delegate: self)

    logMessage(messageText: "Attempting to connect to room \(String(describing: roomName))")

    self.showRoomUI(inRoom: true)
}

0 个答案:

没有答案