David Zhao

fixed protobuf references

@@ -10,7 +10,7 @@ buildscript { @@ -10,7 +10,7 @@ buildscript {
10 10
11 } 11 }
12 dependencies { 12 dependencies {
13 - classpath 'com.android.tools.build:gradle:4.1.2' 13 + classpath 'com.android.tools.build:gradle:4.1.3'
14 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 14 classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
15 classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" 15 classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version"
16 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.15' 16 classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.15'
1 package io.livekit.android.room 1 package io.livekit.android.room
2 2
3 import com.github.ajalt.timberkt.Timber 3 import com.github.ajalt.timberkt.Timber
4 -import livekit.Rtc 4 +import livekit.LivekitRtc
5 import org.webrtc.* 5 import org.webrtc.*
6 6
7 class PublisherTransportObserver( 7 class PublisherTransportObserver(
@@ -11,7 +11,7 @@ class PublisherTransportObserver( @@ -11,7 +11,7 @@ class PublisherTransportObserver(
11 override fun onIceCandidate(iceCandidate: IceCandidate?) { 11 override fun onIceCandidate(iceCandidate: IceCandidate?) {
12 val candidate = iceCandidate ?: return 12 val candidate = iceCandidate ?: return
13 if (engine.rtcConnected) { 13 if (engine.rtcConnected) {
14 - engine.client.sendCandidate(candidate, target = Rtc.SignalTarget.PUBLISHER) 14 + engine.client.sendCandidate(candidate, target = LivekitRtc.SignalTarget.PUBLISHER)
15 } else { 15 } else {
16 engine.pendingCandidates.add(candidate) 16 engine.pendingCandidates.add(candidate)
17 } 17 }
@@ -7,8 +7,8 @@ import io.livekit.android.room.track.Track @@ -7,8 +7,8 @@ import io.livekit.android.room.track.Track
7 import kotlinx.serialization.decodeFromString 7 import kotlinx.serialization.decodeFromString
8 import kotlinx.serialization.encodeToString 8 import kotlinx.serialization.encodeToString
9 import kotlinx.serialization.json.Json 9 import kotlinx.serialization.json.Json
10 -import livekit.Model  
11 -import livekit.Rtc 10 +import livekit.LivekitModels
  11 +import livekit.LivekitRtc
12 import okhttp3.Request 12 import okhttp3.Request
13 import okhttp3.Response 13 import okhttp3.Response
14 import okhttp3.WebSocket 14 import okhttp3.WebSocket
@@ -60,7 +60,7 @@ constructor( @@ -60,7 +60,7 @@ constructor(
60 60
61 override fun onMessage(webSocket: WebSocket, text: String) { 61 override fun onMessage(webSocket: WebSocket, text: String) {
62 Timber.v { text } 62 Timber.v { text }
63 - val signalResponseBuilder = Rtc.SignalResponse.newBuilder() 63 + val signalResponseBuilder = LivekitRtc.SignalResponse.newBuilder()
64 fromJsonProtobuf.merge(text, signalResponseBuilder) 64 fromJsonProtobuf.merge(text, signalResponseBuilder)
65 val response = signalResponseBuilder.build() 65 val response = signalResponseBuilder.build()
66 66
@@ -69,7 +69,7 @@ constructor( @@ -69,7 +69,7 @@ constructor(
69 69
70 override fun onMessage(webSocket: WebSocket, bytes: ByteString) { 70 override fun onMessage(webSocket: WebSocket, bytes: ByteString) {
71 val byteArray = bytes.toByteArray() 71 val byteArray = bytes.toByteArray()
72 - val signalResponseBuilder = Rtc.SignalResponse.newBuilder() 72 + val signalResponseBuilder = LivekitRtc.SignalResponse.newBuilder()
73 .mergeFrom(byteArray) 73 .mergeFrom(byteArray)
74 val response = signalResponseBuilder.build() 74 val response = signalResponseBuilder.build()
75 75
@@ -93,7 +93,7 @@ constructor( @@ -93,7 +93,7 @@ constructor(
93 } 93 }
94 94
95 95
96 - fun fromProtoSessionDescription(sd: Rtc.SessionDescription): SessionDescription { 96 + fun fromProtoSessionDescription(sd: LivekitRtc.SessionDescription): SessionDescription {
97 val rtcSdpType = when (sd.type) { 97 val rtcSdpType = when (sd.type) {
98 SD_TYPE_ANSWER -> SessionDescription.Type.ANSWER 98 SD_TYPE_ANSWER -> SessionDescription.Type.ANSWER
99 SD_TYPE_OFFER -> SessionDescription.Type.OFFER 99 SD_TYPE_OFFER -> SessionDescription.Type.OFFER
@@ -103,8 +103,8 @@ constructor( @@ -103,8 +103,8 @@ constructor(
103 return SessionDescription(rtcSdpType, sd.sdp) 103 return SessionDescription(rtcSdpType, sd.sdp)
104 } 104 }
105 105
106 - fun toProtoSessionDescription(sdp: SessionDescription): Rtc.SessionDescription {  
107 - val sdBuilder = Rtc.SessionDescription.newBuilder() 106 + fun toProtoSessionDescription(sdp: SessionDescription): LivekitRtc.SessionDescription {
  107 + val sdBuilder = LivekitRtc.SessionDescription.newBuilder()
108 sdBuilder.sdp = sdp.description 108 sdBuilder.sdp = sdp.description
109 sdBuilder.type = when (sdp.type) { 109 sdBuilder.type = when (sdp.type) {
110 SessionDescription.Type.ANSWER -> SD_TYPE_ANSWER 110 SessionDescription.Type.ANSWER -> SD_TYPE_ANSWER
@@ -118,7 +118,7 @@ constructor( @@ -118,7 +118,7 @@ constructor(
118 118
119 fun sendOffer(offer: SessionDescription) { 119 fun sendOffer(offer: SessionDescription) {
120 val sd = toProtoSessionDescription(offer) 120 val sd = toProtoSessionDescription(offer)
121 - val request = Rtc.SignalRequest.newBuilder() 121 + val request = LivekitRtc.SignalRequest.newBuilder()
122 .setOffer(sd) 122 .setOffer(sd)
123 .build() 123 .build()
124 124
@@ -127,26 +127,26 @@ constructor( @@ -127,26 +127,26 @@ constructor(
127 127
128 fun sendAnswer(answer: SessionDescription) { 128 fun sendAnswer(answer: SessionDescription) {
129 val sd = toProtoSessionDescription(answer) 129 val sd = toProtoSessionDescription(answer)
130 - val request = Rtc.SignalRequest.newBuilder() 130 + val request = LivekitRtc.SignalRequest.newBuilder()
131 .setAnswer(sd) 131 .setAnswer(sd)
132 .build() 132 .build()
133 133
134 sendRequest(request) 134 sendRequest(request)
135 } 135 }
136 136
137 - fun sendCandidate(candidate: IceCandidate, target: Rtc.SignalTarget){ 137 + fun sendCandidate(candidate: IceCandidate, target: LivekitRtc.SignalTarget){
138 val iceCandidateJSON = IceCandidateJSON( 138 val iceCandidateJSON = IceCandidateJSON(
139 candidate = candidate.sdp, 139 candidate = candidate.sdp,
140 sdpMid = candidate.sdpMid, 140 sdpMid = candidate.sdpMid,
141 sdpMLineIndex = candidate.sdpMLineIndex 141 sdpMLineIndex = candidate.sdpMLineIndex
142 ) 142 )
143 143
144 - val trickleRequest = Rtc.TrickleRequest.newBuilder() 144 + val trickleRequest = LivekitRtc.TrickleRequest.newBuilder()
145 .setCandidateInit(json.encodeToString(iceCandidateJSON)) 145 .setCandidateInit(json.encodeToString(iceCandidateJSON))
146 .setTarget(target) 146 .setTarget(target)
147 .build() 147 .build()
148 148
149 - val request = Rtc.SignalRequest.newBuilder() 149 + val request = LivekitRtc.SignalRequest.newBuilder()
150 .setTrickle(trickleRequest) 150 .setTrickle(trickleRequest)
151 .build() 151 .build()
152 152
@@ -154,33 +154,33 @@ constructor( @@ -154,33 +154,33 @@ constructor(
154 } 154 }
155 155
156 fun sendMuteTrack(trackSid: Track.Sid, muted: Boolean) { 156 fun sendMuteTrack(trackSid: Track.Sid, muted: Boolean) {
157 - val muteRequest = Rtc.MuteTrackRequest.newBuilder() 157 + val muteRequest = LivekitRtc.MuteTrackRequest.newBuilder()
158 .setSid(trackSid.sid) 158 .setSid(trackSid.sid)
159 .setMuted(muted) 159 .setMuted(muted)
160 .build() 160 .build()
161 161
162 - val request = Rtc.SignalRequest.newBuilder() 162 + val request = LivekitRtc.SignalRequest.newBuilder()
163 .setMute(muteRequest) 163 .setMute(muteRequest)
164 .build() 164 .build()
165 165
166 sendRequest(request) 166 sendRequest(request)
167 } 167 }
168 168
169 - fun sendAddTrack(cid: Track.Cid, name: String, type: Model.TrackType) {  
170 - val addTrackRequest = Rtc.AddTrackRequest.newBuilder() 169 + fun sendAddTrack(cid: Track.Cid, name: String, type: LivekitModels.TrackType) {
  170 + val addTrackRequest = LivekitRtc.AddTrackRequest.newBuilder()
171 .setCid(cid.cid) 171 .setCid(cid.cid)
172 .setName(name) 172 .setName(name)
173 .setType(type) 173 .setType(type)
174 .build() 174 .build()
175 175
176 - val request = Rtc.SignalRequest.newBuilder() 176 + val request = LivekitRtc.SignalRequest.newBuilder()
177 .setAddTrack(addTrackRequest) 177 .setAddTrack(addTrackRequest)
178 .build() 178 .build()
179 179
180 sendRequest(request) 180 sendRequest(request)
181 } 181 }
182 182
183 - fun sendRequest(request: Rtc.SignalRequest) { 183 + fun sendRequest(request: LivekitRtc.SignalRequest) {
184 Timber.v { "sending request: $request" } 184 Timber.v { "sending request: $request" }
185 if (!isConnected || currentWs == null) { 185 if (!isConnected || currentWs == null) {
186 throw IllegalStateException("not connected!") 186 throw IllegalStateException("not connected!")
@@ -200,7 +200,7 @@ constructor( @@ -200,7 +200,7 @@ constructor(
200 } 200 }
201 } 201 }
202 202
203 - fun handleSignalResponse(response: Rtc.SignalResponse) { 203 + fun handleSignalResponse(response: LivekitRtc.SignalResponse) {
204 if (!isConnected) { 204 if (!isConnected) {
205 // Only handle joins if not connected. 205 // Only handle joins if not connected.
206 if (response.hasJoin()) { 206 if (response.hasJoin()) {
@@ -212,15 +212,15 @@ constructor( @@ -212,15 +212,15 @@ constructor(
212 return 212 return
213 } 213 }
214 when (response.messageCase) { 214 when (response.messageCase) {
215 - Rtc.SignalResponse.MessageCase.ANSWER -> { 215 + LivekitRtc.SignalResponse.MessageCase.ANSWER -> {
216 val sd = fromProtoSessionDescription(response.answer) 216 val sd = fromProtoSessionDescription(response.answer)
217 listener?.onAnswer(sd) 217 listener?.onAnswer(sd)
218 } 218 }
219 - Rtc.SignalResponse.MessageCase.OFFER -> { 219 + LivekitRtc.SignalResponse.MessageCase.OFFER -> {
220 val sd = fromProtoSessionDescription(response.offer) 220 val sd = fromProtoSessionDescription(response.offer)
221 listener?.onOffer(sd) 221 listener?.onOffer(sd)
222 } 222 }
223 - Rtc.SignalResponse.MessageCase.TRICKLE -> { 223 + LivekitRtc.SignalResponse.MessageCase.TRICKLE -> {
224 val iceCandidateJson = 224 val iceCandidateJson =
225 json.decodeFromString<IceCandidateJSON>(response.trickle.candidateInit) 225 json.decodeFromString<IceCandidateJSON>(response.trickle.candidateInit)
226 val iceCandidate = IceCandidate( 226 val iceCandidate = IceCandidate(
@@ -230,16 +230,16 @@ constructor( @@ -230,16 +230,16 @@ constructor(
230 ) 230 )
231 listener?.onTrickle(iceCandidate, response.trickle.target) 231 listener?.onTrickle(iceCandidate, response.trickle.target)
232 } 232 }
233 - Rtc.SignalResponse.MessageCase.UPDATE -> { 233 + LivekitRtc.SignalResponse.MessageCase.UPDATE -> {
234 listener?.onParticipantUpdate(response.update.participantsList) 234 listener?.onParticipantUpdate(response.update.participantsList)
235 } 235 }
236 - Rtc.SignalResponse.MessageCase.TRACK_PUBLISHED -> { 236 + LivekitRtc.SignalResponse.MessageCase.TRACK_PUBLISHED -> {
237 listener?.onLocalTrackPublished(response.trackPublished) 237 listener?.onLocalTrackPublished(response.trackPublished)
238 } 238 }
239 - Rtc.SignalResponse.MessageCase.SPEAKER -> { 239 + LivekitRtc.SignalResponse.MessageCase.SPEAKER -> {
240 listener?.onActiveSpeakersChanged(response.speaker.speakersList) 240 listener?.onActiveSpeakersChanged(response.speaker.speakersList)
241 } 241 }
242 - Rtc.SignalResponse.MessageCase.MESSAGE_NOT_SET -> TODO() 242 + LivekitRtc.SignalResponse.MessageCase.MESSAGE_NOT_SET -> TODO()
243 else -> { 243 else -> {
244 Timber.v { "unhandled response type: ${response.messageCase.name}" } 244 Timber.v { "unhandled response type: ${response.messageCase.name}" }
245 } 245 }
@@ -252,13 +252,13 @@ constructor( @@ -252,13 +252,13 @@ constructor(
252 } 252 }
253 253
254 interface Listener { 254 interface Listener {
255 - fun onJoin(info: Rtc.JoinResponse) 255 + fun onJoin(info: LivekitRtc.JoinResponse)
256 fun onAnswer(sessionDescription: SessionDescription) 256 fun onAnswer(sessionDescription: SessionDescription)
257 fun onOffer(sessionDescription: SessionDescription) 257 fun onOffer(sessionDescription: SessionDescription)
258 - fun onTrickle(candidate: IceCandidate, target: Rtc.SignalTarget)  
259 - fun onLocalTrackPublished(response: Rtc.TrackPublishedResponse)  
260 - fun onParticipantUpdate(updates: List<Model.ParticipantInfo>)  
261 - fun onActiveSpeakersChanged(speakers: List<Rtc.SpeakerInfo>) 258 + fun onTrickle(candidate: IceCandidate, target: LivekitRtc.SignalTarget)
  259 + fun onLocalTrackPublished(response: LivekitRtc.TrackPublishedResponse)
  260 + fun onParticipantUpdate(updates: List<LivekitModels.ParticipantInfo>)
  261 + fun onActiveSpeakersChanged(speakers: List<LivekitRtc.SpeakerInfo>)
262 fun onClose(reason: String, code: Int) 262 fun onClose(reason: String, code: Int)
263 fun onError(error: Exception) 263 fun onError(error: Exception)
264 } 264 }
@@ -11,8 +11,8 @@ import io.livekit.android.util.Either @@ -11,8 +11,8 @@ import io.livekit.android.util.Either
11 import kotlinx.coroutines.CoroutineDispatcher 11 import kotlinx.coroutines.CoroutineDispatcher
12 import kotlinx.coroutines.SupervisorJob 12 import kotlinx.coroutines.SupervisorJob
13 import kotlinx.coroutines.launch 13 import kotlinx.coroutines.launch
14 -import livekit.Model  
15 -import livekit.Rtc 14 +import livekit.LivekitModels
  15 +import livekit.LivekitRtc
16 import org.webrtc.* 16 import org.webrtc.*
17 import javax.inject.Inject 17 import javax.inject.Inject
18 import javax.inject.Named 18 import javax.inject.Named
@@ -32,7 +32,7 @@ constructor( @@ -32,7 +32,7 @@ constructor(
32 32
33 var listener: Listener? = null 33 var listener: Listener? = null
34 var rtcConnected: Boolean = false 34 var rtcConnected: Boolean = false
35 - var joinResponse: Rtc.JoinResponse? = null 35 + var joinResponse: LivekitRtc.JoinResponse? = null
36 var iceConnected: Boolean = false 36 var iceConnected: Boolean = false
37 set(value) { 37 set(value) {
38 field = value 38 field = value
@@ -43,7 +43,7 @@ constructor( @@ -43,7 +43,7 @@ constructor(
43 } 43 }
44 } 44 }
45 val pendingCandidates = mutableListOf<IceCandidate>() 45 val pendingCandidates = mutableListOf<IceCandidate>()
46 - private val pendingTrackResolvers: MutableMap<Track.Cid, Continuation<Model.TrackInfo>> = 46 + private val pendingTrackResolvers: MutableMap<Track.Cid, Continuation<LivekitModels.TrackInfo>> =
47 mutableMapOf() 47 mutableMapOf()
48 48
49 private val publisherObserver = PublisherTransportObserver(this) 49 private val publisherObserver = PublisherTransportObserver(this)
@@ -74,7 +74,7 @@ constructor( @@ -74,7 +74,7 @@ constructor(
74 client.join(url, token, isSecure) 74 client.join(url, token, isSecure)
75 } 75 }
76 76
77 - suspend fun addTrack(cid: Track.Cid, name: String, kind: Model.TrackType): Model.TrackInfo { 77 + suspend fun addTrack(cid: Track.Cid, name: String, kind: LivekitModels.TrackType): LivekitModels.TrackInfo {
78 if (pendingTrackResolvers[cid] != null) { 78 if (pendingTrackResolvers[cid] != null) {
79 throw TrackException.DuplicateTrackException("Track with same ID $cid has already been published!") 79 throw TrackException.DuplicateTrackException("Track with same ID $cid has already been published!")
80 } 80 }
@@ -127,18 +127,18 @@ constructor( @@ -127,18 +127,18 @@ constructor(
127 Timber.v { "RTC Connected" } 127 Timber.v { "RTC Connected" }
128 rtcConnected = true 128 rtcConnected = true
129 pendingCandidates.forEach { candidate -> 129 pendingCandidates.forEach { candidate ->
130 - client.sendCandidate(candidate, Rtc.SignalTarget.PUBLISHER) 130 + client.sendCandidate(candidate, LivekitRtc.SignalTarget.PUBLISHER)
131 } 131 }
132 pendingCandidates.clear() 132 pendingCandidates.clear()
133 } 133 }
134 134
135 interface Listener { 135 interface Listener {
136 - fun onJoin(response: Rtc.JoinResponse) 136 + fun onJoin(response: LivekitRtc.JoinResponse)
137 fun onAddTrack(track: MediaStreamTrack, streams: Array<out MediaStream>) 137 fun onAddTrack(track: MediaStreamTrack, streams: Array<out MediaStream>)
138 - fun onPublishLocalTrack(cid: Track.Cid, track: Model.TrackInfo) 138 + fun onPublishLocalTrack(cid: Track.Cid, track: LivekitModels.TrackInfo)
139 fun onAddDataChannel(channel: DataChannel) 139 fun onAddDataChannel(channel: DataChannel)
140 - fun onUpdateParticipants(updates: List<Model.ParticipantInfo>)  
141 - fun onUpdateSpeakers(speakers: List<Rtc.SpeakerInfo>) 140 + fun onUpdateParticipants(updates: List<LivekitModels.ParticipantInfo>)
  141 + fun onUpdateSpeakers(speakers: List<LivekitRtc.SpeakerInfo>)
142 fun onDisconnect(reason: String) 142 fun onDisconnect(reason: String)
143 fun onFailToConnect(error: Exception) 143 fun onFailToConnect(error: Exception)
144 } 144 }
@@ -162,7 +162,7 @@ constructor( @@ -162,7 +162,7 @@ constructor(
162 } 162 }
163 } 163 }
164 164
165 - override fun onJoin(info: Rtc.JoinResponse) { 165 + override fun onJoin(info: LivekitRtc.JoinResponse) {
166 joinResponse = info 166 joinResponse = info
167 167
168 coroutineScope.launch { 168 coroutineScope.launch {
@@ -237,16 +237,16 @@ constructor( @@ -237,16 +237,16 @@ constructor(
237 } 237 }
238 } 238 }
239 239
240 - override fun onTrickle(candidate: IceCandidate, target: Rtc.SignalTarget) { 240 + override fun onTrickle(candidate: IceCandidate, target: LivekitRtc.SignalTarget) {
241 Timber.v { "received ice candidate from peer: $candidate, $target" } 241 Timber.v { "received ice candidate from peer: $candidate, $target" }
242 when (target) { 242 when (target) {
243 - Rtc.SignalTarget.PUBLISHER -> publisher.addIceCandidate(candidate)  
244 - Rtc.SignalTarget.SUBSCRIBER -> publisher.addIceCandidate(candidate) 243 + LivekitRtc.SignalTarget.PUBLISHER -> publisher.addIceCandidate(candidate)
  244 + LivekitRtc.SignalTarget.SUBSCRIBER -> publisher.addIceCandidate(candidate)
245 else -> Timber.i { "unknown ice candidate target?" } 245 else -> Timber.i { "unknown ice candidate target?" }
246 } 246 }
247 } 247 }
248 248
249 - override fun onLocalTrackPublished(response: Rtc.TrackPublishedResponse) { 249 + override fun onLocalTrackPublished(response: LivekitRtc.TrackPublishedResponse) {
250 val signalCid = response.cid ?: run { 250 val signalCid = response.cid ?: run {
251 Timber.e { "local track published with null cid?" } 251 Timber.e { "local track published with null cid?" }
252 return 252 return
@@ -269,11 +269,11 @@ constructor( @@ -269,11 +269,11 @@ constructor(
269 269
270 } 270 }
271 271
272 - override fun onParticipantUpdate(updates: List<Model.ParticipantInfo>) { 272 + override fun onParticipantUpdate(updates: List<LivekitModels.ParticipantInfo>) {
273 listener?.onUpdateParticipants(updates) 273 listener?.onUpdateParticipants(updates)
274 } 274 }
275 275
276 - override fun onActiveSpeakersChanged(speakers: List<Rtc.SpeakerInfo>) { 276 + override fun onActiveSpeakersChanged(speakers: List<LivekitRtc.SpeakerInfo>) {
277 listener?.onUpdateSpeakers(speakers) 277 listener?.onUpdateSpeakers(speakers)
278 } 278 }
279 279
@@ -11,8 +11,8 @@ import io.livekit.android.room.participant.Participant @@ -11,8 +11,8 @@ import io.livekit.android.room.participant.Participant
11 import io.livekit.android.room.participant.RemoteParticipant 11 import io.livekit.android.room.participant.RemoteParticipant
12 import io.livekit.android.room.track.Track 12 import io.livekit.android.room.track.Track
13 import io.livekit.android.room.util.unpackedTrackLabel 13 import io.livekit.android.room.util.unpackedTrackLabel
14 -import livekit.Model  
15 -import livekit.Rtc 14 +import livekit.LivekitModels
  15 +import livekit.LivekitRtc
16 import org.webrtc.* 16 import org.webrtc.*
17 import kotlin.coroutines.Continuation 17 import kotlin.coroutines.Continuation
18 import kotlin.coroutines.resume 18 import kotlin.coroutines.resume
@@ -84,7 +84,7 @@ constructor( @@ -84,7 +84,7 @@ constructor(
84 84
85 private fun getOrCreateRemoteParticipant( 85 private fun getOrCreateRemoteParticipant(
86 sid: Participant.Sid, 86 sid: Participant.Sid,
87 - info: Model.ParticipantInfo? = null 87 + info: LivekitModels.ParticipantInfo? = null
88 ): RemoteParticipant { 88 ): RemoteParticipant {
89 var participant = remoteParticipants[sid] 89 var participant = remoteParticipants[sid]
90 if (participant != null) { 90 if (participant != null) {
@@ -100,7 +100,7 @@ constructor( @@ -100,7 +100,7 @@ constructor(
100 return participant 100 return participant
101 } 101 }
102 102
103 - private fun handleSpeakerUpdate(speakerInfos: List<Rtc.SpeakerInfo>) { 103 + private fun handleSpeakerUpdate(speakerInfos: List<LivekitRtc.SpeakerInfo>) {
104 val speakers = mutableListOf<Participant>() 104 val speakers = mutableListOf<Participant>()
105 val seenSids = mutableSetOf<Participant.Sid>() 105 val seenSids = mutableSetOf<Participant.Sid>()
106 val localParticipant = localParticipant 106 val localParticipant = localParticipant
@@ -150,7 +150,7 @@ constructor( @@ -150,7 +150,7 @@ constructor(
150 fun onActiveSpeakersChanged(speakers: List<Participant>, room: Room) {} 150 fun onActiveSpeakersChanged(speakers: List<Participant>, room: Room) {}
151 } 151 }
152 152
153 - override fun onJoin(response: Rtc.JoinResponse) { 153 + override fun onJoin(response: LivekitRtc.JoinResponse) {
154 Timber.v { "engine did join, version: ${response.serverVersion}" } 154 Timber.v { "engine did join, version: ${response.serverVersion}" }
155 155
156 try { 156 try {
@@ -200,11 +200,11 @@ constructor( @@ -200,11 +200,11 @@ constructor(
200 participant.addSubscribedDataTrack(channel, trackSid, name) 200 participant.addSubscribedDataTrack(channel, trackSid, name)
201 } 201 }
202 202
203 - override fun onPublishLocalTrack(cid: Track.Cid, track: Model.TrackInfo) { 203 + override fun onPublishLocalTrack(cid: Track.Cid, track: LivekitModels.TrackInfo) {
204 } 204 }
205 205
206 206
207 - override fun onUpdateParticipants(updates: List<Model.ParticipantInfo>) { 207 + override fun onUpdateParticipants(updates: List<LivekitModels.ParticipantInfo>) {
208 for (info in updates) { 208 for (info in updates) {
209 val participantSid = Participant.Sid(info.sid) 209 val participantSid = Participant.Sid(info.sid)
210 210
@@ -215,7 +215,7 @@ constructor( @@ -215,7 +215,7 @@ constructor(
215 val isNewParticipant = remoteParticipants.contains(participantSid) 215 val isNewParticipant = remoteParticipants.contains(participantSid)
216 val participant = getOrCreateRemoteParticipant(participantSid, info) 216 val participant = getOrCreateRemoteParticipant(participantSid, info)
217 217
218 - if (info.state == Model.ParticipantInfo.State.DISCONNECTED) { 218 + if (info.state == LivekitModels.ParticipantInfo.State.DISCONNECTED) {
219 handleParticipantDisconnect(participantSid, participant) 219 handleParticipantDisconnect(participantSid, participant)
220 } else if (isNewParticipant) { 220 } else if (isNewParticipant) {
221 listener?.onParticipantConnected(this, participant) 221 listener?.onParticipantConnected(this, participant)
@@ -225,7 +225,7 @@ constructor( @@ -225,7 +225,7 @@ constructor(
225 } 225 }
226 } 226 }
227 227
228 - override fun onUpdateSpeakers(speakers: List<Rtc.SpeakerInfo>) { 228 + override fun onUpdateSpeakers(speakers: List<LivekitRtc.SpeakerInfo>) {
229 handleSpeakerUpdate(speakers) 229 handleSpeakerUpdate(speakers)
230 } 230 }
231 231
1 package io.livekit.android.room 1 package io.livekit.android.room
2 2
3 import com.github.ajalt.timberkt.Timber 3 import com.github.ajalt.timberkt.Timber
4 -import livekit.Rtc 4 +import livekit.LivekitRtc
5 import org.webrtc.* 5 import org.webrtc.*
6 6
7 class SubscriberTransportObserver( 7 class SubscriberTransportObserver(
@@ -11,7 +11,7 @@ class SubscriberTransportObserver( @@ -11,7 +11,7 @@ class SubscriberTransportObserver(
11 11
12 override fun onIceCandidate(candidate: IceCandidate) { 12 override fun onIceCandidate(candidate: IceCandidate) {
13 Timber.v { "onIceCandidate: $candidate" } 13 Timber.v { "onIceCandidate: $candidate" }
14 - engine.client.sendCandidate(candidate, Rtc.SignalTarget.SUBSCRIBER) 14 + engine.client.sendCandidate(candidate, LivekitRtc.SignalTarget.SUBSCRIBER)
15 } 15 }
16 16
17 override fun onAddTrack(receiver: RtpReceiver, streams: Array<out MediaStream>) { 17 override fun onAddTrack(receiver: RtpReceiver, streams: Array<out MediaStream>) {
@@ -3,14 +3,14 @@ package io.livekit.android.room.participant @@ -3,14 +3,14 @@ package io.livekit.android.room.participant
3 import com.github.ajalt.timberkt.Timber 3 import com.github.ajalt.timberkt.Timber
4 import io.livekit.android.room.RTCEngine 4 import io.livekit.android.room.RTCEngine
5 import io.livekit.android.room.track.* 5 import io.livekit.android.room.track.*
6 -import livekit.Model 6 +import livekit.LivekitModels
7 import org.webrtc.DataChannel 7 import org.webrtc.DataChannel
8 import org.webrtc.RtpTransceiver 8 import org.webrtc.RtpTransceiver
9 import java.util.* 9 import java.util.*
10 10
11 class LocalParticipant(sid: Sid, name: String? = null) : 11 class LocalParticipant(sid: Sid, name: String? = null) :
12 Participant(sid, name) { 12 Participant(sid, name) {
13 - constructor(info: Model.ParticipantInfo, engine: RTCEngine) : this( 13 + constructor(info: LivekitModels.ParticipantInfo, engine: RTCEngine) : this(
14 Sid(info.sid), 14 Sid(info.sid),
15 info.identity 15 info.identity
16 ) { 16 ) {
@@ -30,7 +30,7 @@ class LocalParticipant(sid: Sid, name: String? = null) : @@ -30,7 +30,7 @@ class LocalParticipant(sid: Sid, name: String? = null) :
30 var engine: RTCEngine? = null 30 var engine: RTCEngine? = null
31 val listener: Listener? = null 31 val listener: Listener? = null
32 32
33 - fun updateFromInfo(info: Model.ParticipantInfo) { 33 + fun updateFromInfo(info: LivekitModels.ParticipantInfo) {
34 sid = Sid(info.sid) 34 sid = Sid(info.sid)
35 name = info.identity 35 name = info.identity
36 metadata = info.metadata 36 metadata = info.metadata
@@ -52,7 +52,7 @@ class LocalParticipant(sid: Sid, name: String? = null) : @@ -52,7 +52,7 @@ class LocalParticipant(sid: Sid, name: String? = null) :
52 } 52 }
53 53
54 val trackInfo = 54 val trackInfo =
55 - engine.addTrack(cid = Track.Cid(cid), name = track.name, kind = Model.TrackType.AUDIO) 55 + engine.addTrack(cid = Track.Cid(cid), name = track.name, kind = LivekitModels.TrackType.AUDIO)
56 val transInit = RtpTransceiver.RtpTransceiverInit( 56 val transInit = RtpTransceiver.RtpTransceiverInit(
57 RtpTransceiver.RtpTransceiverDirection.SEND_ONLY, 57 RtpTransceiver.RtpTransceiverDirection.SEND_ONLY,
58 listOf(streamId) 58 listOf(streamId)
@@ -89,7 +89,7 @@ class LocalParticipant(sid: Sid, name: String? = null) : @@ -89,7 +89,7 @@ class LocalParticipant(sid: Sid, name: String? = null) :
89 } 89 }
90 90
91 val trackInfo = 91 val trackInfo =
92 - engine.addTrack(cid = Track.Cid(cid), name = track.name, kind = Model.TrackType.VIDEO) 92 + engine.addTrack(cid = Track.Cid(cid), name = track.name, kind = LivekitModels.TrackType.VIDEO)
93 val transInit = RtpTransceiver.RtpTransceiverInit( 93 val transInit = RtpTransceiver.RtpTransceiverInit(
94 RtpTransceiver.RtpTransceiverDirection.SEND_ONLY, 94 RtpTransceiver.RtpTransceiverDirection.SEND_ONLY,
95 listOf(streamId) 95 listOf(streamId)
@@ -126,7 +126,7 @@ class LocalParticipant(sid: Sid, name: String? = null) : @@ -126,7 +126,7 @@ class LocalParticipant(sid: Sid, name: String? = null) :
126 } 126 }
127 127
128 val trackInfo = 128 val trackInfo =
129 - engine.addTrack(cid = cid, name = track.name, kind = Model.TrackType.DATA) 129 + engine.addTrack(cid = cid, name = track.name, kind = LivekitModels.TrackType.DATA)
130 val publication = LocalDataTrackPublication(trackInfo, track) 130 val publication = LocalDataTrackPublication(trackInfo, track)
131 val trackSid = Track.Sid(trackInfo.sid) 131 val trackSid = Track.Sid(trackInfo.sid)
132 track.sid = trackSid 132 track.sid = trackSid
@@ -6,7 +6,7 @@ import io.livekit.android.util.CloseableCoroutineScope @@ -6,7 +6,7 @@ import io.livekit.android.util.CloseableCoroutineScope
6 import kotlinx.coroutines.SupervisorJob 6 import kotlinx.coroutines.SupervisorJob
7 import kotlinx.coroutines.delay 7 import kotlinx.coroutines.delay
8 import kotlinx.coroutines.launch 8 import kotlinx.coroutines.launch
9 -import livekit.Model 9 +import livekit.LivekitModels
10 import org.webrtc.AudioTrack 10 import org.webrtc.AudioTrack
11 import org.webrtc.DataChannel 11 import org.webrtc.DataChannel
12 import org.webrtc.MediaStreamTrack 12 import org.webrtc.MediaStreamTrack
@@ -17,7 +17,7 @@ class RemoteParticipant( @@ -17,7 +17,7 @@ class RemoteParticipant(
17 sid: Sid, name: String? = null 17 sid: Sid, name: String? = null
18 ) : Participant(sid, name), RemoteDataTrack.Listener { 18 ) : Participant(sid, name), RemoteDataTrack.Listener {
19 19
20 - constructor(info: Model.ParticipantInfo) : this(Sid(info.sid), info.identity) { 20 + constructor(info: LivekitModels.ParticipantInfo) : this(Sid(info.sid), info.identity) {
21 updateFromInfo(info) 21 updateFromInfo(info)
22 } 22 }
23 23
@@ -30,7 +30,7 @@ class RemoteParticipant( @@ -30,7 +30,7 @@ class RemoteParticipant(
30 30
31 var listener: Listener? = null 31 var listener: Listener? = null
32 32
33 - var participantInfo: Model.ParticipantInfo? = null 33 + var participantInfo: LivekitModels.ParticipantInfo? = null
34 34
35 val hasInfo 35 val hasInfo
36 get() = participantInfo != null 36 get() = participantInfo != null
@@ -40,7 +40,7 @@ class RemoteParticipant( @@ -40,7 +40,7 @@ class RemoteParticipant(
40 fun getTrackPublication(sid: Track.Sid): RemoteTrackPublication? = 40 fun getTrackPublication(sid: Track.Sid): RemoteTrackPublication? =
41 tracks[sid] as? RemoteTrackPublication 41 tracks[sid] as? RemoteTrackPublication
42 42
43 - fun updateFromInfo(info: Model.ParticipantInfo) { 43 + fun updateFromInfo(info: LivekitModels.ParticipantInfo) {
44 val hadInfo = hasInfo 44 val hadInfo = hasInfo
45 sid = Sid(info.sid) 45 sid = Sid(info.sid)
46 name = info.identity 46 name = info.identity
@@ -56,10 +56,10 @@ class RemoteParticipant( @@ -56,10 +56,10 @@ class RemoteParticipant(
56 56
57 if (publication == null) { 57 if (publication == null) {
58 publication = when (trackInfo.type) { 58 publication = when (trackInfo.type) {
59 - Model.TrackType.AUDIO -> RemoteAudioTrackPublication(trackInfo)  
60 - Model.TrackType.VIDEO -> RemoteVideoTrackPublication(trackInfo)  
61 - Model.TrackType.DATA -> RemoteDataTrackPublication(trackInfo)  
62 - Model.TrackType.UNRECOGNIZED -> throw TrackException.InvalidTrackTypeException() 59 + LivekitModels.TrackType.AUDIO -> RemoteAudioTrackPublication(trackInfo)
  60 + LivekitModels.TrackType.VIDEO -> RemoteVideoTrackPublication(trackInfo)
  61 + LivekitModels.TrackType.DATA -> RemoteDataTrackPublication(trackInfo)
  62 + LivekitModels.TrackType.UNRECOGNIZED -> throw TrackException.InvalidTrackTypeException()
63 null -> throw NullPointerException("trackInfo.type is null") 63 null -> throw NullPointerException("trackInfo.type is null")
64 } 64 }
65 65
@@ -143,10 +143,10 @@ class RemoteParticipant( @@ -143,10 +143,10 @@ class RemoteParticipant(
143 if (publication != null) { 143 if (publication != null) {
144 publication.track = track 144 publication.track = track
145 } else { 145 } else {
146 - val trackInfo = Model.TrackInfo.newBuilder() 146 + val trackInfo = LivekitModels.TrackInfo.newBuilder()
147 .setSid(sid.sid) 147 .setSid(sid.sid)
148 .setName(name) 148 .setName(name)
149 - .setType(Model.TrackType.DATA) 149 + .setType(LivekitModels.TrackType.DATA)
150 .build() 150 .build()
151 publication = RemoteDataTrackPublication(info = trackInfo, track = track) 151 publication = RemoteDataTrackPublication(info = trackInfo, track = track)
152 addTrack(publication) 152 addTrack(publication)
1 package io.livekit.android.room.track 1 package io.livekit.android.room.track
2 2
3 -import livekit.Model 3 +import livekit.LivekitModels
4 4
5 -class LocalAudioTrackPublication(info: Model.TrackInfo, track: Track? = null) : 5 +class LocalAudioTrackPublication(info: LivekitModels.TrackInfo, track: Track? = null) :
6 LocalTrackPublication(info, track), AudioTrackPublication { 6 LocalTrackPublication(info, track), AudioTrackPublication {
7 override val audioTrack: AudioTrack? 7 override val audioTrack: AudioTrack?
8 get() = track as? AudioTrack 8 get() = track as? AudioTrack
1 package io.livekit.android.room.track 1 package io.livekit.android.room.track
2 2
3 -import livekit.Model 3 +import livekit.LivekitModels
4 4
5 -class LocalDataTrackPublication(info: Model.TrackInfo, track: Track? = null) : 5 +class LocalDataTrackPublication(info: LivekitModels.TrackInfo, track: Track? = null) :
6 LocalTrackPublication(info, track), DataTrackPublication { 6 LocalTrackPublication(info, track), DataTrackPublication {
7 override val dataTrack: DataTrack? 7 override val dataTrack: DataTrack?
8 get() = track as? DataTrack 8 get() = track as? DataTrack
1 package io.livekit.android.room.track 1 package io.livekit.android.room.track
2 2
3 -import livekit.Model 3 +import livekit.LivekitModels
4 4
5 -open class LocalTrackPublication(info: Model.TrackInfo, track: Track? = null) : 5 +open class LocalTrackPublication(info: LivekitModels.TrackInfo, track: Track? = null) :
6 TrackPublication(info, track) { 6 TrackPublication(info, track) {
7 val localTrack 7 val localTrack
8 get() = track 8 get() = track
1 package io.livekit.android.room.track 1 package io.livekit.android.room.track
2 2
3 -import livekit.Model 3 +import livekit.LivekitModels
4 4
5 -class LocalVideoTrackPublication(info: Model.TrackInfo, track: Track? = null) : 5 +class LocalVideoTrackPublication(info: LivekitModels.TrackInfo, track: Track? = null) :
6 LocalTrackPublication(info, track), VideoTrackPublication { 6 LocalTrackPublication(info, track), VideoTrackPublication {
7 override val videoTrack: VideoTrack? 7 override val videoTrack: VideoTrack?
8 get() = track as? VideoTrack 8 get() = track as? VideoTrack
1 package io.livekit.android.room.track 1 package io.livekit.android.room.track
2 2
3 -import livekit.Model 3 +import livekit.LivekitModels
4 4
5 class RemoteAudioTrackPublication( 5 class RemoteAudioTrackPublication(
6 - info: Model.TrackInfo, 6 + info: LivekitModels.TrackInfo,
7 track: Track? = null 7 track: Track? = null
8 ) : RemoteTrackPublication(info, track), AudioTrackPublication { 8 ) : RemoteTrackPublication(info, track), AudioTrackPublication {
9 override val audioTrack: AudioTrack? 9 override val audioTrack: AudioTrack?
1 package io.livekit.android.room.track 1 package io.livekit.android.room.track
2 2
3 -import livekit.Model 3 +import livekit.LivekitModels
4 4
5 class RemoteDataTrackPublication( 5 class RemoteDataTrackPublication(
6 - info: Model.TrackInfo, 6 + info: LivekitModels.TrackInfo,
7 track: Track? = null 7 track: Track? = null
8 ) : RemoteTrackPublication(info, track), DataTrackPublication { 8 ) : RemoteTrackPublication(info, track), DataTrackPublication {
9 override val dataTrack: DataTrack? 9 override val dataTrack: DataTrack?
1 package io.livekit.android.room.track 1 package io.livekit.android.room.track
2 2
3 -import livekit.Model 3 +import livekit.LivekitModels
4 4
5 -open class RemoteTrackPublication(info: Model.TrackInfo, track: Track? = null) : 5 +open class RemoteTrackPublication(info: LivekitModels.TrackInfo, track: Track? = null) :
6 TrackPublication(info, track) { 6 TrackPublication(info, track) {
7 7
8 val remoteTrack: Track? 8 val remoteTrack: Track?
1 package io.livekit.android.room.track 1 package io.livekit.android.room.track
2 2
3 -import livekit.Model 3 +import livekit.LivekitModels
4 4
5 -class RemoteVideoTrackPublication(info: Model.TrackInfo, track: Track? = null) : 5 +class RemoteVideoTrackPublication(info: LivekitModels.TrackInfo, track: Track? = null) :
6 RemoteTrackPublication(info, track), 6 RemoteTrackPublication(info, track),
7 VideoTrackPublication { 7 VideoTrackPublication {
8 8
1 package io.livekit.android.room.track 1 package io.livekit.android.room.track
2 2
3 -import livekit.Model 3 +import livekit.LivekitModels
4 4
5 -open class TrackPublication(info: Model.TrackInfo, track: Track? = null) { 5 +open class TrackPublication(info: LivekitModels.TrackInfo, track: Track? = null) {
6 var track: Track? = track 6 var track: Track? = track
7 internal set 7 internal set
8 var trackName: String 8 var trackName: String
@@ -15,7 +15,7 @@ open class TrackPublication(info: Model.TrackInfo, track: Track? = null) { @@ -15,7 +15,7 @@ open class TrackPublication(info: Model.TrackInfo, track: Track? = null) {
15 trackName = info.name 15 trackName = info.name
16 } 16 }
17 17
18 - fun updateFromInfo(info: Model.TrackInfo) { 18 + fun updateFromInfo(info: LivekitModels.TrackInfo) {
19 trackSid = Track.Sid(info.sid) 19 trackSid = Track.Sid(info.sid)
20 trackName = info.name 20 trackName = info.name
21 } 21 }