VTDecompressionSession DecodeFrame never returns on real device


I am trying to load and decode h264 rtsp stream. I managed to receive NAL packages but can't start decoding it.
It works for Android so NAL packages are correct.
On iOS I am creating VTDecompressionSession using sps and pps packages. After that I try to feed my session with NAL packages. When I do it on simulator it returns some errors(-8969) but on real device it never returns anything.

Did anyone manage to DecodeFrames using VRDecompressionSession?

Below my code:
var nalUnitWithLength = new byte[nalUnit.Length + 4]; //Nal unit doesn't contain header
Array.Copy(BitConverter.GetBytes(nalUnit.Length).Reverse().ToArray(), nalUnitWithLength, 4);
Array.Copy(nalUnit, 0, nalUnitWithLength, 4, nalUnit.Length);
var blockBuffer =
CMBlockBuffer.FromMemoryBlock(nalUnitWithLength, 0, 0,
out var error);

var sampleBuffer = CMSampleBuffer.CreateReady(blockBuffer, videoFormatDescription, 1,
new[] {(nuint) nalUnit.Length },
out var error2);

session.DecodeFrame(sampleBuffer, VTDecodeFrameFlags.EnableAsynchronousDecompression, new IntPtr(time++),
out var flagOut);

And here creating DecompressionSession"
var initLists = new List<byte[]>();

videoFormatDescription = CMVideoFormatDescription.FromH264ParameterSets(initLists, 4, out var error);
session = VTDecompressionSession.Create(Decompressed, videoFormatDescription, new VTVideoDecoderSpecification(new NSDictionary()), new CVPixelBufferAttributes());

Sign In or Register to comment.