DVB-C radio not working (1 Viewer)

Owlsroost

Retired Team Member
  • Premium Supporter
  • October 28, 2008
    5,540
    5,038
    Cambridge
    Home Country
    United Kingdom United Kingdom
    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' :

    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:

    hello_joe

    Portal Member
    April 2, 2013
    28
    18
    Home Country
    United States of America United States of America
    @Owlsroost
    Creating PCR is too complex for me, but hunting for PCR within the channel streams in TsWriter is quite straightforward.
    Patch and TsWriter.ax attached.
    @torrinha Can you please try the TsWriter.ax in TsWriter_hunt_pcr.zip?
     

    Attachments

    • TsWriter_hunt_pcr.zip
      116 KB
    • PCR_hunt.patch
      1.5 KB

    torrinha

    Portal Pro
    October 14, 2009
    55
    31
    Home Country
    Brazil Brazil
    @hello_joe Sure I can test. I'm at work right now, but I'll give it a go as soon as I can. (y)

    @Owlsroost It would be great if you could attach your patched TsReader.ax also... ;);)


    thank you both for the help!!


    edit:
    @hello_joe: I was just looking at your patch and saw that you changed the CDiskRecorder::WriteTS method. Wouldn't you need to change also the OnTsPacket() (remove the "if (header.Pid==0x1fff) return;", as you stated before) ???
     
    Last edited:

    tourettes

    Retired Team Member
  • Premium Supporter
  • January 7, 2005
    17,301
    4,800
    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 -

    0x1FFF is NULL stream according to the DVB specs. It should be always ignored and not written to any TS file. For example on my local DVB-C network the recording files will increase around 100% in size - DVB-T stream is send as DVB-C 1:1 and padded with the huge NULL stream.
     

    hello_joe

    Portal Member
    April 2, 2013
    28
    18
    Home Country
    United States of America United States of America
    Just realised I made a small mistake in that patch. :oops:
    Sorry, please try this one! :)[DOUBLEPOST=1365676084][/DOUBLEPOST]
    0x1FFF is NULL stream according to the DVB specs. It should be always ignored and not written to any TS file. For example on my local DVB-C network the recording files will increase around 100% in size - DVB-T stream is send as DVB-C 1:1 and padded with the huge NULL stream.
    If you check the patch, you'll see that Tony is checking for PCR in the adaption fields of the other streams that are already part of the channel. This solution is ***not*** writing NULL packets to the TS files. Even if it was, it would be possible to throw away the packets that don't have PCR. We know there is no need to create files that are larger than necessary. ;)
     

    Attachments

    • TsWriter_hunt_pcr_v2.zip
      116 KB
    • PCR_hunt_v2.patch
      1.6 KB

    torrinha

    Portal Pro
    October 14, 2009
    55
    31
    Home Country
    Brazil Brazil
    @hello_hoe:

    and what about the OnTsPacket() ==> "if (header.Pid==0x1fff) return;" ?
     

    hello_joe

    Portal Member
    April 2, 2013
    28
    18
    Home Country
    United States of America United States of America
    I left that untouched. It is correct to throw those packets away.
    The logic is this:
    When attempting to start timeshifting, if the PMT says that the PCR PID is 0x1fff then check for PCR in the adaption fields of the other streams in the channel. If you find PCR, adopt that PID as the PCR PID.

    So "PID == 0x1fff" is like a marker to say "I don't have a valid PCR PID, please search for PCR".[DOUBLEPOST=1365676887][/DOUBLEPOST]By the way, you do not need an updated TsReader to test the TsWriter. The TsWriter change will fix the PMT so that TsReader knows where to find the PCR without the patch from Owlsroost. But just in case somebody somehow had a recording with PCR PID set to 0x1fff in the PMT, you could try the attached TsReader containing the patch from Owlsroost... :)
     

    Attachments

    • TsReader_pcr_hunt.zip
      166.3 KB

    torrinha

    Portal Pro
    October 14, 2009
    55
    31
    Home Country
    Brazil Brazil
    I left that untouched

    I was just talking about the OnTsPacket because it seems to me that you are searching for PCR inside WriteTs(), and the IF statement on the previous method would prevent you to even reach the OnTsPacket method, but I guess the WriteTs() may be called from other parts of the code... anyway, don't worry!
    Maybe I'm missing something about the whole story, so I'll just try your patched file when I get home... ;);)
     

    Owlsroost

    Retired Team Member
  • Premium Supporter
  • October 28, 2008
    5,540
    5,038
    Cambridge
    Home Country
    United Kingdom United Kingdom
    Just realised I made a small mistake in that patch. :oops: Sorry, please try this one! :)

    Haven't had time to look at the code overalll, but the patch looks OK to me, provided it ensures that the PMT in the output stream is updated correctly with the new PCR PID, and that the PMT parsing of the input stream won't get upset by changing 'm_pcrPid' to a different value (in case it compares new PMT PCR pid against the stored version to work out if it has been updated since the last PMT was received).

    I guess the other thing is to decide is if this is a good idea in a general sense i.e. is it a 'safe' thing to have in TsWriter.ax in the long term ?

    Tony
     

    Edalex

    Community Plugin Dev
  • Premium Supporter
  • January 3, 2008
    2,955
    1,264
    Saratov
    Home Country
    Russian Federation Russian Federation
    Hey guys.
    I'm very interested in playing channels without PCR in stream so please keep posting ;)
     

    Users who are viewing this thread

    Top Bottom