Committed by
GitHub
Add spotless check to CI builds (#270)
* add spotless * fix some format violations * kotlin styling * add spotless check to ci * Update actions and fix spotless check * ktlint fixes * more spotless fixes * more spotless fixes * turn off annotation lint * run spotless check first
正在显示
100 个修改的文件
包含
516 行增加
和
316 行删除
.editorconfig
0 → 100644
| 1 | +# https://editorconfig.org | ||
| 2 | +root = true | ||
| 3 | + | ||
| 4 | +[*] | ||
| 5 | +indent_style = space | ||
| 6 | +indent_size = 2 | ||
| 7 | +max_line_length = 180 | ||
| 8 | + | ||
| 9 | +end_of_line = lf | ||
| 10 | +charset = utf-8 | ||
| 11 | +trim_trailing_whitespace = true | ||
| 12 | +insert_final_newline = true | ||
| 13 | + | ||
| 14 | +[*.{java,kt,kts,scala,rs,xml,kt.spec,kts.spec,gradle,md}] | ||
| 15 | +indent_size = 4 | ||
| 16 | + | ||
| 17 | +[*.{kt,kts}] | ||
| 18 | +ktlint_code_style = android_studio | ||
| 19 | + | ||
| 20 | +# default IntelliJ IDEA style, same as alphabetical, but with "java", "javax", "kotlin" and alias imports in the end of the imports list | ||
| 21 | +ij_kotlin_imports_layout = *, java.**, javax.**, kotlin.**, ^ | ||
| 22 | + | ||
| 23 | +ktlint_standard = enabled | ||
| 24 | +ktlint_standard_annotation = disabled | ||
| 25 | +ktlint_standard_no-wildcard-imports = disabled | ||
| 26 | + | ||
| 27 | +ktlint_standard_trailing-comma-on-call-site = disabled | ||
| 28 | +ij_kotlin_allow_trailing_comma_on_call_site = true | ||
| 29 | +ktlint_standard_trailing-comma-on-declaration-site = disabled | ||
| 30 | +ij_kotlin_allow_trailing_comma = true | ||
| 31 | + | ||
| 32 | +ktlint_standard_wrapping = disabled | ||
| 33 | + | ||
| 34 | +[*.md] | ||
| 35 | +trim_trailing_whitespace = false | ||
| 36 | +max_line_length = unset | ||
| 37 | + | ||
| 38 | +[*.yml] | ||
| 39 | +ij_yaml_spaces_within_brackets = false |
| @@ -24,18 +24,18 @@ jobs: | @@ -24,18 +24,18 @@ jobs: | ||
| 24 | working-directory: ./client-sdk-android | 24 | working-directory: ./client-sdk-android |
| 25 | steps: | 25 | steps: |
| 26 | - name: checkout client-sdk-android | 26 | - name: checkout client-sdk-android |
| 27 | - uses: actions/checkout@v2.3.4 | 27 | + uses: actions/checkout@v4.0.0 |
| 28 | with: | 28 | with: |
| 29 | path: ./client-sdk-android | 29 | path: ./client-sdk-android |
| 30 | submodules: recursive | 30 | submodules: recursive |
| 31 | 31 | ||
| 32 | - name: set up JDK 12 | 32 | - name: set up JDK 12 |
| 33 | - uses: actions/setup-java@v2 | 33 | + uses: actions/setup-java@v3.12.0 |
| 34 | with: | 34 | with: |
| 35 | java-version: '12' | 35 | java-version: '12' |
| 36 | distribution: 'adopt' | 36 | distribution: 'adopt' |
| 37 | 37 | ||
| 38 | - - uses: actions/cache@v2 | 38 | + - uses: actions/cache@v3.3.2 |
| 39 | with: | 39 | with: |
| 40 | path: | | 40 | path: | |
| 41 | ~/.gradle/caches | 41 | ~/.gradle/caches |
| @@ -45,10 +45,19 @@ jobs: | @@ -45,10 +45,19 @@ jobs: | ||
| 45 | - name: Grant execute permission for gradlew | 45 | - name: Grant execute permission for gradlew |
| 46 | run: chmod +x gradlew | 46 | run: chmod +x gradlew |
| 47 | 47 | ||
| 48 | + - name: Gradle clean | ||
| 49 | + run: ./gradlew clean | ||
| 50 | + | ||
| 51 | + - name: Spotless check | ||
| 52 | + if: github.event_name == 'pull_request' | ||
| 53 | + run: | | ||
| 54 | + git fetch origin main --depth 1 | ||
| 55 | + ./gradlew spotlessCheck | ||
| 56 | + | ||
| 48 | - name: Build with Gradle | 57 | - name: Build with Gradle |
| 49 | - run: ./gradlew clean assembleRelease livekit-android-sdk:testRelease | 58 | + run: ./gradlew assembleRelease livekit-android-sdk:testRelease |
| 50 | 59 | ||
| 51 | -# TODO: Figure out appropriate place to run this. Takes ~3 mins, so pretty slow. | 60 | + # TODO: Figure out appropriate place to run this. Takes ~3 mins, so pretty slow. |
| 52 | # # generates coverage-report.md and publishes as checkrun | 61 | # # generates coverage-report.md and publishes as checkrun |
| 53 | # - name: JaCoCo Code Coverage Report | 62 | # - name: JaCoCo Code Coverage Report |
| 54 | # id: jacoco_reporter | 63 | # id: jacoco_reporter |
LicenseHeaderFile.txt
0 → 100644
| 1 | +/* | ||
| 2 | + * Copyright $YEAR LiveKit, Inc. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + |
| @@ -15,6 +15,7 @@ buildscript { | @@ -15,6 +15,7 @@ buildscript { | ||
| 15 | classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.19' | 15 | classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.19' |
| 16 | classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0" | 16 | classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.30.0" |
| 17 | classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5' | 17 | classpath 'com.dicedmelon.gradle:jacoco-android:0.1.5' |
| 18 | + classpath "com.diffplug.spotless:spotless-plugin-gradle:6.21.0" | ||
| 18 | // NOTE: Do not place your application dependencies here; they belong | 19 | // NOTE: Do not place your application dependencies here; they belong |
| 19 | // in the individual module build.gradle files | 20 | // in the individual module build.gradle files |
| 20 | } | 21 | } |
| @@ -27,6 +28,41 @@ subprojects { | @@ -27,6 +28,41 @@ subprojects { | ||
| 27 | mavenCentral() | 28 | mavenCentral() |
| 28 | maven { url 'https://jitpack.io' } | 29 | maven { url 'https://jitpack.io' } |
| 29 | } | 30 | } |
| 31 | + | ||
| 32 | + apply plugin: "com.diffplug.spotless" | ||
| 33 | + spotless { | ||
| 34 | + // optional: limit format enforcement to just the files changed by this feature branch | ||
| 35 | + ratchetFrom 'origin/main' | ||
| 36 | + | ||
| 37 | + format 'misc', { | ||
| 38 | + // define the files to apply `misc` to | ||
| 39 | + target '*.gradle', '*.md', '.gitignore' | ||
| 40 | + | ||
| 41 | + // define the steps to apply to those files | ||
| 42 | + trimTrailingWhitespace() | ||
| 43 | + indentWithSpaces() | ||
| 44 | + endWithNewline() | ||
| 45 | + } | ||
| 46 | + java { | ||
| 47 | + // apply a specific flavor of google-java-format | ||
| 48 | + googleJavaFormat('1.17.0').aosp().reflowLongStrings() | ||
| 49 | + // fix formatting of type annotations | ||
| 50 | + formatAnnotations() | ||
| 51 | + // make sure every file has the following copyright header. | ||
| 52 | + // optionally, Spotless can set copyright years by digging | ||
| 53 | + // through git history (see "license" section below) | ||
| 54 | + licenseHeaderFile rootProject.file("LicenseHeaderFile.txt") | ||
| 55 | + removeUnusedImports() | ||
| 56 | + } | ||
| 57 | + kotlin { | ||
| 58 | + target("src/*/java/**/*.kt") | ||
| 59 | + ktlint("0.50.0") | ||
| 60 | + .setEditorConfigPath("$rootDir/.editorconfig") | ||
| 61 | + licenseHeaderFile(rootProject.file("LicenseHeaderFile.txt")) | ||
| 62 | + .named('license') | ||
| 63 | + endWithNewline() | ||
| 64 | + } | ||
| 65 | + } | ||
| 30 | } | 66 | } |
| 31 | 67 | ||
| 32 | task clean(type: Delete) { | 68 | task clean(type: Delete) { |
| @@ -16,14 +16,12 @@ | @@ -16,14 +16,12 @@ | ||
| 16 | 16 | ||
| 17 | package io.livekit.android | 17 | package io.livekit.android |
| 18 | 18 | ||
| 19 | -import androidx.test.platform.app.InstrumentationRegistry | ||
| 20 | import androidx.test.ext.junit.runners.AndroidJUnit4 | 19 | import androidx.test.ext.junit.runners.AndroidJUnit4 |
| 21 | - | 20 | +import androidx.test.platform.app.InstrumentationRegistry |
| 21 | +import org.junit.Assert.assertEquals | ||
| 22 | import org.junit.Test | 22 | import org.junit.Test |
| 23 | import org.junit.runner.RunWith | 23 | import org.junit.runner.RunWith |
| 24 | 24 | ||
| 25 | -import org.junit.Assert.* | ||
| 26 | - | ||
| 27 | /** | 25 | /** |
| 28 | * Instrumented test, which will execute on an Android device. | 26 | * Instrumented test, which will execute on an Android device. |
| 29 | * | 27 | * |
| @@ -19,7 +19,6 @@ package io.livekit.android | @@ -19,7 +19,6 @@ package io.livekit.android | ||
| 19 | import io.livekit.android.room.ProtocolVersion | 19 | import io.livekit.android.room.ProtocolVersion |
| 20 | import org.webrtc.PeerConnection | 20 | import org.webrtc.PeerConnection |
| 21 | 21 | ||
| 22 | - | ||
| 23 | data class ConnectOptions( | 22 | data class ConnectOptions( |
| 24 | /** Auto subscribe to room tracks upon connect, defaults to true */ | 23 | /** Auto subscribe to room tracks upon connect, defaults to true */ |
| 25 | val autoSubscribe: Boolean = true, | 24 | val autoSubscribe: Boolean = true, |
| @@ -50,7 +50,6 @@ data class LiveKitOverrides( | @@ -50,7 +50,6 @@ data class LiveKitOverrides( | ||
| 50 | val audioOptions: AudioOptions? = null, | 50 | val audioOptions: AudioOptions? = null, |
| 51 | ) | 51 | ) |
| 52 | 52 | ||
| 53 | - | ||
| 54 | class AudioOptions( | 53 | class AudioOptions( |
| 55 | /** | 54 | /** |
| 56 | * Override the default output [AudioType]. | 55 | * Override the default output [AudioType]. |
| @@ -87,7 +86,7 @@ class AudioOptions( | @@ -87,7 +86,7 @@ class AudioOptions( | ||
| 87 | sealed class AudioType( | 86 | sealed class AudioType( |
| 88 | val audioMode: Int, | 87 | val audioMode: Int, |
| 89 | val audioAttributes: AudioAttributes, | 88 | val audioAttributes: AudioAttributes, |
| 90 | - val audioStreamType: Int | 89 | + val audioStreamType: Int, |
| 91 | ) { | 90 | ) { |
| 92 | /** | 91 | /** |
| 93 | * An audio type for general media playback usage (i.e. listener-only use cases). | 92 | * An audio type for general media playback usage (i.e. listener-only use cases). |
| @@ -101,7 +100,7 @@ sealed class AudioType( | @@ -101,7 +100,7 @@ sealed class AudioType( | ||
| 101 | .setUsage(AudioAttributes.USAGE_MEDIA) | 100 | .setUsage(AudioAttributes.USAGE_MEDIA) |
| 102 | .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN) | 101 | .setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN) |
| 103 | .build(), | 102 | .build(), |
| 104 | - AudioManager.STREAM_MUSIC | 103 | + AudioManager.STREAM_MUSIC, |
| 105 | ) | 104 | ) |
| 106 | 105 | ||
| 107 | /** | 106 | /** |
| @@ -115,7 +114,7 @@ sealed class AudioType( | @@ -115,7 +114,7 @@ sealed class AudioType( | ||
| 115 | .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION) | 114 | .setUsage(AudioAttributes.USAGE_VOICE_COMMUNICATION) |
| 116 | .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH) | 115 | .setContentType(AudioAttributes.CONTENT_TYPE_SPEECH) |
| 117 | .build(), | 116 | .build(), |
| 118 | - AudioManager.STREAM_VOICE_CALL | 117 | + AudioManager.STREAM_VOICE_CALL, |
| 119 | ) | 118 | ) |
| 120 | 119 | ||
| 121 | /** | 120 | /** |
| @@ -106,7 +106,7 @@ constructor(context: Context) : AudioHandler { | @@ -106,7 +106,7 @@ constructor(context: Context) : AudioHandler { | ||
| 106 | AudioAttributes.Builder() | 106 | AudioAttributes.Builder() |
| 107 | .setUsage(audioAttributeUsageType) | 107 | .setUsage(audioAttributeUsageType) |
| 108 | .setContentType(audioAttributeContentType) | 108 | .setContentType(audioAttributeContentType) |
| 109 | - .build() | 109 | + .build(), |
| 110 | ) | 110 | ) |
| 111 | .build() | 111 | .build() |
| 112 | } | 112 | } |
| @@ -150,14 +150,14 @@ constructor(private val context: Context) : AudioHandler { | @@ -150,14 +150,14 @@ constructor(private val context: Context) : AudioHandler { | ||
| 150 | context = context, | 150 | context = context, |
| 151 | loggingEnabled = loggingEnabled, | 151 | loggingEnabled = loggingEnabled, |
| 152 | audioFocusChangeListener = onAudioFocusChangeListener ?: defaultOnAudioFocusChangeListener, | 152 | audioFocusChangeListener = onAudioFocusChangeListener ?: defaultOnAudioFocusChangeListener, |
| 153 | - preferredDeviceList = preferredDeviceList ?: defaultPreferredDeviceList | 153 | + preferredDeviceList = preferredDeviceList ?: defaultPreferredDeviceList, |
| 154 | ) | 154 | ) |
| 155 | } else { | 155 | } else { |
| 156 | LegacyAudioSwitch( | 156 | LegacyAudioSwitch( |
| 157 | context = context, | 157 | context = context, |
| 158 | loggingEnabled = loggingEnabled, | 158 | loggingEnabled = loggingEnabled, |
| 159 | audioFocusChangeListener = onAudioFocusChangeListener ?: defaultOnAudioFocusChangeListener, | 159 | audioFocusChangeListener = onAudioFocusChangeListener ?: defaultOnAudioFocusChangeListener, |
| 160 | - preferredDeviceList = preferredDeviceList ?: defaultPreferredDeviceList | 160 | + preferredDeviceList = preferredDeviceList ?: defaultPreferredDeviceList, |
| 161 | ) | 161 | ) |
| 162 | } | 162 | } |
| 163 | switch.manageAudioFocus = manageAudioFocus | 163 | switch.manageAudioFocus = manageAudioFocus |
| @@ -214,7 +214,7 @@ constructor(private val context: Context) : AudioHandler { | @@ -214,7 +214,7 @@ constructor(private val context: Context) : AudioHandler { | ||
| 214 | AudioDevice.BluetoothHeadset::class.java, | 214 | AudioDevice.BluetoothHeadset::class.java, |
| 215 | AudioDevice.WiredHeadset::class.java, | 215 | AudioDevice.WiredHeadset::class.java, |
| 216 | AudioDevice.Earpiece::class.java, | 216 | AudioDevice.Earpiece::class.java, |
| 217 | - AudioDevice.Speakerphone::class.java | 217 | + AudioDevice.Speakerphone::class.java, |
| 218 | ) | 218 | ) |
| 219 | } | 219 | } |
| 220 | } | 220 | } |
| @@ -37,7 +37,6 @@ fun VideoRenderer( | @@ -37,7 +37,6 @@ fun VideoRenderer( | ||
| 37 | modifier: Modifier = Modifier, | 37 | modifier: Modifier = Modifier, |
| 38 | mirror: Boolean = false, | 38 | mirror: Boolean = false, |
| 39 | ) { | 39 | ) { |
| 40 | - | ||
| 41 | val videoSinkVisibility = remember(room, videoTrack) { ComposeVisibility() } | 40 | val videoSinkVisibility = remember(room, videoTrack) { ComposeVisibility() } |
| 42 | var boundVideoTrack by remember { mutableStateOf<VideoTrack?>(null) } | 41 | var boundVideoTrack by remember { mutableStateOf<VideoTrack?>(null) } |
| 43 | var view: TextureViewRenderer? by remember { mutableStateOf(null) } | 42 | var view: TextureViewRenderer? by remember { mutableStateOf(null) } |
| @@ -42,7 +42,7 @@ object AudioHandlerModule { | @@ -42,7 +42,7 @@ object AudioHandlerModule { | ||
| 42 | 42 | ||
| 43 | @Provides | 43 | @Provides |
| 44 | fun audioOutputAttributes( | 44 | fun audioOutputAttributes( |
| 45 | - audioType: AudioType | 45 | + audioType: AudioType, |
| 46 | ): AudioAttributes { | 46 | ): AudioAttributes { |
| 47 | return audioType.audioAttributes | 47 | return audioType.audioAttributes |
| 48 | } | 48 | } |
| @@ -29,7 +29,7 @@ object InjectionNames { | @@ -29,7 +29,7 @@ object InjectionNames { | ||
| 29 | /** | 29 | /** |
| 30 | * @see [kotlinx.coroutines.Dispatchers.IO] | 30 | * @see [kotlinx.coroutines.Dispatchers.IO] |
| 31 | */ | 31 | */ |
| 32 | - internal const val DISPATCHER_IO = "dispatcher_io"; | 32 | + internal const val DISPATCHER_IO = "dispatcher_io" |
| 33 | 33 | ||
| 34 | /** | 34 | /** |
| 35 | * @see [kotlinx.coroutines.Dispatchers.Main] | 35 | * @see [kotlinx.coroutines.Dispatchers.Main] |
| @@ -35,7 +35,7 @@ import javax.inject.Singleton | @@ -35,7 +35,7 @@ import javax.inject.Singleton | ||
| 35 | OverridesModule::class, | 35 | OverridesModule::class, |
| 36 | AudioHandlerModule::class, | 36 | AudioHandlerModule::class, |
| 37 | MemoryModule::class, | 37 | MemoryModule::class, |
| 38 | - ] | 38 | + ], |
| 39 | ) | 39 | ) |
| 40 | internal interface LiveKitComponent { | 40 | internal interface LiveKitComponent { |
| 41 | 41 | ||
| @@ -49,7 +49,7 @@ internal interface LiveKitComponent { | @@ -49,7 +49,7 @@ internal interface LiveKitComponent { | ||
| 49 | interface Factory { | 49 | interface Factory { |
| 50 | fun create( | 50 | fun create( |
| 51 | @BindsInstance appContext: Context, | 51 | @BindsInstance appContext: Context, |
| 52 | - overridesModule: OverridesModule | 52 | + overridesModule: OverridesModule, |
| 53 | ): LiveKitComponent | 53 | ): LiveKitComponent |
| 54 | } | 54 | } |
| 55 | } | 55 | } |
| @@ -60,7 +60,6 @@ internal fun LiveKitComponent.Factory.create( | @@ -60,7 +60,6 @@ internal fun LiveKitComponent.Factory.create( | ||
| 60 | ): LiveKitComponent { | 60 | ): LiveKitComponent { |
| 61 | return create( | 61 | return create( |
| 62 | appContext = context, | 62 | appContext = context, |
| 63 | - overridesModule = OverridesModule(overrides) | 63 | + overridesModule = OverridesModule(overrides), |
| 64 | ) | 64 | ) |
| 65 | } | 65 | } |
| 66 | - |
| @@ -63,5 +63,4 @@ class OverridesModule(private val overrides: LiveKitOverrides) { | @@ -63,5 +63,4 @@ class OverridesModule(private val overrides: LiveKitOverrides) { | ||
| 63 | @Provides | 63 | @Provides |
| 64 | @Named(InjectionNames.OVERRIDE_AUDIO_OUTPUT_TYPE) | 64 | @Named(InjectionNames.OVERRIDE_AUDIO_OUTPUT_TYPE) |
| 65 | fun audioOutputType() = overrides.audioOptions?.audioOutputType | 65 | fun audioOutputType() = overrides.audioOptions?.audioOutputType |
| 66 | - | ||
| 67 | } | 66 | } |
| @@ -53,7 +53,8 @@ object RTCModule { | @@ -53,7 +53,8 @@ object RTCModule { | ||
| 53 | PeerConnectionFactory.initialize( | 53 | PeerConnectionFactory.initialize( |
| 54 | PeerConnectionFactory.InitializationOptions | 54 | PeerConnectionFactory.InitializationOptions |
| 55 | .builder(appContext) | 55 | .builder(appContext) |
| 56 | - .setInjectableLogger({ s, severity, s2 -> | 56 | + .setInjectableLogger( |
| 57 | + { s, severity, s2 -> | ||
| 57 | if (!LiveKit.enableWebRTCLogging) { | 58 | if (!LiveKit.enableWebRTCLogging) { |
| 58 | return@setInjectableLogger | 59 | return@setInjectableLogger |
| 59 | } | 60 | } |
| @@ -69,8 +70,10 @@ object RTCModule { | @@ -69,8 +70,10 @@ object RTCModule { | ||
| 69 | LKLog.log(loggingLevel) { | 70 | LKLog.log(loggingLevel) { |
| 70 | Timber.log(loggingLevel.toAndroidLogPriority(), "$s2: $s") | 71 | Timber.log(loggingLevel.toAndroidLogPriority(), "$s2: $s") |
| 71 | } | 72 | } |
| 72 | - }, Logging.Severity.LS_VERBOSE) | ||
| 73 | - .createInitializationOptions() | 73 | + }, |
| 74 | + Logging.Severity.LS_VERBOSE, | ||
| 75 | + ) | ||
| 76 | + .createInitializationOptions(), | ||
| 74 | ) | 77 | ) |
| 75 | return LibWebrtcInitialization | 78 | return LibWebrtcInitialization |
| 76 | } | 79 | } |
| @@ -86,7 +89,7 @@ object RTCModule { | @@ -86,7 +89,7 @@ object RTCModule { | ||
| 86 | @Nullable | 89 | @Nullable |
| 87 | moduleCustomizer: ((builder: JavaAudioDeviceModule.Builder) -> Unit)?, | 90 | moduleCustomizer: ((builder: JavaAudioDeviceModule.Builder) -> Unit)?, |
| 88 | audioOutputAttributes: AudioAttributes, | 91 | audioOutputAttributes: AudioAttributes, |
| 89 | - appContext: Context | 92 | + appContext: Context, |
| 90 | ): AudioDeviceModule { | 93 | ): AudioDeviceModule { |
| 91 | if (audioDeviceModuleOverride != null) { | 94 | if (audioDeviceModuleOverride != null) { |
| 92 | return audioDeviceModuleOverride | 95 | return audioDeviceModuleOverride |
| @@ -100,7 +103,7 @@ object RTCModule { | @@ -100,7 +103,7 @@ object RTCModule { | ||
| 100 | 103 | ||
| 101 | override fun onWebRtcAudioRecordStartError( | 104 | override fun onWebRtcAudioRecordStartError( |
| 102 | errorCode: JavaAudioDeviceModule.AudioRecordStartErrorCode?, | 105 | errorCode: JavaAudioDeviceModule.AudioRecordStartErrorCode?, |
| 103 | - errorMessage: String? | 106 | + errorMessage: String?, |
| 104 | ) { | 107 | ) { |
| 105 | LKLog.e { "onWebRtcAudioRecordStartError: $errorCode. $errorMessage" } | 108 | LKLog.e { "onWebRtcAudioRecordStartError: $errorCode. $errorMessage" } |
| 106 | } | 109 | } |
| @@ -117,7 +120,7 @@ object RTCModule { | @@ -117,7 +120,7 @@ object RTCModule { | ||
| 117 | 120 | ||
| 118 | override fun onWebRtcAudioTrackStartError( | 121 | override fun onWebRtcAudioTrackStartError( |
| 119 | errorCode: JavaAudioDeviceModule.AudioTrackStartErrorCode?, | 122 | errorCode: JavaAudioDeviceModule.AudioTrackStartErrorCode?, |
| 120 | - errorMessage: String? | 123 | + errorMessage: String?, |
| 121 | ) { | 124 | ) { |
| 122 | LKLog.e { "onWebRtcAudioTrackStartError: $errorCode. $errorMessage" } | 125 | LKLog.e { "onWebRtcAudioTrackStartError: $errorCode. $errorMessage" } |
| 123 | } | 126 | } |
| @@ -125,7 +128,6 @@ object RTCModule { | @@ -125,7 +128,6 @@ object RTCModule { | ||
| 125 | override fun onWebRtcAudioTrackError(errorMessage: String?) { | 128 | override fun onWebRtcAudioTrackError(errorMessage: String?) { |
| 126 | LKLog.e { "onWebRtcAudioTrackError: $errorMessage" } | 129 | LKLog.e { "onWebRtcAudioTrackError: $errorMessage" } |
| 127 | } | 130 | } |
| 128 | - | ||
| 129 | } | 131 | } |
| 130 | val audioRecordStateCallback: JavaAudioDeviceModule.AudioRecordStateCallback = object : | 132 | val audioRecordStateCallback: JavaAudioDeviceModule.AudioRecordStateCallback = object : |
| 131 | JavaAudioDeviceModule.AudioRecordStateCallback { | 133 | JavaAudioDeviceModule.AudioRecordStateCallback { |
| @@ -168,7 +170,9 @@ object RTCModule { | @@ -168,7 +170,9 @@ object RTCModule { | ||
| 168 | 170 | ||
| 169 | @Provides | 171 | @Provides |
| 170 | @Singleton | 172 | @Singleton |
| 171 | - fun eglBase(@Singleton memoryManager: CloseableManager): EglBase { | 173 | + fun eglBase( |
| 174 | + @Singleton memoryManager: CloseableManager, | ||
| 175 | + ): EglBase { | ||
| 172 | val eglBase = EglBase.create() | 176 | val eglBase = EglBase.create() |
| 173 | memoryManager.registerResource(eglBase) { eglBase.release() } | 177 | memoryManager.registerResource(eglBase) { eglBase.release() } |
| 174 | 178 | ||
| @@ -188,7 +192,7 @@ object RTCModule { | @@ -188,7 +192,7 @@ object RTCModule { | ||
| 188 | eglContext: EglBase.Context, | 192 | eglContext: EglBase.Context, |
| 189 | @Named(InjectionNames.OVERRIDE_VIDEO_ENCODER_FACTORY) | 193 | @Named(InjectionNames.OVERRIDE_VIDEO_ENCODER_FACTORY) |
| 190 | @Nullable | 194 | @Nullable |
| 191 | - videoEncoderFactoryOverride: VideoEncoderFactory? | 195 | + videoEncoderFactoryOverride: VideoEncoderFactory?, |
| 192 | ): VideoEncoderFactory { | 196 | ): VideoEncoderFactory { |
| 193 | return videoEncoderFactoryOverride ?: if (videoHwAccel) { | 197 | return videoEncoderFactoryOverride ?: if (videoHwAccel) { |
| 194 | SimulcastVideoEncoderFactoryWrapper( | 198 | SimulcastVideoEncoderFactoryWrapper( |
| @@ -211,7 +215,7 @@ object RTCModule { | @@ -211,7 +215,7 @@ object RTCModule { | ||
| 211 | eglContext: EglBase.Context, | 215 | eglContext: EglBase.Context, |
| 212 | @Named(InjectionNames.OVERRIDE_VIDEO_DECODER_FACTORY) | 216 | @Named(InjectionNames.OVERRIDE_VIDEO_DECODER_FACTORY) |
| 213 | @Nullable | 217 | @Nullable |
| 214 | - videoDecoderFactoryOverride: VideoDecoderFactory? | 218 | + videoDecoderFactoryOverride: VideoDecoderFactory?, |
| 215 | ): VideoDecoderFactory { | 219 | ): VideoDecoderFactory { |
| 216 | return videoDecoderFactoryOverride ?: if (videoHwAccel) { | 220 | return videoDecoderFactoryOverride ?: if (videoHwAccel) { |
| 217 | WrappedVideoDecoderFactory(eglContext) | 221 | WrappedVideoDecoderFactory(eglContext) |
| @@ -39,7 +39,7 @@ object WebModule { | @@ -39,7 +39,7 @@ object WebModule { | ||
| 39 | fun okHttpClient( | 39 | fun okHttpClient( |
| 40 | @Named(InjectionNames.OVERRIDE_OKHTTP) | 40 | @Named(InjectionNames.OVERRIDE_OKHTTP) |
| 41 | @Nullable | 41 | @Nullable |
| 42 | - okHttpClientOverride: OkHttpClient? | 42 | + okHttpClientOverride: OkHttpClient?, |
| 43 | ): OkHttpClient { | 43 | ): OkHttpClient { |
| 44 | OkHttpClient.Builder() | 44 | OkHttpClient.Builder() |
| 45 | .pingInterval(20, TimeUnit.SECONDS) | 45 | .pingInterval(20, TimeUnit.SECONDS) |
| 1 | +/* | ||
| 2 | + * Copyright 2023 LiveKit, Inc. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 1 | package io.livekit.android.e2ee | 17 | package io.livekit.android.e2ee |
| 2 | 18 | ||
| 3 | import io.livekit.android.events.RoomEvent | 19 | import io.livekit.android.events.RoomEvent |
| @@ -70,10 +86,12 @@ constructor(keyProvider: KeyProvider) { | @@ -70,10 +86,12 @@ constructor(keyProvider: KeyProvider) { | ||
| 70 | LKLog.i { "Receiver::onFrameCryptionStateChanged: $trackId, state: $state" } | 86 | LKLog.i { "Receiver::onFrameCryptionStateChanged: $trackId, state: $state" } |
| 71 | emitEvent( | 87 | emitEvent( |
| 72 | RoomEvent.TrackE2EEStateEvent( | 88 | RoomEvent.TrackE2EEStateEvent( |
| 73 | - room!!, publication.track!!, publication, | 89 | + room!!, |
| 90 | + publication.track!!, | ||
| 91 | + publication, | ||
| 74 | participant, | 92 | participant, |
| 75 | - state = e2eeStateFromFrameCryptoState(state) | ||
| 76 | - ) | 93 | + state = e2eeStateFromFrameCryptoState(state), |
| 94 | + ), | ||
| 77 | ) | 95 | ) |
| 78 | } | 96 | } |
| 79 | } | 97 | } |
| @@ -94,10 +112,12 @@ constructor(keyProvider: KeyProvider) { | @@ -94,10 +112,12 @@ constructor(keyProvider: KeyProvider) { | ||
| 94 | LKLog.i { "Sender::onFrameCryptionStateChanged: $trackId, state: $state" } | 112 | LKLog.i { "Sender::onFrameCryptionStateChanged: $trackId, state: $state" } |
| 95 | emitEvent( | 113 | emitEvent( |
| 96 | RoomEvent.TrackE2EEStateEvent( | 114 | RoomEvent.TrackE2EEStateEvent( |
| 97 | - room!!, publication.track!!, publication, | 115 | + room!!, |
| 116 | + publication.track!!, | ||
| 117 | + publication, | ||
| 98 | participant, | 118 | participant, |
| 99 | - state = e2eeStateFromFrameCryptoState(state) | ||
| 100 | - ) | 119 | + state = e2eeStateFromFrameCryptoState(state), |
| 120 | + ), | ||
| 101 | ) | 121 | ) |
| 102 | } | 122 | } |
| 103 | } | 123 | } |
| @@ -111,18 +131,22 @@ constructor(keyProvider: KeyProvider) { | @@ -111,18 +131,22 @@ constructor(keyProvider: KeyProvider) { | ||
| 111 | FrameCryptionState.ENCRYPTIONFAILED -> E2EEState.ENCRYPTION_FAILED | 131 | FrameCryptionState.ENCRYPTIONFAILED -> E2EEState.ENCRYPTION_FAILED |
| 112 | FrameCryptionState.DECRYPTIONFAILED -> E2EEState.DECRYPTION_FAILED | 132 | FrameCryptionState.DECRYPTIONFAILED -> E2EEState.DECRYPTION_FAILED |
| 113 | FrameCryptionState.INTERNALERROR -> E2EEState.INTERNAL_ERROR | 133 | FrameCryptionState.INTERNALERROR -> E2EEState.INTERNAL_ERROR |
| 114 | - else -> { E2EEState.INTERNAL_ERROR} | 134 | + else -> { E2EEState.INTERNAL_ERROR } |
| 115 | } | 135 | } |
| 116 | } | 136 | } |
| 117 | 137 | ||
| 118 | - private fun addRtpSender(sender: RtpSender, participantId: String, trackId: String , kind: String): FrameCryptor { | 138 | + private fun addRtpSender(sender: RtpSender, participantId: String, trackId: String, kind: String): FrameCryptor { |
| 119 | var pid = "$kind-sender-$participantId-$trackId" | 139 | var pid = "$kind-sender-$participantId-$trackId" |
| 120 | var frameCryptor = FrameCryptorFactory.createFrameCryptorForRtpSender( | 140 | var frameCryptor = FrameCryptorFactory.createFrameCryptorForRtpSender( |
| 121 | - sender, pid, algorithm, keyProvider.rtcKeyProvider) | 141 | + sender, |
| 142 | + pid, | ||
| 143 | + algorithm, | ||
| 144 | + keyProvider.rtcKeyProvider, | ||
| 145 | + ) | ||
| 122 | 146 | ||
| 123 | frameCryptors[trackId] = frameCryptor | 147 | frameCryptors[trackId] = frameCryptor |
| 124 | frameCryptor.setEnabled(enabled) | 148 | frameCryptor.setEnabled(enabled) |
| 125 | - if(keyProvider.enableSharedKey) { | 149 | + if (keyProvider.enableSharedKey) { |
| 126 | keyProvider.rtcKeyProvider?.setKey(pid, 0, keyProvider?.sharedKey) | 150 | keyProvider.rtcKeyProvider?.setKey(pid, 0, keyProvider?.sharedKey) |
| 127 | frameCryptor.setKeyIndex(0) | 151 | frameCryptor.setKeyIndex(0) |
| 128 | } | 152 | } |
| @@ -133,12 +157,16 @@ constructor(keyProvider: KeyProvider) { | @@ -133,12 +157,16 @@ constructor(keyProvider: KeyProvider) { | ||
| 133 | private fun addRtpReceiver(receiver: RtpReceiver, participantId: String, trackId: String, kind: String): FrameCryptor { | 157 | private fun addRtpReceiver(receiver: RtpReceiver, participantId: String, trackId: String, kind: String): FrameCryptor { |
| 134 | var pid = "$kind-receiver-$participantId-$trackId" | 158 | var pid = "$kind-receiver-$participantId-$trackId" |
| 135 | var frameCryptor = FrameCryptorFactory.createFrameCryptorForRtpReceiver( | 159 | var frameCryptor = FrameCryptorFactory.createFrameCryptorForRtpReceiver( |
| 136 | - receiver, pid, algorithm, keyProvider.rtcKeyProvider) | 160 | + receiver, |
| 161 | + pid, | ||
| 162 | + algorithm, | ||
| 163 | + keyProvider.rtcKeyProvider, | ||
| 164 | + ) | ||
| 137 | 165 | ||
| 138 | frameCryptors[trackId] = frameCryptor | 166 | frameCryptors[trackId] = frameCryptor |
| 139 | frameCryptor.setEnabled(enabled) | 167 | frameCryptor.setEnabled(enabled) |
| 140 | 168 | ||
| 141 | - if(keyProvider.enableSharedKey) { | 169 | + if (keyProvider.enableSharedKey) { |
| 142 | keyProvider.rtcKeyProvider?.setKey(pid, 0, keyProvider?.sharedKey) | 170 | keyProvider.rtcKeyProvider?.setKey(pid, 0, keyProvider?.sharedKey) |
| 143 | frameCryptor.setKeyIndex(0) | 171 | frameCryptor.setKeyIndex(0) |
| 144 | } | 172 | } |
| @@ -156,7 +184,7 @@ constructor(keyProvider: KeyProvider) { | @@ -156,7 +184,7 @@ constructor(keyProvider: KeyProvider) { | ||
| 156 | var frameCryptor = item.value | 184 | var frameCryptor = item.value |
| 157 | var participantId = item.key | 185 | var participantId = item.key |
| 158 | frameCryptor.setEnabled(enabled) | 186 | frameCryptor.setEnabled(enabled) |
| 159 | - if(keyProvider.enableSharedKey) { | 187 | + if (keyProvider.enableSharedKey) { |
| 160 | keyProvider.rtcKeyProvider?.setKey(participantId, 0, keyProvider?.sharedKey) | 188 | keyProvider.rtcKeyProvider?.setKey(participantId, 0, keyProvider?.sharedKey) |
| 161 | frameCryptor.setKeyIndex(0) | 189 | frameCryptor.setKeyIndex(0) |
| 162 | } | 190 | } |
| @@ -169,7 +197,7 @@ constructor(keyProvider: KeyProvider) { | @@ -169,7 +197,7 @@ constructor(keyProvider: KeyProvider) { | ||
| 169 | fun ratchetKey() { | 197 | fun ratchetKey() { |
| 170 | for (participantId in frameCryptors.keys) { | 198 | for (participantId in frameCryptors.keys) { |
| 171 | var newKey = keyProvider.rtcKeyProvider?.ratchetKey(participantId, 0) | 199 | var newKey = keyProvider.rtcKeyProvider?.ratchetKey(participantId, 0) |
| 172 | - LKLog.d{ "ratchetKey: newKey: $newKey" } | 200 | + LKLog.d { "ratchetKey: newKey: $newKey" } |
| 173 | } | 201 | } |
| 174 | } | 202 | } |
| 175 | 203 |
| 1 | +/* | ||
| 2 | + * Copyright 2023 LiveKit, Inc. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 1 | package io.livekit.android.e2ee | 17 | package io.livekit.android.e2ee |
| 2 | 18 | ||
| 3 | import livekit.LivekitModels.Encryption | 19 | import livekit.LivekitModels.Encryption |
| @@ -15,7 +31,8 @@ constructor( | @@ -15,7 +31,8 @@ constructor( | ||
| 15 | defaultRatchetWindowSize, | 31 | defaultRatchetWindowSize, |
| 16 | true, | 32 | true, |
| 17 | defaultFaultTolerance, | 33 | defaultFaultTolerance, |
| 18 | - ), encryptionType: Encryption.Type = Encryption.Type.GCM | 34 | + ), |
| 35 | + encryptionType: Encryption.Type = Encryption.Type.GCM, | ||
| 19 | ) { | 36 | ) { |
| 20 | var keyProvider: KeyProvider | 37 | var keyProvider: KeyProvider |
| 21 | var encryptionType: Encryption.Type = Encryption.Type.NONE | 38 | var encryptionType: Encryption.Type = Encryption.Type.NONE |
| 1 | +/* | ||
| 2 | + * Copyright 2023 LiveKit, Inc. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 1 | package io.livekit.android.e2ee | 17 | package io.livekit.android.e2ee |
| 2 | 18 | ||
| 3 | enum class E2EEState { | 19 | enum class E2EEState { |
| @@ -7,5 +23,5 @@ enum class E2EEState { | @@ -7,5 +23,5 @@ enum class E2EEState { | ||
| 7 | MISSING_KEY, // missing key | 23 | MISSING_KEY, // missing key |
| 8 | ENCRYPTION_FAILED, // encryption failed | 24 | ENCRYPTION_FAILED, // encryption failed |
| 9 | DECRYPTION_FAILED, // decryption failed | 25 | DECRYPTION_FAILED, // decryption failed |
| 10 | - INTERNAL_ERROR // internal error | 26 | + INTERNAL_ERROR, // internal error |
| 11 | } | 27 | } |
| 1 | +/* | ||
| 2 | + * Copyright 2023 LiveKit, Inc. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 1 | package io.livekit.android.e2ee | 17 | package io.livekit.android.e2ee |
| 2 | 18 | ||
| 3 | import io.livekit.android.util.LKLog | 19 | import io.livekit.android.util.LKLog |
| @@ -5,13 +21,13 @@ import org.webrtc.FrameCryptorFactory | @@ -5,13 +21,13 @@ import org.webrtc.FrameCryptorFactory | ||
| 5 | import org.webrtc.FrameCryptorKeyProvider | 21 | import org.webrtc.FrameCryptorKeyProvider |
| 6 | 22 | ||
| 7 | class KeyInfo | 23 | class KeyInfo |
| 8 | -constructor(var participantId: String, var keyIndex: Int, var key: String ) { | 24 | +constructor(var participantId: String, var keyIndex: Int, var key: String) { |
| 9 | override fun toString(): String { | 25 | override fun toString(): String { |
| 10 | return "KeyInfo(participantId='$participantId', keyIndex=$keyIndex)" | 26 | return "KeyInfo(participantId='$participantId', keyIndex=$keyIndex)" |
| 11 | } | 27 | } |
| 12 | } | 28 | } |
| 13 | 29 | ||
| 14 | - public interface KeyProvider { | 30 | +public interface KeyProvider { |
| 15 | fun setKey(key: String, participantId: String?, keyIndex: Int? = 0) | 31 | fun setKey(key: String, participantId: String?, keyIndex: Int? = 0) |
| 16 | fun ratchetKey(participantId: String, index: Int): ByteArray | 32 | fun ratchetKey(participantId: String, index: Int): ByteArray |
| 17 | 33 | ||
| @@ -28,7 +44,7 @@ constructor( | @@ -28,7 +44,7 @@ constructor( | ||
| 28 | private var uncryptedMagicBytes: String, | 44 | private var uncryptedMagicBytes: String, |
| 29 | private var ratchetWindowSize: Int, | 45 | private var ratchetWindowSize: Int, |
| 30 | override var enableSharedKey: Boolean = true, | 46 | override var enableSharedKey: Boolean = true, |
| 31 | - private var failureTolerance:Int, | 47 | + private var failureTolerance: Int, |
| 32 | ) : | 48 | ) : |
| 33 | KeyProvider { | 49 | KeyProvider { |
| 34 | override var sharedKey: ByteArray? = null | 50 | override var sharedKey: ByteArray? = null |
| @@ -46,8 +62,8 @@ constructor( | @@ -46,8 +62,8 @@ constructor( | ||
| 46 | return | 62 | return |
| 47 | } | 63 | } |
| 48 | 64 | ||
| 49 | - if(participantId == null) { | ||
| 50 | - LKLog.d{ "Please provide valid participantId for non-SharedKey mode." } | 65 | + if (participantId == null) { |
| 66 | + LKLog.d { "Please provide valid participantId for non-SharedKey mode." } | ||
| 51 | return | 67 | return |
| 52 | } | 68 | } |
| 53 | 69 | ||
| @@ -72,7 +88,7 @@ constructor( | @@ -72,7 +88,7 @@ constructor( | ||
| 72 | ratchetSalt.toByteArray(), | 88 | ratchetSalt.toByteArray(), |
| 73 | ratchetWindowSize, | 89 | ratchetWindowSize, |
| 74 | uncryptedMagicBytes.toByteArray(), | 90 | uncryptedMagicBytes.toByteArray(), |
| 75 | - failureTolerance | 91 | + failureTolerance, |
| 76 | ) | 92 | ) |
| 77 | } | 93 | } |
| 78 | } | 94 | } |
| @@ -58,7 +58,6 @@ sealed class ParticipantEvent(open val participant: Participant) : Event() { | @@ -58,7 +58,6 @@ sealed class ParticipantEvent(open val participant: Participant) : Event() { | ||
| 58 | */ | 58 | */ |
| 59 | class TrackUnmuted(participant: Participant, val publication: TrackPublication) : ParticipantEvent(participant) | 59 | class TrackUnmuted(participant: Participant, val publication: TrackPublication) : ParticipantEvent(participant) |
| 60 | 60 | ||
| 61 | - | ||
| 62 | // local participants | 61 | // local participants |
| 63 | /** | 62 | /** |
| 64 | * When a new track is published by the local participant. | 63 | * When a new track is published by the local participant. |
| @@ -113,7 +112,7 @@ sealed class ParticipantEvent(open val participant: Participant) : Event() { | @@ -113,7 +112,7 @@ sealed class ParticipantEvent(open val participant: Participant) : Event() { | ||
| 113 | class TrackUnsubscribed( | 112 | class TrackUnsubscribed( |
| 114 | override val participant: RemoteParticipant, | 113 | override val participant: RemoteParticipant, |
| 115 | val track: Track, | 114 | val track: Track, |
| 116 | - val publication: RemoteTrackPublication | 115 | + val publication: RemoteTrackPublication, |
| 117 | ) : ParticipantEvent(participant) | 116 | ) : ParticipantEvent(participant) |
| 118 | 117 | ||
| 119 | /** | 118 | /** |
| @@ -122,7 +121,7 @@ sealed class ParticipantEvent(open val participant: Participant) : Event() { | @@ -122,7 +121,7 @@ sealed class ParticipantEvent(open val participant: Participant) : Event() { | ||
| 122 | class DataReceived( | 121 | class DataReceived( |
| 123 | override val participant: RemoteParticipant, | 122 | override val participant: RemoteParticipant, |
| 124 | val data: ByteArray, | 123 | val data: ByteArray, |
| 125 | - val topic: String? | 124 | + val topic: String?, |
| 126 | ) : ParticipantEvent(participant) | 125 | ) : ParticipantEvent(participant) |
| 127 | 126 | ||
| 128 | /** | 127 | /** |
| @@ -131,17 +130,16 @@ sealed class ParticipantEvent(open val participant: Participant) : Event() { | @@ -131,17 +130,16 @@ sealed class ParticipantEvent(open val participant: Participant) : Event() { | ||
| 131 | class TrackStreamStateChanged( | 130 | class TrackStreamStateChanged( |
| 132 | override val participant: Participant, | 131 | override val participant: Participant, |
| 133 | val trackPublication: TrackPublication, | 132 | val trackPublication: TrackPublication, |
| 134 | - val streamState: Track.StreamState | 133 | + val streamState: Track.StreamState, |
| 135 | ) : ParticipantEvent(participant) | 134 | ) : ParticipantEvent(participant) |
| 136 | 135 | ||
| 137 | - | ||
| 138 | /** | 136 | /** |
| 139 | * A remote track's subscription permissions have changed. | 137 | * A remote track's subscription permissions have changed. |
| 140 | */ | 138 | */ |
| 141 | class TrackSubscriptionPermissionChanged( | 139 | class TrackSubscriptionPermissionChanged( |
| 142 | override val participant: RemoteParticipant, | 140 | override val participant: RemoteParticipant, |
| 143 | val trackPublication: RemoteTrackPublication, | 141 | val trackPublication: RemoteTrackPublication, |
| 144 | - val subscriptionAllowed: Boolean | 142 | + val subscriptionAllowed: Boolean, |
| 145 | ) : ParticipantEvent(participant) | 143 | ) : ParticipantEvent(participant) |
| 146 | 144 | ||
| 147 | /** | 145 | /** |
| @@ -62,7 +62,7 @@ sealed class RoomEvent(val room: Room) : Event() { | @@ -62,7 +62,7 @@ sealed class RoomEvent(val room: Room) : Event() { | ||
| 62 | class RoomMetadataChanged( | 62 | class RoomMetadataChanged( |
| 63 | room: Room, | 63 | room: Room, |
| 64 | val newMetadata: String?, | 64 | val newMetadata: String?, |
| 65 | - val prevMetadata: String? | 65 | + val prevMetadata: String?, |
| 66 | ) : RoomEvent(room) | 66 | ) : RoomEvent(room) |
| 67 | 67 | ||
| 68 | // Participant callbacks | 68 | // Participant callbacks |
| @@ -74,13 +74,13 @@ sealed class RoomEvent(val room: Room) : Event() { | @@ -74,13 +74,13 @@ sealed class RoomEvent(val room: Room) : Event() { | ||
| 74 | class ParticipantMetadataChanged( | 74 | class ParticipantMetadataChanged( |
| 75 | room: Room, | 75 | room: Room, |
| 76 | val participant: Participant, | 76 | val participant: Participant, |
| 77 | - val prevMetadata: String? | 77 | + val prevMetadata: String?, |
| 78 | ) : RoomEvent(room) | 78 | ) : RoomEvent(room) |
| 79 | 79 | ||
| 80 | class ParticipantNameChanged( | 80 | class ParticipantNameChanged( |
| 81 | room: Room, | 81 | room: Room, |
| 82 | val participant: Participant, | 82 | val participant: Participant, |
| 83 | - val name: String? | 83 | + val name: String?, |
| 84 | ) : RoomEvent(room) | 84 | ) : RoomEvent(room) |
| 85 | 85 | ||
| 86 | /** | 86 | /** |
| @@ -119,7 +119,7 @@ sealed class RoomEvent(val room: Room) : Event() { | @@ -119,7 +119,7 @@ sealed class RoomEvent(val room: Room) : Event() { | ||
| 119 | room: Room, | 119 | room: Room, |
| 120 | val track: Track, | 120 | val track: Track, |
| 121 | val publication: TrackPublication, | 121 | val publication: TrackPublication, |
| 122 | - val participant: RemoteParticipant | 122 | + val participant: RemoteParticipant, |
| 123 | ) : RoomEvent(room) | 123 | ) : RoomEvent(room) |
| 124 | 124 | ||
| 125 | /** | 125 | /** |
| @@ -129,7 +129,7 @@ sealed class RoomEvent(val room: Room) : Event() { | @@ -129,7 +129,7 @@ sealed class RoomEvent(val room: Room) : Event() { | ||
| 129 | room: Room, | 129 | room: Room, |
| 130 | val sid: String, | 130 | val sid: String, |
| 131 | val exception: Exception, | 131 | val exception: Exception, |
| 132 | - val participant: RemoteParticipant | 132 | + val participant: RemoteParticipant, |
| 133 | ) : RoomEvent(room) | 133 | ) : RoomEvent(room) |
| 134 | 134 | ||
| 135 | /** | 135 | /** |
| @@ -140,7 +140,7 @@ sealed class RoomEvent(val room: Room) : Event() { | @@ -140,7 +140,7 @@ sealed class RoomEvent(val room: Room) : Event() { | ||
| 140 | room: Room, | 140 | room: Room, |
| 141 | val track: Track, | 141 | val track: Track, |
| 142 | val publications: TrackPublication, | 142 | val publications: TrackPublication, |
| 143 | - val participant: RemoteParticipant | 143 | + val participant: RemoteParticipant, |
| 144 | ) : RoomEvent(room) | 144 | ) : RoomEvent(room) |
| 145 | 145 | ||
| 146 | /** | 146 | /** |
| @@ -149,7 +149,7 @@ sealed class RoomEvent(val room: Room) : Event() { | @@ -149,7 +149,7 @@ sealed class RoomEvent(val room: Room) : Event() { | ||
| 149 | class TrackStreamStateChanged( | 149 | class TrackStreamStateChanged( |
| 150 | room: Room, | 150 | room: Room, |
| 151 | val trackPublication: TrackPublication, | 151 | val trackPublication: TrackPublication, |
| 152 | - val streamState: Track.StreamState | 152 | + val streamState: Track.StreamState, |
| 153 | ) : RoomEvent(room) | 153 | ) : RoomEvent(room) |
| 154 | 154 | ||
| 155 | /** | 155 | /** |
| @@ -159,7 +159,7 @@ sealed class RoomEvent(val room: Room) : Event() { | @@ -159,7 +159,7 @@ sealed class RoomEvent(val room: Room) : Event() { | ||
| 159 | room: Room, | 159 | room: Room, |
| 160 | val participant: RemoteParticipant, | 160 | val participant: RemoteParticipant, |
| 161 | val trackPublication: RemoteTrackPublication, | 161 | val trackPublication: RemoteTrackPublication, |
| 162 | - val subscriptionAllowed: Boolean | 162 | + val subscriptionAllowed: Boolean, |
| 163 | ) : RoomEvent(room) | 163 | ) : RoomEvent(room) |
| 164 | 164 | ||
| 165 | /** | 165 | /** |
| @@ -207,7 +207,7 @@ sealed class RoomEvent(val room: Room) : Event() { | @@ -207,7 +207,7 @@ sealed class RoomEvent(val room: Room) : Event() { | ||
| 207 | val track: Track, | 207 | val track: Track, |
| 208 | val publication: TrackPublication, | 208 | val publication: TrackPublication, |
| 209 | val participant: Participant, | 209 | val participant: Participant, |
| 210 | - var state: E2EEState | 210 | + var state: E2EEState, |
| 211 | ) : RoomEvent(room) | 211 | ) : RoomEvent(room) |
| 212 | } | 212 | } |
| 213 | 213 | ||
| @@ -219,7 +219,7 @@ enum class DisconnectReason { | @@ -219,7 +219,7 @@ enum class DisconnectReason { | ||
| 219 | PARTICIPANT_REMOVED, | 219 | PARTICIPANT_REMOVED, |
| 220 | ROOM_DELETED, | 220 | ROOM_DELETED, |
| 221 | STATE_MISMATCH, | 221 | STATE_MISMATCH, |
| 222 | - JOIN_FAILURE; | 222 | + JOIN_FAILURE, |
| 223 | } | 223 | } |
| 224 | 224 | ||
| 225 | fun LivekitModels.DisconnectReason?.convert(): DisconnectReason { | 225 | fun LivekitModels.DisconnectReason?.convert(): DisconnectReason { |
| @@ -233,6 +233,7 @@ fun LivekitModels.DisconnectReason?.convert(): DisconnectReason { | @@ -233,6 +233,7 @@ fun LivekitModels.DisconnectReason?.convert(): DisconnectReason { | ||
| 233 | LivekitModels.DisconnectReason.JOIN_FAILURE -> DisconnectReason.JOIN_FAILURE | 233 | LivekitModels.DisconnectReason.JOIN_FAILURE -> DisconnectReason.JOIN_FAILURE |
| 234 | LivekitModels.DisconnectReason.UNKNOWN_REASON, | 234 | LivekitModels.DisconnectReason.UNKNOWN_REASON, |
| 235 | LivekitModels.DisconnectReason.UNRECOGNIZED, | 235 | LivekitModels.DisconnectReason.UNRECOGNIZED, |
| 236 | - null -> DisconnectReason.UNKNOWN_REASON | 236 | + null, |
| 237 | + -> DisconnectReason.UNKNOWN_REASON | ||
| 237 | } | 238 | } |
| 238 | } | 239 | } |
| @@ -23,12 +23,16 @@ import org.webrtc.* | @@ -23,12 +23,16 @@ import org.webrtc.* | ||
| 23 | import org.webrtc.RendererCommon.* | 23 | import org.webrtc.RendererCommon.* |
| 24 | import java.util.concurrent.CountDownLatch | 24 | import java.util.concurrent.CountDownLatch |
| 25 | 25 | ||
| 26 | - | ||
| 27 | /** | 26 | /** |
| 28 | * Display the video stream on a TextureView. | 27 | * Display the video stream on a TextureView. |
| 29 | */ | 28 | */ |
| 30 | -open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureView.SurfaceTextureListener, VideoSink, | ||
| 31 | - RendererEvents, ViewVisibility.Notifier { | 29 | +open class TextureViewRenderer : |
| 30 | + TextureView, | ||
| 31 | + SurfaceHolder.Callback, | ||
| 32 | + TextureView.SurfaceTextureListener, | ||
| 33 | + VideoSink, | ||
| 34 | + RendererEvents, | ||
| 35 | + ViewVisibility.Notifier { | ||
| 32 | // Cached resource name. | 36 | // Cached resource name. |
| 33 | private val resourceName: String | 37 | private val resourceName: String |
| 34 | private val videoLayoutMeasure = VideoLayoutMeasure() | 38 | private val videoLayoutMeasure = VideoLayoutMeasure() |
| @@ -68,6 +72,7 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | @@ -68,6 +72,7 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | ||
| 68 | * `drawer`. It is allowed to call init() to reinitialize the renderer after a previous | 72 | * `drawer`. It is allowed to call init() to reinitialize the renderer after a previous |
| 69 | * init()/release() cycle. | 73 | * init()/release() cycle. |
| 70 | */ | 74 | */ |
| 75 | + | ||
| 71 | /** | 76 | /** |
| 72 | * Initialize this class, sharing resources with `sharedContext`. It is allowed to call init() to | 77 | * Initialize this class, sharing resources with `sharedContext`. It is allowed to call init() to |
| 73 | * reinitialize the renderer after a previous init()/release() cycle. | 78 | * reinitialize the renderer after a previous init()/release() cycle. |
| @@ -75,14 +80,15 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | @@ -75,14 +80,15 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | ||
| 75 | @JvmOverloads | 80 | @JvmOverloads |
| 76 | fun init( | 81 | fun init( |
| 77 | sharedContext: EglBase.Context?, | 82 | sharedContext: EglBase.Context?, |
| 78 | - rendererEvents: RendererEvents?, configAttributes: IntArray? = EglBase.CONFIG_PLAIN, | ||
| 79 | - drawer: GlDrawer? = GlRectDrawer() | 83 | + rendererEvents: RendererEvents?, |
| 84 | + configAttributes: IntArray? = EglBase.CONFIG_PLAIN, | ||
| 85 | + drawer: GlDrawer? = GlRectDrawer(), | ||
| 80 | ) { | 86 | ) { |
| 81 | ThreadUtils.checkIsOnMainThread() | 87 | ThreadUtils.checkIsOnMainThread() |
| 82 | this.rendererEvents = rendererEvents | 88 | this.rendererEvents = rendererEvents |
| 83 | rotatedFrameWidth = 0 | 89 | rotatedFrameWidth = 0 |
| 84 | rotatedFrameHeight = 0 | 90 | rotatedFrameHeight = 0 |
| 85 | - eglRenderer.init(sharedContext, this /* rendererEvents */, configAttributes, drawer) | 91 | + eglRenderer.init(sharedContext, this, configAttributes, drawer) |
| 86 | } | 92 | } |
| 87 | 93 | ||
| 88 | /** | 94 | /** |
| @@ -105,7 +111,9 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | @@ -105,7 +111,9 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | ||
| 105 | * @param drawer Custom drawer to use for this frame listener. | 111 | * @param drawer Custom drawer to use for this frame listener. |
| 106 | */ | 112 | */ |
| 107 | fun addFrameListener( | 113 | fun addFrameListener( |
| 108 | - listener: EglRenderer.FrameListener?, scale: Float, drawerParam: GlDrawer? | 114 | + listener: EglRenderer.FrameListener?, |
| 115 | + scale: Float, | ||
| 116 | + drawerParam: GlDrawer?, | ||
| 109 | ) { | 117 | ) { |
| 110 | eglRenderer.addFrameListener(listener, scale, drawerParam) | 118 | eglRenderer.addFrameListener(listener, scale, drawerParam) |
| 111 | } | 119 | } |
| @@ -155,12 +163,12 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | @@ -155,12 +163,12 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | ||
| 155 | 163 | ||
| 156 | fun setScalingType( | 164 | fun setScalingType( |
| 157 | scalingTypeMatchOrientation: ScalingType?, | 165 | scalingTypeMatchOrientation: ScalingType?, |
| 158 | - scalingTypeMismatchOrientation: ScalingType? | 166 | + scalingTypeMismatchOrientation: ScalingType?, |
| 159 | ) { | 167 | ) { |
| 160 | ThreadUtils.checkIsOnMainThread() | 168 | ThreadUtils.checkIsOnMainThread() |
| 161 | videoLayoutMeasure.setScalingType( | 169 | videoLayoutMeasure.setScalingType( |
| 162 | scalingTypeMatchOrientation, | 170 | scalingTypeMatchOrientation, |
| 163 | - scalingTypeMismatchOrientation | 171 | + scalingTypeMismatchOrientation, |
| 164 | ) | 172 | ) |
| 165 | requestLayout() | 173 | requestLayout() |
| 166 | } | 174 | } |
| @@ -221,14 +229,14 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | @@ -221,14 +229,14 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | ||
| 221 | val width = Math.min(width, drawnFrameWidth) | 229 | val width = Math.min(width, drawnFrameWidth) |
| 222 | val height = Math.min(height, drawnFrameHeight) | 230 | val height = Math.min(height, drawnFrameHeight) |
| 223 | logD( | 231 | logD( |
| 224 | - "updateSurfaceSize. Layout size: " + getWidth() + "x" + getHeight() + ", frame size: " | ||
| 225 | - + rotatedFrameWidth + "x" + rotatedFrameHeight + ", requested surface size: " + width | ||
| 226 | - + "x" + height + ", old surface size: " + surfaceWidth + "x" + surfaceHeight | 232 | + "updateSurfaceSize. Layout size: " + getWidth() + "x" + getHeight() + ", frame size: " + |
| 233 | + rotatedFrameWidth + "x" + rotatedFrameHeight + ", requested surface size: " + width + | ||
| 234 | + "x" + height + ", old surface size: " + surfaceWidth + "x" + surfaceHeight, | ||
| 227 | ) | 235 | ) |
| 228 | if (width != surfaceWidth || height != surfaceHeight) { | 236 | if (width != surfaceWidth || height != surfaceHeight) { |
| 229 | surfaceWidth = width | 237 | surfaceWidth = width |
| 230 | surfaceHeight = height | 238 | surfaceHeight = height |
| 231 | - adjustAspectRatio(surfaceWidth, surfaceHeight); | 239 | + adjustAspectRatio(surfaceWidth, surfaceHeight) |
| 232 | } | 240 | } |
| 233 | } else { | 241 | } else { |
| 234 | surfaceHeight = 0 | 242 | surfaceHeight = 0 |
| @@ -257,8 +265,8 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | @@ -257,8 +265,8 @@ open class TextureViewRenderer : TextureView, SurfaceHolder.Callback, TextureVie | ||
| 257 | val xoff = (viewWidth - newWidth) / 2 | 265 | val xoff = (viewWidth - newWidth) / 2 |
| 258 | val yoff = (viewHeight - newHeight) / 2 | 266 | val yoff = (viewHeight - newHeight) / 2 |
| 259 | logD( | 267 | logD( |
| 260 | - "video=" + videoWidth + "x" + videoHeight + " view=" + viewWidth + "x" + viewHeight | ||
| 261 | - + " newView=" + newWidth + "x" + newHeight + " off=" + xoff + "," + yoff | 268 | + "video=" + videoWidth + "x" + videoHeight + " view=" + viewWidth + "x" + viewHeight + |
| 269 | + " newView=" + newWidth + "x" + newHeight + " off=" + xoff + "," + yoff, | ||
| 262 | ) | 270 | ) |
| 263 | val txform = Matrix() | 271 | val txform = Matrix() |
| 264 | getTransform(txform) | 272 | getTransform(txform) |
| @@ -27,7 +27,7 @@ object DeviceManager { | @@ -27,7 +27,7 @@ object DeviceManager { | ||
| 27 | 27 | ||
| 28 | enum class Kind { | 28 | enum class Kind { |
| 29 | // Only camera input currently, audio input/output only has one option atm. | 29 | // Only camera input currently, audio input/output only has one option atm. |
| 30 | - CAMERA; | 30 | + CAMERA, |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | private val defaultDevices = mutableMapOf<Kind, String>() | 33 | private val defaultDevices = mutableMapOf<Kind, String>() |
| @@ -44,7 +44,8 @@ object DeviceManager { | @@ -44,7 +44,8 @@ object DeviceManager { | ||
| 44 | 44 | ||
| 45 | hasSetupListeners = true | 45 | hasSetupListeners = true |
| 46 | val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager | 46 | val cameraManager = context.getSystemService(Context.CAMERA_SERVICE) as CameraManager |
| 47 | - cameraManager.registerAvailabilityCallback(object : CameraManager.AvailabilityCallback() { | 47 | + cameraManager.registerAvailabilityCallback( |
| 48 | + object : CameraManager.AvailabilityCallback() { | ||
| 48 | override fun onCameraAvailable(cameraId: String) { | 49 | override fun onCameraAvailable(cameraId: String) { |
| 49 | notifyListeners(Kind.CAMERA) | 50 | notifyListeners(Kind.CAMERA) |
| 50 | } | 51 | } |
| @@ -56,7 +57,9 @@ object DeviceManager { | @@ -56,7 +57,9 @@ object DeviceManager { | ||
| 56 | override fun onCameraAccessPrioritiesChanged() { | 57 | override fun onCameraAccessPrioritiesChanged() { |
| 57 | notifyListeners(Kind.CAMERA) | 58 | notifyListeners(Kind.CAMERA) |
| 58 | } | 59 | } |
| 59 | - }, Handler(Looper.getMainLooper())) | 60 | + }, |
| 61 | + Handler(Looper.getMainLooper()), | ||
| 62 | + ) | ||
| 60 | } | 63 | } |
| 61 | 64 | ||
| 62 | fun getDefaultDevice(kind: Kind): String? { | 65 | fun getDefaultDevice(kind: Kind): String? { |
| @@ -89,7 +92,7 @@ object DeviceManager { | @@ -89,7 +92,7 @@ object DeviceManager { | ||
| 89 | 92 | ||
| 90 | fun registerOnDeviceAvailabilityChange( | 93 | fun registerOnDeviceAvailabilityChange( |
| 91 | kind: Kind, | 94 | kind: Kind, |
| 92 | - listener: OnDeviceAvailabilityChangeListener | 95 | + listener: OnDeviceAvailabilityChangeListener, |
| 93 | ) { | 96 | ) { |
| 94 | if (listeners[kind] == null) { | 97 | if (listeners[kind] == null) { |
| 95 | listeners[kind] = mutableListOf() | 98 | listeners[kind] = mutableListOf() |
| @@ -99,7 +102,7 @@ object DeviceManager { | @@ -99,7 +102,7 @@ object DeviceManager { | ||
| 99 | 102 | ||
| 100 | fun unregisterOnDeviceAvailabilityChange( | 103 | fun unregisterOnDeviceAvailabilityChange( |
| 101 | kind: Kind, | 104 | kind: Kind, |
| 102 | - listener: OnDeviceAvailabilityChangeListener | 105 | + listener: OnDeviceAvailabilityChangeListener, |
| 103 | ) { | 106 | ) { |
| 104 | listeners[kind]?.remove(listener) | 107 | listeners[kind]?.remove(listener) |
| 105 | } | 108 | } |
| @@ -45,12 +45,12 @@ constructor( | @@ -45,12 +45,12 @@ constructor( | ||
| 45 | @Assisted private val listener: Listener?, | 45 | @Assisted private val listener: Listener?, |
| 46 | @Named(InjectionNames.DISPATCHER_IO) | 46 | @Named(InjectionNames.DISPATCHER_IO) |
| 47 | private val ioDispatcher: CoroutineDispatcher, | 47 | private val ioDispatcher: CoroutineDispatcher, |
| 48 | - connectionFactory: PeerConnectionFactory | 48 | + connectionFactory: PeerConnectionFactory, |
| 49 | ) { | 49 | ) { |
| 50 | private val coroutineScope = CoroutineScope(ioDispatcher + SupervisorJob()) | 50 | private val coroutineScope = CoroutineScope(ioDispatcher + SupervisorJob()) |
| 51 | internal val peerConnection: PeerConnection = connectionFactory.createPeerConnection( | 51 | internal val peerConnection: PeerConnection = connectionFactory.createPeerConnection( |
| 52 | config, | 52 | config, |
| 53 | - pcObserver | 53 | + pcObserver, |
| 54 | ) ?: throw IllegalStateException("peer connection creation failed?") | 54 | ) ?: throw IllegalStateException("peer connection creation failed?") |
| 55 | private val pendingCandidates = mutableListOf<IceCandidate>() | 55 | private val pendingCandidates = mutableListOf<IceCandidate>() |
| 56 | private var restartingIce: Boolean = false | 56 | private var restartingIce: Boolean = false |
| @@ -76,7 +76,6 @@ constructor( | @@ -76,7 +76,6 @@ constructor( | ||
| 76 | } | 76 | } |
| 77 | 77 | ||
| 78 | suspend fun setRemoteDescription(sd: SessionDescription): Either<Unit, String?> { | 78 | suspend fun setRemoteDescription(sd: SessionDescription): Either<Unit, String?> { |
| 79 | - | ||
| 80 | val result = peerConnection.setRemoteDescription(sd) | 79 | val result = peerConnection.setRemoteDescription(sd) |
| 81 | if (result is Either.Left) { | 80 | if (result is Either.Left) { |
| 82 | mutex.withLock { | 81 | mutex.withLock { |
| @@ -145,7 +144,6 @@ constructor( | @@ -145,7 +144,6 @@ constructor( | ||
| 145 | listener?.onOffer(sdpOffer) | 144 | listener?.onOffer(sdpOffer) |
| 146 | } | 145 | } |
| 147 | 146 | ||
| 148 | - | ||
| 149 | fun prepareForIceRestart() { | 147 | fun prepareForIceRestart() { |
| 150 | restartingIce = true | 148 | restartingIce = true |
| 151 | } | 149 | } |
| @@ -163,7 +161,7 @@ constructor( | @@ -163,7 +161,7 @@ constructor( | ||
| 163 | fun create( | 161 | fun create( |
| 164 | config: PeerConnection.RTCConfiguration, | 162 | config: PeerConnection.RTCConfiguration, |
| 165 | pcObserver: PeerConnection.Observer, | 163 | pcObserver: PeerConnection.Observer, |
| 166 | - listener: Listener? | 164 | + listener: Listener?, |
| 167 | ): PeerConnectionTransport | 165 | ): PeerConnectionTransport |
| 168 | } | 166 | } |
| 169 | } | 167 | } |
| @@ -21,7 +21,6 @@ import com.google.protobuf.ByteString | @@ -21,7 +21,6 @@ import com.google.protobuf.ByteString | ||
| 21 | import io.livekit.android.ConnectOptions | 21 | import io.livekit.android.ConnectOptions |
| 22 | import io.livekit.android.RoomOptions | 22 | import io.livekit.android.RoomOptions |
| 23 | import io.livekit.android.dagger.InjectionNames | 23 | import io.livekit.android.dagger.InjectionNames |
| 24 | -import io.livekit.android.e2ee.E2EEOptions | ||
| 25 | import io.livekit.android.events.DisconnectReason | 24 | import io.livekit.android.events.DisconnectReason |
| 26 | import io.livekit.android.events.convert | 25 | import io.livekit.android.events.convert |
| 27 | import io.livekit.android.room.participant.ParticipantTrackPermission | 26 | import io.livekit.android.room.participant.ParticipantTrackPermission |
| @@ -39,7 +38,6 @@ import io.livekit.android.webrtc.toProtoSessionDescription | @@ -39,7 +38,6 @@ import io.livekit.android.webrtc.toProtoSessionDescription | ||
| 39 | import kotlinx.coroutines.* | 38 | import kotlinx.coroutines.* |
| 40 | import kotlinx.coroutines.sync.Mutex | 39 | import kotlinx.coroutines.sync.Mutex |
| 41 | import livekit.LivekitModels | 40 | import livekit.LivekitModels |
| 42 | -import livekit.LivekitModels.Encryption | ||
| 43 | import livekit.LivekitRtc | 41 | import livekit.LivekitRtc |
| 44 | import livekit.LivekitRtc.JoinResponse | 42 | import livekit.LivekitRtc.JoinResponse |
| 45 | import livekit.LivekitRtc.ReconnectResponse | 43 | import livekit.LivekitRtc.ReconnectResponse |
| @@ -150,7 +148,7 @@ internal constructor( | @@ -150,7 +148,7 @@ internal constructor( | ||
| 150 | url: String, | 148 | url: String, |
| 151 | token: String, | 149 | token: String, |
| 152 | options: ConnectOptions, | 150 | options: ConnectOptions, |
| 153 | - roomOptions: RoomOptions | 151 | + roomOptions: RoomOptions, |
| 154 | ): JoinResponse { | 152 | ): JoinResponse { |
| 155 | coroutineScope.close() | 153 | coroutineScope.close() |
| 156 | coroutineScope = CloseableCoroutineScope(SupervisorJob() + ioDispatcher) | 154 | coroutineScope = CloseableCoroutineScope(SupervisorJob() + ioDispatcher) |
| @@ -165,7 +163,7 @@ internal constructor( | @@ -165,7 +163,7 @@ internal constructor( | ||
| 165 | url: String, | 163 | url: String, |
| 166 | token: String, | 164 | token: String, |
| 167 | options: ConnectOptions, | 165 | options: ConnectOptions, |
| 168 | - roomOptions: RoomOptions | 166 | + roomOptions: RoomOptions, |
| 169 | ): JoinResponse { | 167 | ): JoinResponse { |
| 170 | val joinResponse = client.join(url, token, options, roomOptions) | 168 | val joinResponse = client.join(url, token, options, roomOptions) |
| 171 | listener?.onJoinResponse(joinResponse) | 169 | listener?.onJoinResponse(joinResponse) |
| @@ -248,7 +246,7 @@ internal constructor( | @@ -248,7 +246,7 @@ internal constructor( | ||
| 248 | reliableInit.ordered = true | 246 | reliableInit.ordered = true |
| 249 | reliableDataChannel = publisher.peerConnection.createDataChannel( | 247 | reliableDataChannel = publisher.peerConnection.createDataChannel( |
| 250 | RELIABLE_DATA_CHANNEL_LABEL, | 248 | RELIABLE_DATA_CHANNEL_LABEL, |
| 251 | - reliableInit | 249 | + reliableInit, |
| 252 | ) | 250 | ) |
| 253 | reliableDataChannel!!.registerObserver(this) | 251 | reliableDataChannel!!.registerObserver(this) |
| 254 | val lossyInit = DataChannel.Init() | 252 | val lossyInit = DataChannel.Init() |
| @@ -256,7 +254,7 @@ internal constructor( | @@ -256,7 +254,7 @@ internal constructor( | ||
| 256 | lossyInit.maxRetransmits = 0 | 254 | lossyInit.maxRetransmits = 0 |
| 257 | lossyDataChannel = publisher.peerConnection.createDataChannel( | 255 | lossyDataChannel = publisher.peerConnection.createDataChannel( |
| 258 | LOSSY_DATA_CHANNEL_LABEL, | 256 | LOSSY_DATA_CHANNEL_LABEL, |
| 259 | - lossyInit | 257 | + lossyInit, |
| 260 | ) | 258 | ) |
| 261 | lossyDataChannel!!.registerObserver(this) | 259 | lossyDataChannel!!.registerObserver(this) |
| 262 | } | 260 | } |
| @@ -268,7 +266,7 @@ internal constructor( | @@ -268,7 +266,7 @@ internal constructor( | ||
| 268 | cid: String, | 266 | cid: String, |
| 269 | name: String, | 267 | name: String, |
| 270 | kind: LivekitModels.TrackType, | 268 | kind: LivekitModels.TrackType, |
| 271 | - builder: LivekitRtc.AddTrackRequest.Builder = LivekitRtc.AddTrackRequest.newBuilder() | 269 | + builder: LivekitRtc.AddTrackRequest.Builder = LivekitRtc.AddTrackRequest.newBuilder(), |
| 272 | ): LivekitModels.TrackInfo { | 270 | ): LivekitModels.TrackInfo { |
| 273 | if (pendingTrackResolvers[cid] != null) { | 271 | if (pendingTrackResolvers[cid] != null) { |
| 274 | throw TrackException.DuplicateTrackException("Track with same ID $cid has already been published!") | 272 | throw TrackException.DuplicateTrackException("Track with same ID $cid has already been published!") |
| @@ -282,7 +280,7 @@ internal constructor( | @@ -282,7 +280,7 @@ internal constructor( | ||
| 282 | 280 | ||
| 283 | fun updateSubscriptionPermissions( | 281 | fun updateSubscriptionPermissions( |
| 284 | allParticipants: Boolean, | 282 | allParticipants: Boolean, |
| 285 | - participantTrackPermissions: List<ParticipantTrackPermission> | 283 | + participantTrackPermissions: List<ParticipantTrackPermission>, |
| 286 | ) { | 284 | ) { |
| 287 | client.sendUpdateSubscriptionPermissions(allParticipants, participantTrackPermissions) | 285 | client.sendUpdateSubscriptionPermissions(allParticipants, participantTrackPermissions) |
| 288 | } | 286 | } |
| @@ -348,7 +346,6 @@ internal constructor( | @@ -348,7 +346,6 @@ internal constructor( | ||
| 348 | val forceFullReconnect = fullReconnectOnNext | 346 | val forceFullReconnect = fullReconnectOnNext |
| 349 | fullReconnectOnNext = false | 347 | fullReconnectOnNext = false |
| 350 | val job = coroutineScope.launch { | 348 | val job = coroutineScope.launch { |
| 351 | - | ||
| 352 | connectionState = ConnectionState.RECONNECTING | 349 | connectionState = ConnectionState.RECONNECTING |
| 353 | listener?.onEngineReconnecting() | 350 | listener?.onEngineReconnecting() |
| 354 | 351 | ||
| @@ -498,7 +495,6 @@ internal constructor( | @@ -498,7 +495,6 @@ internal constructor( | ||
| 498 | this.negotiatePublisher() | 495 | this.negotiatePublisher() |
| 499 | } | 496 | } |
| 500 | 497 | ||
| 501 | - | ||
| 502 | val targetChannel = dataChannelForKind(kind) ?: throw IllegalArgumentException("Unknown data packet kind!") | 498 | val targetChannel = dataChannelForKind(kind) ?: throw IllegalArgumentException("Unknown data packet kind!") |
| 503 | if (targetChannel.state() == DataChannel.State.OPEN) { | 499 | if (targetChannel.state() == DataChannel.State.OPEN) { |
| 504 | return | 500 | return |
| @@ -529,21 +525,21 @@ internal constructor( | @@ -529,21 +525,21 @@ internal constructor( | ||
| 529 | add( | 525 | add( |
| 530 | MediaConstraints.KeyValuePair( | 526 | MediaConstraints.KeyValuePair( |
| 531 | MediaConstraintKeys.OFFER_TO_RECV_AUDIO, | 527 | MediaConstraintKeys.OFFER_TO_RECV_AUDIO, |
| 532 | - MediaConstraintKeys.FALSE | ||
| 533 | - ) | 528 | + MediaConstraintKeys.FALSE, |
| 529 | + ), | ||
| 534 | ) | 530 | ) |
| 535 | add( | 531 | add( |
| 536 | MediaConstraints.KeyValuePair( | 532 | MediaConstraints.KeyValuePair( |
| 537 | MediaConstraintKeys.OFFER_TO_RECV_VIDEO, | 533 | MediaConstraintKeys.OFFER_TO_RECV_VIDEO, |
| 538 | - MediaConstraintKeys.FALSE | ||
| 539 | - ) | 534 | + MediaConstraintKeys.FALSE, |
| 535 | + ), | ||
| 540 | ) | 536 | ) |
| 541 | if (connectionState == ConnectionState.RECONNECTING) { | 537 | if (connectionState == ConnectionState.RECONNECTING) { |
| 542 | add( | 538 | add( |
| 543 | MediaConstraints.KeyValuePair( | 539 | MediaConstraints.KeyValuePair( |
| 544 | MediaConstraintKeys.ICE_RESTART, | 540 | MediaConstraintKeys.ICE_RESTART, |
| 545 | - MediaConstraintKeys.TRUE | ||
| 546 | - ) | 541 | + MediaConstraintKeys.TRUE, |
| 542 | + ), | ||
| 547 | ) | 543 | ) |
| 548 | } | 544 | } |
| 549 | } | 545 | } |
| @@ -552,9 +548,8 @@ internal constructor( | @@ -552,9 +548,8 @@ internal constructor( | ||
| 552 | 548 | ||
| 553 | private fun makeRTCConfig( | 549 | private fun makeRTCConfig( |
| 554 | serverResponse: Either<JoinResponse, ReconnectResponse>, | 550 | serverResponse: Either<JoinResponse, ReconnectResponse>, |
| 555 | - connectOptions: ConnectOptions | 551 | + connectOptions: ConnectOptions, |
| 556 | ): RTCConfiguration { | 552 | ): RTCConfiguration { |
| 557 | - | ||
| 558 | // Convert protobuf ice servers | 553 | // Convert protobuf ice servers |
| 559 | val serverIceServers = run { | 554 | val serverIceServers = run { |
| 560 | val servers = mutableListOf<PeerConnection.IceServer>() | 555 | val servers = mutableListOf<PeerConnection.IceServer>() |
| @@ -664,7 +659,7 @@ internal constructor( | @@ -664,7 +659,7 @@ internal constructor( | ||
| 664 | } | 659 | } |
| 665 | } | 660 | } |
| 666 | 661 | ||
| 667 | - //---------------------------------- SignalClient.Listener --------------------------------------// | 662 | + // ---------------------------------- SignalClient.Listener --------------------------------------// |
| 668 | 663 | ||
| 669 | override fun onAnswer(sessionDescription: SessionDescription) { | 664 | override fun onAnswer(sessionDescription: SessionDescription) { |
| 670 | LKLog.v { "received server answer: ${sessionDescription.type}, ${publisher.peerConnection.signalingState()}" } | 665 | LKLog.v { "received server answer: ${sessionDescription.type}, ${publisher.peerConnection.signalingState()}" } |
| @@ -686,8 +681,10 @@ internal constructor( | @@ -686,8 +681,10 @@ internal constructor( | ||
| 686 | LKLog.v { "received server offer: ${sessionDescription.type}, ${subscriber.peerConnection.signalingState()}" } | 681 | LKLog.v { "received server offer: ${sessionDescription.type}, ${subscriber.peerConnection.signalingState()}" } |
| 687 | coroutineScope.launch { | 682 | coroutineScope.launch { |
| 688 | run<Unit> { | 683 | run<Unit> { |
| 689 | - when (val outcome = | ||
| 690 | - subscriber.setRemoteDescription(sessionDescription)) { | 684 | + when ( |
| 685 | + val outcome = | ||
| 686 | + subscriber.setRemoteDescription(sessionDescription) | ||
| 687 | + ) { | ||
| 691 | is Either.Right -> { | 688 | is Either.Right -> { |
| 692 | LKLog.e { "error setting remote description for answer: ${outcome.value} " } | 689 | LKLog.e { "error setting remote description for answer: ${outcome.value} " } |
| 693 | return@launch | 690 | return@launch |
| @@ -821,7 +818,7 @@ internal constructor( | @@ -821,7 +818,7 @@ internal constructor( | ||
| 821 | listener?.onLocalTrackUnpublished(trackUnpublished) | 818 | listener?.onLocalTrackUnpublished(trackUnpublished) |
| 822 | } | 819 | } |
| 823 | 820 | ||
| 824 | - //--------------------------------- DataChannel.Observer ------------------------------------// | 821 | + // --------------------------------- DataChannel.Observer ------------------------------------// |
| 825 | 822 | ||
| 826 | override fun onBufferedAmountChange(previousAmount: Long) { | 823 | override fun onBufferedAmountChange(previousAmount: Long) { |
| 827 | } | 824 | } |
| @@ -844,7 +841,8 @@ internal constructor( | @@ -844,7 +841,8 @@ internal constructor( | ||
| 844 | } | 841 | } |
| 845 | 842 | ||
| 846 | LivekitModels.DataPacket.ValueCase.VALUE_NOT_SET, | 843 | LivekitModels.DataPacket.ValueCase.VALUE_NOT_SET, |
| 847 | - null -> { | 844 | + null, |
| 845 | + -> { | ||
| 848 | LKLog.v { "invalid value for data packet" } | 846 | LKLog.v { "invalid value for data packet" } |
| 849 | } | 847 | } |
| 850 | } | 848 | } |
| @@ -852,7 +850,7 @@ internal constructor( | @@ -852,7 +850,7 @@ internal constructor( | ||
| 852 | 850 | ||
| 853 | fun sendSyncState( | 851 | fun sendSyncState( |
| 854 | subscription: LivekitRtc.UpdateSubscription, | 852 | subscription: LivekitRtc.UpdateSubscription, |
| 855 | - publishedTracks: List<LivekitRtc.TrackPublishedResponse> | 853 | + publishedTracks: List<LivekitRtc.TrackPublishedResponse>, |
| 856 | ) { | 854 | ) { |
| 857 | val answer = subscriber.peerConnection.localDescription?.toProtoSessionDescription() | 855 | val answer = subscriber.peerConnection.localDescription?.toProtoSessionDescription() |
| 858 | 856 | ||
| @@ -894,7 +892,7 @@ internal constructor( | @@ -894,7 +892,7 @@ internal constructor( | ||
| 894 | enum class ReconnectType { | 892 | enum class ReconnectType { |
| 895 | DEFAULT, | 893 | DEFAULT, |
| 896 | FORCE_SOFT_RECONNECT, | 894 | FORCE_SOFT_RECONNECT, |
| 897 | - FORCE_FULL_RECONNECT; | 895 | + FORCE_FULL_RECONNECT, |
| 898 | } | 896 | } |
| 899 | 897 | ||
| 900 | internal fun LivekitRtc.ICEServer.toWebrtc() = PeerConnection.IceServer.builder(urlsList) | 898 | internal fun LivekitRtc.ICEServer.toWebrtc() = PeerConnection.IceServer.builder(urlsList) |
| @@ -80,7 +80,7 @@ constructor( | @@ -80,7 +80,7 @@ constructor( | ||
| 80 | CONNECTING, | 80 | CONNECTING, |
| 81 | CONNECTED, | 81 | CONNECTED, |
| 82 | DISCONNECTED, | 82 | DISCONNECTED, |
| 83 | - RECONNECTING; | 83 | + RECONNECTING, |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | /** | 86 | /** |
| @@ -90,7 +90,7 @@ constructor( | @@ -90,7 +90,7 @@ constructor( | ||
| 90 | SPEAKER_UPDATE, | 90 | SPEAKER_UPDATE, |
| 91 | NODE_FAILURE, | 91 | NODE_FAILURE, |
| 92 | MIGRATION, | 92 | MIGRATION, |
| 93 | - SERVER_LEAVE; | 93 | + SERVER_LEAVE, |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | @JvmInline | 96 | @JvmInline |
| @@ -224,7 +224,7 @@ constructor( | @@ -224,7 +224,7 @@ constructor( | ||
| 224 | room = this@Room, | 224 | room = this@Room, |
| 225 | publication = it.publication, | 225 | publication = it.publication, |
| 226 | participant = it.participant, | 226 | participant = it.participant, |
| 227 | - ) | 227 | + ), |
| 228 | ) | 228 | ) |
| 229 | 229 | ||
| 230 | is ParticipantEvent.ParticipantPermissionsChanged -> emitWhenConnected( | 230 | is ParticipantEvent.ParticipantPermissionsChanged -> emitWhenConnected( |
| @@ -233,7 +233,7 @@ constructor( | @@ -233,7 +233,7 @@ constructor( | ||
| 233 | participant = it.participant, | 233 | participant = it.participant, |
| 234 | newPermissions = it.newPermissions, | 234 | newPermissions = it.newPermissions, |
| 235 | oldPermissions = it.oldPermissions, | 235 | oldPermissions = it.oldPermissions, |
| 236 | - ) | 236 | + ), |
| 237 | ) | 237 | ) |
| 238 | 238 | ||
| 239 | is ParticipantEvent.MetadataChanged -> { | 239 | is ParticipantEvent.MetadataChanged -> { |
| @@ -242,8 +242,8 @@ constructor( | @@ -242,8 +242,8 @@ constructor( | ||
| 242 | RoomEvent.ParticipantMetadataChanged( | 242 | RoomEvent.ParticipantMetadataChanged( |
| 243 | this@Room, | 243 | this@Room, |
| 244 | it.participant, | 244 | it.participant, |
| 245 | - it.prevMetadata | ||
| 246 | - ) | 245 | + it.prevMetadata, |
| 246 | + ), | ||
| 247 | ) | 247 | ) |
| 248 | } | 248 | } |
| 249 | 249 | ||
| @@ -252,13 +252,13 @@ constructor( | @@ -252,13 +252,13 @@ constructor( | ||
| 252 | RoomEvent.ParticipantNameChanged( | 252 | RoomEvent.ParticipantNameChanged( |
| 253 | this@Room, | 253 | this@Room, |
| 254 | it.participant, | 254 | it.participant, |
| 255 | - it.name | ||
| 256 | - ) | 255 | + it.name, |
| 256 | + ), | ||
| 257 | ) | 257 | ) |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | else -> { | 260 | else -> { |
| 261 | - /* do nothing */ | 261 | + // do nothing |
| 262 | } | 262 | } |
| 263 | } | 263 | } |
| 264 | } | 264 | } |
| @@ -267,9 +267,9 @@ constructor( | @@ -267,9 +267,9 @@ constructor( | ||
| 267 | state = State.CONNECTING | 267 | state = State.CONNECTING |
| 268 | connectOptions = options | 268 | connectOptions = options |
| 269 | 269 | ||
| 270 | - if(roomOptions.e2eeOptions != null) { | 270 | + if (roomOptions.e2eeOptions != null) { |
| 271 | e2eeManager = E2EEManager(roomOptions!!.e2eeOptions!!.keyProvider) | 271 | e2eeManager = E2EEManager(roomOptions!!.e2eeOptions!!.keyProvider) |
| 272 | - e2eeManager!!.setup(this, {event -> | 272 | + e2eeManager!!.setup(this, { event -> |
| 273 | coroutineScope.launch { | 273 | coroutineScope.launch { |
| 274 | emitWhenConnected(event) | 274 | emitWhenConnected(event) |
| 275 | } | 275 | } |
| @@ -316,7 +316,6 @@ constructor( | @@ -316,7 +316,6 @@ constructor( | ||
| 316 | * @suppress | 316 | * @suppress |
| 317 | */ | 317 | */ |
| 318 | override fun onJoinResponse(response: LivekitRtc.JoinResponse) { | 318 | override fun onJoinResponse(response: LivekitRtc.JoinResponse) { |
| 319 | - | ||
| 320 | LKLog.i { "Connected to server, server version: ${response.serverVersion}, client version: ${Version.CLIENT_VERSION}" } | 319 | LKLog.i { "Connected to server, server version: ${response.serverVersion}, client version: ${Version.CLIENT_VERSION}" } |
| 321 | 320 | ||
| 322 | sid = Sid(response.room.sid) | 321 | sid = Sid(response.room.sid) |
| @@ -365,7 +364,7 @@ constructor( | @@ -365,7 +364,7 @@ constructor( | ||
| 365 | @Synchronized | 364 | @Synchronized |
| 366 | private fun getOrCreateRemoteParticipant( | 365 | private fun getOrCreateRemoteParticipant( |
| 367 | sid: String, | 366 | sid: String, |
| 368 | - info: LivekitModels.ParticipantInfo? = null | 367 | + info: LivekitModels.ParticipantInfo? = null, |
| 369 | ): RemoteParticipant { | 368 | ): RemoteParticipant { |
| 370 | var participant = remoteParticipants[sid] | 369 | var participant = remoteParticipants[sid] |
| 371 | if (participant != null) { | 370 | if (participant != null) { |
| @@ -389,7 +388,7 @@ constructor( | @@ -389,7 +388,7 @@ constructor( | ||
| 389 | room = this@Room, | 388 | room = this@Room, |
| 390 | publication = it.publication, | 389 | publication = it.publication, |
| 391 | participant = it.participant, | 390 | participant = it.participant, |
| 392 | - ) | 391 | + ), |
| 393 | ) | 392 | ) |
| 394 | } | 393 | } |
| 395 | } | 394 | } |
| @@ -398,8 +397,8 @@ constructor( | @@ -398,8 +397,8 @@ constructor( | ||
| 398 | RoomEvent.TrackStreamStateChanged( | 397 | RoomEvent.TrackStreamStateChanged( |
| 399 | this@Room, | 398 | this@Room, |
| 400 | it.trackPublication, | 399 | it.trackPublication, |
| 401 | - it.streamState | ||
| 402 | - ) | 400 | + it.streamState, |
| 401 | + ), | ||
| 403 | ) | 402 | ) |
| 404 | 403 | ||
| 405 | is ParticipantEvent.TrackSubscriptionPermissionChanged -> eventBus.postEvent( | 404 | is ParticipantEvent.TrackSubscriptionPermissionChanged -> eventBus.postEvent( |
| @@ -407,8 +406,8 @@ constructor( | @@ -407,8 +406,8 @@ constructor( | ||
| 407 | this@Room, | 406 | this@Room, |
| 408 | it.participant, | 407 | it.participant, |
| 409 | it.trackPublication, | 408 | it.trackPublication, |
| 410 | - it.subscriptionAllowed | ||
| 411 | - ) | 409 | + it.subscriptionAllowed, |
| 410 | + ), | ||
| 412 | ) | 411 | ) |
| 413 | 412 | ||
| 414 | is ParticipantEvent.MetadataChanged -> { | 413 | is ParticipantEvent.MetadataChanged -> { |
| @@ -417,8 +416,8 @@ constructor( | @@ -417,8 +416,8 @@ constructor( | ||
| 417 | RoomEvent.ParticipantMetadataChanged( | 416 | RoomEvent.ParticipantMetadataChanged( |
| 418 | this@Room, | 417 | this@Room, |
| 419 | it.participant, | 418 | it.participant, |
| 420 | - it.prevMetadata | ||
| 421 | - ) | 419 | + it.prevMetadata, |
| 420 | + ), | ||
| 422 | ) | 421 | ) |
| 423 | } | 422 | } |
| 424 | 423 | ||
| @@ -428,7 +427,7 @@ constructor( | @@ -428,7 +427,7 @@ constructor( | ||
| 428 | this@Room, | 427 | this@Room, |
| 429 | it.participant, | 428 | it.participant, |
| 430 | it.name, | 429 | it.name, |
| 431 | - ) | 430 | + ), |
| 432 | ) | 431 | ) |
| 433 | } | 432 | } |
| 434 | 433 | ||
| @@ -438,11 +437,11 @@ constructor( | @@ -438,11 +437,11 @@ constructor( | ||
| 438 | participant = it.participant, | 437 | participant = it.participant, |
| 439 | newPermissions = it.newPermissions, | 438 | newPermissions = it.newPermissions, |
| 440 | oldPermissions = it.oldPermissions, | 439 | oldPermissions = it.oldPermissions, |
| 441 | - ) | 440 | + ), |
| 442 | ) | 441 | ) |
| 443 | 442 | ||
| 444 | else -> { | 443 | else -> { |
| 445 | - /* do nothing */ | 444 | + // do nothing |
| 446 | } | 445 | } |
| 447 | } | 446 | } |
| 448 | } | 447 | } |
| @@ -632,7 +631,7 @@ constructor( | @@ -632,7 +631,7 @@ constructor( | ||
| 632 | fun create(context: Context): Room | 631 | fun create(context: Context): Room |
| 633 | } | 632 | } |
| 634 | 633 | ||
| 635 | - //------------------------------------- NetworkCallback -------------------------------------// | 634 | + // ------------------------------------- NetworkCallback -------------------------------------// |
| 636 | private val networkCallback = object : ConnectivityManager.NetworkCallback() { | 635 | private val networkCallback = object : ConnectivityManager.NetworkCallback() { |
| 637 | /** | 636 | /** |
| 638 | * @suppress | 637 | * @suppress |
| @@ -656,7 +655,7 @@ constructor( | @@ -656,7 +655,7 @@ constructor( | ||
| 656 | } | 655 | } |
| 657 | } | 656 | } |
| 658 | 657 | ||
| 659 | - //----------------------------------- RTCEngine.Listener ------------------------------------// | 658 | + // ----------------------------------- RTCEngine.Listener ------------------------------------// |
| 660 | 659 | ||
| 661 | /** | 660 | /** |
| 662 | * @suppress | 661 | * @suppress |
| @@ -703,7 +702,7 @@ constructor( | @@ -703,7 +702,7 @@ constructor( | ||
| 703 | trackSid!!, | 702 | trackSid!!, |
| 704 | autoManageVideo = adaptiveStream, | 703 | autoManageVideo = adaptiveStream, |
| 705 | statsGetter = statsGetter, | 704 | statsGetter = statsGetter, |
| 706 | - receiver = receiver | 705 | + receiver = receiver, |
| 707 | ) | 706 | ) |
| 708 | } | 707 | } |
| 709 | 708 | ||
| @@ -895,7 +894,7 @@ constructor( | @@ -895,7 +894,7 @@ constructor( | ||
| 895 | localParticipant.handleLocalTrackUnpublished(trackUnpublished) | 894 | localParticipant.handleLocalTrackUnpublished(trackUnpublished) |
| 896 | } | 895 | } |
| 897 | 896 | ||
| 898 | - //------------------------------- ParticipantListener --------------------------------// | 897 | + // ------------------------------- ParticipantListener --------------------------------// |
| 899 | /** | 898 | /** |
| 900 | * This is called for both Local and Remote participants | 899 | * This is called for both Local and Remote participants |
| 901 | * @suppress | 900 | * @suppress |
| @@ -928,11 +927,12 @@ constructor( | @@ -928,11 +927,12 @@ constructor( | ||
| 928 | */ | 927 | */ |
| 929 | override fun onTrackPublished(publication: LocalTrackPublication, participant: LocalParticipant) { | 928 | override fun onTrackPublished(publication: LocalTrackPublication, participant: LocalParticipant) { |
| 930 | listener?.onTrackPublished(publication, participant, this) | 929 | listener?.onTrackPublished(publication, participant, this) |
| 931 | - if(e2eeManager != null) { | 930 | + if (e2eeManager != null) { |
| 932 | e2eeManager!!.addPublishedTrack(publication.track!!, publication, participant, this) | 931 | e2eeManager!!.addPublishedTrack(publication.track!!, publication, participant, this) |
| 933 | } | 932 | } |
| 934 | eventBus.postEvent(RoomEvent.TrackPublished(this, publication, participant), coroutineScope) | 933 | eventBus.postEvent(RoomEvent.TrackPublished(this, publication, participant), coroutineScope) |
| 935 | } | 934 | } |
| 935 | + | ||
| 936 | /** | 936 | /** |
| 937 | * @suppress | 937 | * @suppress |
| 938 | */ | 938 | */ |
| @@ -946,7 +946,7 @@ constructor( | @@ -946,7 +946,7 @@ constructor( | ||
| 946 | */ | 946 | */ |
| 947 | override fun onTrackSubscribed(track: Track, publication: RemoteTrackPublication, participant: RemoteParticipant) { | 947 | override fun onTrackSubscribed(track: Track, publication: RemoteTrackPublication, participant: RemoteParticipant) { |
| 948 | listener?.onTrackSubscribed(track, publication, participant, this) | 948 | listener?.onTrackSubscribed(track, publication, participant, this) |
| 949 | - if(e2eeManager != null) { | 949 | + if (e2eeManager != null) { |
| 950 | e2eeManager!!.addSubscribedTrack(track, publication, participant, this) | 950 | e2eeManager!!.addSubscribedTrack(track, publication, participant, this) |
| 951 | } | 951 | } |
| 952 | eventBus.postEvent(RoomEvent.TrackSubscribed(this, track, publication, participant), coroutineScope) | 952 | eventBus.postEvent(RoomEvent.TrackSubscribed(this, track, publication, participant), coroutineScope) |
| @@ -958,7 +958,7 @@ constructor( | @@ -958,7 +958,7 @@ constructor( | ||
| 958 | override fun onTrackSubscriptionFailed( | 958 | override fun onTrackSubscriptionFailed( |
| 959 | sid: String, | 959 | sid: String, |
| 960 | exception: Exception, | 960 | exception: Exception, |
| 961 | - participant: RemoteParticipant | 961 | + participant: RemoteParticipant, |
| 962 | ) { | 962 | ) { |
| 963 | listener?.onTrackSubscriptionFailed(sid, exception, participant, this) | 963 | listener?.onTrackSubscriptionFailed(sid, exception, participant, this) |
| 964 | eventBus.postEvent(RoomEvent.TrackSubscriptionFailed(this, sid, exception, participant), coroutineScope) | 964 | eventBus.postEvent(RoomEvent.TrackSubscriptionFailed(this, sid, exception, participant), coroutineScope) |
| @@ -970,7 +970,7 @@ constructor( | @@ -970,7 +970,7 @@ constructor( | ||
| 970 | override fun onTrackUnsubscribed( | 970 | override fun onTrackUnsubscribed( |
| 971 | track: Track, | 971 | track: Track, |
| 972 | publication: RemoteTrackPublication, | 972 | publication: RemoteTrackPublication, |
| 973 | - participant: RemoteParticipant | 973 | + participant: RemoteParticipant, |
| 974 | ) { | 974 | ) { |
| 975 | listener?.onTrackUnsubscribed(track, publication, participant, this) | 975 | listener?.onTrackUnsubscribed(track, publication, participant, this) |
| 976 | eventBus.postEvent(RoomEvent.TrackUnsubscribed(this, track, publication, participant), coroutineScope) | 976 | eventBus.postEvent(RoomEvent.TrackUnsubscribed(this, track, publication, participant), coroutineScope) |
| @@ -982,7 +982,7 @@ constructor( | @@ -982,7 +982,7 @@ constructor( | ||
| 982 | fun initVideoRenderer(viewRenderer: SurfaceViewRenderer) { | 982 | fun initVideoRenderer(viewRenderer: SurfaceViewRenderer) { |
| 983 | viewRenderer.init(eglBase.eglBaseContext, null) | 983 | viewRenderer.init(eglBase.eglBaseContext, null) |
| 984 | viewRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT) | 984 | viewRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT) |
| 985 | - viewRenderer.setEnableHardwareScaler(false /* enabled */) | 985 | + viewRenderer.setEnableHardwareScaler(false) |
| 986 | } | 986 | } |
| 987 | 987 | ||
| 988 | /** | 988 | /** |
| @@ -991,7 +991,7 @@ constructor( | @@ -991,7 +991,7 @@ constructor( | ||
| 991 | fun initVideoRenderer(viewRenderer: TextureViewRenderer) { | 991 | fun initVideoRenderer(viewRenderer: TextureViewRenderer) { |
| 992 | viewRenderer.init(eglBase.eglBaseContext, null) | 992 | viewRenderer.init(eglBase.eglBaseContext, null) |
| 993 | viewRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT) | 993 | viewRenderer.setScalingType(RendererCommon.ScalingType.SCALE_ASPECT_FIT) |
| 994 | - viewRenderer.setEnableHardwareScaler(false /* enabled */) | 994 | + viewRenderer.setEnableHardwareScaler(false) |
| 995 | } | 995 | } |
| 996 | 996 | ||
| 997 | private suspend fun emitWhenConnected(event: RoomEvent) { | 997 | private suspend fun emitWhenConnected(event: RoomEvent) { |
| @@ -80,7 +80,9 @@ constructor( | @@ -80,7 +80,9 @@ constructor( | ||
| 80 | private var joinContinuation: CancellableContinuation< | 80 | private var joinContinuation: CancellableContinuation< |
| 81 | Either< | 81 | Either< |
| 82 | JoinResponse, | 82 | JoinResponse, |
| 83 | - Either<ReconnectResponse, Unit>>>? = null | 83 | + Either<ReconnectResponse, Unit>, |
| 84 | + >, | ||
| 85 | + >? = null | ||
| 84 | private lateinit var coroutineScope: CloseableCoroutineScope | 86 | private lateinit var coroutineScope: CloseableCoroutineScope |
| 85 | 87 | ||
| 86 | private val requestFlowJobLock = Object() | 88 | private val requestFlowJobLock = Object() |
| @@ -121,7 +123,7 @@ constructor( | @@ -121,7 +123,7 @@ constructor( | ||
| 121 | reconnect = true | 123 | reconnect = true |
| 122 | this.participantSid = participantSid | 124 | this.participantSid = participantSid |
| 123 | }, | 125 | }, |
| 124 | - lastRoomOptions ?: RoomOptions() | 126 | + lastRoomOptions ?: RoomOptions(), |
| 125 | ) | 127 | ) |
| 126 | return (reconnectResponse as Either.Right).value | 128 | return (reconnectResponse as Either.Right).value |
| 127 | } | 129 | } |
| @@ -130,7 +132,7 @@ constructor( | @@ -130,7 +132,7 @@ constructor( | ||
| 130 | url: String, | 132 | url: String, |
| 131 | token: String, | 133 | token: String, |
| 132 | options: ConnectOptions, | 134 | options: ConnectOptions, |
| 133 | - roomOptions: RoomOptions | 135 | + roomOptions: RoomOptions, |
| 134 | ): Either<JoinResponse, Either<ReconnectResponse, Unit>> { | 136 | ): Either<JoinResponse, Either<ReconnectResponse, Unit>> { |
| 135 | // Clean up any pre-existing connection. | 137 | // Clean up any pre-existing connection. |
| 136 | close(reason = "Starting new connection") | 138 | close(reason = "Starting new connection") |
| @@ -160,9 +162,8 @@ constructor( | @@ -160,9 +162,8 @@ constructor( | ||
| 160 | token: String, | 162 | token: String, |
| 161 | clientInfo: LivekitModels.ClientInfo, | 163 | clientInfo: LivekitModels.ClientInfo, |
| 162 | options: ConnectOptions, | 164 | options: ConnectOptions, |
| 163 | - roomOptions: RoomOptions | 165 | + roomOptions: RoomOptions, |
| 164 | ): String { | 166 | ): String { |
| 165 | - | ||
| 166 | val queryParams = mutableListOf<Pair<String, String>>() | 167 | val queryParams = mutableListOf<Pair<String, String>>() |
| 167 | queryParams.add(CONNECT_QUERY_TOKEN to token) | 168 | queryParams.add(CONNECT_QUERY_TOKEN to token) |
| 168 | queryParams.add(CONNECT_QUERY_PROTOCOL to options.protocolVersion.value.toString()) | 169 | queryParams.add(CONNECT_QUERY_PROTOCOL to options.protocolVersion.value.toString()) |
| @@ -234,7 +235,7 @@ constructor( | @@ -234,7 +235,7 @@ constructor( | ||
| 234 | startRequestQueue() | 235 | startRequestQueue() |
| 235 | } | 236 | } |
| 236 | 237 | ||
| 237 | - //--------------------------------- WebSocket Listener --------------------------------------// | 238 | + // --------------------------------- WebSocket Listener --------------------------------------// |
| 238 | override fun onMessage(webSocket: WebSocket, text: String) { | 239 | override fun onMessage(webSocket: WebSocket, text: String) { |
| 239 | LKLog.w { "received JSON message, unsupported in this version." } | 240 | LKLog.w { "received JSON message, unsupported in this version." } |
| 240 | } | 241 | } |
| @@ -291,7 +292,7 @@ constructor( | @@ -291,7 +292,7 @@ constructor( | ||
| 291 | // Handle websocket closure here. | 292 | // Handle websocket closure here. |
| 292 | handleWebSocketClose( | 293 | handleWebSocketClose( |
| 293 | reason = reason ?: response?.toString() ?: t.localizedMessage ?: "websocket failure", | 294 | reason = reason ?: response?.toString() ?: t.localizedMessage ?: "websocket failure", |
| 294 | - code = response?.code ?: CLOSE_REASON_WEBSOCKET_FAILURE | 295 | + code = response?.code ?: CLOSE_REASON_WEBSOCKET_FAILURE, |
| 295 | ) | 296 | ) |
| 296 | } | 297 | } |
| 297 | } | 298 | } |
| @@ -306,7 +307,7 @@ constructor( | @@ -306,7 +307,7 @@ constructor( | ||
| 306 | pongJob?.cancel() | 307 | pongJob?.cancel() |
| 307 | } | 308 | } |
| 308 | 309 | ||
| 309 | - //------------------------------- End WebSocket Listener ------------------------------------// | 310 | + // ------------------------------- End WebSocket Listener ------------------------------------// |
| 310 | 311 | ||
| 311 | private fun fromProtoSessionDescription(sd: LivekitRtc.SessionDescription): SessionDescription { | 312 | private fun fromProtoSessionDescription(sd: LivekitRtc.SessionDescription): SessionDescription { |
| 312 | val rtcSdpType = when (sd.type) { | 313 | val rtcSdpType = when (sd.type) { |
| @@ -340,7 +341,7 @@ constructor( | @@ -340,7 +341,7 @@ constructor( | ||
| 340 | val iceCandidateJSON = IceCandidateJSON( | 341 | val iceCandidateJSON = IceCandidateJSON( |
| 341 | candidate = candidate.sdp, | 342 | candidate = candidate.sdp, |
| 342 | sdpMid = candidate.sdpMid, | 343 | sdpMid = candidate.sdpMid, |
| 343 | - sdpMLineIndex = candidate.sdpMLineIndex | 344 | + sdpMLineIndex = candidate.sdpMLineIndex, |
| 344 | ) | 345 | ) |
| 345 | 346 | ||
| 346 | val trickleRequest = LivekitRtc.TrickleRequest.newBuilder() | 347 | val trickleRequest = LivekitRtc.TrickleRequest.newBuilder() |
| @@ -375,7 +376,7 @@ constructor( | @@ -375,7 +376,7 @@ constructor( | ||
| 375 | cid: String, | 376 | cid: String, |
| 376 | name: String, | 377 | name: String, |
| 377 | type: LivekitModels.TrackType, | 378 | type: LivekitModels.TrackType, |
| 378 | - builder: LivekitRtc.AddTrackRequest.Builder = LivekitRtc.AddTrackRequest.newBuilder() | 379 | + builder: LivekitRtc.AddTrackRequest.Builder = LivekitRtc.AddTrackRequest.newBuilder(), |
| 379 | ) { | 380 | ) { |
| 380 | var encryptionType = lastRoomOptions?.e2eeOptions?.encryptionType ?: LivekitModels.Encryption.Type.NONE | 381 | var encryptionType = lastRoomOptions?.e2eeOptions?.encryptionType ?: LivekitModels.Encryption.Type.NONE |
| 381 | val addTrackRequest = builder | 382 | val addTrackRequest = builder |
| @@ -442,7 +443,7 @@ constructor( | @@ -442,7 +443,7 @@ constructor( | ||
| 442 | 443 | ||
| 443 | fun sendUpdateSubscriptionPermissions( | 444 | fun sendUpdateSubscriptionPermissions( |
| 444 | allParticipants: Boolean, | 445 | allParticipants: Boolean, |
| 445 | - participantTrackPermissions: List<ParticipantTrackPermission> | 446 | + participantTrackPermissions: List<ParticipantTrackPermission>, |
| 446 | ) { | 447 | ) { |
| 447 | val update = LivekitRtc.SubscriptionPermission.newBuilder() | 448 | val update = LivekitRtc.SubscriptionPermission.newBuilder() |
| 448 | .setAllParticipants(allParticipants) | 449 | .setAllParticipants(allParticipants) |
| @@ -580,7 +581,7 @@ constructor( | @@ -580,7 +581,7 @@ constructor( | ||
| 580 | val iceCandidate = IceCandidate( | 581 | val iceCandidate = IceCandidate( |
| 581 | iceCandidateJson.sdpMid, | 582 | iceCandidateJson.sdpMid, |
| 582 | iceCandidateJson.sdpMLineIndex, | 583 | iceCandidateJson.sdpMLineIndex, |
| 583 | - iceCandidateJson.candidate | 584 | + iceCandidateJson.candidate, |
| 584 | ) | 585 | ) |
| 585 | listener?.onTrickle(iceCandidate, response.trickle.target) | 586 | listener?.onTrickle(iceCandidate, response.trickle.target) |
| 586 | } | 587 | } |
| @@ -658,7 +659,8 @@ constructor( | @@ -658,7 +659,8 @@ constructor( | ||
| 658 | } | 659 | } |
| 659 | 660 | ||
| 660 | LivekitRtc.SignalResponse.MessageCase.MESSAGE_NOT_SET, | 661 | LivekitRtc.SignalResponse.MessageCase.MESSAGE_NOT_SET, |
| 661 | - null -> { | 662 | + null, |
| 663 | + -> { | ||
| 662 | LKLog.v { "empty messageCase!" } | 664 | LKLog.v { "empty messageCase!" } |
| 663 | } | 665 | } |
| 664 | } | 666 | } |
| @@ -721,7 +723,7 @@ constructor( | @@ -721,7 +723,7 @@ constructor( | ||
| 721 | joinContinuation?.cancel() | 723 | joinContinuation?.cancel() |
| 722 | joinContinuation = null | 724 | joinContinuation = null |
| 723 | // TODO: support calling this from connect without wiping any queued requests. | 725 | // TODO: support calling this from connect without wiping any queued requests. |
| 724 | - //requestFlow.resetReplayCache() | 726 | + // requestFlow.resetReplayCache() |
| 725 | responseFlow.resetReplayCache() | 727 | responseFlow.resetReplayCache() |
| 726 | lastUrl = null | 728 | lastUrl = null |
| 727 | lastOptions = null | 729 | lastOptions = null |
| @@ -144,7 +144,7 @@ internal constructor( | @@ -144,7 +144,7 @@ internal constructor( | ||
| 144 | name, | 144 | name, |
| 145 | LocalVideoTrackOptions(isScreencast = true), | 145 | LocalVideoTrackOptions(isScreencast = true), |
| 146 | eglBase, | 146 | eglBase, |
| 147 | - screencastVideoTrackFactory | 147 | + screencastVideoTrackFactory, |
| 148 | ) | 148 | ) |
| 149 | } | 149 | } |
| 150 | 150 | ||
| @@ -171,7 +171,7 @@ internal constructor( | @@ -171,7 +171,7 @@ internal constructor( | ||
| 171 | */ | 171 | */ |
| 172 | suspend fun setScreenShareEnabled( | 172 | suspend fun setScreenShareEnabled( |
| 173 | enabled: Boolean, | 173 | enabled: Boolean, |
| 174 | - mediaProjectionPermissionResultData: Intent? = null | 174 | + mediaProjectionPermissionResultData: Intent? = null, |
| 175 | ) { | 175 | ) { |
| 176 | setTrackEnabled(Track.Source.SCREEN_SHARE, enabled, mediaProjectionPermissionResultData) | 176 | setTrackEnabled(Track.Source.SCREEN_SHARE, enabled, mediaProjectionPermissionResultData) |
| 177 | } | 177 | } |
| @@ -179,7 +179,7 @@ internal constructor( | @@ -179,7 +179,7 @@ internal constructor( | ||
| 179 | private suspend fun setTrackEnabled( | 179 | private suspend fun setTrackEnabled( |
| 180 | source: Track.Source, | 180 | source: Track.Source, |
| 181 | enabled: Boolean, | 181 | enabled: Boolean, |
| 182 | - mediaProjectionPermissionResultData: Intent? = null | 182 | + mediaProjectionPermissionResultData: Intent? = null, |
| 183 | 183 | ||
| 184 | ) { | 184 | ) { |
| 185 | val pub = getTrackPublication(source) | 185 | val pub = getTrackPublication(source) |
| @@ -238,16 +238,16 @@ internal constructor( | @@ -238,16 +238,16 @@ internal constructor( | ||
| 238 | track: LocalAudioTrack, | 238 | track: LocalAudioTrack, |
| 239 | options: AudioTrackPublishOptions = AudioTrackPublishOptions( | 239 | options: AudioTrackPublishOptions = AudioTrackPublishOptions( |
| 240 | null, | 240 | null, |
| 241 | - audioTrackPublishDefaults | 241 | + audioTrackPublishDefaults, |
| 242 | ), | 242 | ), |
| 243 | - publishListener: PublishListener? = null | 243 | + publishListener: PublishListener? = null, |
| 244 | ) { | 244 | ) { |
| 245 | val encodings = listOf( | 245 | val encodings = listOf( |
| 246 | RtpParameters.Encoding(null, true, null).apply { | 246 | RtpParameters.Encoding(null, true, null).apply { |
| 247 | if (options.audioBitrate != null && options.audioBitrate > 0) { | 247 | if (options.audioBitrate != null && options.audioBitrate > 0) { |
| 248 | maxBitrateBps = options.audioBitrate | 248 | maxBitrateBps = options.audioBitrate |
| 249 | } | 249 | } |
| 250 | - } | 250 | + }, |
| 251 | ) | 251 | ) |
| 252 | publishTrackImpl( | 252 | publishTrackImpl( |
| 253 | track = track, | 253 | track = track, |
| @@ -264,9 +264,8 @@ internal constructor( | @@ -264,9 +264,8 @@ internal constructor( | ||
| 264 | suspend fun publishVideoTrack( | 264 | suspend fun publishVideoTrack( |
| 265 | track: LocalVideoTrack, | 265 | track: LocalVideoTrack, |
| 266 | options: VideoTrackPublishOptions = VideoTrackPublishOptions(null, videoTrackPublishDefaults), | 266 | options: VideoTrackPublishOptions = VideoTrackPublishOptions(null, videoTrackPublishDefaults), |
| 267 | - publishListener: PublishListener? = null | 267 | + publishListener: PublishListener? = null, |
| 268 | ) { | 268 | ) { |
| 269 | - | ||
| 270 | val encodings = computeVideoEncodings(track.dimensions, options) | 269 | val encodings = computeVideoEncodings(track.dimensions, options) |
| 271 | val videoLayers = | 270 | val videoLayers = |
| 272 | EncodingUtils.videoLayersFromEncodings(track.dimensions.width, track.dimensions.height, encodings) | 271 | EncodingUtils.videoLayersFromEncodings(track.dimensions.width, track.dimensions.height, encodings) |
| @@ -285,11 +284,10 @@ internal constructor( | @@ -285,11 +284,10 @@ internal constructor( | ||
| 285 | addAllLayers(videoLayers) | 284 | addAllLayers(videoLayers) |
| 286 | }, | 285 | }, |
| 287 | encodings = encodings, | 286 | encodings = encodings, |
| 288 | - publishListener = publishListener | 287 | + publishListener = publishListener, |
| 289 | ) | 288 | ) |
| 290 | } | 289 | } |
| 291 | 290 | ||
| 292 | - | ||
| 293 | /** | 291 | /** |
| 294 | * @return true if the track publish was successful. | 292 | * @return true if the track publish was successful. |
| 295 | */ | 293 | */ |
| @@ -298,7 +296,7 @@ internal constructor( | @@ -298,7 +296,7 @@ internal constructor( | ||
| 298 | options: TrackPublishOptions, | 296 | options: TrackPublishOptions, |
| 299 | requestConfig: LivekitRtc.AddTrackRequest.Builder.() -> Unit, | 297 | requestConfig: LivekitRtc.AddTrackRequest.Builder.() -> Unit, |
| 300 | encodings: List<RtpParameters.Encoding> = emptyList(), | 298 | encodings: List<RtpParameters.Encoding> = emptyList(), |
| 301 | - publishListener: PublishListener? = null | 299 | + publishListener: PublishListener? = null, |
| 302 | ): Boolean { | 300 | ): Boolean { |
| 303 | if (localTrackPublications.any { it.track == track }) { | 301 | if (localTrackPublications.any { it.track == track }) { |
| 304 | publishListener?.onPublishFailure(TrackException.PublishException("Track has already been published")) | 302 | publishListener?.onPublishFailure(TrackException.PublishException("Track has already been published")) |
| @@ -313,12 +311,12 @@ internal constructor( | @@ -313,12 +311,12 @@ internal constructor( | ||
| 313 | cid = cid, | 311 | cid = cid, |
| 314 | name = track.name, | 312 | name = track.name, |
| 315 | kind = track.kind.toProto(), | 313 | kind = track.kind.toProto(), |
| 316 | - builder = builder | 314 | + builder = builder, |
| 317 | ) | 315 | ) |
| 318 | val transInit = RtpTransceiver.RtpTransceiverInit( | 316 | val transInit = RtpTransceiver.RtpTransceiverInit( |
| 319 | RtpTransceiver.RtpTransceiverDirection.SEND_ONLY, | 317 | RtpTransceiver.RtpTransceiverDirection.SEND_ONLY, |
| 320 | listOf(this.sid), | 318 | listOf(this.sid), |
| 321 | - encodings | 319 | + encodings, |
| 322 | ) | 320 | ) |
| 323 | val transceiver = engine.publisher.peerConnection.addTransceiver(track.rtcTrack, transInit) | 321 | val transceiver = engine.publisher.peerConnection.addTransceiver(track.rtcTrack, transInit) |
| 324 | 322 | ||
| @@ -393,7 +391,7 @@ internal constructor( | @@ -393,7 +391,7 @@ internal constructor( | ||
| 393 | 391 | ||
| 394 | private fun computeVideoEncodings( | 392 | private fun computeVideoEncodings( |
| 395 | dimensions: Track.Dimensions, | 393 | dimensions: Track.Dimensions, |
| 396 | - options: VideoTrackPublishOptions | 394 | + options: VideoTrackPublishOptions, |
| 397 | ): List<RtpParameters.Encoding> { | 395 | ): List<RtpParameters.Encoding> { |
| 398 | val (width, height) = dimensions | 396 | val (width, height) = dimensions |
| 399 | var encoding = options.videoEncoding | 397 | var encoding = options.videoEncoding |
| @@ -410,7 +408,6 @@ internal constructor( | @@ -410,7 +408,6 @@ internal constructor( | ||
| 410 | 408 | ||
| 411 | val encodings = mutableListOf<RtpParameters.Encoding>() | 409 | val encodings = mutableListOf<RtpParameters.Encoding>() |
| 412 | if (simulcast) { | 410 | if (simulcast) { |
| 413 | - | ||
| 414 | val presets = EncodingUtils.presetsForResolution(width, height) | 411 | val presets = EncodingUtils.presetsForResolution(width, height) |
| 415 | val midPreset = presets[1] | 412 | val midPreset = presets[1] |
| 416 | val lowPreset = presets[0] | 413 | val lowPreset = presets[0] |
| @@ -456,7 +453,6 @@ internal constructor( | @@ -456,7 +453,6 @@ internal constructor( | ||
| 456 | return encodings | 453 | return encodings |
| 457 | } | 454 | } |
| 458 | 455 | ||
| 459 | - | ||
| 460 | /** | 456 | /** |
| 461 | * Control who can subscribe to LocalParticipant's published tracks. | 457 | * Control who can subscribe to LocalParticipant's published tracks. |
| 462 | * | 458 | * |
| @@ -476,7 +472,7 @@ internal constructor( | @@ -476,7 +472,7 @@ internal constructor( | ||
| 476 | */ | 472 | */ |
| 477 | fun setTrackSubscriptionPermissions( | 473 | fun setTrackSubscriptionPermissions( |
| 478 | allParticipantsAllowed: Boolean, | 474 | allParticipantsAllowed: Boolean, |
| 479 | - participantTrackPermissions: List<ParticipantTrackPermission> = emptyList() | 475 | + participantTrackPermissions: List<ParticipantTrackPermission> = emptyList(), |
| 480 | ) { | 476 | ) { |
| 481 | engine.updateSubscriptionPermissions(allParticipantsAllowed, participantTrackPermissions) | 477 | engine.updateSubscriptionPermissions(allParticipantsAllowed, participantTrackPermissions) |
| 482 | } | 478 | } |
| @@ -732,7 +728,7 @@ data class VideoTrackPublishOptions( | @@ -732,7 +728,7 @@ data class VideoTrackPublishOptions( | ||
| 732 | ) : BaseVideoTrackPublishOptions(), TrackPublishOptions { | 728 | ) : BaseVideoTrackPublishOptions(), TrackPublishOptions { |
| 733 | constructor( | 729 | constructor( |
| 734 | name: String? = null, | 730 | name: String? = null, |
| 735 | - base: BaseVideoTrackPublishOptions | 731 | + base: BaseVideoTrackPublishOptions, |
| 736 | ) : this( | 732 | ) : this( |
| 737 | name, | 733 | name, |
| 738 | base.videoEncoding, | 734 | base.videoEncoding, |
| @@ -748,21 +744,21 @@ abstract class BaseAudioTrackPublishOptions { | @@ -748,21 +744,21 @@ abstract class BaseAudioTrackPublishOptions { | ||
| 748 | 744 | ||
| 749 | data class AudioTrackPublishDefaults( | 745 | data class AudioTrackPublishDefaults( |
| 750 | override val audioBitrate: Int? = 20_000, | 746 | override val audioBitrate: Int? = 20_000, |
| 751 | - override val dtx: Boolean = true | 747 | + override val dtx: Boolean = true, |
| 752 | ) : BaseAudioTrackPublishOptions() | 748 | ) : BaseAudioTrackPublishOptions() |
| 753 | 749 | ||
| 754 | data class AudioTrackPublishOptions( | 750 | data class AudioTrackPublishOptions( |
| 755 | override val name: String? = null, | 751 | override val name: String? = null, |
| 756 | override val audioBitrate: Int? = null, | 752 | override val audioBitrate: Int? = null, |
| 757 | - override val dtx: Boolean = true | 753 | + override val dtx: Boolean = true, |
| 758 | ) : BaseAudioTrackPublishOptions(), TrackPublishOptions { | 754 | ) : BaseAudioTrackPublishOptions(), TrackPublishOptions { |
| 759 | constructor( | 755 | constructor( |
| 760 | name: String? = null, | 756 | name: String? = null, |
| 761 | - base: BaseAudioTrackPublishOptions | 757 | + base: BaseAudioTrackPublishOptions, |
| 762 | ) : this( | 758 | ) : this( |
| 763 | name, | 759 | name, |
| 764 | base.audioBitrate, | 760 | base.audioBitrate, |
| 765 | - base.dtx | 761 | + base.dtx, |
| 766 | ) | 762 | ) |
| 767 | } | 763 | } |
| 768 | 764 | ||
| @@ -785,7 +781,7 @@ data class ParticipantTrackPermission( | @@ -785,7 +781,7 @@ data class ParticipantTrackPermission( | ||
| 785 | /** | 781 | /** |
| 786 | * The list of track ids that the target participant can subscribe to. | 782 | * The list of track ids that the target participant can subscribe to. |
| 787 | */ | 783 | */ |
| 788 | - val allowedTrackSids: List<String> = emptyList() | 784 | + val allowedTrackSids: List<String> = emptyList(), |
| 789 | ) { | 785 | ) { |
| 790 | init { | 786 | init { |
| 791 | if (participantIdentity == null && participantSid == null) { | 787 | if (participantIdentity == null && participantSid == null) { |
| @@ -806,11 +802,11 @@ data class ParticipantTrackPermission( | @@ -806,11 +802,11 @@ data class ParticipantTrackPermission( | ||
| 806 | sealed class PublishRecord() { | 802 | sealed class PublishRecord() { |
| 807 | data class AudioTrackPublishRecord( | 803 | data class AudioTrackPublishRecord( |
| 808 | val track: LocalAudioTrack, | 804 | val track: LocalAudioTrack, |
| 809 | - val options: AudioTrackPublishOptions | 805 | + val options: AudioTrackPublishOptions, |
| 810 | ) | 806 | ) |
| 811 | 807 | ||
| 812 | data class VideoTrackPublishRecord( | 808 | data class VideoTrackPublishRecord( |
| 813 | val track: LocalVideoTrack, | 809 | val track: LocalVideoTrack, |
| 814 | - val options: VideoTrackPublishOptions | 810 | + val options: VideoTrackPublishOptions, |
| 815 | ) | 811 | ) |
| 816 | } | 812 | } |
| @@ -127,9 +127,9 @@ open class Participant( | @@ -127,9 +127,9 @@ open class Participant( | ||
| 127 | ParticipantEvent.ParticipantPermissionsChanged( | 127 | ParticipantEvent.ParticipantPermissionsChanged( |
| 128 | this, | 128 | this, |
| 129 | newPermissions, | 129 | newPermissions, |
| 130 | - oldPermissions | 130 | + oldPermissions, |
| 131 | ), | 131 | ), |
| 132 | - scope | 132 | + scope, |
| 133 | ) | 133 | ) |
| 134 | } | 134 | } |
| 135 | } | 135 | } |
| @@ -191,7 +191,7 @@ open class Participant( | @@ -191,7 +191,7 @@ open class Participant( | ||
| 191 | // Re-emit when track changes | 191 | // Re-emit when track changes |
| 192 | trackPublication::track.flow | 192 | trackPublication::track.flow |
| 193 | .map { trackPublication to trackPublication.track } | 193 | .map { trackPublication to trackPublication.track } |
| 194 | - } | 194 | + }, |
| 195 | ) { trackPubs -> | 195 | ) { trackPubs -> |
| 196 | trackPubs.toList() | 196 | trackPubs.toList() |
| 197 | } | 197 | } |
| @@ -208,7 +208,7 @@ open class Participant( | @@ -208,7 +208,7 @@ open class Participant( | ||
| 208 | stateFlow = ::tracks.flow | 208 | stateFlow = ::tracks.flow |
| 209 | .map { it.filterValues { publication -> publication.kind == Track.Kind.AUDIO } } | 209 | .map { it.filterValues { publication -> publication.kind == Track.Kind.AUDIO } } |
| 210 | .trackUpdateFlow() | 210 | .trackUpdateFlow() |
| 211 | - .stateIn(delegateScope, SharingStarted.Eagerly, emptyList()) | 211 | + .stateIn(delegateScope, SharingStarted.Eagerly, emptyList()), |
| 212 | ) | 212 | ) |
| 213 | 213 | ||
| 214 | /** | 214 | /** |
| @@ -220,7 +220,7 @@ open class Participant( | @@ -220,7 +220,7 @@ open class Participant( | ||
| 220 | stateFlow = ::tracks.flow | 220 | stateFlow = ::tracks.flow |
| 221 | .map { it.filterValues { publication -> publication.kind == Track.Kind.VIDEO } } | 221 | .map { it.filterValues { publication -> publication.kind == Track.Kind.VIDEO } } |
| 222 | .trackUpdateFlow() | 222 | .trackUpdateFlow() |
| 223 | - .stateIn(delegateScope, SharingStarted.Eagerly, emptyList()) | 223 | + .stateIn(delegateScope, SharingStarted.Eagerly, emptyList()), |
| 224 | ) | 224 | ) |
| 225 | 225 | ||
| 226 | /** | 226 | /** |
| @@ -340,7 +340,7 @@ open class Participant( | @@ -340,7 +340,7 @@ open class Participant( | ||
| 340 | val trackPublication = tracks[trackEvent.track.sid] ?: return | 340 | val trackPublication = tracks[trackEvent.track.sid] ?: return |
| 341 | eventBus.postEvent( | 341 | eventBus.postEvent( |
| 342 | ParticipantEvent.TrackStreamStateChanged(this, trackPublication, trackEvent.streamState), | 342 | ParticipantEvent.TrackStreamStateChanged(this, trackPublication, trackEvent.streamState), |
| 343 | - scope | 343 | + scope, |
| 344 | ) | 344 | ) |
| 345 | } | 345 | } |
| 346 | 346 | ||
| @@ -392,7 +392,6 @@ interface ParticipantListener { | @@ -392,7 +392,6 @@ interface ParticipantListener { | ||
| 392 | */ | 392 | */ |
| 393 | fun onTrackUnmuted(publication: TrackPublication, participant: Participant) {} | 393 | fun onTrackUnmuted(publication: TrackPublication, participant: Participant) {} |
| 394 | 394 | ||
| 395 | - | ||
| 396 | // local participants | 395 | // local participants |
| 397 | /** | 396 | /** |
| 398 | * When a new track is published by the local participant. | 397 | * When a new track is published by the local participant. |
| @@ -428,7 +427,7 @@ interface ParticipantListener { | @@ -428,7 +427,7 @@ interface ParticipantListener { | ||
| 428 | fun onTrackSubscriptionFailed( | 427 | fun onTrackSubscriptionFailed( |
| 429 | sid: String, | 428 | sid: String, |
| 430 | exception: Exception, | 429 | exception: Exception, |
| 431 | - participant: RemoteParticipant | 430 | + participant: RemoteParticipant, |
| 432 | ) { | 431 | ) { |
| 433 | } | 432 | } |
| 434 | 433 | ||
| @@ -439,7 +438,7 @@ interface ParticipantListener { | @@ -439,7 +438,7 @@ interface ParticipantListener { | ||
| 439 | fun onTrackUnsubscribed( | 438 | fun onTrackUnsubscribed( |
| 440 | track: Track, | 439 | track: Track, |
| 441 | publication: RemoteTrackPublication, | 440 | publication: RemoteTrackPublication, |
| 442 | - participant: RemoteParticipant | 441 | + participant: RemoteParticipant, |
| 443 | ) { | 442 | ) { |
| 444 | } | 443 | } |
| 445 | 444 | ||
| @@ -453,7 +452,8 @@ enum class ConnectionQuality { | @@ -453,7 +452,8 @@ enum class ConnectionQuality { | ||
| 453 | EXCELLENT, | 452 | EXCELLENT, |
| 454 | GOOD, | 453 | GOOD, |
| 455 | POOR, | 454 | POOR, |
| 456 | - UNKNOWN; | 455 | + UNKNOWN, |
| 456 | + ; | ||
| 457 | 457 | ||
| 458 | companion object { | 458 | companion object { |
| 459 | fun fromProto(proto: LivekitModels.ConnectionQuality): ConnectionQuality { | 459 | fun fromProto(proto: LivekitModels.ConnectionQuality): ConnectionQuality { |
| @@ -31,7 +31,6 @@ import livekit.LivekitRtc | @@ -31,7 +31,6 @@ import livekit.LivekitRtc | ||
| 31 | import org.webrtc.AudioTrack | 31 | import org.webrtc.AudioTrack |
| 32 | import org.webrtc.MediaStreamTrack | 32 | import org.webrtc.MediaStreamTrack |
| 33 | import org.webrtc.RtpReceiver | 33 | import org.webrtc.RtpReceiver |
| 34 | -import org.webrtc.RtpTransceiver | ||
| 35 | import org.webrtc.VideoTrack | 34 | import org.webrtc.VideoTrack |
| 36 | 35 | ||
| 37 | class RemoteParticipant( | 36 | class RemoteParticipant( |
| @@ -135,7 +134,7 @@ class RemoteParticipant( | @@ -135,7 +134,7 @@ class RemoteParticipant( | ||
| 135 | } else { | 134 | } else { |
| 136 | coroutineScope.launch { | 135 | coroutineScope.launch { |
| 137 | delay(150) | 136 | delay(150) |
| 138 | - addSubscribedMediaTrack(mediaTrack, sid, statsGetter,receiver = receiver, autoManageVideo, triesLeft - 1) | 137 | + addSubscribedMediaTrack(mediaTrack, sid, statsGetter, receiver = receiver, autoManageVideo, triesLeft - 1) |
| 139 | } | 138 | } |
| 140 | } | 139 | } |
| 141 | return | 140 | return |
| @@ -19,5 +19,4 @@ package io.livekit.android.room.track | @@ -19,5 +19,4 @@ package io.livekit.android.room.track | ||
| 19 | import org.webrtc.AudioTrack | 19 | import org.webrtc.AudioTrack |
| 20 | 20 | ||
| 21 | abstract class AudioTrack(name: String, override val rtcTrack: AudioTrack) : | 21 | abstract class AudioTrack(name: String, override val rtcTrack: AudioTrack) : |
| 22 | - Track(name, Kind.AUDIO, rtcTrack) { | ||
| 23 | -} | 22 | + Track(name, Kind.AUDIO, rtcTrack) |
| @@ -55,7 +55,7 @@ constructor( | @@ -55,7 +55,7 @@ constructor( | ||
| 55 | context, | 55 | context, |
| 56 | eglBase, | 56 | eglBase, |
| 57 | defaultsManager, | 57 | defaultsManager, |
| 58 | - videoTrackFactory | 58 | + videoTrackFactory, |
| 59 | ) { | 59 | ) { |
| 60 | 60 | ||
| 61 | private val serviceConnection = ScreenCaptureConnection(context) | 61 | private val serviceConnection = ScreenCaptureConnection(context) |
| @@ -128,7 +128,7 @@ constructor( | @@ -128,7 +128,7 @@ constructor( | ||
| 128 | name: String, | 128 | name: String, |
| 129 | options: LocalVideoTrackOptions, | 129 | options: LocalVideoTrackOptions, |
| 130 | rootEglBase: EglBase, | 130 | rootEglBase: EglBase, |
| 131 | - screencastVideoTrackFactory: Factory | 131 | + screencastVideoTrackFactory: Factory, |
| 132 | ): LocalScreencastVideoTrack { | 132 | ): LocalScreencastVideoTrack { |
| 133 | val source = peerConnectionFactory.createVideoSource(options.isScreencast) | 133 | val source = peerConnectionFactory.createVideoSource(options.isScreencast) |
| 134 | val callback = MediaProjectionCallback() | 134 | val callback = MediaProjectionCallback() |
| @@ -136,7 +136,7 @@ constructor( | @@ -136,7 +136,7 @@ constructor( | ||
| 136 | capturer.initialize( | 136 | capturer.initialize( |
| 137 | SurfaceTextureHelper.create("ScreenVideoCaptureThread", rootEglBase.eglBaseContext), | 137 | SurfaceTextureHelper.create("ScreenVideoCaptureThread", rootEglBase.eglBaseContext), |
| 138 | context, | 138 | context, |
| 139 | - source.capturerObserver | 139 | + source.capturerObserver, |
| 140 | ) | 140 | ) |
| 141 | val track = peerConnectionFactory.createVideoTrack(UUID.randomUUID().toString(), source) | 141 | val track = peerConnectionFactory.createVideoTrack(UUID.randomUUID().toString(), source) |
| 142 | 142 | ||
| @@ -146,14 +146,13 @@ constructor( | @@ -146,14 +146,13 @@ constructor( | ||
| 146 | options = options, | 146 | options = options, |
| 147 | name = name, | 147 | name = name, |
| 148 | rtcTrack = track, | 148 | rtcTrack = track, |
| 149 | - mediaProjectionCallback = callback | 149 | + mediaProjectionCallback = callback, |
| 150 | ) | 150 | ) |
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | - | ||
| 154 | private fun createScreenCapturer( | 153 | private fun createScreenCapturer( |
| 155 | resultData: Intent, | 154 | resultData: Intent, |
| 156 | - callback: MediaProjectionCallback | 155 | + callback: MediaProjectionCallback, |
| 157 | ): ScreenCapturerAndroid { | 156 | ): ScreenCapturerAndroid { |
| 158 | return ScreenCapturerAndroid(resultData, callback) | 157 | return ScreenCapturerAndroid(resultData, callback) |
| 159 | } | 158 | } |
| @@ -21,7 +21,6 @@ import android.content.Context | @@ -21,7 +21,6 @@ import android.content.Context | ||
| 21 | import android.content.pm.PackageManager | 21 | import android.content.pm.PackageManager |
| 22 | import android.hardware.camera2.CameraManager | 22 | import android.hardware.camera2.CameraManager |
| 23 | import androidx.core.content.ContextCompat | 23 | import androidx.core.content.ContextCompat |
| 24 | -import com.github.ajalt.timberkt.Timber | ||
| 25 | import dagger.assisted.Assisted | 24 | import dagger.assisted.Assisted |
| 26 | import dagger.assisted.AssistedFactory | 25 | import dagger.assisted.AssistedFactory |
| 27 | import dagger.assisted.AssistedInject | 26 | import dagger.assisted.AssistedInject |
| @@ -36,7 +35,6 @@ import org.webrtc.* | @@ -36,7 +35,6 @@ import org.webrtc.* | ||
| 36 | import org.webrtc.CameraVideoCapturer.CameraEventsHandler | 35 | import org.webrtc.CameraVideoCapturer.CameraEventsHandler |
| 37 | import java.util.* | 36 | import java.util.* |
| 38 | 37 | ||
| 39 | - | ||
| 40 | /** | 38 | /** |
| 41 | * A representation of a local video track (generally input coming from camera or screen). | 39 | * A representation of a local video track (generally input coming from camera or screen). |
| 42 | * | 40 | * |
| @@ -116,7 +114,6 @@ constructor( | @@ -116,7 +114,6 @@ constructor( | ||
| 116 | * this will switch to the next camera, if one is available. | 114 | * this will switch to the next camera, if one is available. |
| 117 | */ | 115 | */ |
| 118 | fun switchCamera(deviceId: String? = null, position: CameraPosition? = null) { | 116 | fun switchCamera(deviceId: String? = null, position: CameraPosition? = null) { |
| 119 | - | ||
| 120 | val cameraCapturer = capturer as? CameraVideoCapturer ?: run { | 117 | val cameraCapturer = capturer as? CameraVideoCapturer ?: run { |
| 121 | LKLog.w { "Attempting to switch camera on a non-camera video track!" } | 118 | LKLog.w { "Attempting to switch camera on a non-camera video track!" } |
| 122 | return | 119 | return |
| @@ -183,7 +180,6 @@ constructor( | @@ -183,7 +180,6 @@ constructor( | ||
| 183 | override fun onCameraSwitchError(errorDescription: String?) { | 180 | override fun onCameraSwitchError(errorDescription: String?) { |
| 184 | LKLog.w { "switching camera failed: $errorDescription" } | 181 | LKLog.w { "switching camera failed: $errorDescription" } |
| 185 | } | 182 | } |
| 186 | - | ||
| 187 | } | 183 | } |
| 188 | if (targetDeviceId == null) { | 184 | if (targetDeviceId == null) { |
| 189 | LKLog.w { "No target camera found!" } | 185 | LKLog.w { "No target camera found!" } |
| @@ -197,7 +193,6 @@ constructor( | @@ -197,7 +193,6 @@ constructor( | ||
| 197 | * Restart a track with new options. | 193 | * Restart a track with new options. |
| 198 | */ | 194 | */ |
| 199 | fun restartTrack(options: LocalVideoTrackOptions = defaultsManager.videoTrackCaptureDefaults.copy()) { | 195 | fun restartTrack(options: LocalVideoTrackOptions = defaultsManager.videoTrackCaptureDefaults.copy()) { |
| 200 | - | ||
| 201 | val oldCapturer = capturer | 196 | val oldCapturer = capturer |
| 202 | val oldSource = source | 197 | val oldSource = source |
| 203 | val oldRtcTrack = rtcTrack | 198 | val oldRtcTrack = rtcTrack |
| @@ -293,7 +288,6 @@ constructor( | @@ -293,7 +288,6 @@ constructor( | ||
| 293 | trackFactory: Factory, | 288 | trackFactory: Factory, |
| 294 | videoProcessor: VideoProcessor? = null, | 289 | videoProcessor: VideoProcessor? = null, |
| 295 | ): LocalVideoTrack { | 290 | ): LocalVideoTrack { |
| 296 | - | ||
| 297 | if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != | 291 | if (ContextCompat.checkSelfPermission(context, Manifest.permission.CAMERA) != |
| 298 | PackageManager.PERMISSION_GRANTED | 292 | PackageManager.PERMISSION_GRANTED |
| 299 | ) { | 293 | ) { |
| @@ -450,5 +444,4 @@ constructor( | @@ -450,5 +444,4 @@ constructor( | ||
| 450 | return null | 444 | return null |
| 451 | } | 445 | } |
| 452 | } | 446 | } |
| 453 | - | ||
| 454 | } | 447 | } |
| @@ -26,7 +26,7 @@ data class LocalVideoTrackOptions( | @@ -26,7 +26,7 @@ data class LocalVideoTrackOptions( | ||
| 26 | */ | 26 | */ |
| 27 | val deviceId: String? = null, | 27 | val deviceId: String? = null, |
| 28 | val position: CameraPosition? = CameraPosition.FRONT, | 28 | val position: CameraPosition? = CameraPosition.FRONT, |
| 29 | - val captureParams: VideoCaptureParameter = VideoPreset169.QHD.capture | 29 | + val captureParams: VideoCaptureParameter = VideoPreset169.QHD.capture, |
| 30 | ) | 30 | ) |
| 31 | 31 | ||
| 32 | data class VideoCaptureParameter( | 32 | data class VideoCaptureParameter( |
| @@ -56,7 +56,6 @@ data class VideoEncoding( | @@ -56,7 +56,6 @@ data class VideoEncoding( | ||
| 56 | networkPriority = 1 // low, from priority.h in webrtc | 56 | networkPriority = 1 // low, from priority.h in webrtc |
| 57 | bitratePriority = 1.0 | 57 | bitratePriority = 1.0 |
| 58 | } | 58 | } |
| 59 | - | ||
| 60 | } | 59 | } |
| 61 | } | 60 | } |
| 62 | } | 61 | } |
| @@ -68,7 +67,7 @@ enum class VideoCodec(val codecName: String) { | @@ -68,7 +67,7 @@ enum class VideoCodec(val codecName: String) { | ||
| 68 | 67 | ||
| 69 | enum class CameraPosition { | 68 | enum class CameraPosition { |
| 70 | FRONT, | 69 | FRONT, |
| 71 | - BACK | 70 | + BACK, |
| 72 | } | 71 | } |
| 73 | 72 | ||
| 74 | interface VideoPreset { | 73 | interface VideoPreset { |
| @@ -125,26 +124,30 @@ enum class VideoPreset169( | @@ -125,26 +124,30 @@ enum class VideoPreset169( | ||
| 125 | VideoCaptureParameter(320, 180, 15), | 124 | VideoCaptureParameter(320, 180, 15), |
| 126 | VideoEncoding(125_000, 15), | 125 | VideoEncoding(125_000, 15), |
| 127 | ), | 126 | ), |
| 127 | + | ||
| 128 | @Deprecated("VGA is deprecated, use H360 instead") | 128 | @Deprecated("VGA is deprecated, use H360 instead") |
| 129 | VGA( | 129 | VGA( |
| 130 | VideoCaptureParameter(640, 360, 30), | 130 | VideoCaptureParameter(640, 360, 30), |
| 131 | VideoEncoding(400_000, 30), | 131 | VideoEncoding(400_000, 30), |
| 132 | ), | 132 | ), |
| 133 | + | ||
| 133 | @Deprecated("QHD is deprecated, use H540 instead") | 134 | @Deprecated("QHD is deprecated, use H540 instead") |
| 134 | QHD( | 135 | QHD( |
| 135 | VideoCaptureParameter(960, 540, 30), | 136 | VideoCaptureParameter(960, 540, 30), |
| 136 | VideoEncoding(800_000, 30), | 137 | VideoEncoding(800_000, 30), |
| 137 | ), | 138 | ), |
| 139 | + | ||
| 138 | @Deprecated("HD is deprecated, use H720 instead") | 140 | @Deprecated("HD is deprecated, use H720 instead") |
| 139 | HD( | 141 | HD( |
| 140 | VideoCaptureParameter(1280, 720, 30), | 142 | VideoCaptureParameter(1280, 720, 30), |
| 141 | VideoEncoding(2_500_000, 30), | 143 | VideoEncoding(2_500_000, 30), |
| 142 | ), | 144 | ), |
| 145 | + | ||
| 143 | @Deprecated("FHD is deprecated, use H1080 instead") | 146 | @Deprecated("FHD is deprecated, use H1080 instead") |
| 144 | FHD( | 147 | FHD( |
| 145 | VideoCaptureParameter(1920, 1080, 30), | 148 | VideoCaptureParameter(1920, 1080, 30), |
| 146 | VideoEncoding(4_000_000, 30), | 149 | VideoEncoding(4_000_000, 30), |
| 147 | - ) | 150 | + ), |
| 148 | } | 151 | } |
| 149 | 152 | ||
| 150 | /** | 153 | /** |
| @@ -196,24 +199,28 @@ enum class VideoPreset43( | @@ -196,24 +199,28 @@ enum class VideoPreset43( | ||
| 196 | VideoCaptureParameter(240, 180, 15), | 199 | VideoCaptureParameter(240, 180, 15), |
| 197 | VideoEncoding(100_000, 15), | 200 | VideoEncoding(100_000, 15), |
| 198 | ), | 201 | ), |
| 202 | + | ||
| 199 | @Deprecated("VGA is deprecated, use H360 instead") | 203 | @Deprecated("VGA is deprecated, use H360 instead") |
| 200 | VGA( | 204 | VGA( |
| 201 | VideoCaptureParameter(480, 360, 30), | 205 | VideoCaptureParameter(480, 360, 30), |
| 202 | VideoEncoding(320_000, 30), | 206 | VideoEncoding(320_000, 30), |
| 203 | ), | 207 | ), |
| 208 | + | ||
| 204 | @Deprecated("QHD is deprecated, use H540 instead") | 209 | @Deprecated("QHD is deprecated, use H540 instead") |
| 205 | QHD( | 210 | QHD( |
| 206 | VideoCaptureParameter(720, 540, 30), | 211 | VideoCaptureParameter(720, 540, 30), |
| 207 | VideoEncoding(640_000, 30), | 212 | VideoEncoding(640_000, 30), |
| 208 | ), | 213 | ), |
| 214 | + | ||
| 209 | @Deprecated("HD is deprecated, use H720 instead") | 215 | @Deprecated("HD is deprecated, use H720 instead") |
| 210 | HD( | 216 | HD( |
| 211 | VideoCaptureParameter(960, 720, 30), | 217 | VideoCaptureParameter(960, 720, 30), |
| 212 | VideoEncoding(2_000_000, 30), | 218 | VideoEncoding(2_000_000, 30), |
| 213 | ), | 219 | ), |
| 220 | + | ||
| 214 | @Deprecated("FHD is deprecated, use H1080 instead") | 221 | @Deprecated("FHD is deprecated, use H1080 instead") |
| 215 | FHD( | 222 | FHD( |
| 216 | VideoCaptureParameter(1440, 1080, 30), | 223 | VideoCaptureParameter(1440, 1080, 30), |
| 217 | VideoEncoding(3_200_000, 30), | 224 | VideoEncoding(3_200_000, 30), |
| 218 | - ) | 225 | + ), |
| 219 | } | 226 | } |
| @@ -153,10 +153,10 @@ class RemoteTrackPublication( | @@ -153,10 +153,10 @@ class RemoteTrackPublication( | ||
| 153 | * Will override previous calls to [setVideoDimensions]. | 153 | * Will override previous calls to [setVideoDimensions]. |
| 154 | */ | 154 | */ |
| 155 | fun setVideoQuality(quality: LivekitModels.VideoQuality) { | 155 | fun setVideoQuality(quality: LivekitModels.VideoQuality) { |
| 156 | - if (isAutoManaged | ||
| 157 | - || !subscribed | ||
| 158 | - || quality == videoQuality | ||
| 159 | - || track !is VideoTrack | 156 | + if (isAutoManaged || |
| 157 | + !subscribed || | ||
| 158 | + quality == videoQuality || | ||
| 159 | + track !is VideoTrack | ||
| 160 | ) { | 160 | ) { |
| 161 | return | 161 | return |
| 162 | } | 162 | } |
| @@ -171,10 +171,10 @@ class RemoteTrackPublication( | @@ -171,10 +171,10 @@ class RemoteTrackPublication( | ||
| 171 | * Will override previous calls to [setVideoQuality]. | 171 | * Will override previous calls to [setVideoQuality]. |
| 172 | */ | 172 | */ |
| 173 | fun setVideoDimensions(dimensions: Track.Dimensions) { | 173 | fun setVideoDimensions(dimensions: Track.Dimensions) { |
| 174 | - if (isAutoManaged | ||
| 175 | - || !subscribed | ||
| 176 | - || videoDimensions == dimensions | ||
| 177 | - || track !is VideoTrack | 174 | + if (isAutoManaged || |
| 175 | + !subscribed || | ||
| 176 | + videoDimensions == dimensions || | ||
| 177 | + track !is VideoTrack | ||
| 178 | ) { | 178 | ) { |
| 179 | return | 179 | return |
| 180 | } | 180 | } |
| @@ -188,10 +188,10 @@ class RemoteTrackPublication( | @@ -188,10 +188,10 @@ class RemoteTrackPublication( | ||
| 188 | * Update the fps that the server will use for determining the video quality to send down. | 188 | * Update the fps that the server will use for determining the video quality to send down. |
| 189 | */ | 189 | */ |
| 190 | fun setVideoFps(fps: Int?) { | 190 | fun setVideoFps(fps: Int?) { |
| 191 | - if (isAutoManaged | ||
| 192 | - || !subscribed | ||
| 193 | - || this.fps == fps | ||
| 194 | - || track !is VideoTrack | 191 | + if (isAutoManaged || |
| 192 | + !subscribed || | ||
| 193 | + this.fps == fps || | ||
| 194 | + track !is VideoTrack | ||
| 195 | ) { | 195 | ) { |
| 196 | return | 196 | return |
| 197 | } | 197 | } |
| @@ -232,7 +232,7 @@ class RemoteTrackPublication( | @@ -232,7 +232,7 @@ class RemoteTrackPublication( | ||
| 232 | disabled, | 232 | disabled, |
| 233 | videoDimensions, | 233 | videoDimensions, |
| 234 | videoQuality, | 234 | videoQuality, |
| 235 | - fps | 235 | + fps, |
| 236 | ) | 236 | ) |
| 237 | } | 237 | } |
| 238 | 238 | ||
| @@ -250,6 +250,6 @@ class RemoteTrackPublication( | @@ -250,6 +250,6 @@ class RemoteTrackPublication( | ||
| 250 | /** | 250 | /** |
| 251 | * Not subscribed. | 251 | * Not subscribed. |
| 252 | */ | 252 | */ |
| 253 | - UNSUBSCRIBED | 253 | + UNSUBSCRIBED, |
| 254 | } | 254 | } |
| 255 | } | 255 | } |
| @@ -25,7 +25,6 @@ import io.livekit.android.room.track.video.ViewVisibility | @@ -25,7 +25,6 @@ import io.livekit.android.room.track.video.ViewVisibility | ||
| 25 | import io.livekit.android.util.LKLog | 25 | import io.livekit.android.util.LKLog |
| 26 | import kotlinx.coroutines.* | 26 | import kotlinx.coroutines.* |
| 27 | import org.webrtc.RtpReceiver | 27 | import org.webrtc.RtpReceiver |
| 28 | -import org.webrtc.RtpTransceiver | ||
| 29 | import org.webrtc.VideoSink | 28 | import org.webrtc.VideoSink |
| 30 | import javax.inject.Named | 29 | import javax.inject.Named |
| 31 | import kotlin.math.max | 30 | import kotlin.math.max |
| @@ -30,7 +30,7 @@ import org.webrtc.RTCStatsReport | @@ -30,7 +30,7 @@ import org.webrtc.RTCStatsReport | ||
| 30 | abstract class Track( | 30 | abstract class Track( |
| 31 | name: String, | 31 | name: String, |
| 32 | kind: Kind, | 32 | kind: Kind, |
| 33 | - open val rtcTrack: MediaStreamTrack | 33 | + open val rtcTrack: MediaStreamTrack, |
| 34 | ) { | 34 | ) { |
| 35 | protected val eventBus = BroadcastEventBus<TrackEvent>() | 35 | protected val eventBus = BroadcastEventBus<TrackEvent>() |
| 36 | val events = eventBus.readOnly() | 36 | val events = eventBus.readOnly() |
| @@ -67,7 +67,8 @@ abstract class Track( | @@ -67,7 +67,8 @@ abstract class Track( | ||
| 67 | VIDEO("video"), | 67 | VIDEO("video"), |
| 68 | 68 | ||
| 69 | // unknown | 69 | // unknown |
| 70 | - UNRECOGNIZED("unrecognized"); | 70 | + UNRECOGNIZED("unrecognized"), |
| 71 | + ; | ||
| 71 | 72 | ||
| 72 | fun toProto(): LivekitModels.TrackType { | 73 | fun toProto(): LivekitModels.TrackType { |
| 73 | return when (this) { | 74 | return when (this) { |
| @@ -78,7 +79,7 @@ abstract class Track( | @@ -78,7 +79,7 @@ abstract class Track( | ||
| 78 | } | 79 | } |
| 79 | 80 | ||
| 80 | override fun toString(): String { | 81 | override fun toString(): String { |
| 81 | - return value; | 82 | + return value |
| 82 | } | 83 | } |
| 83 | 84 | ||
| 84 | companion object { | 85 | companion object { |
| @@ -96,8 +97,8 @@ abstract class Track( | @@ -96,8 +97,8 @@ abstract class Track( | ||
| 96 | CAMERA, | 97 | CAMERA, |
| 97 | MICROPHONE, | 98 | MICROPHONE, |
| 98 | SCREEN_SHARE, | 99 | SCREEN_SHARE, |
| 99 | - UNKNOWN; | ||
| 100 | - | 100 | + UNKNOWN, |
| 101 | + ; | ||
| 101 | 102 | ||
| 102 | fun toProto(): LivekitModels.TrackSource { | 103 | fun toProto(): LivekitModels.TrackSource { |
| 103 | return when (this) { | 104 | return when (this) { |
| @@ -123,7 +124,8 @@ abstract class Track( | @@ -123,7 +124,8 @@ abstract class Track( | ||
| 123 | enum class StreamState { | 124 | enum class StreamState { |
| 124 | ACTIVE, | 125 | ACTIVE, |
| 125 | PAUSED, | 126 | PAUSED, |
| 126 | - UNKNOWN; | 127 | + UNKNOWN, |
| 128 | + ; | ||
| 127 | 129 | ||
| 128 | fun toProto(): LivekitRtc.StreamState { | 130 | fun toProto(): LivekitRtc.StreamState { |
| 129 | return when (this) { | 131 | return when (this) { |
| @@ -159,7 +161,6 @@ abstract class Track( | @@ -159,7 +161,6 @@ abstract class Track( | ||
| 159 | } | 161 | } |
| 160 | } | 162 | } |
| 161 | 163 | ||
| 162 | - | ||
| 163 | sealed class TrackException(message: String? = null, cause: Throwable? = null) : | 164 | sealed class TrackException(message: String? = null, cause: Throwable? = null) : |
| 164 | Exception(message, cause) { | 165 | Exception(message, cause) { |
| 165 | class InvalidTrackTypeException(message: String? = null, cause: Throwable? = null) : | 166 | class InvalidTrackTypeException(message: String? = null, cause: Throwable? = null) : |
| @@ -21,7 +21,7 @@ import org.webrtc.VideoTrack | @@ -21,7 +21,7 @@ import org.webrtc.VideoTrack | ||
| 21 | 21 | ||
| 22 | abstract class VideoTrack(name: String, override val rtcTrack: VideoTrack) : | 22 | abstract class VideoTrack(name: String, override val rtcTrack: VideoTrack) : |
| 23 | Track(name, Kind.VIDEO, rtcTrack) { | 23 | Track(name, Kind.VIDEO, rtcTrack) { |
| 24 | - protected val sinks: MutableList<VideoSink> = ArrayList(); | 24 | + protected val sinks: MutableList<VideoSink> = ArrayList() |
| 25 | 25 | ||
| 26 | var enabled: Boolean | 26 | var enabled: Boolean |
| 27 | get() = rtcTrack.enabled() | 27 | get() = rtcTrack.enabled() |
| @@ -67,7 +67,7 @@ open class ScreenCaptureService : Service() { | @@ -67,7 +67,7 @@ open class ScreenCaptureService : Service() { | ||
| 67 | val channel = NotificationChannel( | 67 | val channel = NotificationChannel( |
| 68 | DEFAULT_CHANNEL_ID, | 68 | DEFAULT_CHANNEL_ID, |
| 69 | "Screen Capture", | 69 | "Screen Capture", |
| 70 | - NotificationManager.IMPORTANCE_LOW | 70 | + NotificationManager.IMPORTANCE_LOW, |
| 71 | ) | 71 | ) |
| 72 | val service = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager | 72 | val service = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager |
| 73 | service.createNotificationChannel(channel) | 73 | service.createNotificationChannel(channel) |
| @@ -82,7 +82,6 @@ open class ScreenCaptureService : Service() { | @@ -82,7 +82,6 @@ open class ScreenCaptureService : Service() { | ||
| 82 | return false | 82 | return false |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | - | ||
| 86 | inner class ScreenCaptureBinder : Binder() { | 85 | inner class ScreenCaptureBinder : Binder() { |
| 87 | val service: ScreenCaptureService | 86 | val service: ScreenCaptureService |
| 88 | get() = this@ScreenCaptureService | 87 | get() = this@ScreenCaptureService |
| @@ -31,7 +31,7 @@ internal interface VideoCapturerWithSize : VideoCapturer { | @@ -31,7 +31,7 @@ internal interface VideoCapturerWithSize : VideoCapturer { | ||
| 31 | */ | 31 | */ |
| 32 | 32 | ||
| 33 | internal abstract class CameraCapturerWithSize( | 33 | internal abstract class CameraCapturerWithSize( |
| 34 | - val cameraEventsDispatchHandler: CameraEventsDispatchHandler | 34 | + val cameraEventsDispatchHandler: CameraEventsDispatchHandler, |
| 35 | ) : VideoCapturerWithSize | 35 | ) : VideoCapturerWithSize |
| 36 | 36 | ||
| 37 | /** | 37 | /** |
| @@ -40,7 +40,7 @@ internal object EncodingUtils { | @@ -40,7 +40,7 @@ internal object EncodingUtils { | ||
| 40 | VideoPreset169.H720, | 40 | VideoPreset169.H720, |
| 41 | VideoPreset169.H1080, | 41 | VideoPreset169.H1080, |
| 42 | VideoPreset169.H1440, | 42 | VideoPreset169.H1440, |
| 43 | - VideoPreset169.H2160 | 43 | + VideoPreset169.H2160, |
| 44 | ) | 44 | ) |
| 45 | 45 | ||
| 46 | // Note: maintain order from smallest to biggest. | 46 | // Note: maintain order from smallest to biggest. |
| @@ -82,7 +82,7 @@ internal object EncodingUtils { | @@ -82,7 +82,7 @@ internal object EncodingUtils { | ||
| 82 | fun videoLayersFromEncodings( | 82 | fun videoLayersFromEncodings( |
| 83 | trackWidth: Int, | 83 | trackWidth: Int, |
| 84 | trackHeight: Int, | 84 | trackHeight: Int, |
| 85 | - encodings: List<RtpParameters.Encoding> | 85 | + encodings: List<RtpParameters.Encoding>, |
| 86 | ): List<LivekitModels.VideoLayer> { | 86 | ): List<LivekitModels.VideoLayer> { |
| 87 | return if (encodings.isEmpty()) { | 87 | return if (encodings.isEmpty()) { |
| 88 | listOf( | 88 | listOf( |
| @@ -92,7 +92,7 @@ internal object EncodingUtils { | @@ -92,7 +92,7 @@ internal object EncodingUtils { | ||
| 92 | quality = LivekitModels.VideoQuality.HIGH | 92 | quality = LivekitModels.VideoQuality.HIGH |
| 93 | bitrate = 0 | 93 | bitrate = 0 |
| 94 | ssrc = 0 | 94 | ssrc = 0 |
| 95 | - }.build() | 95 | + }.build(), |
| 96 | ) | 96 | ) |
| 97 | } else { | 97 | } else { |
| 98 | encodings.map { encoding -> | 98 | encodings.map { encoding -> |
| @@ -16,8 +16,6 @@ | @@ -16,8 +16,6 @@ | ||
| 16 | 16 | ||
| 17 | package io.livekit.android.room.util | 17 | package io.livekit.android.room.util |
| 18 | 18 | ||
| 19 | -import io.livekit.android.room.participant.Participant | ||
| 20 | -import io.livekit.android.room.track.Track | ||
| 21 | import org.webrtc.DataChannel | 19 | import org.webrtc.DataChannel |
| 22 | 20 | ||
| 23 | fun DataChannel.unpackedTrackLabel(): Triple<String, String, String> { | 21 | fun DataChannel.unpackedTrackLabel(): Triple<String, String, String> { |
| @@ -30,7 +30,6 @@ internal class NetworkMonitor(private val context: Context) { | @@ -30,7 +30,6 @@ internal class NetworkMonitor(private val context: Context) { | ||
| 30 | coroutineContext = SupervisorJob() + Dispatchers.IO | 30 | coroutineContext = SupervisorJob() + Dispatchers.IO |
| 31 | scope = CoroutineScope(coroutineContext) | 31 | scope = CoroutineScope(coroutineContext) |
| 32 | scope.launch { | 32 | scope.launch { |
| 33 | - | ||
| 34 | val uid = context.packageManager.getApplicationInfo(context.packageName, 0).uid | 33 | val uid = context.packageManager.getApplicationInfo(context.packageName, 0).uid |
| 35 | 34 | ||
| 36 | var prevTxBytes = TrafficStats.getUidTxBytes(uid) | 35 | var prevTxBytes = TrafficStats.getUidTxBytes(uid) |
| @@ -21,7 +21,7 @@ import kotlinx.coroutines.* | @@ -21,7 +21,7 @@ import kotlinx.coroutines.* | ||
| 21 | fun <T, R> debounce( | 21 | fun <T, R> debounce( |
| 22 | waitMs: Long = 300L, | 22 | waitMs: Long = 300L, |
| 23 | coroutineScope: CoroutineScope, | 23 | coroutineScope: CoroutineScope, |
| 24 | - destinationFunction: suspend (T) -> R | 24 | + destinationFunction: suspend (T) -> R, |
| 25 | ): (T) -> Unit { | 25 | ): (T) -> Unit { |
| 26 | var debounceJob: Deferred<R>? = null | 26 | var debounceJob: Deferred<R>? = null |
| 27 | return { param: T -> | 27 | return { param: T -> |
| @@ -34,7 +34,6 @@ import kotlinx.coroutines.flow.StateFlow | @@ -34,7 +34,6 @@ import kotlinx.coroutines.flow.StateFlow | ||
| 34 | import kotlin.reflect.KProperty | 34 | import kotlin.reflect.KProperty |
| 35 | import kotlin.reflect.KProperty0 | 35 | import kotlin.reflect.KProperty0 |
| 36 | 36 | ||
| 37 | - | ||
| 38 | /** | 37 | /** |
| 39 | * A little circuitous but the way this works is: | 38 | * A little circuitous but the way this works is: |
| 40 | * 1. [delegateRequested] set to true indicates that [delegate] should be filled. | 39 | * 1. [delegateRequested] set to true indicates that [delegate] should be filled. |
| @@ -74,7 +73,7 @@ annotation class FlowObservable | @@ -74,7 +73,7 @@ annotation class FlowObservable | ||
| 74 | internal class MutableStateFlowDelegate<T> | 73 | internal class MutableStateFlowDelegate<T> |
| 75 | internal constructor( | 74 | internal constructor( |
| 76 | private val flow: MutableStateFlow<T>, | 75 | private val flow: MutableStateFlow<T>, |
| 77 | - private val onSetValue: ((newValue: T, oldValue: T) -> Unit)? = null | 76 | + private val onSetValue: ((newValue: T, oldValue: T) -> Unit)? = null, |
| 78 | ) : MutableStateFlow<T> by flow { | 77 | ) : MutableStateFlow<T> by flow { |
| 79 | 78 | ||
| 80 | operator fun getValue(thisRef: Any?, property: KProperty<*>): T { | 79 | operator fun getValue(thisRef: Any?, property: KProperty<*>): T { |
| @@ -94,7 +93,7 @@ internal constructor( | @@ -94,7 +93,7 @@ internal constructor( | ||
| 94 | @FlowObservable | 93 | @FlowObservable |
| 95 | internal class StateFlowDelegate<T> | 94 | internal class StateFlowDelegate<T> |
| 96 | internal constructor( | 95 | internal constructor( |
| 97 | - private val flow: StateFlow<T> | 96 | + private val flow: StateFlow<T>, |
| 98 | ) : StateFlow<T> by flow { | 97 | ) : StateFlow<T> by flow { |
| 99 | 98 | ||
| 100 | operator fun getValue(thisRef: Any?, property: KProperty<*>): T { | 99 | operator fun getValue(thisRef: Any?, property: KProperty<*>): T { |
| @@ -107,13 +106,13 @@ internal constructor( | @@ -107,13 +106,13 @@ internal constructor( | ||
| 107 | 106 | ||
| 108 | internal fun <T> flowDelegate( | 107 | internal fun <T> flowDelegate( |
| 109 | initialValue: T, | 108 | initialValue: T, |
| 110 | - onSetValue: ((newValue: T, oldValue: T) -> Unit)? = null | 109 | + onSetValue: ((newValue: T, oldValue: T) -> Unit)? = null, |
| 111 | ): MutableStateFlowDelegate<T> { | 110 | ): MutableStateFlowDelegate<T> { |
| 112 | return MutableStateFlowDelegate(MutableStateFlow(initialValue), onSetValue) | 111 | return MutableStateFlowDelegate(MutableStateFlow(initialValue), onSetValue) |
| 113 | } | 112 | } |
| 114 | 113 | ||
| 115 | internal fun <T> flowDelegate( | 114 | internal fun <T> flowDelegate( |
| 116 | - stateFlow: StateFlow<T> | 115 | + stateFlow: StateFlow<T>, |
| 117 | ): StateFlowDelegate<T> { | 116 | ): StateFlowDelegate<T> { |
| 118 | return StateFlowDelegate(stateFlow) | 117 | return StateFlowDelegate(stateFlow) |
| 119 | } | 118 | } |
| 1 | +/* | ||
| 2 | + * Copyright 2023 LiveKit, Inc. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 1 | package io.livekit.android.util | 17 | package io.livekit.android.util |
| 2 | 18 | ||
| 3 | import io.livekit.android.util.LoggingLevel.* | 19 | import io.livekit.android.util.LoggingLevel.* |
| @@ -25,7 +41,6 @@ internal class LKLog { | @@ -25,7 +41,6 @@ internal class LKLog { | ||
| 25 | companion object { | 41 | companion object { |
| 26 | var loggingLevel = OFF | 42 | var loggingLevel = OFF |
| 27 | 43 | ||
| 28 | - | ||
| 29 | /** Log a verbose exception and a message that will be evaluated lazily when the message is printed */ | 44 | /** Log a verbose exception and a message that will be evaluated lazily when the message is printed */ |
| 30 | @JvmStatic | 45 | @JvmStatic |
| 31 | inline fun v(t: Throwable? = null, message: () -> String) = | 46 | inline fun v(t: Throwable? = null, message: () -> String) = |
| @@ -25,7 +25,8 @@ enum class LoggingLevel { | @@ -25,7 +25,8 @@ enum class LoggingLevel { | ||
| 25 | WARN, | 25 | WARN, |
| 26 | ERROR, | 26 | ERROR, |
| 27 | WTF, | 27 | WTF, |
| 28 | - OFF; | 28 | + OFF, |
| 29 | + ; | ||
| 29 | 30 | ||
| 30 | fun toAndroidLogPriority(): Int { | 31 | fun toAndroidLogPriority(): Int { |
| 31 | return when (this) { | 32 | return when (this) { |
| @@ -39,4 +40,3 @@ enum class LoggingLevel { | @@ -39,4 +40,3 @@ enum class LoggingLevel { | ||
| 39 | } | 40 | } |
| 40 | } | 41 | } |
| 41 | } | 42 | } |
| 42 | - |
| @@ -98,8 +98,8 @@ fun RTCStatsReport.getFilteredStats(trackIdentifier: String): RTCStatsReport { | @@ -98,8 +98,8 @@ fun RTCStatsReport.getFilteredStats(trackIdentifier: String): RTCStatsReport { | ||
| 98 | codecIds, | 98 | codecIds, |
| 99 | localCandidateId, | 99 | localCandidateId, |
| 100 | remoteCandidateId, | 100 | remoteCandidateId, |
| 101 | - statsMap | ||
| 102 | - ) | 101 | + statsMap, |
| 102 | + ), | ||
| 103 | ) | 103 | ) |
| 104 | val filteredStatsMap: MutableMap<String, RTCStats> = HashMap() | 104 | val filteredStatsMap: MutableMap<String, RTCStats> = HashMap() |
| 105 | for (stats in filteredStats) { | 105 | for (stats in filteredStats) { |
| @@ -120,7 +120,6 @@ private fun getTrackStats(trackIdentifier: String, statsMap: Map<String, RTCStat | @@ -120,7 +120,6 @@ private fun getTrackStats(trackIdentifier: String, statsMap: Map<String, RTCStat | ||
| 120 | return null | 120 | return null |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | - | ||
| 124 | private fun getStreamStats(trackId: String, statsMap: Map<String, RTCStats>): RTCStats? { | 123 | private fun getStreamStats(trackId: String, statsMap: Map<String, RTCStats>): RTCStats? { |
| 125 | for (stats in statsMap.values) { | 124 | for (stats in statsMap.values) { |
| 126 | if (stats.type == "stream") { | 125 | if (stats.type == "stream") { |
| @@ -141,7 +140,7 @@ private fun getExtraStats( | @@ -141,7 +140,7 @@ private fun getExtraStats( | ||
| 141 | codecIds: Set<String?>, | 140 | codecIds: Set<String?>, |
| 142 | localCandidateId: String?, | 141 | localCandidateId: String?, |
| 143 | remoteCandidateId: String?, | 142 | remoteCandidateId: String?, |
| 144 | - statsMap: Map<String, RTCStats> | 143 | + statsMap: Map<String, RTCStats>, |
| 145 | ): Set<RTCStats> { | 144 | ): Set<RTCStats> { |
| 146 | val extraStats: MutableSet<RTCStats> = HashSet() | 145 | val extraStats: MutableSet<RTCStats> = HashSet() |
| 147 | for (stats in statsMap.values) { | 146 | for (stats in statsMap.values) { |
| @@ -185,4 +184,3 @@ fun createStatsGetter(peerConnection: PeerConnection, receiver: RtpReceiver): RT | @@ -185,4 +184,3 @@ fun createStatsGetter(peerConnection: PeerConnection, receiver: RtpReceiver): RT | ||
| 185 | { statsCallback: RTCStatsCollectorCallback -> | 184 | { statsCallback: RTCStatsCollectorCallback -> |
| 186 | peerConnection.getStats(receiver, statsCallback) | 185 | peerConnection.getStats(receiver, statsCallback) |
| 187 | } | 186 | } |
| 188 | - |
| 1 | +/* | ||
| 2 | + * Copyright 2023 LiveKit, Inc. | ||
| 3 | + * | ||
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| 5 | + * you may not use this file except in compliance with the License. | ||
| 6 | + * You may obtain a copy of the License at | ||
| 7 | + * | ||
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
| 9 | + * | ||
| 10 | + * Unless required by applicable law or agreed to in writing, software | ||
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| 13 | + * See the License for the specific language governing permissions and | ||
| 14 | + * limitations under the License. | ||
| 15 | + */ | ||
| 16 | + | ||
| 1 | package io.livekit.android.webrtc | 17 | package io.livekit.android.webrtc |
| 2 | 18 | ||
| 3 | import io.livekit.android.util.LKLog | 19 | import io.livekit.android.util.LKLog |
| @@ -25,7 +41,7 @@ limitations under the License. | @@ -25,7 +41,7 @@ limitations under the License. | ||
| 25 | open class SimulcastVideoEncoderFactoryWrapper( | 41 | open class SimulcastVideoEncoderFactoryWrapper( |
| 26 | sharedContext: EglBase.Context?, | 42 | sharedContext: EglBase.Context?, |
| 27 | enableIntelVp8Encoder: Boolean, | 43 | enableIntelVp8Encoder: Boolean, |
| 28 | - enableH264HighProfile: Boolean | 44 | + enableH264HighProfile: Boolean, |
| 29 | ) : VideoEncoderFactory { | 45 | ) : VideoEncoderFactory { |
| 30 | 46 | ||
| 31 | /** | 47 | /** |
| @@ -72,7 +88,6 @@ open class SimulcastVideoEncoderFactoryWrapper( | @@ -72,7 +88,6 @@ open class SimulcastVideoEncoderFactoryWrapper( | ||
| 72 | supportedCodecInfos.addAll(hardwareVideoEncoderFactory.supportedCodecs) | 88 | supportedCodecInfos.addAll(hardwareVideoEncoderFactory.supportedCodecs) |
| 73 | return supportedCodecInfos.toTypedArray() | 89 | return supportedCodecInfos.toTypedArray() |
| 74 | } | 90 | } |
| 75 | - | ||
| 76 | } | 91 | } |
| 77 | 92 | ||
| 78 | /** | 93 | /** |
| @@ -89,10 +104,11 @@ open class SimulcastVideoEncoderFactoryWrapper( | @@ -89,10 +104,11 @@ open class SimulcastVideoEncoderFactoryWrapper( | ||
| 89 | 104 | ||
| 90 | override fun initEncode( | 105 | override fun initEncode( |
| 91 | settings: VideoEncoder.Settings, | 106 | settings: VideoEncoder.Settings, |
| 92 | - callback: VideoEncoder.Callback? | 107 | + callback: VideoEncoder.Callback?, |
| 93 | ): VideoCodecStatus { | 108 | ): VideoCodecStatus { |
| 94 | streamSettings = settings | 109 | streamSettings = settings |
| 95 | - val future = executor.submit(Callable { | 110 | + val future = executor.submit( |
| 111 | + Callable { | ||
| 96 | LKLog.i { | 112 | LKLog.i { |
| 97 | """initEncode() thread=${Thread.currentThread().name} [${Thread.currentThread().id}] | 113 | """initEncode() thread=${Thread.currentThread().name} [${Thread.currentThread().id}] |
| 98 | | encoder=${encoder.implementationName} | 114 | | encoder=${encoder.implementationName} |
| @@ -108,7 +124,8 @@ open class SimulcastVideoEncoderFactoryWrapper( | @@ -108,7 +124,8 @@ open class SimulcastVideoEncoderFactoryWrapper( | ||
| 108 | """.trimMargin() | 124 | """.trimMargin() |
| 109 | } | 125 | } |
| 110 | return@Callable encoder.initEncode(settings, callback) | 126 | return@Callable encoder.initEncode(settings, callback) |
| 111 | - }) | 127 | + }, |
| 128 | + ) | ||
| 112 | return future.get() | 129 | return future.get() |
| 113 | } | 130 | } |
| 114 | 131 | ||
| @@ -119,10 +136,11 @@ open class SimulcastVideoEncoderFactoryWrapper( | @@ -119,10 +136,11 @@ open class SimulcastVideoEncoderFactoryWrapper( | ||
| 119 | 136 | ||
| 120 | override fun encode( | 137 | override fun encode( |
| 121 | frame: VideoFrame, | 138 | frame: VideoFrame, |
| 122 | - encodeInfo: VideoEncoder.EncodeInfo? | 139 | + encodeInfo: VideoEncoder.EncodeInfo?, |
| 123 | ): VideoCodecStatus { | 140 | ): VideoCodecStatus { |
| 124 | - val future = executor.submit(Callable { | ||
| 125 | - //LKLog.d { "encode() buffer=${frame.buffer}, thread=${Thread.currentThread().name} " + | 141 | + val future = executor.submit( |
| 142 | + Callable { | ||
| 143 | + // LKLog.d { "encode() buffer=${frame.buffer}, thread=${Thread.currentThread().name} " + | ||
| 126 | // "[${Thread.currentThread().id}]" } | 144 | // "[${Thread.currentThread().id}]" } |
| 127 | if (streamSettings == null) { | 145 | if (streamSettings == null) { |
| 128 | return@Callable encoder.encode(frame, encodeInfo) | 146 | return@Callable encoder.encode(frame, encodeInfo) |
| @@ -134,28 +152,35 @@ open class SimulcastVideoEncoderFactoryWrapper( | @@ -134,28 +152,35 @@ open class SimulcastVideoEncoderFactoryWrapper( | ||
| 134 | val originalBuffer = frame.buffer | 152 | val originalBuffer = frame.buffer |
| 135 | // TODO: Do we need to handle when the scale factor is weird? | 153 | // TODO: Do we need to handle when the scale factor is weird? |
| 136 | val adaptedBuffer = originalBuffer.cropAndScale( | 154 | val adaptedBuffer = originalBuffer.cropAndScale( |
| 137 | - 0, 0, originalBuffer.width, originalBuffer.height, | ||
| 138 | - streamSettings!!.width, streamSettings!!.height | 155 | + 0, |
| 156 | + 0, | ||
| 157 | + originalBuffer.width, | ||
| 158 | + originalBuffer.height, | ||
| 159 | + streamSettings!!.width, | ||
| 160 | + streamSettings!!.height, | ||
| 139 | ) | 161 | ) |
| 140 | val adaptedFrame = VideoFrame(adaptedBuffer, frame.rotation, frame.timestampNs) | 162 | val adaptedFrame = VideoFrame(adaptedBuffer, frame.rotation, frame.timestampNs) |
| 141 | val result = encoder.encode(adaptedFrame, encodeInfo) | 163 | val result = encoder.encode(adaptedFrame, encodeInfo) |
| 142 | adaptedBuffer.release() | 164 | adaptedBuffer.release() |
| 143 | return@Callable result | 165 | return@Callable result |
| 144 | } | 166 | } |
| 145 | - }) | 167 | + }, |
| 168 | + ) | ||
| 146 | return future.get() | 169 | return future.get() |
| 147 | } | 170 | } |
| 148 | 171 | ||
| 149 | override fun setRateAllocation( | 172 | override fun setRateAllocation( |
| 150 | allocation: VideoEncoder.BitrateAllocation?, | 173 | allocation: VideoEncoder.BitrateAllocation?, |
| 151 | - frameRate: Int | 174 | + frameRate: Int, |
| 152 | ): VideoCodecStatus { | 175 | ): VideoCodecStatus { |
| 153 | - val future = executor.submit(Callable { | 176 | + val future = executor.submit( |
| 177 | + Callable { | ||
| 154 | return@Callable encoder.setRateAllocation( | 178 | return@Callable encoder.setRateAllocation( |
| 155 | allocation, | 179 | allocation, |
| 156 | - frameRate | 180 | + frameRate, |
| 181 | + ) | ||
| 182 | + }, | ||
| 157 | ) | 183 | ) |
| 158 | - }) | ||
| 159 | return future.get() | 184 | return future.get() |
| 160 | } | 185 | } |
| 161 | 186 | ||
| @@ -202,7 +227,7 @@ open class SimulcastVideoEncoderFactoryWrapper( | @@ -202,7 +227,7 @@ open class SimulcastVideoEncoderFactoryWrapper( | ||
| 202 | if (encoder == null) { | 227 | if (encoder == null) { |
| 203 | return null | 228 | return null |
| 204 | } | 229 | } |
| 205 | - if(encoder is WrappedNativeVideoEncoder){ | 230 | + if (encoder is WrappedNativeVideoEncoder) { |
| 206 | return encoder | 231 | return encoder |
| 207 | } | 232 | } |
| 208 | return StreamEncoderWrapper(encoder) | 233 | return StreamEncoderWrapper(encoder) |
| @@ -213,14 +238,15 @@ open class SimulcastVideoEncoderFactoryWrapper( | @@ -213,14 +238,15 @@ open class SimulcastVideoEncoderFactoryWrapper( | ||
| 213 | } | 238 | } |
| 214 | } | 239 | } |
| 215 | 240 | ||
| 216 | - | ||
| 217 | private val primary: VideoEncoderFactory | 241 | private val primary: VideoEncoderFactory |
| 218 | private val fallback: VideoEncoderFactory | 242 | private val fallback: VideoEncoderFactory |
| 219 | private val native: SimulcastVideoEncoderFactory | 243 | private val native: SimulcastVideoEncoderFactory |
| 220 | 244 | ||
| 221 | init { | 245 | init { |
| 222 | val hardwareVideoEncoderFactory = HardwareVideoEncoderFactory( | 246 | val hardwareVideoEncoderFactory = HardwareVideoEncoderFactory( |
| 223 | - sharedContext, enableIntelVp8Encoder, enableH264HighProfile | 247 | + sharedContext, |
| 248 | + enableIntelVp8Encoder, | ||
| 249 | + enableH264HighProfile, | ||
| 224 | ) | 250 | ) |
| 225 | primary = StreamEncoderWrapperFactory(hardwareVideoEncoderFactory) | 251 | primary = StreamEncoderWrapperFactory(hardwareVideoEncoderFactory) |
| 226 | fallback = StreamEncoderWrapperFactory(FallbackFactory(primary)) | 252 | fallback = StreamEncoderWrapperFactory(FallbackFactory(primary)) |
| @@ -234,5 +260,4 @@ open class SimulcastVideoEncoderFactoryWrapper( | @@ -234,5 +260,4 @@ open class SimulcastVideoEncoderFactoryWrapper( | ||
| 234 | override fun getSupportedCodecs(): Array<VideoCodecInfo> { | 260 | override fun getSupportedCodecs(): Array<VideoCodecInfo> { |
| 235 | return native.supportedCodecs | 261 | return native.supportedCodecs |
| 236 | } | 262 | } |
| 237 | - | ||
| 238 | } | 263 | } |
| @@ -32,13 +32,13 @@ internal class Camera1Helper { | @@ -32,13 +32,13 @@ internal class Camera1Helper { | ||
| 32 | fun findClosestCaptureFormat( | 32 | fun findClosestCaptureFormat( |
| 33 | cameraId: Int, | 33 | cameraId: Int, |
| 34 | width: Int, | 34 | width: Int, |
| 35 | - height: Int | 35 | + height: Int, |
| 36 | ): Size { | 36 | ): Size { |
| 37 | return CameraEnumerationAndroid.getClosestSupportedSize( | 37 | return CameraEnumerationAndroid.getClosestSupportedSize( |
| 38 | getSupportedFormats(cameraId) | 38 | getSupportedFormats(cameraId) |
| 39 | .map { Size(it.width, it.height) }, | 39 | .map { Size(it.width, it.height) }, |
| 40 | width, | 40 | width, |
| 41 | - height | 41 | + height, |
| 42 | ) | 42 | ) |
| 43 | } | 43 | } |
| 44 | } | 44 | } |
| @@ -38,7 +38,7 @@ internal class Camera2Helper { | @@ -38,7 +38,7 @@ internal class Camera2Helper { | ||
| 38 | cameraManager: CameraManager, | 38 | cameraManager: CameraManager, |
| 39 | cameraId: String?, | 39 | cameraId: String?, |
| 40 | width: Int, | 40 | width: Int, |
| 41 | - height: Int | 41 | + height: Int, |
| 42 | ): Size { | 42 | ): Size { |
| 43 | val sizes = getSupportedFormats(cameraManager, cameraId) | 43 | val sizes = getSupportedFormats(cameraManager, cameraId) |
| 44 | ?.map { Size(it.width, it.height) } | 44 | ?.map { Size(it.width, it.height) } |
| @@ -45,8 +45,7 @@ fun <T> Flow<T>.takeUntilSignal(signal: Flow<Unit?>): Flow<T> = flow { | @@ -45,8 +45,7 @@ fun <T> Flow<T>.takeUntilSignal(signal: Flow<Unit?>): Flow<T> = flow { | ||
| 45 | emit(it) | 45 | emit(it) |
| 46 | } | 46 | } |
| 47 | } | 47 | } |
| 48 | - | ||
| 49 | } catch (e: CancellationException) { | 48 | } catch (e: CancellationException) { |
| 50 | - //ignore | 49 | + // ignore |
| 51 | } | 50 | } |
| 52 | } | 51 | } |
| @@ -41,7 +41,7 @@ class TestCoroutineRule : TestRule { | @@ -41,7 +41,7 @@ class TestCoroutineRule : TestRule { | ||
| 41 | dispatcher.scheduler.advanceUntilIdle() // run the remaining tasks | 41 | dispatcher.scheduler.advanceUntilIdle() // run the remaining tasks |
| 42 | Assert.assertEquals( | 42 | Assert.assertEquals( |
| 43 | timeAfterTest, | 43 | timeAfterTest, |
| 44 | - dispatcher.scheduler.currentTime | 44 | + dispatcher.scheduler.currentTime, |
| 45 | ) // will fail if there were tasks scheduled at a later moment | 45 | ) // will fail if there were tasks scheduled at a later moment |
| 46 | Dispatchers.resetMain() | 46 | Dispatchers.resetMain() |
| 47 | } | 47 | } |
| @@ -20,5 +20,5 @@ import kotlinx.coroutines.CoroutineScope | @@ -20,5 +20,5 @@ import kotlinx.coroutines.CoroutineScope | ||
| 20 | 20 | ||
| 21 | class EventCollector<T : Event>( | 21 | class EventCollector<T : Event>( |
| 22 | eventListenable: EventListenable<T>, | 22 | eventListenable: EventListenable<T>, |
| 23 | - coroutineScope: CoroutineScope | 23 | + coroutineScope: CoroutineScope, |
| 24 | ) : FlowCollector<T>(eventListenable.events, coroutineScope) | 24 | ) : FlowCollector<T>(eventListenable.events, coroutineScope) |
| @@ -25,7 +25,7 @@ import kotlinx.coroutines.flow.MutableStateFlow | @@ -25,7 +25,7 @@ import kotlinx.coroutines.flow.MutableStateFlow | ||
| 25 | 25 | ||
| 26 | open class FlowCollector<T>( | 26 | open class FlowCollector<T>( |
| 27 | private val flow: Flow<T>, | 27 | private val flow: Flow<T>, |
| 28 | - coroutineScope: CoroutineScope | 28 | + coroutineScope: CoroutineScope, |
| 29 | ) { | 29 | ) { |
| 30 | private val signal = MutableStateFlow<Unit?>(null) | 30 | private val signal = MutableStateFlow<Unit?>(null) |
| 31 | private val collectEventsDeferred = coroutineScope.async { | 31 | private val collectEventsDeferred = coroutineScope.async { |
| @@ -40,5 +40,4 @@ open class FlowCollector<T>( | @@ -40,5 +40,4 @@ open class FlowCollector<T>( | ||
| 40 | signal.compareAndSet(null, Unit) | 40 | signal.compareAndSet(null, Unit) |
| 41 | return collectEventsDeferred.await() | 41 | return collectEventsDeferred.await() |
| 42 | } | 42 | } |
| 43 | - | ||
| 44 | } | 43 | } |
| @@ -21,7 +21,7 @@ import android.view.Surface | @@ -21,7 +21,7 @@ import android.view.Surface | ||
| 21 | import org.webrtc.EglBase | 21 | import org.webrtc.EglBase |
| 22 | 22 | ||
| 23 | class MockEglBase( | 23 | class MockEglBase( |
| 24 | - private val eglContext: EglBase.Context = EglBase.Context { 0 } | 24 | + private val eglContext: EglBase.Context = EglBase.Context { 0 }, |
| 25 | ) : EglBase { | 25 | ) : EglBase { |
| 26 | 26 | ||
| 27 | override fun createSurface(p0: Surface?) {} | 27 | override fun createSurface(p0: Surface?) {} |
| @@ -21,7 +21,7 @@ import org.webrtc.MediaStream | @@ -21,7 +21,7 @@ import org.webrtc.MediaStream | ||
| 21 | import org.webrtc.VideoTrack | 21 | import org.webrtc.VideoTrack |
| 22 | 22 | ||
| 23 | fun createMediaStreamId(participantSid: String, trackSid: String) = | 23 | fun createMediaStreamId(participantSid: String, trackSid: String) = |
| 24 | - "${participantSid}|${trackSid}" | 24 | + "$participantSid|$trackSid" |
| 25 | 25 | ||
| 26 | class MockMediaStream(private val id: String = "id") : MediaStream(1L) { | 26 | class MockMediaStream(private val id: String = "id") : MediaStream(1L) { |
| 27 | 27 |
| @@ -40,7 +40,7 @@ private class MockNativePeerConnectionFactory : NativePeerConnectionFactory { | @@ -40,7 +40,7 @@ private class MockNativePeerConnectionFactory : NativePeerConnectionFactory { | ||
| 40 | 40 | ||
| 41 | class MockPeerConnection( | 41 | class MockPeerConnection( |
| 42 | var rtcConfig: RTCConfiguration, | 42 | var rtcConfig: RTCConfiguration, |
| 43 | - val observer: Observer? | 43 | + val observer: Observer?, |
| 44 | ) : PeerConnection(MockNativePeerConnectionFactory()) { | 44 | ) : PeerConnection(MockNativePeerConnectionFactory()) { |
| 45 | 45 | ||
| 46 | private var closed = false | 46 | private var closed = false |
| @@ -78,7 +78,6 @@ class MockPeerConnection( | @@ -78,7 +78,6 @@ class MockPeerConnection( | ||
| 78 | observer?.onCreateSuccess(sdp) | 78 | observer?.onCreateSuccess(sdp) |
| 79 | } | 79 | } |
| 80 | 80 | ||
| 81 | - | ||
| 82 | override fun setAudioPlayout(playout: Boolean) { | 81 | override fun setAudioPlayout(playout: Boolean) { |
| 83 | } | 82 | } |
| 84 | 83 | ||
| @@ -142,7 +141,7 @@ class MockPeerConnection( | @@ -142,7 +141,7 @@ class MockPeerConnection( | ||
| 142 | 141 | ||
| 143 | override fun addTransceiver( | 142 | override fun addTransceiver( |
| 144 | track: MediaStreamTrack, | 143 | track: MediaStreamTrack, |
| 145 | - init: RtpTransceiver.RtpTransceiverInit? | 144 | + init: RtpTransceiver.RtpTransceiverInit?, |
| 146 | ): RtpTransceiver { | 145 | ): RtpTransceiver { |
| 147 | val transceiver = MockRtpTransceiver.create(track, init ?: RtpTransceiver.RtpTransceiverInit()) | 146 | val transceiver = MockRtpTransceiver.create(track, init ?: RtpTransceiver.RtpTransceiverInit()) |
| 148 | transceivers.add(transceiver) | 147 | transceivers.add(transceiver) |
| @@ -155,7 +154,7 @@ class MockPeerConnection( | @@ -155,7 +154,7 @@ class MockPeerConnection( | ||
| 155 | 154 | ||
| 156 | override fun addTransceiver( | 155 | override fun addTransceiver( |
| 157 | mediaType: MediaStreamTrack.MediaType?, | 156 | mediaType: MediaStreamTrack.MediaType?, |
| 158 | - init: RtpTransceiver.RtpTransceiverInit? | 157 | + init: RtpTransceiver.RtpTransceiverInit?, |
| 159 | ): RtpTransceiver { | 158 | ): RtpTransceiver { |
| 160 | return super.addTransceiver(mediaType, init) | 159 | return super.addTransceiver(mediaType, init) |
| 161 | } | 160 | } |
-
请 注册 或 登录 后发表评论