All I've done so far is modify TsReader.ax to look for any PCR it can find in any TS packet when PCR pid = 0x1fff - see below the 'is this the PCR pid ?' comment in 'OnTsPacket' :
I haven't done anything to TsWriter yet (and I'm probably not going to have much time to spend on it for a few days - going away for a long weekend tomorrow) so feel free to have a go at the problem - ideas/patches welcome
Tony
Code:
void CDeMultiplexer::OnTsPacket(byte* tsPacket)
{
//LogDebug("OnTsPacket() start");
CTsHeader header(tsPacket);
//header.LogHeader();
m_patParser.OnTsPacket(tsPacket);
if ((m_iPatVersion==-1) || m_bWaitGoodPat)
{
// First PAT not found or waiting for correct PAT
return;
}
// Wait for new PAT if required.
if ((m_iPatVersion & 0x0F) != (m_ReqPatVersion & 0x0F)) //No PAT yet, or PAT version doesn't match requested e.g. PAT data from old channel
{
if (m_ReqPatVersion==-1)
{ // Now, unless channel change,
m_ReqPatVersion = m_iPatVersion; // Initialize Pat Request.
m_WaitNewPatTmo = GET_TIME_NOW(); // Now, unless channel change request,timeout will be always true.
}
if (GET_TIME_NOW() < m_WaitNewPatTmo)
{
// Timeout not reached.
return;
}
}
//if we have no PCR pid (yet) then there's nothing to decode, so return
if (m_pids.PcrPid==0) return;
if (header.Pid==0) return;
// 'TScrambling' check commented out - headers are never scrambled,
// so it's safe to detect scrambled payload at PES level (in FillVideo()/FillAudio())
//if (header.TScrambling) return;
//skip any packets with errors in it
if (header.TransportError) return;
if( m_pids.TeletextPid > 0 && m_pids.TeletextPid != m_currentTeletextPid )
{
IDVBSubtitle* pDVBSubtitleFilter(m_filter.GetSubtitleFilter());
if( pTeletextServiceInfoCallback )
{
std::vector<TeletextServiceInfo>::iterator vit = m_pids.TeletextInfo.begin();
while(vit != m_pids.TeletextInfo.end())
{
TeletextServiceInfo& info = *vit;
LogDebug("Calling Teletext Service info callback");
(*pTeletextServiceInfoCallback)(info.page, info.type, (byte)info.lang[0],(byte)info.lang[1],(byte)info.lang[2]);
vit++;
}
m_currentTeletextPid = m_pids.TeletextPid;
}
}
//is this the PCR pid ?
if ((header.Pid==m_pids.PcrPid) || (m_pids.PcrPid==0x1fff))
{
//yep, does it have a PCR timestamp?
CAdaptionField field;
field.Decode(header,tsPacket);
if (field.Pcr.IsValid)
{
//then update our stream pcr which holds the current playback timestamp
m_streamPcr=field.Pcr;
if (m_pids.PcrPid==0x1fff)
{
if (m_duration.GetPid() != header.Pid)
{
m_duration.SetVideoPid(header.Pid);
LogDebug("OnTsPacket: Real PCR pid updated to 0x%x", header.Pid);
}
}
}
}
//as long as we dont have a stream pcr timestamp we return
if (m_streamPcr.IsValid==false)
{
return;
}
//Buffers about to be flushed
if (m_bFlushDelgNow || m_bFlushRunning || m_bShuttingDown)
{
return;
}
//process the ts packet further
FillVideo(header,tsPacket);
FillAudio(header,tsPacket);
FillSubtitle(header,tsPacket);
FillTeletext(header,tsPacket);
}
I haven't done anything to TsWriter yet (and I'm probably not going to have much time to spend on it for a few days - going away for a long weekend tomorrow) so feel free to have a go at the problem - ideas/patches welcome
Tony
Last edited: