It sounds like you have a well-structured pipeline for receiving and decoding video data, but the 2-second delay you're experiencing could be attributed to several factors beyond the measurements you've already taken. Here are a few suggestions to investigate further:
- Buffering: Media Foundation may be buffering frames before they are decoded and displayed. Check if there are any settings or configurations in your Media Foundation pipeline that control buffering behavior.
- Latency in UDP: While the initial response time from the drone is quick, UDP can introduce variability in packet arrival times. Ensure that you are handling packet loss and reordering correctly, as this can lead to delays in displaying the video.
- Decoding Latency: Even if your native decoder function is fast, the overall decoding process might still introduce latency. Investigate if the decoder has any internal buffering or if it waits for a certain number of frames before processing.
- Unity Frame Rate: Ensure that your Unity app is running at a consistent frame rate. If the frame rate drops, it could lead to perceived delays in video display.
- Synchronization: Make sure that the timestamps for the video frames are being handled correctly. If the frames are being displayed out of order or if there is a mismatch in timing, it could contribute to the delay.
- Testing with Different Settings: Experiment with different settings for the video stream, such as resolution and frame rate, to see if they affect the delay.
By systematically checking these areas, you may be able to identify the source of the delay and make adjustments to achieve real-time video display.
References: