Advertisement
Guest User

Untitled

a guest
Jan 17th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.96 KB | None | 0 0
  1. diff --git a/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp b/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp
  2. index 0fb91b1..a6c423d 100644
  3. --- a/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp
  4. +++ b/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.cpp
  5. @@ -26,6 +26,12 @@ void AvFormatDecoderDVD::UpdateFramesPlayed(void)
  6.      m_parent->SetFramesPlayed(currentpos + 1);
  7.  }
  8.  
  9. +bool AvFormatDecoderDVD::GetFrame(DecodeType decodetype)
  10. +{
  11. +    // Always try to decode audio and video for DVDs
  12. +    return AvFormatDecoder::GetFrame( kDecodeAV );
  13. +}
  14. +
  15.  void AvFormatDecoderDVD::PostProcessTracks(void)
  16.  {
  17.      if (!ringBuffer)
  18. diff --git a/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.h b/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.h
  19. index 4c9c15d..5044ba4 100644
  20. --- a/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.h
  21. +++ b/mythtv/libs/libmythtv/DVD/avformatdecoderdvd.h
  22. @@ -10,6 +10,7 @@ class AvFormatDecoderDVD : public AvFormatDecoder
  23.                         PlayerFlags flags);
  24.      virtual void Reset(bool reset_video_data, bool seek_reset, bool reset_file);
  25.      virtual void UpdateFramesPlayed(void);
  26. +    virtual bool GetFrame(DecodeType decodetype); // DecoderBase
  27.  
  28.    private:
  29.      virtual bool DoRewindSeek(long long desiredFrame);
  30. diff --git a/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp b/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp
  31. index 0913fe2..1a21400 100644
  32. --- a/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp
  33. +++ b/mythtv/libs/libmythtv/DVD/dvdringbuffer.cpp
  34. @@ -340,55 +340,6 @@ bool DVDRingBuffer::OpenFile(const QString &lfilename, uint retry_ms)
  35.      dvdnav_set_readahead_flag(m_dvdnav, 0);
  36.      dvdnav_set_PGC_positioning_flag(m_dvdnav, 1);
  37.  
  38. -    int32_t num_titles = 0;
  39. -    res = dvdnav_get_number_of_titles(m_dvdnav, &num_titles);
  40. -    if (num_titles == 0 || res == DVDNAV_STATUS_ERR)
  41. -    {
  42. -        char buf[DVD_BLOCK_SIZE * 5];
  43. -        LOG(VB_GENERAL, LOG_INFO,
  44. -            LOC + QString("Reading %1 bytes from the drive")
  45. -                .arg(DVD_BLOCK_SIZE * 5));
  46. -        safe_read(buf, DVD_BLOCK_SIZE * 5);
  47. -        res = dvdnav_get_number_of_titles(m_dvdnav, &num_titles);
  48. -    }
  49. -
  50. -    if (res == DVDNAV_STATUS_ERR)
  51. -    {
  52. -        LOG(VB_GENERAL, LOG_ERR,
  53. -            LOC + QString("Failed to get the number of titles on the DVD" ));
  54. -    }
  55. -    else
  56. -    {
  57. -        LOG(VB_GENERAL, LOG_INFO,
  58. -            LOC + QString("There are %1 titles on the disk")
  59. -                .arg(num_titles));
  60. -    }
  61. -
  62. -    int startTitle = 1;
  63. -    dvdnav_status_t result;
  64. -    while (startTitle <= num_titles)
  65. -    {
  66. -        result = dvdnav_title_play(m_dvdnav, startTitle);
  67. -        if (result == DVDNAV_STATUS_OK)
  68. -            break;
  69. -        else if (startTitle < num_titles)
  70. -            LOG(VB_GENERAL, LOG_WARNING, QString("Unable to play DVD title %1, "
  71. -                                                 "trying next title")
  72. -                                                    .arg(startTitle));
  73. -        startTitle++;
  74. -    }
  75. -
  76. -    if (result == DVDNAV_STATUS_ERR)
  77. -    {
  78. -        LOG(VB_GENERAL, LOG_ERR, QString("Unable to play any title on this "
  79. -                                         "DVD. Disc may be damaged or "
  80. -                                         "corrupted as a means of copy "
  81. -                                         "protection."));
  82. -
  83. -        rwlock.unlock();
  84. -        return false;
  85. -    }
  86. -
  87.      // Check we aren't starting in a still frame (which will probably fail as
  88.      // ffmpeg will be unable to create a decoder)
  89.      if (dvdnav_get_next_still_flag(m_dvdnav))
  90. @@ -444,6 +395,7 @@ bool DVDRingBuffer::StartFromBeginning(void)
  91.      if (m_dvdnav)
  92.      {
  93.          QMutexLocker lock(&m_seekLock);
  94. +        dvdnav_reset(m_dvdnav);
  95.          dvdnav_first_play(m_dvdnav);
  96.          m_audioStreamsChanged = true;
  97.      }
  98. diff --git a/mythtv/libs/libmythtv/avformatdecoder.cpp b/mythtv/libs/libmythtv/avformatdecoder.cpp
  99. index 29f8dbb..5a4d965 100644
  100. --- a/mythtv/libs/libmythtv/avformatdecoder.cpp
  101. +++ b/mythtv/libs/libmythtv/avformatdecoder.cpp
  102. @@ -335,7 +335,8 @@ AvFormatDecoder::AvFormatDecoder(MythPlayer *parent,
  103.        // Audio
  104.        disable_passthru(false),
  105.        m_fps(0.0f),
  106. -      codec_is_mpeg(false)
  107. +      codec_is_mpeg(false),
  108. +      m_processFrames(true)
  109.  {
  110.      memset(&readcontext, 0, sizeof(readcontext));
  111.      memset(ccX08_in_pmt, 0, sizeof(ccX08_in_pmt));
  112. @@ -684,9 +685,6 @@ bool AvFormatDecoder::DoFastForward(long long desiredFrame, bool discardFrames)
  113.  void AvFormatDecoder::SeekReset(long long newKey, uint skipFrames,
  114.                                  bool doflush, bool discardFrames)
  115.  {
  116. -    if (ringBuffer->IsInDiscMenuOrStillFrame() || newKey == 0)
  117. -        return;
  118. -
  119.      LOG(VB_PLAYBACK, LOG_INFO, LOC +
  120.          QString("SeekReset(%1, %2, %3 flush, %4 discard)")
  121.              .arg(newKey).arg(skipFrames)
  122. @@ -935,6 +933,11 @@ int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,
  123.  
  124.      ringBuffer = rbuffer;
  125.  
  126. +    // Process frames immediately unless we're decoding
  127. +    // a DVD, in which case don't so that we don't show
  128. +    // anything whilst probing the data streams.
  129. +    m_processFrames = !ringBuffer->IsDVD();
  130. +
  131.      if (avfRingBuffer)
  132.          delete avfRingBuffer;
  133.      avfRingBuffer = new AVFRingBuffer(rbuffer);
  134. @@ -982,12 +985,6 @@ int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,
  135.      }
  136.  
  137.      int ret = FindStreamInfo();
  138. -
  139. -    // Reset DVD/bluray ringbuffers
  140. -    if (!ringBuffer->StartFromBeginning())
  141. -        return -1;
  142. -    ringBuffer->IgnoreWaitStates(false);
  143. -
  144.      if (ret < 0)
  145.      {
  146.          LOG(VB_GENERAL, LOG_ERR, LOC + "Could not find codec parameters. " +
  147. @@ -1144,6 +1141,23 @@ int AvFormatDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,
  148.      if (getenv("FORCE_DTS_TIMESTAMPS"))
  149.          force_dts_timestamps = true;
  150.  
  151. +    if (ringBuffer->IsDVD())
  152. +    {
  153. +        // Reset DVD playback and clear any of
  154. +        // our buffers so that none of the data
  155. +        // parsed so far to determine decoders
  156. +        // gets shown.
  157. +        if (!ringBuffer->StartFromBeginning())
  158. +            return -1;
  159. +        ringBuffer->IgnoreWaitStates(false);
  160. +
  161. +        Reset(true, true, true);
  162. +
  163. +        // Now we're ready to process and show frames
  164. +        m_processFrames = true;
  165. +    }
  166. +
  167. +
  168.      // Return true if recording has position map
  169.      return recordingHasPositionMap;
  170.  }
  171. @@ -4418,6 +4432,11 @@ bool AvFormatDecoder::GetFrame(DecodeType decodetype)
  172.  
  173.      skipaudio = (lastvpts == 0);
  174.  
  175. +    if( !m_processFrames )
  176. +    {
  177. +        return false;
  178. +    }
  179. +
  180.      hasVideo = HasVideo(ic);
  181.      needDummyVideoFrames = false;
  182.  
  183. diff --git a/mythtv/libs/libmythtv/avformatdecoder.h b/mythtv/libs/libmythtv/avformatdecoder.h
  184. index 5a97dfd..012eb08 100644
  185. --- a/mythtv/libs/libmythtv/avformatdecoder.h
  186. +++ b/mythtv/libs/libmythtv/avformatdecoder.h
  187. @@ -360,6 +360,7 @@ class AvFormatDecoder : public DecoderBase
  188.  
  189.      float m_fps;
  190.      bool  codec_is_mpeg;
  191. +    bool  m_processFrames;
  192.  };
  193.  
  194.  #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement