I am writing simple software to parse MPEG-TS stream to check CC (cointinuity counter) to see if any packets were dropped. When I run my script against file it works flawlessly. But when using it on UDP stream it shows losses (which are not confirmed by another software):
It is quite simple:
while True:
received = sock.recv(7 * 188)
parsepacket(received)
I left out parsepacket
function for clarity. It is just using bitstring to analyzee packet bit by bit.
In my understanding while I run parsepacket
function other UDP packets are just ignored, because I am not doing sock.recv
quick enough (on 5 Mbps stream it should parse about 500 packets pers second).
I tried using sock.makefile
but no luck. I get same results.
My idea is to have receiving thread running in background and another thread continously parsing what it receives. But honestly I have no idea how (besides putting it all in memory which would run out very quickly).