How do I use the CustomVideoDecoderFactory in the ...
# ask-ai
i
How do I use the CustomVideoDecoderFactory in the android SDK
t
Thanks for reaching out, Andres. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
The
CustomVideoDecoderFactory
in the LiveKit Android SDK is a handy tool that gives you control over whether to use software-based or hardware-accelerated video decoding. Let me walk you through how you can use it: Class Structure: • This factory wraps both software and hardware decoder factories and offers methods to help you configure which decoder to use. Configuration Methods: • `setForceSWCodec(forceSWCodec: Boolean)`: When you set this to
true
, it forces all codecs to use software decoding. • `setForceSWCodecList(forceSWCodecs: List<String>)`: This lets you specify particular codecs for which software decoding should be forced. Usage Examples: • Force Software Decoding for VP9:
val customFactory = CustomVideoDecoderFactory(sharedContext = eglContext, forceSWCodec = false, forceSWCodecs = listOf("VP9", "H264"))
• Force All Software Decoding:
val customFactory = CustomVideoDecoderFactory(sharedContext = eglContext, forceSWCodec = true, forceSWCodecs = emptyList())
• Runtime Configuration:
customFactory.setForceSWCodec(true)
or
customFactory.setForceSWCodecList(listOf("VP9", "AV1"))
By default, the factory prefers hardware decoding but will force software decoding for VP9 to help avoid known issues on some devices. If you'd like to dive deeper, feel free to check out the LiveKit Android sample app. We're here to help if you have any questions along the way! Sources: livekit-android-sdk/src/main/java/io/livekit/android/dagger/RTCModule.kt | Android quickstart | LiveKit docs
i
where do I get the eglContext ?
t
I'm happy to help you understand how the
eglContext
works in the LiveKit Android SDK! It’s actually managed for you automatically and you can access it easily through the SDK’s dependency injection system. Here’s a quick overview: • The
eglContext
comes from an
EglBase
instance using the
getEglBaseContext()
method. • The SDK provides it as a dependency and it’s automatically passed to components like
CustomVideoDecoderFactory
,
CustomVideoEncoderFactory
, or video renderers. Here’s a simple example:
Copy code
@Provides
fun eglContext(eglBase: EglBase): EglBase.Context = eglBase.eglBaseContext
In most cases, you won’t need to worry about creating or managing the
eglContext
yourself—it’s all taken care of when setting up video encoding, decoding, or rendering. But if you have any specific questions or need help with your implementation, please feel free to ask. I’m here to support you! Sources: README.md | android/src/main/java/com/oney/WebRTCModule/WebRTCModule.java