正在显示
15 个修改的文件
包含
105 行增加
和
28 行删除
| @@ -65,7 +65,7 @@ dokkaHtml { | @@ -65,7 +65,7 @@ dokkaHtml { | ||
| 65 | skipEmptyPackages.set(true) | 65 | skipEmptyPackages.set(true) |
| 66 | includeNonPublic.set(false) | 66 | includeNonPublic.set(false) |
| 67 | includes.from("module.md") | 67 | includes.from("module.md") |
| 68 | - | 68 | + displayName.set("SDK") |
| 69 | sourceLink { | 69 | sourceLink { |
| 70 | localDirectory.set(file("src/main/java")) | 70 | localDirectory.set(file("src/main/java")) |
| 71 | 71 | ||
| @@ -75,6 +75,16 @@ dokkaHtml { | @@ -75,6 +75,16 @@ dokkaHtml { | ||
| 75 | // Suffix which is used to append the line number to the URL. Use #L for GitHub | 75 | // Suffix which is used to append the line number to the URL. Use #L for GitHub |
| 76 | remoteLineSuffix.set("#L") | 76 | remoteLineSuffix.set("#L") |
| 77 | } | 77 | } |
| 78 | + | ||
| 79 | + perPackageOption { | ||
| 80 | + matchingRegex.set(".*\\.dagger.*") | ||
| 81 | + suppress.set(true) | ||
| 82 | + } | ||
| 83 | + | ||
| 84 | + perPackageOption { | ||
| 85 | + matchingRegex.set(".*\\.util.*") | ||
| 86 | + suppress.set(true) | ||
| 87 | + } | ||
| 78 | } | 88 | } |
| 79 | } | 89 | } |
| 80 | } | 90 | } |
| @@ -2,7 +2,6 @@ package io.livekit.android | @@ -2,7 +2,6 @@ package io.livekit.android | ||
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | data class ConnectOptions( | 4 | data class ConnectOptions( |
| 5 | - val isSecure: Boolean = true, | ||
| 6 | val sendAudio: Boolean = true, | 5 | val sendAudio: Boolean = true, |
| 7 | val sendVideo: Boolean = true, | 6 | val sendVideo: Boolean = true, |
| 8 | ) | 7 | ) |
| @@ -11,6 +11,11 @@ import org.webrtc.PeerConnectionFactory | @@ -11,6 +11,11 @@ import org.webrtc.PeerConnectionFactory | ||
| 11 | 11 | ||
| 12 | class LiveKit { | 12 | class LiveKit { |
| 13 | companion object { | 13 | companion object { |
| 14 | + /** | ||
| 15 | + * Connect to a LiveKit room | ||
| 16 | + * @param url URL to LiveKit server (i.e. ws://mylivekitdeploy.io) | ||
| 17 | + * @param listener Listener to Room events. LiveKit interactions take place with these callbacks | ||
| 18 | + */ | ||
| 14 | suspend fun connect( | 19 | suspend fun connect( |
| 15 | appContext: Context, | 20 | appContext: Context, |
| 16 | url: String, | 21 | url: String, |
| @@ -26,7 +31,7 @@ class LiveKit { | @@ -26,7 +31,7 @@ class LiveKit { | ||
| 26 | val room = component.roomFactory() | 31 | val room = component.roomFactory() |
| 27 | .create(options) | 32 | .create(options) |
| 28 | room.listener = listener | 33 | room.listener = listener |
| 29 | - room.connect(url, token, options.isSecure) | 34 | + room.connect(url, token) |
| 30 | 35 | ||
| 31 | val localParticipant = room.localParticipant | 36 | val localParticipant = room.localParticipant |
| 32 | if (localParticipant != null) { | 37 | if (localParticipant != null) { |
| @@ -54,7 +59,7 @@ class LiveKit { | @@ -54,7 +59,7 @@ class LiveKit { | ||
| 54 | context: Context, | 59 | context: Context, |
| 55 | rootEglBase: EglBase, | 60 | rootEglBase: EglBase, |
| 56 | ): LocalVideoTrack { | 61 | ): LocalVideoTrack { |
| 57 | - return LocalVideoTrack.track( | 62 | + return LocalVideoTrack.createTrack( |
| 58 | peerConnectionFactory, | 63 | peerConnectionFactory, |
| 59 | context, | 64 | context, |
| 60 | true, | 65 | true, |
| @@ -2,5 +2,8 @@ package io.livekit.android.room | @@ -2,5 +2,8 @@ package io.livekit.android.room | ||
| 2 | 2 | ||
| 3 | import kotlinx.serialization.Serializable | 3 | import kotlinx.serialization.Serializable |
| 4 | 4 | ||
| 5 | +/** | ||
| 6 | + * @suppress | ||
| 7 | + */ | ||
| 5 | @Serializable | 8 | @Serializable |
| 6 | data class IceCandidateJSON(val candidate: String, val sdpMLineIndex: Int, val sdpMid: String?) | 9 | data class IceCandidateJSON(val candidate: String, val sdpMLineIndex: Int, val sdpMid: String?) |
| @@ -5,6 +5,9 @@ import dagger.assisted.AssistedFactory | @@ -5,6 +5,9 @@ import dagger.assisted.AssistedFactory | ||
| 5 | import dagger.assisted.AssistedInject | 5 | import dagger.assisted.AssistedInject |
| 6 | import org.webrtc.* | 6 | import org.webrtc.* |
| 7 | 7 | ||
| 8 | +/** | ||
| 9 | + * @suppress | ||
| 10 | + */ | ||
| 8 | class PeerConnectionTransport | 11 | class PeerConnectionTransport |
| 9 | @AssistedInject | 12 | @AssistedInject |
| 10 | constructor( | 13 | constructor( |
| @@ -4,6 +4,9 @@ import com.github.ajalt.timberkt.Timber | @@ -4,6 +4,9 @@ import com.github.ajalt.timberkt.Timber | ||
| 4 | import livekit.LivekitRtc | 4 | import livekit.LivekitRtc |
| 5 | import org.webrtc.* | 5 | import org.webrtc.* |
| 6 | 6 | ||
| 7 | +/** | ||
| 8 | + * @suppress | ||
| 9 | + */ | ||
| 7 | class PublisherTransportObserver( | 10 | class PublisherTransportObserver( |
| 8 | private val engine: RTCEngine | 11 | private val engine: RTCEngine |
| 9 | ) : PeerConnection.Observer { | 12 | ) : PeerConnection.Observer { |
| @@ -21,6 +21,9 @@ import org.webrtc.SessionDescription | @@ -21,6 +21,9 @@ import org.webrtc.SessionDescription | ||
| 21 | import javax.inject.Inject | 21 | import javax.inject.Inject |
| 22 | import javax.inject.Named | 22 | import javax.inject.Named |
| 23 | 23 | ||
| 24 | +/** | ||
| 25 | + * @suppress | ||
| 26 | + */ | ||
| 24 | class RTCClient | 27 | class RTCClient |
| 25 | @Inject | 28 | @Inject |
| 26 | constructor( | 29 | constructor( |
| @@ -38,13 +41,10 @@ constructor( | @@ -38,13 +41,10 @@ constructor( | ||
| 38 | var listener: Listener? = null | 41 | var listener: Listener? = null |
| 39 | 42 | ||
| 40 | fun join( | 43 | fun join( |
| 41 | - host: String, | 44 | + url: String, |
| 42 | token: String, | 45 | token: String, |
| 43 | - isSecure: Boolean, | ||
| 44 | ) { | 46 | ) { |
| 45 | - val protocol = if (isSecure) "wss" else "ws" | ||
| 46 | - | ||
| 47 | - val wsUrlString = "$protocol://$host/rtc?access_token=$token" | 47 | + val wsUrlString = "$url/rtc?access_token=$token" |
| 48 | Timber.i { "connecting to $wsUrlString" } | 48 | Timber.i { "connecting to $wsUrlString" } |
| 49 | 49 | ||
| 50 | val request = Request.Builder() | 50 | val request = Request.Builder() |
| @@ -20,7 +20,9 @@ import kotlin.coroutines.Continuation | @@ -20,7 +20,9 @@ import kotlin.coroutines.Continuation | ||
| 20 | import kotlin.coroutines.resume | 20 | import kotlin.coroutines.resume |
| 21 | import kotlin.coroutines.suspendCoroutine | 21 | import kotlin.coroutines.suspendCoroutine |
| 22 | 22 | ||
| 23 | - | 23 | +/** |
| 24 | + * @suppress | ||
| 25 | + */ | ||
| 24 | class RTCEngine | 26 | class RTCEngine |
| 25 | @Inject | 27 | @Inject |
| 26 | constructor( | 28 | constructor( |
| @@ -70,8 +72,8 @@ constructor( | @@ -70,8 +72,8 @@ constructor( | ||
| 70 | ) | 72 | ) |
| 71 | } | 73 | } |
| 72 | 74 | ||
| 73 | - fun join(url: String, token: String, isSecure: Boolean) { | ||
| 74 | - client.join(url, token, isSecure) | 75 | + fun join(url: String, token: String) { |
| 76 | + client.join(url, token) | ||
| 75 | } | 77 | } |
| 76 | 78 | ||
| 77 | suspend fun addTrack(cid: Track.Cid, name: String, kind: LivekitModels.TrackType): LivekitModels.TrackInfo { | 79 | suspend fun addTrack(cid: Track.Cid, name: String, kind: LivekitModels.TrackType): LivekitModels.TrackInfo { |
| @@ -57,12 +57,12 @@ constructor( | @@ -57,12 +57,12 @@ constructor( | ||
| 57 | get() = mutableActiveSpeakers | 57 | get() = mutableActiveSpeakers |
| 58 | 58 | ||
| 59 | private var connectContinuation: Continuation<Unit>? = null | 59 | private var connectContinuation: Continuation<Unit>? = null |
| 60 | - suspend fun connect(url: String, token: String, isSecure: Boolean) { | 60 | + suspend fun connect(url: String, token: String) { |
| 61 | if (localParticipant != null) { | 61 | if (localParticipant != null) { |
| 62 | Timber.d { "Attempting to connect to room when already connected." } | 62 | Timber.d { "Attempting to connect to room when already connected." } |
| 63 | return | 63 | return |
| 64 | } | 64 | } |
| 65 | - engine.join(url, token, isSecure) | 65 | + engine.join(url, token) |
| 66 | 66 | ||
| 67 | return suspendCoroutine { connectContinuation = it } | 67 | return suspendCoroutine { connectContinuation = it } |
| 68 | } | 68 | } |
| @@ -132,11 +132,18 @@ constructor( | @@ -132,11 +132,18 @@ constructor( | ||
| 132 | listener?.onActiveSpeakersChanged(speakers, this) | 132 | listener?.onActiveSpeakersChanged(speakers, this) |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | + /** | ||
| 136 | + * @suppress | ||
| 137 | + */ | ||
| 135 | @AssistedFactory | 138 | @AssistedFactory |
| 136 | interface Factory { | 139 | interface Factory { |
| 137 | fun create(connectOptions: ConnectOptions): Room | 140 | fun create(connectOptions: ConnectOptions): Room |
| 138 | } | 141 | } |
| 139 | 142 | ||
| 143 | + /** | ||
| 144 | + * Room Listener, this class provides callbacks that clients should override. | ||
| 145 | + * | ||
| 146 | + */ | ||
| 140 | interface Listener { | 147 | interface Listener { |
| 141 | fun onConnect(room: Room) {} | 148 | fun onConnect(room: Room) {} |
| 142 | fun onDisconnect(room: Room, error: Exception?) {} | 149 | fun onDisconnect(room: Room, error: Exception?) {} |
| @@ -150,6 +157,9 @@ constructor( | @@ -150,6 +157,9 @@ constructor( | ||
| 150 | fun onActiveSpeakersChanged(speakers: List<Participant>, room: Room) {} | 157 | fun onActiveSpeakersChanged(speakers: List<Participant>, room: Room) {} |
| 151 | } | 158 | } |
| 152 | 159 | ||
| 160 | + /** | ||
| 161 | + * @suppress | ||
| 162 | + */ | ||
| 153 | override fun onJoin(response: LivekitRtc.JoinResponse) { | 163 | override fun onJoin(response: LivekitRtc.JoinResponse) { |
| 154 | Timber.v { "engine did join, version: ${response.serverVersion}" } | 164 | Timber.v { "engine did join, version: ${response.serverVersion}" } |
| 155 | 165 | ||
| @@ -181,6 +191,9 @@ constructor( | @@ -181,6 +191,9 @@ constructor( | ||
| 181 | listener?.onConnect(this) | 191 | listener?.onConnect(this) |
| 182 | } | 192 | } |
| 183 | 193 | ||
| 194 | + /** | ||
| 195 | + * @suppress | ||
| 196 | + */ | ||
| 184 | override fun onAddTrack(track: MediaStreamTrack, streams: Array<out MediaStream>) { | 197 | override fun onAddTrack(track: MediaStreamTrack, streams: Array<out MediaStream>) { |
| 185 | if (streams.count() < 0) { | 198 | if (streams.count() < 0) { |
| 186 | Timber.i { "add track with empty streams?" } | 199 | Timber.i { "add track with empty streams?" } |
| @@ -193,6 +206,9 @@ constructor( | @@ -193,6 +206,9 @@ constructor( | ||
| 193 | participant.addSubscribedMediaTrack(track, trackSid) | 206 | participant.addSubscribedMediaTrack(track, trackSid) |
| 194 | } | 207 | } |
| 195 | 208 | ||
| 209 | + /** | ||
| 210 | + * @suppress | ||
| 211 | + */ | ||
| 196 | override fun onAddDataChannel(channel: DataChannel) { | 212 | override fun onAddDataChannel(channel: DataChannel) { |
| 197 | val unpackedTrackLabel = channel.unpackedTrackLabel() | 213 | val unpackedTrackLabel = channel.unpackedTrackLabel() |
| 198 | val (participantSid, trackSid, name) = unpackedTrackLabel | 214 | val (participantSid, trackSid, name) = unpackedTrackLabel |
| @@ -200,10 +216,15 @@ constructor( | @@ -200,10 +216,15 @@ constructor( | ||
| 200 | participant.addSubscribedDataTrack(channel, trackSid, name) | 216 | participant.addSubscribedDataTrack(channel, trackSid, name) |
| 201 | } | 217 | } |
| 202 | 218 | ||
| 219 | + /** | ||
| 220 | + * @suppress | ||
| 221 | + */ | ||
| 203 | override fun onPublishLocalTrack(cid: Track.Cid, track: LivekitModels.TrackInfo) { | 222 | override fun onPublishLocalTrack(cid: Track.Cid, track: LivekitModels.TrackInfo) { |
| 204 | } | 223 | } |
| 205 | 224 | ||
| 206 | - | 225 | + /** |
| 226 | + * @suppress | ||
| 227 | + */ | ||
| 207 | override fun onUpdateParticipants(updates: List<LivekitModels.ParticipantInfo>) { | 228 | override fun onUpdateParticipants(updates: List<LivekitModels.ParticipantInfo>) { |
| 208 | for (info in updates) { | 229 | for (info in updates) { |
| 209 | val participantSid = Participant.Sid(info.sid) | 230 | val participantSid = Participant.Sid(info.sid) |
| @@ -225,19 +246,32 @@ constructor( | @@ -225,19 +246,32 @@ constructor( | ||
| 225 | } | 246 | } |
| 226 | } | 247 | } |
| 227 | 248 | ||
| 249 | + /** | ||
| 250 | + * @suppress | ||
| 251 | + */ | ||
| 228 | override fun onUpdateSpeakers(speakers: List<LivekitRtc.SpeakerInfo>) { | 252 | override fun onUpdateSpeakers(speakers: List<LivekitRtc.SpeakerInfo>) { |
| 229 | handleSpeakerUpdate(speakers) | 253 | handleSpeakerUpdate(speakers) |
| 230 | } | 254 | } |
| 231 | 255 | ||
| 256 | + /** | ||
| 257 | + * @suppress | ||
| 258 | + */ | ||
| 232 | override fun onDisconnect(reason: String) { | 259 | override fun onDisconnect(reason: String) { |
| 233 | Timber.v { "engine did disconnect: $reason" } | 260 | Timber.v { "engine did disconnect: $reason" } |
| 234 | listener?.onDisconnect(this, null) | 261 | listener?.onDisconnect(this, null) |
| 235 | } | 262 | } |
| 236 | 263 | ||
| 264 | + /** | ||
| 265 | + * @suppress | ||
| 266 | + */ | ||
| 237 | override fun onFailToConnect(error: Exception) { | 267 | override fun onFailToConnect(error: Exception) { |
| 238 | listener?.onFailedToConnect(this, error) | 268 | listener?.onFailedToConnect(this, error) |
| 239 | } | 269 | } |
| 240 | 270 | ||
| 271 | + /** | ||
| 272 | + * @suppress | ||
| 273 | + * // TODO(@dl): can this be moved out of Room/SDK? | ||
| 274 | + */ | ||
| 241 | fun initVideoRenderer(viewRenderer: SurfaceViewRenderer) { | 275 | fun initVideoRenderer(viewRenderer: SurfaceViewRenderer) { |
| 242 | viewRenderer.init(eglBase.eglBaseContext, null) | 276 | viewRenderer.init(eglBase.eglBaseContext, null) |
| 243 | viewRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT) | 277 | viewRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT) |
| @@ -4,6 +4,9 @@ import com.github.ajalt.timberkt.Timber | @@ -4,6 +4,9 @@ import com.github.ajalt.timberkt.Timber | ||
| 4 | import livekit.LivekitRtc | 4 | import livekit.LivekitRtc |
| 5 | import org.webrtc.* | 5 | import org.webrtc.* |
| 6 | 6 | ||
| 7 | +/** | ||
| 8 | + * @suppress | ||
| 9 | + */ | ||
| 7 | class SubscriberTransportObserver( | 10 | class SubscriberTransportObserver( |
| 8 | private val engine: RTCEngine | 11 | private val engine: RTCEngine |
| 9 | ) : PeerConnection.Observer { | 12 | ) : PeerConnection.Observer { |
| @@ -10,6 +10,10 @@ import java.util.* | @@ -10,6 +10,10 @@ 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 | + | ||
| 14 | + /** | ||
| 15 | + * @suppress | ||
| 16 | + */ | ||
| 13 | constructor(info: LivekitModels.ParticipantInfo, engine: RTCEngine) : this( | 17 | constructor(info: LivekitModels.ParticipantInfo, engine: RTCEngine) : this( |
| 14 | Sid(info.sid), | 18 | Sid(info.sid), |
| 15 | info.identity | 19 | info.identity |
| @@ -18,8 +22,6 @@ class LocalParticipant(sid: Sid, name: String? = null) : | @@ -18,8 +22,6 @@ class LocalParticipant(sid: Sid, name: String? = null) : | ||
| 18 | this.engine = engine | 22 | this.engine = engine |
| 19 | } | 23 | } |
| 20 | 24 | ||
| 21 | - private val streamId = UUID.randomUUID().toString() | ||
| 22 | - | ||
| 23 | val localAudioTrackPublications | 25 | val localAudioTrackPublications |
| 24 | get() = audioTracks.values.toList() | 26 | get() = audioTracks.values.toList() |
| 25 | val localVideoTrackPublications | 27 | val localVideoTrackPublications |
| @@ -30,6 +32,9 @@ class LocalParticipant(sid: Sid, name: String? = null) : | @@ -30,6 +32,9 @@ class LocalParticipant(sid: Sid, name: String? = null) : | ||
| 30 | var engine: RTCEngine? = null | 32 | var engine: RTCEngine? = null |
| 31 | val listener: Listener? = null | 33 | val listener: Listener? = null |
| 32 | 34 | ||
| 35 | + /** | ||
| 36 | + * @suppress | ||
| 37 | + */ | ||
| 33 | fun updateFromInfo(info: LivekitModels.ParticipantInfo) { | 38 | fun updateFromInfo(info: LivekitModels.ParticipantInfo) { |
| 34 | sid = Sid(info.sid) | 39 | sid = Sid(info.sid) |
| 35 | name = info.identity | 40 | name = info.identity |
| @@ -55,7 +60,7 @@ class LocalParticipant(sid: Sid, name: String? = null) : | @@ -55,7 +60,7 @@ class LocalParticipant(sid: Sid, name: String? = null) : | ||
| 55 | engine.addTrack(cid = Track.Cid(cid), name = track.name, kind = LivekitModels.TrackType.AUDIO) | 60 | engine.addTrack(cid = Track.Cid(cid), name = track.name, kind = LivekitModels.TrackType.AUDIO) |
| 56 | val transInit = RtpTransceiver.RtpTransceiverInit( | 61 | val transInit = RtpTransceiver.RtpTransceiverInit( |
| 57 | RtpTransceiver.RtpTransceiverDirection.SEND_ONLY, | 62 | RtpTransceiver.RtpTransceiverDirection.SEND_ONLY, |
| 58 | - listOf(streamId) | 63 | + listOf(this.sid.sid) |
| 59 | ) | 64 | ) |
| 60 | val transceiver = | 65 | val transceiver = |
| 61 | engine.publisher.peerConnection.addTransceiver(track.rtcTrack, transInit) | 66 | engine.publisher.peerConnection.addTransceiver(track.rtcTrack, transInit) |
| @@ -92,7 +97,7 @@ class LocalParticipant(sid: Sid, name: String? = null) : | @@ -92,7 +97,7 @@ class LocalParticipant(sid: Sid, name: String? = null) : | ||
| 92 | engine.addTrack(cid = Track.Cid(cid), name = track.name, kind = LivekitModels.TrackType.VIDEO) | 97 | engine.addTrack(cid = Track.Cid(cid), name = track.name, kind = LivekitModels.TrackType.VIDEO) |
| 93 | val transInit = RtpTransceiver.RtpTransceiverInit( | 98 | val transInit = RtpTransceiver.RtpTransceiverInit( |
| 94 | RtpTransceiver.RtpTransceiverDirection.SEND_ONLY, | 99 | RtpTransceiver.RtpTransceiverDirection.SEND_ONLY, |
| 95 | - listOf(streamId) | 100 | + listOf(this.sid.sid) |
| 96 | ) | 101 | ) |
| 97 | val transceiver = | 102 | val transceiver = |
| 98 | engine.publisher.peerConnection.addTransceiver(track.rtcTrack, transInit) | 103 | engine.publisher.peerConnection.addTransceiver(track.rtcTrack, transInit) |
| @@ -166,7 +171,6 @@ class LocalParticipant(sid: Sid, name: String? = null) : | @@ -166,7 +171,6 @@ class LocalParticipant(sid: Sid, name: String? = null) : | ||
| 166 | } | 171 | } |
| 167 | 172 | ||
| 168 | fun unpublishDataTrack(track: LocalDataTrack) { | 173 | fun unpublishDataTrack(track: LocalDataTrack) { |
| 169 | - | ||
| 170 | val sid = track.sid ?: run { | 174 | val sid = track.sid ?: run { |
| 171 | Timber.d { "this track was never published." } | 175 | Timber.d { "this track was never published." } |
| 172 | return | 176 | return |
| @@ -202,7 +206,6 @@ class LocalParticipant(sid: Sid, name: String? = null) : | @@ -202,7 +206,6 @@ class LocalParticipant(sid: Sid, name: String? = null) : | ||
| 202 | } | 206 | } |
| 203 | 207 | ||
| 204 | interface Listener { | 208 | interface Listener { |
| 205 | - | ||
| 206 | fun onPublishAudioTrack(track: LocalAudioTrack) | 209 | fun onPublishAudioTrack(track: LocalAudioTrack) |
| 207 | fun onFailToPublishAudioTrack(exception: Exception) | 210 | fun onFailToPublishAudioTrack(exception: Exception) |
| 208 | fun onPublishVideoTrack(track: LocalVideoTrack) | 211 | fun onPublishVideoTrack(track: LocalVideoTrack) |
| @@ -211,5 +214,4 @@ class LocalParticipant(sid: Sid, name: String? = null) : | @@ -211,5 +214,4 @@ class LocalParticipant(sid: Sid, name: String? = null) : | ||
| 211 | fun onFailToPublishDataTrack(exception: Exception) | 214 | fun onFailToPublishDataTrack(exception: Exception) |
| 212 | //fun onNetworkQualityLevelChange | 215 | //fun onNetworkQualityLevelChange |
| 213 | } | 216 | } |
| 214 | - | ||
| 215 | -} | ||
| 217 | +} |
| @@ -19,6 +19,9 @@ open class Participant(var sid: Sid, name: String? = null) { | @@ -19,6 +19,9 @@ open class Participant(var sid: Sid, name: String? = null) { | ||
| 19 | var dataTracks = mutableMapOf<Track.Sid, TrackPublication>() | 19 | var dataTracks = mutableMapOf<Track.Sid, TrackPublication>() |
| 20 | private set | 20 | private set |
| 21 | 21 | ||
| 22 | + /** | ||
| 23 | + * @suppress | ||
| 24 | + */ | ||
| 22 | fun addTrack(publication: TrackPublication) { | 25 | fun addTrack(publication: TrackPublication) { |
| 23 | tracks[publication.trackSid] = publication | 26 | tracks[publication.trackSid] = publication |
| 24 | when (publication) { | 27 | when (publication) { |
| @@ -16,7 +16,9 @@ import java.nio.ByteBuffer | @@ -16,7 +16,9 @@ import java.nio.ByteBuffer | ||
| 16 | class RemoteParticipant( | 16 | 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 | + * @suppress | ||
| 21 | + */ | ||
| 20 | constructor(info: LivekitModels.ParticipantInfo) : this(Sid(info.sid), info.identity) { | 22 | constructor(info: LivekitModels.ParticipantInfo) : this(Sid(info.sid), info.identity) { |
| 21 | updateFromInfo(info) | 23 | updateFromInfo(info) |
| 22 | } | 24 | } |
| @@ -40,6 +42,9 @@ class RemoteParticipant( | @@ -40,6 +42,9 @@ class RemoteParticipant( | ||
| 40 | fun getTrackPublication(sid: Track.Sid): RemoteTrackPublication? = | 42 | fun getTrackPublication(sid: Track.Sid): RemoteTrackPublication? = |
| 41 | tracks[sid] as? RemoteTrackPublication | 43 | tracks[sid] as? RemoteTrackPublication |
| 42 | 44 | ||
| 45 | + /** | ||
| 46 | + * @suppress | ||
| 47 | + */ | ||
| 43 | fun updateFromInfo(info: LivekitModels.ParticipantInfo) { | 48 | fun updateFromInfo(info: LivekitModels.ParticipantInfo) { |
| 44 | val hadInfo = hasInfo | 49 | val hadInfo = hasInfo |
| 45 | sid = Sid(info.sid) | 50 | sid = Sid(info.sid) |
| @@ -85,6 +90,9 @@ class RemoteParticipant( | @@ -85,6 +90,9 @@ class RemoteParticipant( | ||
| 85 | } | 90 | } |
| 86 | } | 91 | } |
| 87 | 92 | ||
| 93 | + /** | ||
| 94 | + * @suppress | ||
| 95 | + */ | ||
| 88 | fun addSubscribedMediaTrack(rtcTrack: MediaStreamTrack, sid: Track.Sid, triesLeft: Int = 20) { | 96 | fun addSubscribedMediaTrack(rtcTrack: MediaStreamTrack, sid: Track.Sid, triesLeft: Int = 20) { |
| 89 | val publication = getTrackPublication(sid) | 97 | val publication = getTrackPublication(sid) |
| 90 | val track: Track = when (val kind = rtcTrack.kind()) { | 98 | val track: Track = when (val kind = rtcTrack.kind()) { |
| @@ -136,6 +144,9 @@ class RemoteParticipant( | @@ -136,6 +144,9 @@ class RemoteParticipant( | ||
| 136 | } | 144 | } |
| 137 | } | 145 | } |
| 138 | 146 | ||
| 147 | + /** | ||
| 148 | + * @suppress | ||
| 149 | + */ | ||
| 139 | fun addSubscribedDataTrack(rtcTrack: DataChannel, sid: Track.Sid, name: String) { | 150 | fun addSubscribedDataTrack(rtcTrack: DataChannel, sid: Track.Sid, name: String) { |
| 140 | val track = RemoteDataTrack(sid, name, rtcTrack) | 151 | val track = RemoteDataTrack(sid, name, rtcTrack) |
| 141 | var publication = getTrackPublication(sid) as? RemoteDataTrackPublication | 152 | var publication = getTrackPublication(sid) as? RemoteDataTrackPublication |
| @@ -19,7 +19,7 @@ class LocalVideoTrack( | @@ -19,7 +19,7 @@ class LocalVideoTrack( | ||
| 19 | var sid: Sid? = null | 19 | var sid: Sid? = null |
| 20 | 20 | ||
| 21 | companion object { | 21 | companion object { |
| 22 | - internal fun track( | 22 | + internal fun createTrack( |
| 23 | peerConnectionFactory: PeerConnectionFactory, | 23 | peerConnectionFactory: PeerConnectionFactory, |
| 24 | context: Context, | 24 | context: Context, |
| 25 | enabled: Boolean, | 25 | enabled: Boolean, |
| @@ -83,6 +83,5 @@ class LocalVideoTrack( | @@ -83,6 +83,5 @@ class LocalVideoTrack( | ||
| 83 | } | 83 | } |
| 84 | return null | 84 | return null |
| 85 | } | 85 | } |
| 86 | - | ||
| 87 | } | 86 | } |
| 88 | } | 87 | } |
| @@ -71,8 +71,8 @@ class MainActivity : AppCompatActivity() { | @@ -71,8 +71,8 @@ class MainActivity : AppCompatActivity() { | ||
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | companion object { | 73 | companion object { |
| 74 | - val URL = SpannableStringBuilder("192.168.11.2:7880") | 74 | + val URL = SpannableStringBuilder("ws://192.168.91.198:7880") |
| 75 | val TOKEN = | 75 | val TOKEN = |
| 76 | - SpannableStringBuilder("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTg2MjY0NDAsImlzcyI6IkFQSXdMZWFoN2c0ZnVMWURZQUplYUtzU0UiLCJqdGkiOiJwaG9uZSIsIm5iZiI6MTYxNjAzNDQ0MCwidmlkZW8iOnsicm9vbSI6Im15cm9vbSIsInJvb21Kb2luIjp0cnVlfX0.QWN0B_DO8eSP2sJivnr_QzBud_sdIgJeWDQGQz67DvY") | 76 | + SpannableStringBuilder("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2MTgyMDg0NTAsImlzcyI6IkFQSU1teGlMOHJxdUt6dFpFb1pKVjlGYiIsImp0aSI6ImZvcnRoIiwibmJmIjoxNjE1NjE2NDUwLCJ2aWRlbyI6eyJyb29tIjoibXlyb29tIiwicm9vbUpvaW4iOnRydWV9fQ.nu-fOZA-TPFvzleyXk2Zz9b5lFApCXV1npUAexttXQA") |
| 77 | } | 77 | } |
| 78 | } | 78 | } |
-
请 注册 或 登录 后发表评论