Skip to content

Commit

Permalink
Fix simulcast factory not sending back EncoderInfo (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidliu authored Mar 24, 2022
1 parent 0ffff8b commit 7b38cd4
Showing 1 changed file with 31 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package io.livekit.android.webrtc

import io.livekit.android.util.LKLog
import org.webrtc.*
import java.util.concurrent.*
import java.util.concurrent.Callable
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors

/*
Copyright 2017, Lyo Kato <lyo.kato at gmail.com> (Original Author)
Expand Down Expand Up @@ -49,7 +51,7 @@ internal class SimulcastVideoEncoderFactoryWrapper(
* This results in HardwareVideoEncoderFactory being both the primary and fallback,
* but there aren't any specific problems in doing so.
*/
private class Fallback(private val hardwareVideoEncoderFactory: VideoEncoderFactory) :
private class FallbackFactory(private val hardwareVideoEncoderFactory: VideoEncoderFactory) :
VideoEncoderFactory {

private val softwareVideoEncoderFactory: VideoEncoderFactory = SoftwareVideoEncoderFactory()
Expand Down Expand Up @@ -93,6 +95,7 @@ internal class SimulcastVideoEncoderFactoryWrapper(
val future = executor.submit(Callable {
LKLog.i {
"""initEncode() thread=${Thread.currentThread().name} [${Thread.currentThread().id}]
| encoder=${encoder.implementationName}
| streamSettings:
| numberOfCores=${settings.numberOfCores}
| width=${settings.width}
Expand Down Expand Up @@ -165,6 +168,31 @@ internal class SimulcastVideoEncoderFactoryWrapper(
val future = executor.submit(Callable { return@Callable encoder.implementationName })
return future.get()
}

override fun createNativeVideoEncoder(): Long {
val future = executor.submit(Callable { return@Callable encoder.createNativeVideoEncoder() })
return future.get()
}

override fun isHardwareEncoder(): Boolean {
val future = executor.submit(Callable { return@Callable encoder.isHardwareEncoder })
return future.get()
}

override fun setRates(rcParameters: VideoEncoder.RateControlParameters?): VideoCodecStatus {
val future = executor.submit(Callable { return@Callable encoder.setRates(rcParameters) })
return future.get()
}

override fun getResolutionBitrateLimits(): Array<VideoEncoder.ResolutionBitrateLimits> {
val future = executor.submit(Callable { return@Callable encoder.resolutionBitrateLimits })
return future.get()
}

override fun getEncoderInfo(): VideoEncoder.EncoderInfo {
val future = executor.submit(Callable { return@Callable encoder.encoderInfo })
return future.get()
}
}

private class StreamEncoderWrapperFactory(private val factory: VideoEncoderFactory) :
Expand Down Expand Up @@ -195,7 +223,7 @@ internal class SimulcastVideoEncoderFactoryWrapper(
sharedContext, enableIntelVp8Encoder, enableH264HighProfile
)
primary = StreamEncoderWrapperFactory(hardwareVideoEncoderFactory)
fallback = StreamEncoderWrapperFactory(Fallback(primary))
fallback = StreamEncoderWrapperFactory(FallbackFactory(primary))
native = SimulcastVideoEncoderFactory(primary, fallback)
}

Expand Down

0 comments on commit 7b38cd4

Please sign in to comment.