Recomendations to create a logic for a video buffer
Hello i am trying to do the logic for implement a buffer and there are some questions about it.
I am receiving data from usb, the function of usb receiving returns a buffer
That buffer i have to send it to video player.
Here is the first question, the program always are going to be receiving data and the player will read it simultaneously, maybe sounds silly, but the buffer that reads the player always are going to be expand it, getting more a more bigger because i always be storing the data there for the player reads it. How to avoid the buffer gets bigger without interrupt the video.
For another part i have to use threads one thread to fill the buffer for the video and the main thread window for default to reproduce it, i will wait certain time to fill the buffer (milisenconds) and then reproduce it, in the same of the playing i will fill the buffer whit new data.
The problem if the size how to deal with adding new data to the buffer without increase the size, and not delaying the video.
You may implement a circular buffer, it will guarantee a fixed memory use, will allow you to hold a feel data and further more, will overwrite old data information (video with a increasing delay is not helpful nor desired).
I use this solution in a UAV software, one thread to receive and buffered the data in a circular buffer and another thread to get the data (draw over it) and show to the user.
Fell free to as if You have any more questions.
Is it some sort of camera ?