3

I have desktop server which is encode frames. My iOS client is connecting to this client and receives data using NWConnection like this:

NWListener using .udp parameter causes odd logs sometimes

Actual problem:

Device without error (video is ok): iPhone 11 Pro iOS 13.5.1, iPhone Xs Max iOS 13.5.1
Devices with -12909 (nothing shown): iPhone 11 iOS 13.5.1, iPhone 7+ iOS 12.4.1

My question is:

What can causes OSStatus - kVTVideoDecoderBadDataErr -12909. Does it mean I lost a lot of data or maybe some video bytes are reordered or something else?

Full code example: https://github.com/ChoadPet/H.264-Decoding


I receive ❌ Failed state with -12909 OSStatus and imageBuffer == nil from this callback and no frame is displaying:

var record = VTDecompressionOutputCallbackRecord(
    decompressionOutputCallback: callback,
    decompressionOutputRefCon: Unmanaged.passUnretained(self).toOpaque()
)
...
private var callback: VTDecompressionOutputCallback = { 
    (decompressionOutputRefCon: UnsafeMutableRawPointer?,
    sourceFrameRefCon: UnsafeMutableRawPointer?, status: OSStatus,
    infoFlags: VTDecodeInfoFlags, imageBuffer: CVPixelBuffer?,
    presentationTimeStamp: CMTime, duration: CMTime) in
    
    if imageBuffer != nil && status == noErr {
        NSLog("===== ✅ Image successfully decompressed =====")
    } else {
        NSLog("===== ❌ Failed to decompress, OSStatus: \(status), imageBuffer: \(String(describing: imageBuffer)) =====")
    }
}

Displaying part:

var flagOut: VTDecodeInfoFlags = []
let status = VTDecompressionSessionDecodeFrame(session,
                                               sampleBuffer: sampleBuffer,
                                               flags: [._EnableAsynchronousDecompression],
                                               frameRefcon: nil,
                                               infoFlagsOut: &flagOut)
videoLayer?.enqueue(sampleBuffer) // videoLayer - AVSampleBufferDisplayLayer

Thank you.

vpoltave
  • 1,612
  • 3
  • 14
  • 31

0 Answers0