twilio / video-quickstart-ios

Twilio Video Quickstart for iOS
https://www.twilio.com/docs/api/video
MIT License
460 stars 178 forks source link

dominantspeakerdidchange is not getting called in swift #509

Closed gurupatel closed 4 years ago

gurupatel commented 4 years ago

I want to detect who is speaking in a room, according to that I want to change remote participant video in my front screen. I am using following code : - Enabling DominantSpeaker by doing // 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.preferredAudioCodecs = [ IsacCodec() ]
            builder.preferredVideoCodecs = [ H264Codec() ]
            builder.isDominantSpeakerEnabled = true

            builder.audioTracks = self.localAudioTrack != nil ? [self.localAudioTrack!] : [LocalAudioTrack]()

            builder.videoTracks = self.localVideoTrack != nil ? [self.localVideoTrack!] : [LocalVideoTrack]()
        }

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

Also implemented delegate method func dominantSpeakerDidChange(room: Room, participant: RemoteParticipant?)

but still delegate is not getting called, when dominant speaker get changed. I have tested this with a group of 3 to 4 members.

Please suggest.

paynerc commented 4 years ago

@gurupatel,

My first thought is that you are using a P2P room and not a Group Room. Would you be able to provide a Room SID where you were experiencing this behavior and we can easily rule that out. If you are using group rooms and still not receiving the callback looking at debug logs would definitely be useful.

Per the new issue template, can you also provide the following?

Versions

All relevant version information for the issue.

Video iOS SDK

[e.g. 1.3.12 via CocoaPods]

Xcode

[e.g. 9.2]

iOS Version

[e.g. 11.2.6]

iOS Device

[e.g. iPhone 8 Plus]

gurupatel commented 4 years ago

@paynerc Hi, I have checked with my backend guy, we are using P2P room, because we need EndToEndEncryption in our app. Is any way to use EndToEndEncryption feature in (Regular)GroupRoom for 50 participant?

Also DominantSpeaker is for detecting who is speaking in a room, so that we can change UI in front end correct? But it is not showing identity of activated speaker, this method is only showing host name not participant name? Why?

Please suggest.

paynerc commented 4 years ago

@gurupatel,

As I mentioned above, the Dominant Speaker functionality required Group Rooms, as it is the media server in the middle that is able to detect the dominant speaker and broadcasts that information to the other participants in the room.

At the present time Group rooms requires that the media is decrypted at the media server and then is re-encrypted before being transmitted to the other participants.

The dominant speaker delegate method, func dominantSpeakerDidChange(room: Room, participant: RemoteParticipant?) passes in the RemoteParticipant object of the current dominant speaker, or nil if nobody is speaking. When the method is invoked the RemoteParticipant object corresponding to the current dominant speaker is passed in. It all depends on how your UI is configured to map UI elements to your RemoteParticipant objects.

Take a look the Twilio Video App reference application to see how the dominantSpeakerDidChange method is being used to trigger UI updates when the dominant speaker changes.

I hope this helps answer your question.

Ryan

paynerc commented 4 years ago

@gurupatel,

It's been a bit since I have heard back from you on this. I am going to assume the information above was helpful and will close this issue. Feel free to reopen if you have further questions.

Ryan