DVB-C radio not working | Page 3

Discussion in '1.3.x' started by torrinha, April 10, 2013.

  1. Owlsroost
    • Team MediaPortal

    Owlsroost Development Group

    Joined:
    October 28, 2008
    Messages:
    5,537
    Likes Received:
    2,829
    Location:
    Cambridge
    Ratings:
    +4,131 / 1
    Home Country:
    United Kingdom United Kingdom
    Show System Specs
    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 (Text):
    1. void CDeMultiplexer::OnTsPacket(byte* tsPacket)
    2. {
    3.   //LogDebug("OnTsPacket() start");
    4.   CTsHeader header(tsPacket);
    5.   //header.LogHeader();
    6.  
    7.   m_patParser.OnTsPacket(tsPacket);
    8.  
    9.   if ((m_iPatVersion==-1) || m_bWaitGoodPat)
    10.   {
    11.     // First PAT not found or waiting for correct PAT
    12.     return;
    13.   }
    14.  
    15.   // Wait for new PAT if required.
    16.   if ((m_iPatVersion & 0x0F) != (m_ReqPatVersion & 0x0F)) //No PAT yet, or PAT version doesn't match requested e.g. PAT data from old channel
    17.   {
    18.     if (m_ReqPatVersion==-1)               
    19.     {                                   // Now, unless channel change,
    20.       m_ReqPatVersion = m_iPatVersion;  // Initialize Pat Request.
    21.       m_WaitNewPatTmo = GET_TIME_NOW();  // Now, unless channel change request,timeout will be always true.
    22.     }
    23.     if (GET_TIME_NOW() < m_WaitNewPatTmo)
    24.     {
    25.       // Timeout not reached.
    26.       return;
    27.     }
    28.   }
    29.  
    30.   //if we have no PCR pid (yet) then there's nothing to decode, so return
    31.   if (m_pids.PcrPid==0) return;
    32.  
    33.   if (header.Pid==0) return;
    34.  
    35.   // 'TScrambling' check commented out - headers are never scrambled,
    36.   // so it's safe to detect scrambled payload at PES level (in FillVideo()/FillAudio())
    37.  
    38.   //if (header.TScrambling) return;
    39.  
    40.   //skip any packets with errors in it
    41.   if (header.TransportError) return;
    42.  
    43.   if( m_pids.TeletextPid > 0 && m_pids.TeletextPid != m_currentTeletextPid )
    44.   {
    45.     IDVBSubtitle* pDVBSubtitleFilter(m_filter.GetSubtitleFilter());
    46.     if( pTeletextServiceInfoCallback )
    47.       {
    48.       std::vector<TeletextServiceInfo>::iterator vit = m_pids.TeletextInfo.begin();
    49.       while(vit != m_pids.TeletextInfo.end())
    50.       {
    51.         TeletextServiceInfo& info = *vit;
    52.         LogDebug("Calling Teletext Service info callback");
    53.         (*pTeletextServiceInfoCallback)(info.page, info.type, (byte)info.lang[0],(byte)info.lang[1],(byte)info.lang[2]);
    54.         vit++;
    55.       }
    56.       m_currentTeletextPid = m_pids.TeletextPid;
    57.     }
    58.   }
    59.  
    60.  
    61.   //is this the PCR pid ?
    62.   if ((header.Pid==m_pids.PcrPid) || (m_pids.PcrPid==0x1fff))
    63.   {
    64.     //yep, does it have a PCR timestamp?
    65.     CAdaptionField field;
    66.     field.Decode(header,tsPacket);
    67.     if (field.Pcr.IsValid)
    68.     {
    69.       //then update our stream pcr which holds the current playback timestamp
    70.       m_streamPcr=field.Pcr;
    71.       if (m_pids.PcrPid==0x1fff)
    72.       {
    73.          if (m_duration.GetPid() != header.Pid)
    74.         {
    75.           m_duration.SetVideoPid(header.Pid);
    76.           LogDebug("OnTsPacket: Real PCR pid updated to 0x%x", header.Pid);
    77.         }
    78.       }
    79.     }
    80.   }
    81.  
    82.   //as long as we dont have a stream pcr timestamp we return
    83.   if (m_streamPcr.IsValid==false)
    84.   {
    85.     return;
    86.   }
    87.  
    88.   //Buffers about to be flushed
    89.   if (m_bFlushDelgNow || m_bFlushRunning || m_bShuttingDown)
    90.   {
    91.       return;
    92.   }
    93.  
    94.   //process the ts packet further
    95.   FillVideo(header,tsPacket);
    96.   FillAudio(header,tsPacket);
    97.   FillSubtitle(header,tsPacket);
    98.   FillTeletext(header,tsPacket);
    99. }
    100.  
    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: April 11, 2013
    • Like Like x 1
  2. Google AdSense Guest Advertisement



    to hide all adverts.
  3. hello_joe

    hello_joe Portal Member

    Joined:
    April 2, 2013
    Messages:
    28
    Likes Received:
    18
    Ratings:
    +18 / 0
    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?
     

    Attached Files:

    • Like Like x 1
  4. torrinha

    torrinha Portal Pro

    Joined:
    October 14, 2009
    Messages:
    55
    Likes Received:
    31
    Ratings:
    +31 / 0
    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: April 11, 2013
  5. tourettes
    • Premium Supporter

    tourettes Retired Team Member

    Joined:
    January 7, 2005
    Messages:
    17,301
    Likes Received:
    4,595
    Ratings:
    +4,810 / 3
    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.
     
    • Like Like x 1
  6. hello_joe

    hello_joe Portal Member

    Joined:
    April 2, 2013
    Messages:
    28
    Likes Received:
    18
    Ratings:
    +18 / 0
    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]
    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. ;)
     

    Attached Files:

    • Like Like x 1
  7. torrinha

    torrinha Portal Pro

    Joined:
    October 14, 2009
    Messages:
    55
    Likes Received:
    31
    Ratings:
    +31 / 0
    Home Country:
    Brazil Brazil
    @hello_hoe:

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

    hello_joe Portal Member

    Joined:
    April 2, 2013
    Messages:
    28
    Likes Received:
    18
    Ratings:
    +18 / 0
    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... :)
     

    Attached Files:

    • Like Like x 2
  9. torrinha

    torrinha Portal Pro

    Joined:
    October 14, 2009
    Messages:
    55
    Likes Received:
    31
    Ratings:
    +31 / 0
    Home Country:
    Brazil Brazil
    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... ;);)
     
  10. Owlsroost
    • Team MediaPortal

    Owlsroost Development Group

    Joined:
    October 28, 2008
    Messages:
    5,537
    Likes Received:
    2,829
    Location:
    Cambridge
    Ratings:
    +4,131 / 1
    Home Country:
    United Kingdom United Kingdom
    Show System Specs
    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
     
  11. Edalex
    • Premium Supporter

    Edalex Community Plugin Dev

    Joined:
    January 3, 2008
    Messages:
    2,903
    Likes Received:
    709
    Gender:
    Male
    Location:
    Saratov
    Ratings:
    +1,223 / 9
    Home Country:
    Russian Federation Russian Federation
    Show System Specs
    Hey guys.
    I'm very interested in playing channels without PCR in stream so please keep posting ;)
     
Loading...

Users Viewing Thread (Users: 0, Guests: 0)

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice
  • About The Project

    The vision of the MediaPortal project is to create a free open source media centre application, which supports all advanced media centre functions, and is accessible to all Windows users.

    In reaching this goal we are working every day to make sure our software is one of the best.

             

  • Support MediaPortal!

    The team works very hard to make sure the community is running the best HTPC-software. We give away MediaPortal for free but hosting and software is not for us.

    Care to support our work with a few bucks? We'd really appreciate it!