44using LiveKit . Rooms . Participants ;
55using LiveKit . Rooms . TrackPublications ;
66using Newtonsoft . Json ;
7+ using Newtonsoft . Json . Linq ;
78using System ;
89
910namespace SceneRuntime . Apis . Modules . CommsApi
@@ -21,6 +22,26 @@ private static VideoTrackSourceType From(TrackSource trackSource) =>
2122 _ => throw new ArgumentOutOfRangeException ( )
2223 } ;
2324
25+ private static string ResolveDisplayName ( Participant participant )
26+ {
27+ string metadata = participant . Metadata ;
28+
29+ if ( ! string . IsNullOrEmpty ( metadata ) )
30+ {
31+ try
32+ {
33+ var json = JObject . Parse ( metadata ) ;
34+ string displayName = json . Value < string > ( "displayName" ) ;
35+
36+ if ( ! string . IsNullOrEmpty ( displayName ) )
37+ return displayName ;
38+ }
39+ catch ( JsonException ) { }
40+ }
41+
42+ return ! string . IsNullOrEmpty ( participant . Name ) ? participant . Name : participant . Identity ;
43+ }
44+
2445 private static void WriteTo ( JsonWriter writer , string identity , string trackSid , Participant participant , TrackPublication publication )
2546 {
2647 var sourceType = From ( publication . Source ) ;
@@ -33,7 +54,7 @@ private static void WriteTo(JsonWriter writer, string identity, string trackSid,
3354 writer . WritePropertyName ( "sourceType" ) ;
3455 writer . WriteValue ( sourceType ) ;
3556 writer . WritePropertyName ( "name" ) ;
36- writer . WriteValue ( participant . Name ) ;
57+ writer . WriteValue ( ResolveDisplayName ( participant ) ) ;
3758 writer . WritePropertyName ( "speaking" ) ;
3859 writer . WriteValue ( participant . Speaking ) ;
3960 writer . WritePropertyName ( "trackName" ) ;
0 commit comments