Patch for WinTV DVB-S streaming with VideoLAN
Tristan Leteurtre
tristan.leteurtre at videolan.org
Tue Sep 24 04:34:01 CEST 2002
Hi,
I noticed a few issues in the TS stream delivered by the linuxdvb api
when using the WinTV DVB-S from Hauppaugge. As I could understand, since
the DVBS has a built-in mpeg decoder, only the PES layer is accessible
after the demux, and all the TS header infos are trashed. Today, the TS
headers are totally re-generated in softawre by the driver, and I could
isolate some major issues :
. Unit_start_indicator not set for PSI sections : this field
(ts_header[1] & 0x40) is not set for pat and pmt, then a valid mpeg
parser would think that he never receives the beginning of a pat or
pmt.
. Since the adaptation_field info are lost, the PCR (Program Clock
Reference, essential timestamps for streaming) are also lost.
So, I wrote a patch to correct those issues in driver/dvb.c. I chose
to made a patch instead of including it in the VideoLAN server, since
it could also solve direct reading with VideoLAN client, or other apps.
This patch is a kind of beta version, since it is not well programmed
and uses ugly globals variables...
So, here are the corrections made by the patch :
. Unit_start_indicator corrected in 'p_to_t' function : we have to
identify all the pids affected : Pat (0) and pmt (an array of
integer, filled with a 'DecodePAT' function).
If a pat is comes in, we first check if we need to re-parse it
(re-parsing if version_number or transport_stream_id has changed).
Then, we look at section_number. If it's 0, then we set the pes_start
(unit_start_indicator) to 1 in the ts_header.
If it's not a pat, we try to see if the pid matches one in the pmt
array (previously inited with 'decodePAT'). If yes, we directly set
the unit_start_indicator to one, since the specs tells that a pmt
should be on only one section.
Note that those kind of tricks are already made in the case of PES
packets, in the p_to_t function.
. PCR re-generation : since the only reliable time info are PTS
(Presentation Time Stamps) in the stream, I chose to generate PCR
from them, but only the PTS of I frames and P frames. I used a basic
translation : PCR = PTS - Delta. In many stream, this Delta value
seems to be around 55000 (about 2ms).
So, when a PTS of I-P frame is met, a *new video packet is insered*,
with adaptation_field (PCR) only and no payload. All continuity
counters of the video packets are updated as needed. An array of
counters makes the stuff easier.... The job is made in the
'pes2ts_cb' callback.
Since the PCR_pid is not updated in PMTs (boring, CRC stuff...), **
all that suppose PCR_pid = Video = pid (video packet carries the PCR
info) **. That seems to be frequent.
So, what is to be finished :
. move my global variables in a better place, maybe dvb_struct.
. Update PCR_pid in pmts, and CRC.
. more checks
At last, note that this does absolutely not affects the behavior of the
driver with the WinTV NOVA, since you can directly get the original TS.
The patch is available on :
http://www.videolan.org/vls/sat/
Regards,
--
Tristan
--
This is the vls-devel mailing-list, see http://www.videolan.org/vls-devel/
To unsubscribe, please read http://www.videolan.org/lists.html
If you are in trouble, please contact <postmaster at videolan.org>
More information about the vls-devel
mailing list