NalUnitParser does not seem to parse packets with multiple NAL units
It looks like there is a bug in NalUnitParser class when parsing video packets. Specifically, if a packet contains more than one NAL unit, the parser just considers it as a single unit, resulting in info loss and decoder not working properly (e.g. if the video packets contains sps, pps and idr units, they are treated as a single sps unit).
I see that the code for detecting multiple units separated by the Annex B delimiter is there, it just does not work properly. It could be because the bytes array created in startCode closure expression gets deallocated after the closure ends, so its reference is not quite valid anymore, and contains garbage values (e.g. [0,0,0,0] instead of [0,0,0,1]).
The issue might not be there in the example app because the video packets happen to have only a single NAL unit. However, I was testing with a different setup using a different library to encode the packets, and that library produces multi-unit packets.
I have made a quick fix locally, it works and looks the following:
Do you think it is really a bug and if yes, should I open a PR with the fix?
Yes, this is a bug, you can submit a PR, thanks
Here you go @songbihai: https://github.com/songbihai/VideoDecoder/pull/6
Great, I see you merged the MR @songbihai. Would it be possible to create a new Pods version with that change?