'VB code
Dim fi As New IO.FileInfo(StreamLocation)
Dim fs As New IO.FileStream(StreamLocation, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read, 188, IO.FileOptions.SequentialScan)
fs.Position = 0
While bwReader.CancellationPending = False And EndOfStream = False
VolumeRead = fs.Read(buffer, 0, 188)
If VolumeRead <> 188 Then
' End of file
EndOfStream = True
Else
' Test if sync byte isn't present at the beginning => problem
If buffer(0) <> &H47 Then
Input_BadLength += 1
' Searching the next sync byte
SyncFound = 200
For i = 1 To 187
If buffer(i) = &H47 Then
If i < SyncFound Then SyncFound = i
End If
Next
' If sync found, we resync the stream reading, if not, we wait for the next packet
If SyncFound < 200 Then
fs.Position = fs.Position - 188 + SyncFound
End If
Else
' Packet OK
Input_TSPacketsReceived += 1
Analyzer.NewPacket(buffer)
End If
End If
End While
fs.Close()