Committed by
GitHub
expose mime type and participant name (#36)
* expose track mimeType and participant name * update test for name
正在显示
4 个修改的文件
包含
19 行增加
和
2 行删除
| @@ -51,6 +51,7 @@ open class Participant( | @@ -51,6 +51,7 @@ open class Participant( | ||
| 51 | @get:FlowObservable | 51 | @get:FlowObservable |
| 52 | var audioLevel: Float by flowDelegate(0f) | 52 | var audioLevel: Float by flowDelegate(0f) |
| 53 | internal set | 53 | internal set |
| 54 | + | ||
| 54 | /** | 55 | /** |
| 55 | * Changes can be observed by using [io.livekit.android.util.flow] | 56 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 56 | */ | 57 | */ |
| @@ -63,6 +64,10 @@ open class Participant( | @@ -63,6 +64,10 @@ open class Participant( | ||
| 63 | } | 64 | } |
| 64 | } | 65 | } |
| 65 | internal set | 66 | internal set |
| 67 | + | ||
| 68 | + @get:FlowObservable | ||
| 69 | + var name by flowDelegate<String?>(null) | ||
| 70 | + | ||
| 66 | /** | 71 | /** |
| 67 | * Changes can be observed by using [io.livekit.android.util.flow] | 72 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 68 | */ | 73 | */ |
| @@ -104,6 +109,7 @@ open class Participant( | @@ -104,6 +109,7 @@ open class Participant( | ||
| 104 | @get:FlowObservable | 109 | @get:FlowObservable |
| 105 | var tracks by flowDelegate(emptyMap<String, TrackPublication>()) | 110 | var tracks by flowDelegate(emptyMap<String, TrackPublication>()) |
| 106 | protected set | 111 | protected set |
| 112 | + | ||
| 107 | /** | 113 | /** |
| 108 | * Changes can be observed by using [io.livekit.android.util.flow] | 114 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 109 | */ | 115 | */ |
| @@ -113,6 +119,7 @@ open class Participant( | @@ -113,6 +119,7 @@ open class Participant( | ||
| 113 | .map { it.filterValues { publication -> publication.kind == Track.Kind.AUDIO } } | 119 | .map { it.filterValues { publication -> publication.kind == Track.Kind.AUDIO } } |
| 114 | .stateIn(scope, SharingStarted.Eagerly, emptyMap()) | 120 | .stateIn(scope, SharingStarted.Eagerly, emptyMap()) |
| 115 | ) | 121 | ) |
| 122 | + | ||
| 116 | /** | 123 | /** |
| 117 | * Changes can be observed by using [io.livekit.android.util.flow] | 124 | * Changes can be observed by using [io.livekit.android.util.flow] |
| 118 | */ | 125 | */ |
| @@ -204,6 +211,7 @@ open class Participant( | @@ -204,6 +211,7 @@ open class Participant( | ||
| 204 | identity = info.identity | 211 | identity = info.identity |
| 205 | participantInfo = info | 212 | participantInfo = info |
| 206 | metadata = info.metadata | 213 | metadata = info.metadata |
| 214 | + name = info.name | ||
| 207 | } | 215 | } |
| 208 | 216 | ||
| 209 | override fun equals(other: Any?): Boolean { | 217 | override fun equals(other: Any?): Boolean { |
| @@ -237,7 +245,10 @@ open class Participant( | @@ -237,7 +245,10 @@ open class Participant( | ||
| 237 | 245 | ||
| 238 | internal fun onTrackStreamStateChanged(trackEvent: TrackEvent.StreamStateChanged) { | 246 | internal fun onTrackStreamStateChanged(trackEvent: TrackEvent.StreamStateChanged) { |
| 239 | val trackPublication = tracks[trackEvent.track.sid] ?: return | 247 | val trackPublication = tracks[trackEvent.track.sid] ?: return |
| 240 | - eventBus.postEvent(ParticipantEvent.TrackStreamStateChanged(this, trackPublication, trackEvent.streamState), scope) | 248 | + eventBus.postEvent( |
| 249 | + ParticipantEvent.TrackStreamStateChanged(this, trackPublication, trackEvent.streamState), | ||
| 250 | + scope | ||
| 251 | + ) | ||
| 241 | } | 252 | } |
| 242 | 253 | ||
| 243 | } | 254 | } |
| @@ -32,6 +32,8 @@ open class TrackPublication( | @@ -32,6 +32,8 @@ open class TrackPublication( | ||
| 32 | internal set | 32 | internal set |
| 33 | var source: Track.Source = Track.Source.UNKNOWN | 33 | var source: Track.Source = Track.Source.UNKNOWN |
| 34 | internal set | 34 | internal set |
| 35 | + var mimeType: String? = null | ||
| 36 | + internal set | ||
| 35 | 37 | ||
| 36 | var participant: WeakReference<Participant> | 38 | var participant: WeakReference<Participant> |
| 37 | 39 | ||
| @@ -53,5 +55,6 @@ open class TrackPublication( | @@ -53,5 +55,6 @@ open class TrackPublication( | ||
| 53 | simulcasted = info.simulcast | 55 | simulcasted = info.simulcast |
| 54 | dimensions = Track.Dimensions(info.width, info.height) | 56 | dimensions = Track.Dimensions(info.width, info.height) |
| 55 | } | 57 | } |
| 58 | + mimeType = info.mimeType | ||
| 56 | } | 59 | } |
| 57 | } | 60 | } |
| @@ -31,6 +31,7 @@ class ParticipantTest { | @@ -31,6 +31,7 @@ class ParticipantTest { | ||
| 31 | assertEquals(INFO.sid, participant.sid) | 31 | assertEquals(INFO.sid, participant.sid) |
| 32 | assertEquals(INFO.identity, participant.identity) | 32 | assertEquals(INFO.identity, participant.identity) |
| 33 | assertEquals(INFO.metadata, participant.metadata) | 33 | assertEquals(INFO.metadata, participant.metadata) |
| 34 | + assertEquals(INFO.name, participant.name) | ||
| 34 | assertEquals(INFO, participant.participantInfo) | 35 | assertEquals(INFO, participant.participantInfo) |
| 35 | } | 36 | } |
| 36 | 37 | ||
| @@ -118,6 +119,7 @@ class ParticipantTest { | @@ -118,6 +119,7 @@ class ParticipantTest { | ||
| 118 | .setSid("sid") | 119 | .setSid("sid") |
| 119 | .setIdentity("identity") | 120 | .setIdentity("identity") |
| 120 | .setMetadata("metadata") | 121 | .setMetadata("metadata") |
| 122 | + .setName("name") | ||
| 121 | .build() | 123 | .build() |
| 122 | 124 | ||
| 123 | val TRACK_INFO = LivekitModels.TrackInfo.newBuilder() | 125 | val TRACK_INFO = LivekitModels.TrackInfo.newBuilder() |
| @@ -125,6 +127,7 @@ class ParticipantTest { | @@ -125,6 +127,7 @@ class ParticipantTest { | ||
| 125 | .setName("name") | 127 | .setName("name") |
| 126 | .setType(LivekitModels.TrackType.AUDIO) | 128 | .setType(LivekitModels.TrackType.AUDIO) |
| 127 | .setMuted(false) | 129 | .setMuted(false) |
| 130 | + .setMimeType("audio/mpeg") | ||
| 128 | .build() | 131 | .build() |
| 129 | } | 132 | } |
| 130 | } | 133 | } |
-
请 注册 或 登录 后发表评论