@@ -189,12 +189,12 @@ class ChatRoomMemberImpl(
189189
190190 var newRole: MemberRole = MemberRole .VISITOR
191191 chatRoom.getOccupant(this )?.let { newRole = fromSmack(it.role, it.affiliation) }
192- if (! firstPresence && presence.type != Presence .Type .unavailable &&
193- (role == MemberRole .VISITOR ) != (newRole == MemberRole .VISITOR )
194- ) {
195- // This will mess up various member counts
192+ if (! firstPresence && (role == MemberRole .VISITOR ) != (newRole == MemberRole .VISITOR )) {
193+ // Allowing this to change would mess up various member counts, ignore the change
196194 // TODO: Should we try to update them, instead?
197- logger.warn(" Member role changed from $role to $newRole - not supported!" )
195+ if (presence.type != Presence .Type .unavailable) {
196+ logger.warn(" Member role changed from $role to $newRole - not supported!" )
197+ }
198198 } else {
199199 role = newRole
200200 }
@@ -214,35 +214,37 @@ class ChatRoomMemberImpl(
214214 statsId = it.statsId
215215 }
216216
217- presence.getExtension(JitsiParticipantCodecList ::class .java)?.let {
218- if (! firstPresence && it.codecs != videoCodecs) {
219- logger.warn(" Video codec list changed from $videoCodecs to ${it.codecs} - not supported!" )
220- } else {
217+ val newVideoCodecs =
218+ presence.getExtension(JitsiParticipantCodecList ::class .java)?.let {
221219 if (! it.codecs.contains(" vp8" )) {
222220 if (firstPresence) {
223221 logger.warn(" Video codec list {${it.codecs} } does not contain vp8! Adding manually." )
224222 }
225- videoCodecs = it.codecs + " vp8"
223+ it.codecs + " vp8"
226224 } else {
227- videoCodecs = it.codecs
225+ it.codecs
228226 }
229- }
230- } ? : // Older clients sent a single codec in codecType rather than all supported ones in codecList
231- presence.getExtensionElement(" jitsi_participant_codecType" , " jabber:client" )?.let {
232- if (it is StandardExtensionElement ) {
233- val codec = it.text.lowercase()
234- val codecList = if (codec == " vp8" ) {
235- listOf (codec)
236- } else {
237- listOf (codec, " vp8" )
238- }
239- if (! firstPresence && codecList != videoCodecs) {
240- logger.warn(" Video codec list changed from $videoCodecs to $codecList - not supported!" )
227+ } ? : // Older clients sent a single codec in codecType rather than all supported ones in codecList
228+ presence.getExtensionElement(" jitsi_participant_codecType" , " jabber:client" )?.let {
229+ if (it is StandardExtensionElement ) {
230+ val codec = it.text.lowercase()
231+ if (codec == " vp8" ) {
232+ listOf (codec)
233+ } else {
234+ listOf (codec, " vp8" )
235+ }
241236 } else {
242- videoCodecs = codecList
237+ null
243238 }
244239 }
240+ if (! firstPresence && newVideoCodecs != videoCodecs) {
241+ // Allowing this to change would mess up visitor codec preference counts, ignore the change
242+ if (role == MemberRole .VISITOR && presence.type != Presence .Type .unavailable && newVideoCodecs != null ) {
243+ logger.warn(" Visitor video codec list changed from $videoCodecs to $newVideoCodecs - not supported!" )
245244 }
245+ } else {
246+ videoCodecs = newVideoCodecs
247+ }
246248 }
247249
248250 override fun toString () = " ChatMember[id=$name role=$role ]"
0 commit comments