I am developing a realtime video-streaming system which is composed basically by a server and several clients.
For now, let's ignore how packets are forwarded among the server and the clients, let's focus just on how the server can send a MPEGTS stream over UDP packets.
The stream is encoded in MPEGTS format.
What I'm trying to do is reading some packets (the main question is "how many?") and encapsulating them in UDP packets. The destination (a client) reads these UDP packets and then forward them to VLC, which is able to play MPEGTS network streams by reading UDP packets.
If I send only video packets, everything works fine, instead if I try to encapsulate in the same UDP packet, both some video packets and some audio packets, VLC is not able to decode and play the stream. I read somewhere that each UDP packet should contain 7 TS packets, but unfortunately even if I comply with this rule, VLC doesn't decode the stream correctly.
Here is a sample code of my program: http://pastebin.com/evMi6FkY
How should I encapsulate MPEGTS packets in UDP packets?
Thanks!