webrtc-sdk / android

WebRTC pre-compiled library for android.
MIT License
151 stars 23 forks source link

AV1 returned as supported, but it actually not #14

Open dkrivoruchko opened 1 year ago

dkrivoruchko commented 1 year ago

Devices:

Version : com.github.webrtc-sdk:android:104.5112.08

Checking list of system supported video encoders:

MediaCodecList(MediaCodecList.ALL_CODECS).codecInfos.filter { it.isEncoder && it.supportedTypes[0].startsWith("video") }
  .forEach { Log.e(">>>", "Name: ${it.name} => mimeType: ${it.supportedTypes.joinToString()}") }

Result:

Name: OMX.hisi.video.encoder.avc => mimeType: video/avc
Name: OMX.google.h264.encoder => mimeType: video/avc
Name: OMX.google.h263.encoder => mimeType: video/3gpp
Name: OMX.hisi.video.encoder.hevc => mimeType: video/hevc
Name: OMX.google.mpeg4.encoder => mimeType: video/mp4v-es
Name: OMX.google.vp8.encoder => mimeType: video/x-vnd.on2.vp8
Name: OMX.google.vp9.encoder => mimeType: video/x-vnd.on2.vp9

Now checking encoders with PeerConnectionFactory:

val initializationOptions = PeerConnectionFactory.InitializationOptions.builder(context).createInitializationOptions()
PeerConnectionFactory.initialize(initializationOptions)

 val peerConnectionFactory = PeerConnectionFactory.builder()
            .setOptions(PeerConnectionFactory.Options())
            .setVideoDecoderFactory(DefaultVideoDecoderFactory(rootEglBase.eglBaseContext))
            .setVideoEncoderFactory(DefaultVideoEncoderFactory(rootEglBase.eglBaseContext, true, true))
            .createPeerConnectionFactory()

peerConnectionFactory.getRtpSenderCapabilities(MediaStreamTrack.MediaType.MEDIA_TYPE_VIDEO).codecs
   .forEach { Log.e(">>>", "Name: ${it.name} => mimeType: ${it.mimeType}") }

Result:

Name: VP8 => mimeType: video/VP8
Name: rtx => mimeType: video/rtx
Name: VP9 => mimeType: video/VP9
Name: AV1 => mimeType: video/AV1
Name: red => mimeType: video/red
Name: ulpfec => mimeType: video/ulpfec

Problem: Why AV1 is returned as supported?

If we try to use AV1 app obviously crash with:

java.lang.UnsatisfiedLinkError: No implementation found for long org.webrtc.LibaomAv1Encoder.nativeCreateEncoder() (tried Java_org_webrtc_LibaomAv1Encoder_nativeCreateEncoder and Java_org_webrtc_LibaomAv1Encoder_nativeCreateEncoder__)
 at org.webrtc.LibaomAv1Encoder.nativeCreateEncoder(Native Method)
 at org.webrtc.LibaomAv1Encoder.createNativeVideoEncoder(LibaomAv1Encoder.java:16)