dji-sdk / Mobile-SDK-Android

DJI Mobile SDK for Android: http://developer.dji.com/mobile-sdk/
Other
972 stars 579 forks source link

Camera feed does not update Pixel 7a - Mini 2 #1248

Open brien-crean opened 9 months ago

brien-crean commented 9 months ago

Using a DJI Mini 2 with the Pixel 7a the camera feed only updates once or twice a minute. Often it is just a black screen.

If I run the same code on a Samsung A52 it works really well.

private var textureListener: TextureView.SurfaceTextureListener = object :
        TextureView.SurfaceTextureListener {
        override fun onSurfaceTextureAvailable(surfaceTexture: SurfaceTexture, width: Int, height: Int) {
            if (codecManager == null) {
                codecManager =
                    DJICodecManager(context, surfaceTexture, width, height, DJICodecManager.VideoSource.CAMERA)
            }
            if (videoDataListener == null) {
                videoDataListener = VideoDataListener { videoBuffer: ByteArray?, size: Int ->
                    codecManager?.sendDataToDecoder(videoBuffer, size, DJICodecManager.VideoSource.CAMERA)
                }
                videoDataListener?.let {
                    VideoFeeder.getInstance().primaryVideoFeed.addVideoDataListener(it)
                }
            }
        }
    }

I see other users have the same issue with other Pixel devices and newer Samsung devices. I also tried sdk 4.17-alpha but the issue is the same. Will there be a fix for this issue?

dji-dev commented 9 months ago

Agent comment from yating.liao in Zendesk ticket #91288:

This should be a known issue on MSDK V4. We have identified the same problem on Samsung A53, Pixel 6a, Samsung SM-M115F, and Samsung Galaxy SM-X800. The issue is still being addressed.

°°°

dji-dev commented 8 months ago

Agent comment from yating.liao in Zendesk ticket #91288:

I'm sorry for the long wait. The issue with MSDK 4.X not being able to render videos on some models has been reported and the fix code has been submitted. It will be released with the official version 4.17.

°°°

mitchrsm commented 7 months ago

version 4.17 has been released, just update the sdk in the app to solve the problem? I ask because it is not mentioned in the change log, rather I see that it has been added: "Added setCodecName function for DJICodecManager to solve the compatibility issue of video stream decoding on Android phones." How does it work?

brien-crean commented 7 months ago

You need to set the codec name after initializing the codec manager. I used this to set the codec to the Google h264 software decoder for my Pixel 7a and it fixed my issues.

val codecManager = DJICodecManager(context, surfaceTexture, width, height, DJICodecManager.VideoSource.CAMERA)
codecManager?.setCodecName("OMX.google.h264.decoder")

You can also get a list of all supported codecs for your device that are decoders and support video/avc. It should list OMX.google.h264.decoder but you can also try the others it supports to see if they work.

val codecList = MediaCodecList(MediaCodecList.ALL_CODECS)
val codecInfos = codecList.codecInfos
val targetType = "video/avc"

for (codecInfo in codecInfos) {
  if (!codecInfo.isEncoder) {
     val supportedTypes = codecInfo.supportedTypes
     if (supportedTypes.contains(targetType)) {
        println(codecInfo.name)
     }
  }
}

The c2.exynos.h264.decoder hardware decoder on some newer Android devices seems to be causing a lot of the issues