MythTV  master
mythplayer.cpp
Go to the documentation of this file.
1 // -*- Mode: c++ -*-
2 
3 #undef HAVE_AV_CONFIG_H
4 
5 // C++ headers
6 #include <algorithm>
7 #include <cassert>
8 #include <cmath>
9 #include <cstdint>
10 #include <cstdio>
11 #include <cstdlib>
12 #include <unistd.h>
13 
14 // Qt headers
15 #include <QCoreApplication>
16 #include <QDir>
17 #include <QHash>
18 #include <QMap>
19 #include <QThread>
20 #include <utility>
21 
22 // MythTV headers
24 #include "libmythbase/mthread.h"
25 #include "libmythbase/mythconfig.h"
29 #include "libmythbase/mythtimer.h"
33 
34 #include "DetectLetterbox.h"
35 #include "audioplayer.h"
36 #include "cardutil.h"
40 #include "dummydecoder.h"
41 #include "io/mythmediabuffer.h"
42 #include "jitterometer.h"
43 #include "livetvchain.h"
44 #include "mythavutil.h"
45 #include "mythplayer.h"
46 #include "mythvideooutnull.h"
47 #include "remoteencoder.h"
48 #include "tv_actions.h"
49 #include "tv_play.h"
50 
51 extern "C" {
52 #include "libavcodec/avcodec.h"
53 }
54 
55 static unsigned dbg_ident(const MythPlayer* /*player*/);
56 
57 #define LOC QString("Player(%1): ").arg(dbg_ident(this),0,36)
58 
61 
62 // Exact frame seeking, no inaccuracy allowed.
63 const double MythPlayer::kInaccuracyNone = 0;
64 
65 // By default, when seeking, snap to a keyframe if the keyframe's
66 // distance from the target frame is less than 10% of the total seek
67 // distance.
68 const double MythPlayer::kInaccuracyDefault = 0.1;
69 
70 // Allow greater inaccuracy (50%) in the cutlist editor (unless the
71 // editor seek distance is set to 1 frame or 1 keyframe).
72 const double MythPlayer::kInaccuracyEditor = 0.5;
73 
74 // Any negative value means completely inexact, i.e. seek to the
75 // keyframe that is closest to the target.
76 const double MythPlayer::kInaccuracyFull = -1.0;
77 
78 // How close we can seek to the end of a recording.
79 const double MythPlayer::kSeekToEndOffset = 1.0;
80 
82  : m_playerCtx(Context),
83  m_playerThread(QThread::currentThread()),
84  m_playerFlags(Flags),
85  m_liveTV(Context->m_tvchain),
86  //AV subtitles
87  m_subReader(this),
88  // CC608/708
89  m_cc608(this), m_cc708(this),
90  // Audio
91  m_audio(this, (Flags & kAudioMuted) != 0)
92 {
93 #ifdef Q_OS_ANDROID
94  m_playerThreadId = gettid();
95 #endif
97 
100  m_endExitPrompt = gCoreContext->GetNumSetting("EndOfRecordingExitPrompt");
101 
102  // Get VBI page number
103  QString mypage = gCoreContext->GetSetting("VBIpageNr", "888");
104  bool valid = false;
105  uint tmp = mypage.toInt(&valid, 16);
106  m_ttPageNum = (valid) ? tmp : m_ttPageNum;
108 }
109 
111 {
112  QMutexLocker lock2(&m_vidExitLock);
113 
114  SetDecoder(nullptr);
115 
116  delete m_decoderThread;
117  m_decoderThread = nullptr;
118 
119  delete m_videoOutput;
120  m_videoOutput = nullptr;
121 }
122 
124 {
125  m_watchingRecording = mode;
126  if (m_decoder)
128 }
129 
131 {
133 }
134 
136 {
137  m_bufferPauseLock.lock();
138  if (m_playerCtx->m_buffer)
139  {
142  }
143  m_bufferPaused = true;
144  m_bufferPauseLock.unlock();
145 }
146 
148 {
149  m_bufferPauseLock.lock();
150  if (m_playerCtx->m_buffer)
152  m_bufferPaused = false;
153  m_bufferPauseLock.unlock();
154 }
155 
157 {
158  while (!m_pauseLock.tryLock(100))
159  {
160  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Waited 100ms to get pause lock.");
162  }
163  bool already_paused = m_allPaused;
164  if (already_paused)
165  {
166  m_pauseLock.unlock();
167  return already_paused;
168  }
169  m_nextPlaySpeed = 0.0;
170  m_nextNormalSpeed = false;
171  PauseVideo();
172  m_audio.Pause(true);
173  PauseDecoder();
174  PauseBuffer();
175  if (!m_decoderPaused)
176  PauseDecoder(); // Retry in case audio only stream
178  {
181  else if (m_videoOutput && !FlagIsSet(kVideoIsNull))
183  }
184  m_pauseLock.unlock();
186  return already_paused;
187 }
188 
189 bool MythPlayer::Play(float speed, bool normal, bool unpauseaudio)
190 {
191  m_pauseLock.lock();
192  LOG(VB_PLAYBACK, LOG_INFO, LOC +
193  QString("Play(%1, normal %2, unpause audio %3)")
194  .arg(speed,5,'f',1).arg(normal).arg(unpauseaudio));
195 
196  if (m_deleteMap.IsEditing())
197  {
198  LOG(VB_GENERAL, LOG_ERR, LOC + "Ignoring Play(), in edit mode.");
199  m_pauseLock.unlock();
200  return false;
201  }
202 
204 
206  UnpauseBuffer();
207  UnpauseDecoder();
208  if (unpauseaudio)
209  m_audio.Pause(false);
210  UnpauseVideo();
211  m_allPaused = false;
212  m_nextPlaySpeed = speed;
213  m_nextNormalSpeed = normal;
214  m_pauseLock.unlock();
216  return true;
217 }
218 
220 {
221  m_videoPauseLock.lock();
222  m_needNewPauseFrame = true;
223  m_videoPaused = true;
224  m_videoPauseLock.unlock();
225 }
226 
228 {
229  m_videoPauseLock.lock();
230  m_videoPaused = false;
231  m_videoPauseLock.unlock();
232 }
233 
235 {
237  if (!m_playerCtx)
238  return;
239 
240  m_playerCtx->LockPlayingInfo(__FILE__, __LINE__);
241  m_playerCtx->SetPlayingInfo(&pginfo);
242  m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
243 }
244 
245 void MythPlayer::SetPlaying(bool is_playing)
246 {
247  QMutexLocker locker(&m_playingLock);
248 
249  m_playing = is_playing;
250 
251  m_playingWaitCond.wakeAll();
252 }
253 
254 bool MythPlayer::IsPlaying(std::chrono::milliseconds wait_in_msec, bool wait_for) const
255 {
256  QMutexLocker locker(&m_playingLock);
257 
258  if (wait_in_msec == 0ms)
259  return m_playing;
260 
261  MythTimer t;
262  t.start();
263 
264  while ((wait_for != m_playing) && (t.elapsed() < wait_in_msec))
265  {
266  m_playingWaitCond.wait(
267  &m_playingLock, std::max(0ms,wait_in_msec - t.elapsed()).count());
268  }
269 
270  return m_playing;
271 }
272 
274 {
275  if (!m_playerCtx)
276  return false;
277 
278  if (!m_decoder)
279  {
280  LOG(VB_GENERAL, LOG_ERR, LOC + "Cannot create a video renderer without a decoder.");
281  return false;
282  }
283 
286 
287  if (!m_videoOutput)
288  {
289  LOG(VB_GENERAL, LOG_ERR, LOC + "Couldn't create VideoOutput instance. Exiting..");
290  SetErrored(tr("Failed to initialize video output"));
291  return false;
292  }
293 
294  return true;
295 }
296 
297 void MythPlayer::ReinitVideo(bool ForceUpdate)
298 {
299 
300  bool aspect_only = false;
301  {
302  QMutexLocker locker(&m_vidExitLock);
303  m_videoOutput->SetVideoFrameRate(static_cast<float>(m_videoFrameRate));
304  float video_aspect = (m_forcedVideoAspect > 0) ? m_forcedVideoAspect : m_videoAspect;
306  m_decoder->GetVideoCodecID(), aspect_only,
307  m_maxReferenceFrames, ForceUpdate))
308  {
309  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to Reinitialize Video. Exiting..");
310  SetErrored(tr("Failed to reinitialize video output"));
311  return;
312  }
313  }
314 
315  if (!aspect_only)
316  ClearAfterSeek();
317 }
318 
319 void MythPlayer::SetKeyframeDistance(int keyframedistance)
320 {
321  m_keyframeDist = (keyframedistance > 0) ? static_cast<uint>(keyframedistance) : m_keyframeDist;
322 }
323 
324 void MythPlayer::SetVideoParams(int width, int height, double fps,
325  float aspect, bool ForceUpdate,
326  int ReferenceFrames, FrameScanType /*scan*/, const QString& codecName)
327 {
328  bool paramsChanged = ForceUpdate;
329 
330  if (width >= 0 && height >= 0)
331  {
332  paramsChanged = true;
333  m_videoDim = m_videoDispDim = QSize(width, height);
334  m_videoAspect = aspect > 0.0F ? aspect : static_cast<float>(width) / height;
335  }
336 
337  if (!qIsNaN(fps) && fps > 0.0 && fps < 121.0)
338  {
339  paramsChanged = true;
340  m_videoFrameRate = fps;
341  if (m_ffrewSkip != 0 && m_ffrewSkip != 1)
342  {
343  UpdateFFRewSkip();
344  }
345  else
346  {
347  float temp_speed = (m_playSpeed == 0.0F) ?
350  1.0 / (m_videoFrameRate * static_cast<double>(temp_speed)));
351  }
352  }
353 
354  if (!codecName.isEmpty())
355  {
356  m_codecName = codecName;
357  paramsChanged = true;
358  }
359 
360  if (ReferenceFrames > 0)
361  {
362  m_maxReferenceFrames = ReferenceFrames;
363  paramsChanged = true;
364  }
365 
366  if (!paramsChanged)
367  return;
368 
369  if (m_videoOutput)
370  ReinitVideo(ForceUpdate);
371 
372  if (IsErrored())
373  return;
374 }
375 
376 
377 void MythPlayer::SetFrameRate(double fps)
378 {
379  m_videoFrameRate = fps;
380  float temp_speed = (m_playSpeed == 0.0F) ? m_audio.GetStretchFactor() : m_playSpeed;
381  if (abs(m_ffrewSkip) > 1)
382  UpdateFFRewSkip();
383  else
384  SetFrameInterval(kScan_Progressive, 1.0 / (m_videoFrameRate * static_cast<double>(temp_speed)));
385 }
386 
387 void MythPlayer::SetFileLength(std::chrono::seconds total, int frames)
388 {
389  m_totalLength = total;
390  m_totalFrames = frames;
391 }
392 
393 void MythPlayer::SetDuration(std::chrono::seconds duration)
394 {
395  m_totalDuration = duration;
396 }
397 
399 {
400  m_isDummy = true;
401 
402  if (!m_videoOutput)
403  {
405  SetVideoParams(720, 576, 25.00, 1.25F, false, 2);
406  }
407 
408  m_playerCtx->LockPlayingInfo(__FILE__, __LINE__);
409  auto *dec = new DummyDecoder(this, *(m_playerCtx->m_playingInfo));
410  m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
411  SetDecoder(dec);
412 }
413 
415 {
418 }
419 
420 int MythPlayer::OpenFile(int Retries)
421 {
422  // Sanity check
423  if (!m_playerCtx || !m_playerCtx->m_buffer)
424  return -1;
425 
426  LOG(VB_GENERAL, LOG_INFO, LOC + QString("Opening '%1'").arg(m_playerCtx->m_buffer->GetSafeFilename()));
427 
428  m_isDummy = false;
430 
431  // Dummy setup for livetv transtions. Can we get rid of this?
432  if (m_playerCtx->m_tvchain)
433  {
434  int currentposition = m_playerCtx->m_tvchain->GetCurPos();
435  if (m_playerCtx->m_tvchain->GetInputType(currentposition) == "DUMMY")
436  {
437  OpenDummy();
438  return 0;
439  }
440  }
441 
442  // Start the RingBuffer read ahead thread
444 
446  TestBufferVec testbuf {};
447  testbuf.reserve(kDecoderProbeBufferSize);
448 
449  UnpauseBuffer();
450 
451  // delete any pre-existing recorder
452  SetDecoder(nullptr);
453  int testreadsize = 2048;
454 
455  // Test the incoming buffer and create a suitable decoder
456  MythTimer bigTimer;
457  bigTimer.start();
458  std::chrono::milliseconds timeout =
459  std::max(500ms * (Retries + 1), 30000ms);
460  while (testreadsize <= kDecoderProbeBufferSize)
461  {
462  testbuf.resize(testreadsize);
463  MythTimer peekTimer;
464  peekTimer.start();
465  while (m_playerCtx->m_buffer->Peek(testbuf) != testreadsize)
466  {
467  // NB need to allow for streams encountering network congestion
468  if (peekTimer.elapsed() > 30s || bigTimer.elapsed() > timeout
470  {
471  LOG(VB_GENERAL, LOG_ERR, LOC +
472  QString("OpenFile(): Could not read first %1 bytes of '%2'")
473  .arg(testreadsize)
474  .arg(m_playerCtx->m_buffer->GetFilename()));
475  SetErrored(tr("Could not read first %1 bytes").arg(testreadsize));
476  return -1;
477  }
478  LOG(VB_GENERAL, LOG_WARNING, LOC + "OpenFile() waiting on data");
479  std::this_thread::sleep_for(50ms);
480  }
481 
482  m_playerCtx->LockPlayingInfo(__FILE__, __LINE__);
483  CreateDecoder(testbuf);
484  m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
485  if (m_decoder || (bigTimer.elapsed() > timeout))
486  break;
487  testreadsize <<= 1;
488  }
489 
490  // Fail
491  if (!m_decoder)
492  {
493  LOG(VB_GENERAL, LOG_ERR, LOC +
494  QString("Couldn't find an A/V decoder for: '%1'")
495  .arg(m_playerCtx->m_buffer->GetFilename()));
496  SetErrored(tr("Could not find an A/V decoder"));
497 
498  return -1;
499  }
500 
501  if (m_decoder->IsErrored())
502  {
503  LOG(VB_GENERAL, LOG_ERR, LOC + "Could not initialize A/V decoder.");
504  SetDecoder(nullptr);
505  SetErrored(tr("Could not initialize A/V decoder"));
506 
507  return -1;
508  }
509 
510  // Pre-init the decoder
514  // TODO (re)move this into MythTranscode player
516 
517  // Open the decoder
518  int result = m_decoder->OpenFile(m_playerCtx->m_buffer, false, testbuf);
519 
520  if (result < 0)
521  {
522  LOG(VB_GENERAL, LOG_ERR, QString("Couldn't open decoder for: %1")
523  .arg(m_playerCtx->m_buffer->GetFilename()));
524  SetErrored(tr("Could not open decoder"));
525  return -1;
526  }
527 
528  // Disable audio if necessary
530 
531  // Livetv, recording or in-progress
532  if (result > 0)
533  {
534  m_hasFullPositionMap = true;
537  }
538 
539  // Determine the initial bookmark and update it for the cutlist
543 
546  {
547  gCoreContext->SaveSetting("DefaultChanid",
548  static_cast<int>(m_playerCtx->m_playingInfo->GetChanID()));
549  QString callsign = m_playerCtx->m_playingInfo->GetChannelSchedulingID();
550  QString channum = m_playerCtx->m_playingInfo->GetChanNum();
551  gCoreContext->SaveSetting("DefaultChanKeys", callsign + "[]:[]" + channum);
553  {
554  uint cardid = static_cast<uint>(m_playerCtx->m_recorder->GetRecorderNumber());
555  CardUtil::SetStartChannel(cardid, channum);
556  }
557  }
558 
559  return IsErrored() ? -1 : 0;
560 }
561 
562 void MythPlayer::SetFramesPlayed(uint64_t played)
563 {
564  m_framesPlayed = played;
565  if (m_videoOutput)
567 }
568 
573 {
574  if (m_videoOutput)
575  return m_videoOutput->FreeVideoFrames();
576  return 0;
577 }
578 
589 {
590  if (m_videoOutput)
592  return nullptr;
593 }
594 
599  std::chrono::milliseconds timecode,
600  bool wrap)
601 {
602  if (wrap)
603  WrapTimecode(timecode, TC_VIDEO);
604  buffer->m_timecode = timecode;
605  m_latestVideoTimecode = timecode;
606 
607  if (m_decodeOneFrame)
608  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + "Clearing decode one");
609  m_decodeOneFrame = false;
610 
611  if (m_videoOutput)
612  {
613  if (abs(m_ffrewSkip) > 1)
614  {
615  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + "Setting render one");
616  m_renderOneFrame = true;
617  }
618  m_videoOutput->ReleaseFrame(buffer);
619  }
620 
621  // FIXME need to handle this in the correct place in the main thread (DVD stills?)
622  //if (m_allPaused)
623  // CheckAspectRatio(buffer);
624 }
625 
630 {
631  if (m_videoOutput)
632  m_videoOutput->DiscardFrame(buffer);
633 }
634 
648 void MythPlayer::DiscardVideoFrames(bool KeyFrame, bool Flushed)
649 {
650  if (m_videoOutput)
651  {
652  m_videoOutput->DiscardFrames(KeyFrame, Flushed);
653  if (m_renderOneFrame)
654  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + "Clearing render one");
655  m_renderOneFrame = false;
656  }
657 }
658 
660 {
661  EofState eof = GetEof();
662  if (eof != kEofStateNone && !m_allPaused)
663  return true;
664  if (GetEditMode())
665  return false;
666  if (m_liveTV)
667  return false;
669  return true;
670  return false;
671 }
672 
674 {
675  if (m_videoOutput)
676  m_videoOutput->DeLimboFrame(frame);
677 }
678 
680 {
681  if (enable)
683  else
685 }
686 
688 {
689  if (m_decoder)
691  m_frameInterval = microsecondsFromFloat(1000000.0 * frame_period / m_fpsMultiplier);
692 
693  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("SetFrameInterval Interval:%1 Speed:%2 Scan:%3 (Multiplier: %4)")
694  .arg(m_frameInterval.count()).arg(static_cast<double>(m_playSpeed)).arg(ScanTypeToString(scan)).arg(m_fpsMultiplier));
695 }
696 
698 {
699  // try to get preferential scheduling, but ignore if we fail to.
700  myth_nice(-19);
701 }
702 
703 void MythPlayer::SetBuffering(bool new_buffering)
704 {
705  if (!m_buffering && new_buffering)
706  {
707  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Waiting for video buffers...");
708  m_buffering = true;
709  m_bufferingStart = QTime::currentTime();
710  m_bufferingLastMsg = QTime::currentTime();
711  }
712  else if (m_buffering && !new_buffering)
713  {
714  m_buffering = false;
715  }
716 }
717 
718 // For debugging playback set this to increase the timeout so that
719 // playback does not fail if stepping through code.
720 // Set PREBUFFERDEBUG to any value and you will get 30 minutes.
721 static bool preBufferDebug = qEnvironmentVariableIsSet("PREBUFFERDEBUG");
722 
724 {
725  if (!m_videoOutput)
726  return false;
727 
728  if (!min_buffers
730  || abs(m_ffrewSkip) > 1
731  || GetEof() != kEofStateNone))
732  min_buffers = 1;
733 
734  auto wait = false;
735  if (min_buffers)
736  wait = m_videoOutput->ValidVideoFrames() < min_buffers;
737  else
739 
740  if (!wait)
741  {
743  m_audio.Pause(false);
744  SetBuffering(false);
746  }
747 
748  SetBuffering(true);
749 
750  // This piece of code is to address the problem, when starting
751  // Live TV, of jerking and stuttering. Without this code
752  // that could go on forever, but is cured by a pause and play.
753  // This code inserts a brief pause and play when the potential
754  // for the jerking is detected.
755  if ((m_liveTV || IsWatchingInprogress())
757  && m_ffrewSkip == 1
759  {
760  auto behind = (GetCurrentFrameCount() - m_framesPlayed) /
762  if (behind < 3.0)
763  {
764  LOG(VB_PLAYBACK, LOG_NOTICE, LOC +
765  "Pause to allow live tv catch up");
767  }
768  }
769 
770  std::this_thread::sleep_for(m_frameInterval / 8);
771  auto waited_for = std::chrono::milliseconds(m_bufferingStart.msecsTo(QTime::currentTime()));
772  auto last_msg = std::chrono::milliseconds(m_bufferingLastMsg.msecsTo(QTime::currentTime()));
773  if (last_msg > 100ms && !FlagIsSet(kMusicChoice))
774  {
775  if (++m_bufferingCounter == 10)
776  LOG(VB_GENERAL, LOG_NOTICE, LOC +
777  "To see more buffering messages use -v playback");
778  LOG(m_bufferingCounter >= 10 ? VB_PLAYBACK : VB_GENERAL,
779  LOG_NOTICE, LOC +
780  QString("Waited %1ms for video buffers %2")
781  .arg(waited_for.count()).arg(m_videoOutput->GetFrameStatus()));
782  m_bufferingLastMsg = QTime::currentTime();
783  if (waited_for > 7s && m_audio.IsBufferAlmostFull()
784  && m_framesPlayed < 5
785  && gCoreContext->GetBoolSetting("MusicChoiceEnabled", false))
786  {
788  LOG(VB_GENERAL, LOG_NOTICE, LOC + "Music Choice program detected - disabling AV Sync.");
790  }
791  if (waited_for > 7s && m_audio.IsBufferAlmostFull()
792  && !FlagIsSet(kMusicChoice))
793  {
794  // We are likely to enter this condition
795  // if the audio buffer was too full during GetFrame in AVFD
796  LOG(VB_GENERAL, LOG_NOTICE, LOC + "Resetting audio buffer");
797  m_audio.Reset();
798  }
799  }
800 
801  std::chrono::milliseconds msecs { 500ms };
802  if (preBufferDebug)
803  msecs = 30min;
804  if ((waited_for > msecs) && !m_videoOutput->EnoughFreeFrames())
805  {
806  LOG(VB_GENERAL, LOG_NOTICE, LOC +
807  "Timed out waiting for frames, and"
808  "\n\t\t\tthere are not enough free frames. "
809  "Discarding buffered frames.");
810  // This call will result in some ugly frames, but allows us
811  // to recover from serious problems if frames get leaked.
812  DiscardVideoFrames(true, true);
813  }
814 
815  msecs = 30s;
816  if (preBufferDebug)
817  msecs = 30min;
818  if (waited_for > msecs) // 30 seconds for internet streamed media
819  {
820  LOG(VB_GENERAL, LOG_ERR, LOC +
821  "Waited too long for decoder to fill video buffers. Exiting..");
822  SetErrored(tr("Video frame buffering failed too many times."));
823  }
824 
825  return false;
826 }
827 
829 {
830  m_vidExitLock.lock();
831  delete m_videoOutput;
832  m_videoOutput = nullptr;
833  m_vidExitLock.unlock();
834 }
835 
836 bool MythPlayer::FastForward(float seconds)
837 {
838  if (!m_videoOutput)
839  return false;
840 
841  // Update m_totalFrames so we know how far we can skip
842  if (m_decoder)
844 
845  if (m_ffTime <= 0)
846  {
847  float current = ComputeSecs(m_framesPlayed, true);
848  float dest = current + seconds;
849  float length = ComputeSecs(m_totalFrames, true);
850 
851  if (dest > length)
852  {
853  auto msec = millisecondsFromFloat(seconds * 1000);
854  int64_t pos = TranslatePositionMsToFrame(msec, false);
855  if (CalcMaxFFTime(pos) < 0)
856  return true;
857  // Reach end of recording, go to offset before the end
859  }
860  uint64_t target = FindFrame(dest, true);
861  m_ffTime = target - m_framesPlayed;
862  }
863  return m_ffTime > CalcMaxFFTime(m_ffTime, false);
864 }
865 
866 bool MythPlayer::Rewind(float seconds)
867 {
868  if (!m_videoOutput)
869  return false;
870 
871  if (m_rewindTime <= 0)
872  {
873  float current = ComputeSecs(m_framesPlayed, true);
874  float dest = current - seconds;
875  if (dest < 0)
876  {
877  auto msec = millisecondsFromFloat(seconds * 1000);
878  int64_t pos = TranslatePositionMsToFrame(msec, false);
879  if (CalcRWTime(pos) < 0)
880  return true;
881  dest = 0;
882  }
883  uint64_t target = FindFrame(dest, true);
884  m_rewindTime = m_framesPlayed - target;
885  }
886  return (uint64_t)m_rewindTime >= m_framesPlayed;
887 }
888 
889 bool MythPlayer::JumpToFrame(uint64_t frame)
890 {
891  if (!m_videoOutput)
892  return false;
893 
894  bool ret = false;
895  m_ffTime = m_rewindTime = 0;
896  if (frame > m_framesPlayed)
897  {
898  m_ffTime = frame - m_framesPlayed;
899  ret = m_ffTime > CalcMaxFFTime(m_ffTime, false);
900  }
901  else if (frame < m_framesPlayed)
902  {
903  m_rewindTime = m_framesPlayed - frame;
904  ret = m_ffTime > CalcMaxFFTime(m_ffTime, false);
905  }
906  return ret;
907 }
908 
909 
910 void MythPlayer::JumpChapter(int chapter)
911 {
912  if (m_jumpChapter == 0)
913  m_jumpChapter = chapter;
914 }
915 
916 void MythPlayer::ResetPlaying(bool resetframes)
917 {
918  ClearAfterSeek();
919  m_ffrewSkip = 1;
920  if (resetframes)
921  m_framesPlayed = 0;
922  if (m_decoder)
923  {
924  m_decoder->Reset(true, true, true);
925  if (m_decoder->IsErrored())
926  SetErrored("Unable to reset video decoder");
927  }
928 }
929 
931 {
932  bool last = !(m_playerCtx->m_tvchain->HasNext());
933  SetWatchingRecording(last);
934 }
935 
936 // This is called from decoder thread. Set an indicator that will
937 // be checked and actioned in the player thread.
939 {
940  LOG(VB_PLAYBACK, LOG_INFO, LOC + "FileChangedCallback");
941  m_fileChanged = true;
942 }
943 
945 {
946  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("StopPlaying - begin"));
947  m_playerThread->setPriority(QThread::NormalPriority);
948 #ifdef Q_OS_ANDROID
949  setpriority(PRIO_PROCESS, m_playerThreadId, 0);
950 #endif
951 
952  emit CheckCallbacks();
953  DecoderEnd();
954  VideoEnd();
955  AudioEnd();
956 
957  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("StopPlaying - end"));
958 }
959 
961 {
963 }
964 
966 {
967  m_decoderPauseLock.lock();
969  {
970  m_decoderPaused = true;
971  m_decoderThreadPause.wakeAll();
972  m_decoderPauseLock.unlock();
973  return m_decoderPaused;
974  }
975 
976  int tries = 0;
977  m_pauseDecoder = true;
978  while (m_decoderThread && !m_killDecoder && (tries++ < 100) &&
980  {
981  emit CheckCallbacks();
982  LOG(VB_GENERAL, LOG_WARNING, LOC + "Waited 100ms for decoder to pause");
983  }
984  m_pauseDecoder = false;
985  m_decoderPauseLock.unlock();
986  return m_decoderPaused;
987 }
988 
990 {
991  m_decoderPauseLock.lock();
992 
994  {
995  m_decoderPaused = false;
996  m_decoderThreadUnpause.wakeAll();
997  m_decoderPauseLock.unlock();
998  return;
999  }
1000 
1001  if (!IsInStillFrame())
1002  {
1003  int tries = 0;
1004  m_unpauseDecoder = true;
1005  while (m_decoderThread && !m_killDecoder && (tries++ < 100) &&
1007  {
1008  emit CheckCallbacks();
1009  LOG(VB_GENERAL, LOG_WARNING, LOC + "Waited 100ms for decoder to unpause");
1010  }
1011  m_unpauseDecoder = false;
1012  }
1013  m_decoderPauseLock.unlock();
1014 }
1015 
1016 void MythPlayer::DecoderStart(bool start_paused)
1017 {
1018  if (m_decoderThread)
1019  {
1020  if (m_decoderThread->isRunning())
1021  {
1022  LOG(VB_GENERAL, LOG_ERR, LOC + "Decoder thread already running");
1023  }
1024  delete m_decoderThread;
1025  }
1026 
1027  m_killDecoder = false;
1028  m_decoderPaused = start_paused;
1029  m_decoderThread = new MythDecoderThread(this, start_paused);
1030  if (m_decoderThread)
1032 }
1033 
1035 {
1036  PauseDecoder();
1037  SetPlaying(false);
1038  // Ensure any hardware frames are released (after pausing the decoder) to
1039  // allow the decoder to exit cleanly
1040  DiscardVideoFrames(true, true);
1041 
1042  m_killDecoder = true;
1043  int tries = 0;
1044  while (m_decoderThread && !m_decoderThread->wait(100ms) && (tries++ < 50))
1045  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1046  "Waited 100ms for decoder loop to stop");
1047 
1049  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to stop decoder loop.");
1050  else
1051  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Exited decoder loop.");
1052  SetDecoder(nullptr);
1053 }
1054 
1056 {
1058  {
1059  if (m_pauseDecoder)
1060  PauseDecoder();
1061  if (m_unpauseDecoder)
1062  UnpauseDecoder();
1063  }
1064 }
1065 
1068 {
1071 
1072  if (!m_decoderChangeLock.tryLock(50))
1073  return kEofStateNone;
1074 
1076  m_decoderChangeLock.unlock();
1077  return eof;
1078 }
1079 
1081 {
1083  {
1084  if (m_decoder)
1085  m_decoder->SetEofState(eof);
1086  return;
1087  }
1088 
1089  if (!m_decoderChangeLock.tryLock(50))
1090  return;
1091 
1092  if (m_decoder)
1093  m_decoder->SetEofState(eof);
1094  m_decoderChangeLock.unlock();
1095 }
1097 
1098 void MythPlayer::DecoderLoop(bool pause)
1099 {
1100  if (pause)
1101  PauseDecoder();
1102 
1103  while (!m_killDecoder && !IsErrored())
1104  {
1106 
1108  {
1109  std::this_thread::sleep_for(1ms);
1110  continue;
1111  }
1112 
1114  {
1115  if (!m_decoderChangeLock.tryLock(1))
1116  continue;
1117  if (m_decoder)
1118  {
1119  m_forcePositionMapSync = false;
1121  }
1122  m_decoderChangeLock.unlock();
1123  }
1124 
1125  if (m_decoderSeek >= 0)
1126  {
1127  if (!m_decoderChangeLock.tryLock(1))
1128  continue;
1129  if (m_decoder)
1130  {
1131  m_decoderSeekLock.lock();
1132  if (((uint64_t)m_decoderSeek < m_framesPlayed) && m_decoder)
1134  else if (m_decoder)
1136  m_decoderSeek = -1;
1137  m_decoderSeekLock.unlock();
1138  }
1139  m_decoderChangeLock.unlock();
1140  }
1141 
1142  bool obey_eof = (GetEof() != kEofStateNone) &&
1144  if (m_isDummy || ((m_decoderPaused || m_ffrewSkip == 0 || obey_eof) &&
1145  !m_decodeOneFrame))
1146  {
1147  std::this_thread::sleep_for(1ms);
1148  continue;
1149  }
1150 
1153 
1154  DecoderGetFrame(dt);
1155  }
1156 
1157  // Clear any wait conditions
1159  m_decoderSeek = -1;
1160 }
1161 
1162 static float ffrewScaleAdjust = 0.10F;
1163 static float ffrewSkipThresh = 0.60F;
1164 static float ffrewScaleLowest = 1.00F;
1165 static float ffrewScaleHighest = 2.50F;
1166 
1168 {
1169  if (!m_decoder)
1170  return;
1171 
1172  if (m_ffrewSkip > 0)
1173  {
1174  long long delta = m_decoder->GetFramesRead() - m_framesPlayed;
1175  long long real_skip = CalcMaxFFTime(m_ffrewSkip - m_ffrewAdjust + delta) - delta;
1176  long long target_frame = m_decoder->GetFramesRead() + real_skip;
1177  if (real_skip >= 0)
1178  m_decoder->DoFastForward(target_frame, true);
1179 
1180  long long seek_frame = m_decoder->GetFramesRead();
1181  m_ffrewAdjust = seek_frame - target_frame;
1182  float adjustRatio = float(m_ffrewAdjust) / m_ffrewSkip;
1183  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1184  QString("skip %1, adjust %2, ratio %3")
1185  .arg(m_ffrewSkip).arg(m_ffrewAdjust).arg(adjustRatio));
1186 
1187  // If the needed adjustment is too large either way, adjust
1188  // the scale factor up or down accordingly.
1189  if (adjustRatio > ffrewSkipThresh
1190  && m_ffrewScale < (ffrewScaleHighest - 0.01F))
1192  else if (adjustRatio < -ffrewSkipThresh
1193  && m_ffrewScale > (ffrewScaleLowest + 0.01F))
1195  }
1196  else if (CalcRWTime(-m_ffrewSkip) >= 0)
1197  {
1198  long long cur_frame = m_decoder->GetFramesPlayed();
1199  bool toBegin = -cur_frame > m_ffrewSkip + m_ffrewAdjust;
1200  long long real_skip = (toBegin) ? -cur_frame : m_ffrewSkip + m_ffrewAdjust;
1201  long long target_frame = cur_frame + real_skip;
1202  m_decoder->DoRewind(target_frame, true);
1203 
1204  long long seek_frame = m_decoder->GetFramesPlayed();
1205  m_ffrewAdjust = target_frame - seek_frame;
1206  float adjustRatio = float(m_ffrewAdjust) / m_ffrewSkip;
1207  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1208  QString("skip %1, adjust, %2, ratio %3")
1209  .arg(m_ffrewSkip).arg(m_ffrewAdjust).arg(adjustRatio));
1210 
1211  // If the needed adjustment is too large either way, adjust the
1212  // scale factor up or down accordingly.
1213  if (adjustRatio < -ffrewSkipThresh
1214  && m_ffrewScale < (ffrewScaleHighest - 0.01F))
1216  else if (adjustRatio > ffrewSkipThresh
1217  && m_ffrewScale > (ffrewScaleLowest + 0.01F))
1219  }
1220 
1221  LOG(VB_PLAYBACK, LOG_DEBUG, "Setting decode one");
1222  m_decodeOneFrame = true;
1223 }
1224 
1225 bool MythPlayer::DecoderGetFrame(DecodeType decodetype, bool unsafe)
1226 {
1227  bool ret = false;
1228  if (!m_videoOutput)
1229  return false;
1230 
1231  // Wait for frames to be available for decoding onto
1232  int tries = 0;
1233  while (!unsafe && (!m_videoOutput->EnoughFreeFrames() || m_audio.IsBufferAlmostFull()))
1234  {
1236  return false;
1237 
1238  if (++tries > 10)
1239  {
1240  if (++m_videobufRetries >= 2000)
1241  {
1242  LOG(VB_GENERAL, LOG_ERR, LOC +
1243  "Decoder timed out waiting for free video buffers.");
1244  // We've tried for 20 seconds now, give up so that we don't
1245  // get stuck permanently in this state
1246  SetErrored("Decoder timed out waiting for free video buffers.");
1247  }
1248  return false;
1249  }
1250  std::this_thread::sleep_for(1ms);
1251  }
1252  m_videobufRetries = 0;
1253 
1254  if (!m_decoderChangeLock.tryLock(5))
1255  return false;
1257  {
1258  m_decoderChangeLock.unlock();
1259  return false;
1260  }
1261 
1262  if (abs(m_ffrewSkip) > 1 && !m_decodeOneFrame && !m_renderOneFrame)
1263  DoFFRewSkip();
1264 
1265  if ((abs(m_ffrewSkip) > 0 || m_decodeOneFrame) && !m_renderOneFrame)
1266  ret = DoGetFrame(decodetype);
1267 
1268  m_decoderChangeLock.unlock();
1269  return ret;
1270 }
1271 
1287 {
1288  bool retry = false;
1289  bool ret = m_decoder->GetFrame(Type, retry);
1290  if (retry)
1291  {
1292  // Delay here so we don't spin too fast.
1293  m_decoderChangeLock.unlock();
1294  std::this_thread::sleep_for(1ms);
1295  m_decoderChangeLock.lock();
1296  return false;
1297  }
1298  return ret;
1299 }
1300 
1301 void MythPlayer::WrapTimecode(std::chrono::milliseconds &timecode, TCTypes tc_type)
1302 {
1303  timecode += m_tcWrap[tc_type];
1304 }
1305 
1306 bool MythPlayer::PrepareAudioSample(std::chrono::milliseconds &timecode)
1307 {
1308  WrapTimecode(timecode, TC_AUDIO);
1309  return false;
1310 }
1311 
1313 {
1314  uint64_t bookmark = 0;
1315 
1318  bookmark = 0;
1319  else
1320  {
1321  m_playerCtx->LockPlayingInfo(__FILE__, __LINE__);
1322  if (const ProgramInfo *pi = m_playerCtx->m_playingInfo)
1323  bookmark = pi->QueryStartMark();
1324  m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
1325  }
1326 
1327  return bookmark;
1328 }
1329 
1330 bool MythPlayer::UpdateFFRewSkip(float ffrewScale)
1331 {
1332  bool skip_changed = false;
1333 
1334  float temp_speed = (m_playSpeed == 0.0F) ?
1336  if (m_playSpeed >= 0.0F && m_playSpeed <= 3.0F)
1337  {
1338  skip_changed = (m_ffrewSkip != 1);
1339  if (m_decoder)
1341  m_frameInterval = microsecondsFromFloat((1000000.0 / m_videoFrameRate / static_cast<double>(temp_speed))
1342  / m_fpsMultiplier);
1343  m_ffrewSkip = static_cast<int>(m_playSpeed != 0.0F);
1344  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + "Clearing render one");
1345  }
1346  else
1347  {
1348  skip_changed = true;
1349  m_ffrewScale = ffrewScale;
1350  if (fabs(m_playSpeed) <= 10.0F)
1351  m_frameInterval = 200000us; // 5.00 fps
1352  else if (fabs(m_playSpeed) <= 20.0F)
1353  m_frameInterval = 166667us; // 6.00 fps
1354  else
1355  m_frameInterval = 150000us; // 6.67 fps
1357  float ffw_fps = fabs(static_cast<double>(m_playSpeed)) * m_videoFrameRate;
1358  float dis_fps = 1000000.0F / m_frameInterval.count();
1359  m_ffrewSkip = (int)ceil(ffw_fps / dis_fps);
1361  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1362  QString("new skip %1, interval %2, scale %3")
1363  .arg(m_ffrewSkip).arg(m_frameInterval.count()).arg(m_ffrewScale));
1364  m_ffrewAdjust = 0;
1365  }
1366 
1367  return skip_changed;
1368 }
1369 
1371 {
1372  float last_speed = m_playSpeed;
1376 
1377  bool skip_changed = UpdateFFRewSkip();
1378 
1379  if (skip_changed && m_videoOutput)
1380  {
1382  if (m_playSpeed != 0.0F && (last_speed != 0.0F || m_ffrewSkip != 1))
1384  }
1385 
1386  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Play speed: " +
1387  QString("rate: %1 speed: %2 skip: %3 => new interval %4")
1388  .arg(m_videoFrameRate).arg(static_cast<double>(m_playSpeed))
1389  .arg(m_ffrewSkip).arg(m_frameInterval.count()));
1390 
1391  if (m_videoOutput)
1392  m_videoOutput->SetVideoFrameRate(static_cast<float>(m_videoFrameRate));
1393 
1395  {
1398  }
1399 }
1400 
1401 bool MythPlayer::DoRewind(uint64_t frames, double inaccuracy)
1402 {
1404  return false;
1405 
1406  uint64_t number = frames + 1;
1407  uint64_t desiredFrame = (m_framesPlayed > number) ? m_framesPlayed - number : 0;
1408 
1409  m_limitKeyRepeat = false;
1410  if (desiredFrame < m_videoFrameRate)
1411  m_limitKeyRepeat = true;
1412 
1413  uint64_t seeksnap_wanted = UINT64_MAX;
1414  if (inaccuracy != kInaccuracyFull)
1415  seeksnap_wanted = frames * inaccuracy;
1416  WaitForSeek(desiredFrame, seeksnap_wanted);
1417  m_rewindTime = 0;
1418  ClearAfterSeek();
1419  return true;
1420 }
1421 
1427 long long MythPlayer::CalcRWTime(long long rw) const
1428 {
1429  bool hasliveprev = (m_liveTV && m_playerCtx->m_tvchain &&
1431 
1432  if (!hasliveprev || ((int64_t)m_framesPlayed >= rw))
1433  {
1434  return rw;
1435  }
1436 
1437  auto seconds = secondsFromFloat(((int64_t)m_framesPlayed - rw) / m_videoFrameRate);
1438  m_playerCtx->m_tvchain->JumpToNext(false, seconds);
1439 
1440  return -1;
1441 }
1442 
1447 long long MythPlayer::CalcMaxFFTime(long long ffframes, bool setjump) const
1448 {
1449  float maxtime = kSeekToEndOffset;
1450  bool islivetvcur = (m_liveTV && m_playerCtx->m_tvchain &&
1452 
1453  long long ret = ffframes;
1454  float ff = ComputeSecs(ffframes, true);
1455  float secsPlayed = ComputeSecs(m_framesPlayed, true);
1456  float secsWritten = ComputeSecs(m_totalFrames, true);
1457 
1458  m_limitKeyRepeat = false;
1459 
1460  if (m_liveTV && !islivetvcur && m_playerCtx->m_tvchain)
1461  {
1462  // recording has completed, totalFrames will always be up to date
1463  if ((ffframes + m_framesPlayed > m_totalFrames) && setjump)
1464  {
1465  ret = -1;
1466  // Number of frames to be skipped is from the end of the current segment
1467  int64_t frames = (int64_t)m_totalFrames - (int64_t)m_framesPlayed - ffframes;
1468  auto seconds = secondsFromFloat(frames / m_videoFrameRate);
1469  m_playerCtx->m_tvchain->JumpToNext(true, seconds);
1470  }
1471  }
1472  else if (islivetvcur || IsWatchingInprogress())
1473  {
1474  if ((ff + secsPlayed) > secsWritten)
1475  {
1476  // If we attempt to seek past the last known duration,
1477  // check for up to date data
1478  long long framesWritten = m_playerCtx->m_recorder->GetFramesWritten();
1479 
1480  secsWritten = ComputeSecs(framesWritten, true);
1481  }
1482 
1483  float behind = secsWritten - secsPlayed;
1484 
1485  if (behind < maxtime) // if we're close, do nothing
1486  ret = 0;
1487  else if (behind - ff <= maxtime)
1488  {
1489  auto msec = millisecondsFromFloat(1000 * (secsWritten - maxtime));
1490  ret = TranslatePositionMsToFrame(msec, true) - m_framesPlayed;
1491  }
1492 
1493  if (behind < maxtime * 3)
1494  m_limitKeyRepeat = true;
1495  }
1496  else if (IsPaused())
1497  {
1498  uint64_t lastFrame =
1500  if (m_framesPlayed + ffframes >= lastFrame)
1501  ret = lastFrame - 1 - m_framesPlayed;
1502  }
1503  else
1504  {
1505  float secsMax = secsWritten - (2.F * maxtime);
1506  if (secsMax <= 0.F)
1507  ret = 0;
1508  else if (secsMax < secsPlayed + ff)
1509  {
1510  auto msec = millisecondsFromFloat(1000 * secsMax);
1511  ret = TranslatePositionMsToFrame(msec, true) - m_framesPlayed;
1512  }
1513  }
1514 
1515  return ret;
1516 }
1517 
1525 {
1526  if (!m_videoOutput || !m_decoder)
1527  return false;
1528 
1529  return m_playerCtx->m_buffer->IsNearEnd(
1531 }
1532 
1536 {
1537  if (!m_playerCtx)
1538  return false;
1539 
1540  m_playerCtx->LockPlayingInfo(__FILE__, __LINE__);
1542  !m_decoder)
1543  {
1544  m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
1545  return false;
1546  }
1547  m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
1548 
1549  auto margin = (long long)(m_videoFrameRate * 2);
1550  margin = (long long) (margin * m_audio.GetStretchFactor());
1551  bool watchingTV = IsWatchingInprogress();
1552 
1553  uint64_t framesRead = m_framesPlayed;
1554  uint64_t framesLeft = 0;
1555 
1557  {
1558  if (framesRead >= m_deleteMap.GetLastFrame())
1559  return true;
1560  uint64_t frameCount = GetCurrentFrameCount();
1561  framesLeft = (frameCount > framesRead) ? frameCount - framesRead : 0;
1562  return (framesLeft < (uint64_t)margin);
1563  }
1564 
1565  if (!m_liveTV && !watchingTV)
1566  return false;
1567 
1569  return false;
1570 
1571  if (m_playerCtx->m_recorder)
1572  {
1573  framesLeft =
1575 
1576  // if it looks like we are near end, get an updated GetFramesWritten()
1577  if (framesLeft < (uint64_t)margin)
1578  framesLeft = m_playerCtx->m_recorder->GetFramesWritten() - framesRead;
1579  }
1580 
1581  return (framesLeft < (uint64_t)margin);
1582 }
1583 
1584 bool MythPlayer::DoFastForward(uint64_t frames, double inaccuracy)
1585 {
1587  return false;
1588 
1589  uint64_t number = (frames ? frames - 1 : 0);
1590  uint64_t desiredFrame = m_framesPlayed + number;
1591 
1592  if (!m_deleteMap.IsEditing() && IsInDelete(desiredFrame))
1593  {
1594  uint64_t endcheck = m_deleteMap.GetLastFrame();
1595  desiredFrame = std::min(desiredFrame, endcheck);
1596  }
1597 
1598  uint64_t seeksnap_wanted = UINT64_MAX;
1599  if (inaccuracy != kInaccuracyFull)
1600  seeksnap_wanted = frames * inaccuracy;
1601  WaitForSeek(desiredFrame, seeksnap_wanted);
1602  m_ffTime = 0;
1603  ClearAfterSeek(false);
1604  return true;
1605 }
1606 
1607 void MythPlayer::DoJumpToFrame(uint64_t frame, double inaccuracy)
1608 {
1609  if (frame > m_framesPlayed)
1610  DoFastForward(frame - m_framesPlayed, inaccuracy);
1611  else
1612  DoRewind(m_framesPlayed - frame, inaccuracy);
1613 }
1614 
1615 void MythPlayer::WaitForSeek(uint64_t frame, uint64_t seeksnap_wanted)
1616 {
1617  if (!m_decoder)
1618  return;
1619 
1621  m_decoder->SetSeekSnap(seeksnap_wanted);
1622 
1623  bool islivetvcur = (m_liveTV && m_playerCtx->m_tvchain &&
1625 
1626  uint64_t max = GetCurrentFrameCount();
1627  if (islivetvcur || IsWatchingInprogress())
1628  {
1629  max = (uint64_t)m_playerCtx->m_recorder->GetFramesWritten();
1630  }
1631  if (frame >= max)
1632  frame = max - 1;
1633 
1634  m_decoderSeekLock.lock();
1635  m_decoderSeek = frame;
1636  m_decoderSeekLock.unlock();
1637 
1638  int count = 0;
1639  bool needclear = false;
1640  while (m_decoderSeek >= 0)
1641  {
1642  // Waiting blocks the main UI thread but the decoder may
1643  // have initiated a callback into the UI thread to create
1644  // certain resources. Ensure the callback is processed.
1645  // Ideally MythPlayer should be fully event driven and these
1646  // calls wouldn't be necessary.
1647  emit CheckCallbacks();
1648 
1649  // Wait a little
1650  std::this_thread::sleep_for(50ms);
1651 
1652  // provide some on screen feedback if seeking is slow
1653  count++;
1654  if (!(count % 3) && !m_hasFullPositionMap)
1655  {
1656  emit SeekingSlow(count);
1657  needclear = true;
1658  }
1659  }
1660  if (needclear)
1661  emit SeekingComplete();
1662 
1663  emit SeekingDone();
1664 }
1665 
1678 void MythPlayer::ClearAfterSeek(bool clearvideobuffers)
1679 {
1680  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("ClearAfterSeek(%1)")
1681  .arg(clearvideobuffers));
1682 
1683  if (clearvideobuffers && m_videoOutput)
1685 
1686  std::chrono::milliseconds savedTC = m_tcWrap[TC_AUDIO];
1687 
1688  m_tcWrap.fill(0ms);
1689  m_tcWrap[TC_AUDIO] = savedTC;
1690  m_audio.Reset();
1691 
1692  emit RequestResetCaptions();
1696  m_needNewPauseFrame = true;
1697 
1698  m_avSync.InitAVSync();
1699 }
1700 
1701 bool MythPlayer::IsInDelete(uint64_t frame)
1702 {
1703  return m_deleteMap.IsInDelete(frame);
1704 }
1705 
1707 {
1709 }
1710 
1711 QString MythPlayer::GetEncodingType(void) const
1712 {
1713  if (m_decoder)
1715  return {};
1716 }
1717 
1718 QString MythPlayer::GetXDS(const QString &key) const
1719 {
1720  if (!m_decoder)
1721  return {};
1722  return m_decoder->GetXDS(key);
1723 }
1724 
1726 {
1728  m_forcePositionMapSync = true;
1729 }
1730 
1731 // Returns the total frame count, as totalFrames for a completed
1732 // recording, or the most recent frame count from the recorder for
1733 // live TV or an in-progress recording.
1735 {
1736  uint64_t result = m_totalFrames;
1737  if (IsWatchingInprogress())
1739  return result;
1740 }
1741 
1742 // Finds the frame number associated with the given time offset. A
1743 // positive offset or +0.0F indicate offset from the beginning. A
1744 // negative offset or -0.0F indicate offset from the end. Limit the
1745 // result to within bounds of the video.
1746 uint64_t MythPlayer::FindFrame(float offset, bool use_cutlist) const
1747 {
1748  bool islivetvcur = (m_liveTV && m_playerCtx->m_tvchain &&
1750  std::chrono::milliseconds length_ms = TranslatePositionFrameToMs(m_totalFrames, use_cutlist);
1751  std::chrono::milliseconds position_ms = 0ms;
1752  auto offset_ms = std::chrono::milliseconds(llroundf(fabsf(offset) * 1000));
1753 
1754  if (signbit(offset))
1755  {
1756  // Always get an updated totalFrame value for in progress recordings
1757  if (islivetvcur || IsWatchingInprogress())
1758  {
1759  uint64_t framesWritten = m_playerCtx->m_recorder->GetFramesWritten();
1760 
1761  if (m_totalFrames < framesWritten)
1762  {
1763  // Known duration is less than what the backend reported, use new value
1764  length_ms =
1765  TranslatePositionFrameToMs(framesWritten, use_cutlist);
1766  }
1767  }
1768  position_ms = (offset_ms > length_ms) ? 0ms : length_ms - offset_ms;
1769  }
1770  else
1771  {
1772  position_ms = offset_ms;
1773  if (offset_ms > length_ms)
1774  {
1775  // Make sure we have an updated totalFrames
1776  if ((islivetvcur || IsWatchingInprogress()) &&
1777  (length_ms < offset_ms))
1778  {
1779  long long framesWritten =
1781 
1782  length_ms =
1783  TranslatePositionFrameToMs(framesWritten, use_cutlist);
1784  }
1785  position_ms = std::min(position_ms, length_ms);
1786  }
1787  }
1788  return TranslatePositionMsToFrame(position_ms, use_cutlist);
1789 }
1790 
1791 // If position == -1, it signifies that we are computing the current
1792 // duration of an in-progress recording. In this case, we fetch the
1793 // current frame rate and frame count from the recorder.
1794 std::chrono::milliseconds MythPlayer::TranslatePositionFrameToMs(uint64_t position,
1795  bool use_cutlist) const
1796 {
1797  float frameRate = GetFrameRate();
1798  if (position == UINT64_MAX &&
1800  {
1801  float recorderFrameRate = m_playerCtx->m_recorder->GetFrameRate();
1802  if (recorderFrameRate > 0)
1803  frameRate = recorderFrameRate;
1804  position = m_playerCtx->m_recorder->GetFramesWritten();
1805  }
1806  return m_deleteMap.TranslatePositionFrameToMs(position, frameRate,
1807  use_cutlist);
1808 }
1809 
1811 {
1812  if (m_decoder)
1813  return m_decoder->GetNumChapters();
1814  return 0;
1815 }
1816 
1818 {
1819  if (m_decoder)
1821  return 0;
1822 }
1823 
1824 void MythPlayer::GetChapterTimes(QList<std::chrono::seconds> &times)
1825 {
1826  if (m_decoder)
1827  m_decoder->GetChapterTimes(times);
1828 }
1829 
1830 bool MythPlayer::DoJumpChapter(int chapter)
1831 {
1832  int64_t desiredFrame = -1;
1833  int total = GetNumChapters();
1834  int current = GetCurrentChapter();
1835 
1836  if (chapter < 0 || chapter > total)
1837  {
1838 
1839  if (chapter < 0)
1840  {
1841  chapter = current -1;
1842  chapter = std::max(chapter, 0);
1843  }
1844  else if (chapter > total)
1845  {
1846  chapter = current + 1;
1847  chapter = std::min(chapter, total);
1848  }
1849  }
1850 
1851  desiredFrame = GetChapter(chapter);
1852  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1853  QString("DoJumpChapter: current %1 want %2 (frame %3)")
1854  .arg(current).arg(chapter).arg(desiredFrame));
1855 
1856  if (desiredFrame < 0)
1857  {
1858  LOG(VB_PLAYBACK, LOG_ERR, LOC + QString("DoJumpChapter failed."));
1859  m_jumpChapter = 0;
1860  return false;
1861  }
1862 
1863  DoJumpToFrame(desiredFrame, kInaccuracyNone);
1864  m_jumpChapter = 0;
1865  return true;
1866 }
1867 
1868 int64_t MythPlayer::GetChapter(int chapter)
1869 {
1870  if (m_decoder)
1871  return m_decoder->GetChapter(chapter);
1872  return 0;
1873 }
1874 
1879 {
1880  m_totalDecoderPause = true;
1881  PauseDecoder();
1882 
1883  {
1884  while (!m_decoderChangeLock.tryLock(10))
1885  LOG(VB_GENERAL, LOG_INFO, LOC + "Waited 10ms for decoder lock");
1886  delete m_decoder;
1887  m_decoder = dec;
1888  if (m_decoder)
1890  m_decoderChangeLock.unlock();
1891  }
1892  // reset passthrough override
1893  m_disablePassthrough = false;
1895  m_totalDecoderPause = false;
1896 }
1897 
1898 bool MythPlayer::PosMapFromEnc(uint64_t start,
1899  frm_pos_map_t &posMap,
1900  frm_pos_map_t &durMap)
1901 {
1902  // Reads only new positionmap entries from encoder
1903  if (!(m_liveTV || (m_playerCtx->m_recorder &&
1905  return false;
1906 
1907  // if livetv, and we're not the last entry, don't get it from the encoder
1908  if (HasTVChainNext())
1909  return false;
1910 
1911  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1912  QString("Filling position map from %1 to %2") .arg(start).arg("end"));
1913 
1914  m_playerCtx->m_recorder->FillPositionMap(start, -1, posMap);
1915  m_playerCtx->m_recorder->FillDurationMap(start, -1, durMap);
1916 
1917  return true;
1918 }
1919 
1920 void MythPlayer::SetErrored(const QString &reason)
1921 {
1922  QMutexLocker locker(&m_errorLock);
1923 
1924  if (m_videoOutput)
1926 
1927  if (m_errorMsg.isEmpty())
1928  {
1929  m_errorMsg = reason;
1930  }
1931  else
1932  {
1933  LOG(VB_GENERAL, LOG_ERR, LOC + QString("%1").arg(reason));
1934  }
1935 }
1936 
1938 {
1939  QMutexLocker locker(&m_errorLock);
1940 
1941  m_errorMsg = QString();
1942 }
1943 
1944 bool MythPlayer::IsErrored(void) const
1945 {
1946  QMutexLocker locker(&m_errorLock);
1947  return !m_errorMsg.isEmpty();
1948 }
1949 
1950 QString MythPlayer::GetError(void) const
1951 {
1952  QMutexLocker locker(&m_errorLock);
1953  return m_errorMsg;
1954 }
1955 
1957 {
1958  if (!m_decoder)
1959  return;
1960 
1962 }
1963 
1965 {
1966  if (!m_decoder)
1967  return;
1968 
1970 }
1971 
1973 {
1974  if (!m_decoder)
1975  return;
1976 
1978 }
1979 
1981 {
1982  if (m_decoder && m_audio.HasAudioOut())
1983  {
1984  float stretch = m_audio.GetStretchFactor();
1985  m_disablePassthrough |= (stretch < 0.99F) || (stretch > 1.01F);
1986  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1987  QString("Stretch Factor %1, %2 passthru ")
1988  .arg(m_audio.GetStretchFactor())
1989  .arg((m_disablePassthrough) ? "disable" : "allow"));
1991  }
1992 }
1993 
1995 {
1996  if (m_decoder && m_audio.HasAudioOut())
1998 }
1999 
2001 {
2002  if (m_decoder && m_audio.HasAudioOut())
2004 }
2005 
2006 static unsigned dbg_ident(const MythPlayer *player)
2007 {
2008  static QMutex s_dbgLock;
2009  static unsigned s_dbgNextIdent = 0;
2010  using DbgMapType = QHash<const MythPlayer*, unsigned>;
2011  static DbgMapType s_dbgIdent;
2012 
2013  QMutexLocker locker(&s_dbgLock);
2014  DbgMapType::iterator it = s_dbgIdent.find(player);
2015  if (it != s_dbgIdent.end())
2016  return *it;
2017  return s_dbgIdent[player] = s_dbgNextIdent++;
2018 }
MythPlayer::IsNearEnd
bool IsNearEnd(void)
Returns true iff near end of recording.
Definition: mythplayer.cpp:1535
DeleteMap::SetPlayerContext
void SetPlayerContext(PlayerContext *ctx)
Definition: deletemap.h:32
DecoderBase::GetCurrentChapter
virtual int GetCurrentChapter(long long)
Definition: decoderbase.h:156
MythPlayer::m_buffering
bool m_buffering
Definition: mythplayer.h:447
DecoderBase::DoFastForward
virtual bool DoFastForward(long long desiredFrame, bool discardFrames=true)
Skips ahead or rewinds to desiredFrame.
Definition: decoderbase.cpp:709
TC_VIDEO
@ TC_VIDEO
Definition: mythplayer.h:56
secondsFromFloat
std::enable_if_t< std::is_floating_point_v< T >, std::chrono::seconds > secondsFromFloat(T value)
Helper function for convert a floating point number to a duration.
Definition: mythchrono.h:80
MythTimer::elapsed
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
Definition: mythtimer.cpp:91
build_compdb.dest
dest
Definition: build_compdb.py:9
dbg_ident
static unsigned dbg_ident(const MythPlayer *)
Definition: mythplayer.cpp:2006
PlayerContext::GetState
TVState GetState(void) const
Definition: playercontext.cpp:331
MythPlayer::m_enableForcedSubtitles
bool m_enableForcedSubtitles
Definition: mythplayer.h:462
LiveTVChain::GetCurPos
int GetCurPos(void) const
Definition: livetvchain.h:55
MythPlayer::m_errorLock
QMutex m_errorLock
Definition: mythplayer.h:399
MThread::start
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
Definition: mthread.cpp:283
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:102
kDecoderProbeBufferSize
const int kDecoderProbeBufferSize
Definition: decoderbase.h:23
MythPlayer::m_videoPaused
bool m_videoPaused
Definition: mythplayer.h:392
MythPlayer::m_decoderChangeLock
QRecursiveMutex m_decoderChangeLock
Definition: mythplayer.h:362
MythVideoOutput::InputChanged
virtual bool InputChanged(QSize VideoDim, QSize VideoDispDim, float VideoAspect, MythCodecID CodecID, bool &AspectChanged, int ReferenceFrames, bool ForceChange)
Tells video output to discard decoded frames and wait for new ones.
Definition: mythvideoout.cpp:187
DecoderBase::GetFramesPlayed
long long GetFramesPlayed(void) const
Definition: decoderbase.h:196
MythPlayer::SetFileLength
void SetFileLength(std::chrono::seconds total, int frames)
Definition: mythplayer.cpp:387
PlayerContext::UnlockPlayingInfo
void UnlockPlayingInfo(const char *file, int line) const
Definition: playercontext.cpp:249
MythPlayer::m_watchingRecording
bool m_watchingRecording
Definition: mythplayer.h:403
MythVideoOutputNull::Create
static MythVideoOutputNull * Create(QSize VideoDim, QSize VideoDispDim, float VideoAspect, MythCodecID CodecID)
Definition: mythvideooutnull.cpp:52
LiveTVChain::JumpToNext
void JumpToNext(bool up, std::chrono::seconds pos)
jump to the next (up == true) or previous (up == false) liveTV program If pos > 0: indicate the absol...
Definition: livetvchain.cpp:619
RemoteEncoder::GetRecorderNumber
int GetRecorderNumber(void) const
Definition: remoteencoder.cpp:62
MythPlayer::SetEof
void SetEof(EofState eof)
Definition: mythplayer.cpp:1080
MythPlayer::m_inJumpToProgramPause
bool m_inJumpToProgramPause
Definition: mythplayer.h:384
kEofStateImmediate
@ kEofStateImmediate
Definition: decoderbase.h:72
AudioPlayer::Reset
void Reset(void)
Definition: audioplayer.cpp:84
MythPlayer::m_bufferPaused
bool m_bufferPaused
Definition: mythplayer.h:391
MythPlayer::m_commBreakMap
CommBreakMap m_commBreakMap
Definition: mythplayer.h:474
DecoderBase::GetEof
EofState GetEof(void)
Definition: decoderbase.h:136
MythPlayer::ChangeSpeed
virtual void ChangeSpeed(void)
Definition: mythplayer.cpp:1370
DecodeType
DecodeType
Definition: decoderbase.h:48
MythPlayer::m_decoderThread
MythDecoderThread * m_decoderThread
Definition: mythplayer.h:366
MythPlayer::m_cc608
CC608Reader m_cc608
Definition: mythplayer.h:467
DeleteMap::TrackerReset
void TrackerReset(uint64_t frame)
Resets the internal state tracker.
Definition: deletemap.cpp:811
MythPlayer::m_bufferingCounter
int m_bufferingCounter
Definition: mythplayer.h:502
PlayerContext::SetPlayingInfo
void SetPlayingInfo(const ProgramInfo *info)
assign programinfo to the context
Definition: playercontext.cpp:513
MythTimer
A QElapsedTimer based timer to replace use of QTime as a timer.
Definition: mythtimer.h:13
MythPlayer::kNightModeContrastAdjustment
static const int kNightModeContrastAdjustment
Definition: mythplayer.h:237
LiveTVChain::HasNext
bool HasNext(void) const
Definition: livetvchain.cpp:406
MythPlayer::CheckCallbacks
void CheckCallbacks()
MythPlayer::m_ffrewAdjust
int m_ffrewAdjust
offset after last skip
Definition: mythplayer.h:488
MythPlayer::m_decoderThreadUnpause
QWaitCondition m_decoderThreadUnpause
Definition: mythplayer.h:375
MythPlayer::UnpauseBuffer
void UnpauseBuffer(void)
Definition: mythplayer.cpp:147
MythPlayer::SeekingSlow
void SeekingSlow(int Count)
MythPlayer::m_avSync
MythPlayerAVSync m_avSync
Definition: mythplayer.h:429
MythPlayer::DecoderPauseCheck
virtual void DecoderPauseCheck(void)
Definition: mythplayer.cpp:1055
MythPlayer::m_playSpeed
float m_playSpeed
Definition: mythplayer.h:483
MythVideoOutput::FreeVideoFrames
int FreeVideoFrames()
Returns number of frames available for decoding onto.
Definition: mythvideoout.cpp:284
MythPlayer::m_frameInterval
std::chrono::microseconds m_frameInterval
always adjusted for play_speed
Definition: mythplayer.h:485
kMusicChoice
@ kMusicChoice
Definition: mythplayer.h:76
RemoteEncoder::FillDurationMap
void FillDurationMap(int64_t start, int64_t end, frm_pos_map_t &durationMap)
Definition: remoteencoder.cpp:294
MythVideoOutput::GetError
VideoErrorState GetError() const
Definition: mythvideoout.cpp:260
MThread::wait
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
Definition: mthread.cpp:300
ffrewSkipThresh
static float ffrewSkipThresh
Definition: mythplayer.cpp:1163
MythPlayer::CheckTVChain
void CheckTVChain()
Definition: mythplayer.cpp:930
MythPlayer::m_totalDecoderPause
bool m_totalDecoderPause
Definition: mythplayer.h:382
MythPlayer::OpenFile
virtual int OpenFile(int Retries=4)
Definition: mythplayer.cpp:420
DeleteMap::TranslatePositionFrameToMs
std::chrono::milliseconds TranslatePositionFrameToMs(uint64_t position, float fallback_framerate, bool use_cutlist) const
Definition: deletemap.cpp:902
MythPlayer::m_nextNormalSpeed
bool m_nextNormalSpeed
Definition: mythplayer.h:491
CardUtil::SetStartChannel
static bool SetStartChannel(uint inputid, const QString &channum)
Definition: cardutil.cpp:1678
kScan_Progressive
@ kScan_Progressive
Definition: videoouttypes.h:100
MythPlayer::PrebufferEnoughFrames
virtual bool PrebufferEnoughFrames(int min_buffers=0)
Definition: mythplayer.cpp:723
MythPlayer::m_totalDuration
std::chrono::seconds m_totalDuration
Definition: mythplayer.h:426
CommBreakMap::SetTracker
void SetTracker(uint64_t framesPlayed)
Definition: commbreakmap.cpp:67
MythPlayer::PrepareAudioSample
virtual bool PrepareAudioSample(std::chrono::milliseconds &timecode)
Definition: mythplayer.cpp:1306
DetectLetterbox.h
MythPlayer::m_videobufRetries
int m_videobufRetries
How often we have tried to wait for a video output buffer and failed.
Definition: mythplayer.h:422
MythPlayer::IsPaused
bool IsPaused(void) const
Definition: mythplayer.h:152
MythPlayer::m_decoderSeekLock
QMutex m_decoderSeekLock
Definition: mythplayer.h:377
ProgramInfo::GetChanNum
QString GetChanNum(void) const
This is the channel "number", in the form 1, 1_2, 1-2, 1#1, etc.
Definition: programinfo.h:377
MythPlayer::m_forcePositionMapSync
bool m_forcePositionMapSync
Definition: mythplayer.h:475
chronomult
static constexpr T chronomult(T duration, double f)
Multiply a duration by a float, returning a duration.
Definition: mythchrono.h:199
MythPlayer::HasReachedEof
virtual bool HasReachedEof(void) const
Definition: mythplayer.cpp:659
EofState
EofState
Definition: decoderbase.h:68
MythPlayer::AudioEnd
virtual void AudioEnd(void)
Definition: mythplayer.cpp:960
MythCoreContext::IsDatabaseIgnored
bool IsDatabaseIgnored(void) const
/brief Returns true if database is being ignored.
Definition: mythcorecontext.cpp:880
ffrewScaleAdjust
static float ffrewScaleAdjust
Definition: mythplayer.cpp:1162
microsecondsFromFloat
std::enable_if_t< std::is_floating_point_v< T >, std::chrono::microseconds > microsecondsFromFloat(T value)
Helper function for convert a floating point number to a duration.
Definition: mythchrono.h:102
ProgramInfo::GetChannelSchedulingID
QString GetChannelSchedulingID(void) const
This is the unique programming identifier of a channel.
Definition: programinfo.h:384
AudioPlayer::SetStretchFactor
void SetStretchFactor(float factor)
Definition: audioplayer.cpp:370
MythPlayer::m_ffrewSkip
int m_ffrewSkip
Definition: mythplayer.h:487
frm_dir_map_t
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:117
MythPlayer::syncWithAudioStretch
void syncWithAudioStretch()
Definition: mythplayer.cpp:1980
MythPlayer::m_errorMsg
QString m_errorMsg
Reason why NVP exited with a error.
Definition: mythplayer.h:400
MythPlayer::m_bufferPauseLock
QMutex m_bufferPauseLock
Definition: mythplayer.h:378
AudioPlayer::CheckFormat
void CheckFormat(void)
Definition: audioplayer.cpp:173
DecoderBase::IsErrored
bool IsErrored() const
Definition: decoderbase.h:217
AudioPlayer::IsBufferAlmostFull
bool IsBufferAlmostFull(void)
Definition: audioplayer.cpp:494
MythPlayer::SaveTotalFrames
void SaveTotalFrames(void)
Definition: mythplayer.cpp:1972
MythPlayer::IsErrored
bool IsErrored(void) const
Definition: mythplayer.cpp:1944
MythPlayer::m_normalSpeed
bool m_normalSpeed
Definition: mythplayer.h:492
RemoteEncoder::GetFramesWritten
long long GetFramesWritten(void)
Returns number of frames written to disk by TVRec's RecorderBase instance.
Definition: remoteencoder.cpp:194
CC608Reader::SetTTPageNum
void SetTTPageNum(int page)
Definition: cc608reader.h:84
MythPlayer::GetFrameRate
float GetFrameRate(void) const
Definition: mythplayer.h:134
MythTimer::start
void start(void)
starts measuring elapsed time.
Definition: mythtimer.cpp:47
MythMediaBuffer::Unpause
void Unpause(void)
Unpauses the read-ahead thread. Calls StartReads(void).
Definition: mythmediabuffer.cpp:704
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:39
MythMediaBuffer::GetSafeFilename
QString GetSafeFilename(void)
Definition: mythmediabuffer.cpp:1757
MythPlayer::GetCurrentFrameCount
uint64_t GetCurrentFrameCount(void) const
Definition: mythplayer.cpp:1734
MythPlayer::IsPlaying
bool IsPlaying(std::chrono::milliseconds wait_in_msec=0ms, bool wait_for=true) const
Definition: mythplayer.cpp:254
AudioPlayer::HasAudioOut
bool HasAudioOut(void) const
Definition: audioplayer.h:52
VBIMode::Parse
static uint Parse(const QString &vbiformat)
Definition: tv.h:17
DeleteMap::IsEmpty
bool IsEmpty(void) const
Definition: deletemap.cpp:259
is_current_thread
bool is_current_thread(MThread *thread)
Use this to determine if you are in the named thread.
Definition: mthread.cpp:40
MythPlayerAVSync::GetAVSyncAudioPause
AVSyncAudioPausedType GetAVSyncAudioPause() const
Definition: mythplayeravsync.h:36
mythplayer.h
MythPlayer::m_pauseLock
QMutex m_pauseLock
Definition: mythplayer.h:380
MythVideoOutput::SetFramesPlayed
virtual void SetFramesPlayed(long long FramesPlayed)
Definition: mythvideoout.cpp:245
MythPlayer::CalcRWTime
long long CalcRWTime(long long rw) const
CalcRWTime(rw): rewind rw frames back.
Definition: mythplayer.cpp:1427
PlayerFlags
PlayerFlags
Definition: mythplayer.h:64
MythPlayer::GetEof
EofState GetEof(void) const
Definition: mythplayer.cpp:1067
MythPlayer::Pause
bool Pause(void)
Definition: mythplayer.cpp:156
MythPlayer
Definition: mythplayer.h:83
RemoteEncoder::IsValidRecorder
bool IsValidRecorder(void) const
Definition: remoteencoder.cpp:57
TCTypes
TCTypes
Timecode types.
Definition: mythplayer.h:54
ffrewScaleHighest
static float ffrewScaleHighest
Definition: mythplayer.cpp:1165
MythPlayer::GetBookmark
virtual uint64_t GetBookmark(void)
Definition: mythplayer.cpp:1312
DecoderBase::GetVideoCodecID
virtual MythCodecID GetVideoCodecID(void) const =0
MythPlayer::m_nextPlaySpeed
float m_nextPlaySpeed
Definition: mythplayer.h:482
MythPlayer::m_bufferingLastMsg
QTime m_bufferingLastMsg
Definition: mythplayer.h:449
MythPlayer::SeekingComplete
void SeekingComplete()
CommBreakMap::SetMap
void SetMap(const frm_dir_map_t &newMap, uint64_t framesPlayed)
Definition: commbreakmap.cpp:131
hardwareprofile.scan.scan
def scan(profile, smoonURL, gate)
Definition: scan.py:55
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:15
MythPlayer::m_videoPauseLock
QMutex m_videoPauseLock
Definition: mythplayer.h:379
MythPlayer::SetErrored
void SetErrored(const QString &reason)
Definition: mythplayer.cpp:1920
MythPlayer::GetEncodingType
QString GetEncodingType(void) const
Definition: mythplayer.cpp:1711
MythPlayer::DiscardVideoFrames
void DiscardVideoFrames(bool KeyFrame, bool Flushed)
Places frames in the available frames queue.
Definition: mythplayer.cpp:648
MythPlayer::m_needNewPauseFrame
bool m_needNewPauseFrame
Definition: mythplayer.h:390
MythMediaBuffer::GetStopReads
bool GetStopReads(void) const
Definition: mythmediabuffer.cpp:1788
DeleteMap::TrackerWantsToJump
bool TrackerWantsToJump(uint64_t frame, uint64_t &to) const
Returns true if the given frame has passed the last cut point start and provides the frame number of ...
Definition: deletemap.cpp:847
MythPlayer::SetDecoder
void SetDecoder(DecoderBase *dec)
Sets the stream decoder, deleting any existing recorder.
Definition: mythplayer.cpp:1878
tmp
static guint32 * tmp
Definition: goom_core.cpp:26
MythPlayer::kInaccuracyNone
static const double kInaccuracyNone
Definition: mythplayer.h:238
MythVideoOutput::SetPrebuffering
void SetPrebuffering(bool Normal)
Sets whether to use a normal number of buffers or fewer buffers.
Definition: mythvideoout.cpp:266
MythPlayer::ResetErrored
void ResetErrored(void)
Definition: mythplayer.cpp:1937
DecoderBase::GetChapter
virtual long long GetChapter(int)
Definition: decoderbase.h:158
MythPlayer::HasTVChainNext
bool HasTVChainNext(void) const
Definition: mythplayer.cpp:1706
AudioPlayer::IsPaused
bool IsPaused(void)
Definition: audioplayer.cpp:189
MythPlayer::~MythPlayer
~MythPlayer() override
Definition: mythplayer.cpp:110
mythdecoderthread.h
MythPlayer::m_audio
AudioPlayer m_audio
Definition: mythplayer.h:471
DecoderBase::GetChapterTimes
virtual void GetChapterTimes(QList< std::chrono::seconds > &)
Definition: decoderbase.h:157
MythPlayer::PauseChanged
void PauseChanged(bool Paused)
DecoderBase::SaveTotalDuration
void SaveTotalDuration(void)
Definition: decoderbase.cpp:1282
MythMediaBuffer::GetFilename
QString GetFilename(void) const
Definition: mythmediabuffer.cpp:1749
MythPlayer::UnpauseVideo
void UnpauseVideo(void)
Definition: mythplayer.cpp:227
MythPlayer::m_decoder
DecoderBase * m_decoder
Definition: mythplayer.h:361
MythPlayer::ComputeSecs
float ComputeSecs(uint64_t position, bool use_cutlist) const
Definition: mythplayer.h:271
kEofStateNone
@ kEofStateNone
Definition: decoderbase.h:70
RemoteEncoder::GetCachedFramesWritten
long long GetCachedFramesWritten(void) const
Return value last returned by GetFramesWritten().
Definition: remoteencoder.h:40
MythPlayer::m_framesPlayed
uint64_t m_framesPlayed
Definition: mythplayer.h:423
MythPlayer::m_rewindTime
long long m_rewindTime
Definition: mythplayer.h:427
DecoderBase::ForceSetupAudioStream
virtual void ForceSetupAudioStream(void)
Definition: decoderbase.h:148
MythPlayer::kNightModeBrightenssAdjustment
static const int kNightModeBrightenssAdjustment
Definition: mythplayer.h:236
programinfo.h
mythvideooutnull.h
MythPlayer::GetChapter
virtual int64_t GetChapter(int chapter)
Definition: mythplayer.cpp:1868
mythlogging.h
MythVideoOutput::ValidVideoFrames
virtual int ValidVideoFrames() const
Returns number of frames that are fully decoded.
Definition: mythvideoout.cpp:278
CommBreakMap::ResetLastSkip
void ResetLastSkip(void)
Definition: commbreakmap.cpp:27
MythPlayer::m_ffTime
long long m_ffTime
If m_ffTime>0, number of frames to seek forward.
Definition: mythplayer.h:418
MythMediaBuffer::WaitForPause
void WaitForPause(void)
Waits for Pause(void) to take effect.
Definition: mythmediabuffer.cpp:718
AudioPlayer::DeleteOutput
void DeleteOutput(void)
Definition: audioplayer.cpp:93
PlayerContext::m_playingInfo
ProgramInfo * m_playingInfo
Currently playing info.
Definition: playercontext.h:117
tv_actions.h
MythPlayer::m_tcWrap
tctype_arr m_tcWrap
Definition: mythplayer.h:495
MythPlayer::DecoderGetFrame
bool DecoderGetFrame(DecodeType decodetype, bool unsafe=false)
Definition: mythplayer.cpp:1225
MythPlayer::SetPlayingInfo
void SetPlayingInfo(const ProgramInfo &pginfo)
Definition: mythplayer.cpp:234
MythVideoOutput::ClearAfterSeek
virtual void ClearAfterSeek()
Tells video output to toss decoded buffers due to a seek.
Definition: mythvideoout.cpp:272
MythPlayer::m_captionsEnabledbyDefault
bool m_captionsEnabledbyDefault
This allows us to enable captions/subtitles later if the streams are not immediately available when t...
Definition: mythplayer.h:461
MythVideoOutput::DeLimboFrame
virtual void DeLimboFrame(MythVideoFrame *Frame)
Releases a frame for reuse if it is in limbo.
Definition: mythvideoout.cpp:406
RemoteEncoder::GetFrameRate
float GetFrameRate(void)
Returns recordering frame rate set by nvr.
Definition: remoteencoder.cpp:159
hardwareprofile.i18n.t
t
Definition: i18n.py:36
PlayerContext::LockPlayingInfo
void LockPlayingInfo(const char *file, int line) const
Definition: playercontext.cpp:239
MythPlayer::FindFrame
uint64_t FindFrame(float offset, bool use_cutlist) const
Definition: mythplayer.cpp:1746
MythPlayer::m_bookmarkSeek
uint64_t m_bookmarkSeek
Definition: mythplayer.h:412
MythVideoFrame::m_timecode
std::chrono::milliseconds m_timecode
Definition: mythframe.h:130
DecoderBase::GetfpsMultiplier
int GetfpsMultiplier(void) const
Definition: decoderbase.h:254
MythPlayer::DoJumpChapter
virtual bool DoJumpChapter(int chapter)
Definition: mythplayer.cpp:1830
MythVideoOutput::GetFrameStatus
QString GetFrameStatus() const
Returns string with status of each frame for debugging.
Definition: mythvideoout.cpp:309
MythPlayer::SetDuration
void SetDuration(std::chrono::seconds duration)
Definition: mythplayer.cpp:393
MythPlayer::m_videoOutput
MythVideoOutput * m_videoOutput
Definition: mythplayer.h:363
MythPlayer::m_hasFullPositionMap
bool m_hasFullPositionMap
Definition: mythplayer.h:405
MythPlayer::IsInDelete
bool IsInDelete(uint64_t frame)
Definition: mythplayer.cpp:1701
PlayerContext::m_buffer
MythMediaBuffer * m_buffer
Definition: playercontext.h:116
MythPlayer::MythDecoderThread
friend class MythDecoderThread
Definition: mythplayer.h:91
MythPlayer::MythPlayer
MythPlayer(PlayerContext *Context, PlayerFlags Flags=kNoFlags)
Definition: mythplayer.cpp:81
ScanTypeToString
QString ScanTypeToString(FrameScanType Scan)
Definition: videoouttypes.h:211
MythPlayer::m_decoderPauseLock
QMutex m_decoderPauseLock
Definition: mythplayer.h:376
MythVideoOutput::GetNextFreeFrame
virtual MythVideoFrame * GetNextFreeFrame()
Blocks until it is possible to return a frame for decoding onto.
Definition: mythvideoout.cpp:393
MythPlayer::InitVideo
virtual bool InitVideo(void)
Definition: mythplayer.cpp:273
kDecodeAV
@ kDecodeAV
Definition: decoderbase.h:53
MythPlayer::WrapTimecode
void WrapTimecode(std::chrono::milliseconds &timecode, TCTypes tc_type)
Definition: mythplayer.cpp:1301
MythPlayer::PauseVideo
void PauseVideo(void)
Definition: mythplayer.cpp:219
DeleteMap::IsInDelete
bool IsInDelete(uint64_t frame) const
Returns true if the given frame is deemed to be within a region that should be cut.
Definition: deletemap.cpp:575
MythPlayerAVSync::ResetAVSyncForLiveTV
void ResetAVSyncForLiveTV(AudioPlayer *Audio)
Definition: mythplayeravsync.cpp:36
DecoderBase::ResetTotalDuration
void ResetTotalDuration(void)
Definition: decoderbase.h:251
MythPlayer::ClearAfterSeek
void ClearAfterSeek(bool clearvideobuffers=true)
This is to support seeking...
Definition: mythplayer.cpp:1678
MythPlayer::m_bufferingStart
QTime m_bufferingStart
Definition: mythplayer.h:448
MythPlayer::m_ttPageNum
int m_ttPageNum
VBI page to display when in PAL vbimode.
Definition: mythplayer.h:454
kDecodeVideo
@ kDecodeVideo
Definition: decoderbase.h:51
MythPlayer::SetBuffering
void SetBuffering(bool new_buffering)
Definition: mythplayer.cpp:703
MythPlayer::PauseDecoder
bool PauseDecoder(void)
Definition: mythplayer.cpp:965
DeleteMap::LoadMap
void LoadMap(const QString &undoMessage="")
Loads the delete map from the database.
Definition: deletemap.cpp:742
MythPlayer::m_totalFrames
uint64_t m_totalFrames
Definition: mythplayer.h:424
hardwareprofile.smolt.long
long
Definition: smolt.py:75
MythPlayer::ResetPlaying
virtual void ResetPlaying(bool resetframes=true)
Definition: mythplayer.cpp:916
MythPlayerAVSync::SetAVSyncMusicChoice
void SetAVSyncMusicChoice(AudioPlayer *Audio)
Definition: mythplayeravsync.cpp:43
MythPlayer::m_videoFrameRate
double m_videoFrameRate
Video (input) Frame Rate (often inaccurate)
Definition: mythplayer.h:434
MythPlayer::UpdateFFRewSkip
bool UpdateFFRewSkip(float ffrewScale=1.0F)
Definition: mythplayer.cpp:1330
get_encoding_type
QString get_encoding_type(MythCodecID codecid)
Definition: mythcodecid.cpp:475
MythVideoOutput::GetFramesPlayed
virtual long long GetFramesPlayed()
Definition: mythvideoout.cpp:250
TestBufferVec
std::vector< char > TestBufferVec
Definition: decoderbase.h:24
DecoderBase::GetXDS
virtual QString GetXDS(const QString &) const
Definition: decoderbase.h:241
jitterometer.h
MythPlayer::m_playerCtx
PlayerContext * m_playerCtx
Definition: mythplayer.h:365
DecoderBase::GetFPS
virtual double GetFPS(void) const
Definition: decoderbase.h:190
MythPlayer::m_forcedVideoAspect
float m_forcedVideoAspect
Definition: mythplayer.h:441
MythPlayer::m_videoDispDim
QSize m_videoDispDim
Video (input) width & height.
Definition: mythplayer.h:437
MythPlayer::DeLimboFrame
void DeLimboFrame(MythVideoFrame *frame)
Definition: mythplayer.cpp:673
MythVideoOutput::DiscardFrames
virtual void DiscardFrames(bool KeyFrame, bool Flushed)
Releases all frames not being actively displayed from any queue onto the queue of frames ready for de...
Definition: mythvideoout.cpp:434
MythPlayer::m_codecName
QString m_codecName
Codec Name - used by playback profile.
Definition: mythplayer.h:436
AvFormatDecoder
A decoder for media files.
Definition: avformatdecoder.h:80
MythPlayer::PosMapFromEnc
bool PosMapFromEnc(uint64_t start, frm_pos_map_t &posMap, frm_pos_map_t &durMap)
Definition: mythplayer.cpp:1898
MythPlayer::m_latestVideoTimecode
std::chrono::milliseconds m_latestVideoTimecode
Definition: mythplayer.h:428
MythPlayer::m_disableForcedSubtitles
bool m_disableForcedSubtitles
Definition: mythplayer.h:463
MythMediaBuffer::LiveMode
bool LiveMode(void) const
Returns true if this RingBuffer has been assigned a LiveTVChain.
Definition: mythmediabuffer.cpp:1808
MythPlayer::m_keyframeDist
uint m_keyframeDist
Video (input) Number of frames between key frames (often inaccurate)
Definition: mythplayer.h:444
preBufferDebug
static bool preBufferDebug
Definition: mythplayer.cpp:721
MythPlayer::RequestResetCaptions
void RequestResetCaptions()
MythPlayer::m_pauseDecoder
bool m_pauseDecoder
Definition: mythplayer.h:385
MythPlayer::GetEditMode
bool GetEditMode(void) const
Definition: mythplayer.h:314
MythPlayer::EnableForcedSubtitles
void EnableForcedSubtitles(bool enable)
Definition: mythplayer.cpp:679
MythPlayer::GetChapterTimes
virtual void GetChapterTimes(QList< std::chrono::seconds > &times)
Definition: mythplayer.cpp:1824
MythPlayer::m_fpsMultiplier
int m_fpsMultiplier
used to detect changes
Definition: mythplayer.h:486
MythPlayer::m_endExitPrompt
int m_endExitPrompt
Definition: mythplayer.h:413
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:55
MythPlayer::m_unpauseDecoder
bool m_unpauseDecoder
Definition: mythplayer.h:386
MythPlayer::m_playerFlags
PlayerFlags m_playerFlags
Definition: mythplayer.h:371
MythPlayer::UnpauseDecoder
void UnpauseDecoder(void)
Definition: mythplayer.cpp:989
MythPlayer::m_playingLock
QMutex m_playingLock
Definition: mythplayer.h:398
MythPlayer::PauseBuffer
void PauseBuffer(void)
Definition: mythplayer.cpp:135
MythPlayer::m_deleteMap
DeleteMap m_deleteMap
Definition: mythplayer.h:477
PlayerContext::m_tvchain
LiveTVChain * m_tvchain
Definition: playercontext.h:115
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:916
MythPlayer::m_vbiMode
uint m_vbiMode
VBI decoder to use.
Definition: mythplayer.h:453
MythPlayer::VideoEnd
virtual void VideoEnd(void)
Definition: mythplayer.cpp:828
MythPlayer::DoFastForward
bool DoFastForward(uint64_t frames, double inaccuracy)
Definition: mythplayer.cpp:1584
MythPlayer::m_playerThread
QThread * m_playerThread
Definition: mythplayer.h:367
MythPlayer::m_limitKeyRepeat
bool m_limitKeyRepeat
Definition: mythplayer.h:406
MythPlayer::DecoderEnd
virtual void DecoderEnd(void)
Definition: mythplayer.cpp:1034
mythmediabuffer.h
DecoderBase::SyncPositionMap
virtual bool SyncPositionMap(void)
Updates the position map used for skipping frames.
Definition: decoderbase.cpp:321
MythPlayer::ReinitVideo
virtual void ReinitVideo(bool ForceUpdate)
Definition: mythplayer.cpp:297
frm_pos_map_t
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
Definition: programtypes.h:44
MythPlayer::TranslatePositionFrameToMs
std::chrono::milliseconds TranslatePositionFrameToMs(uint64_t position, bool use_cutlist) const
Definition: mythplayer.cpp:1794
MythVideoOutput::EnoughFreeFrames
bool EnoughFreeFrames()
Returns true iff enough frames are available to decode onto.
Definition: mythvideoout.cpp:290
MythPlayer::m_decoderPaused
bool m_decoderPaused
Definition: mythplayer.h:383
MythPlayer::DoJumpToFrame
void DoJumpToFrame(uint64_t frame, double inaccuracy)
Definition: mythplayer.cpp:1607
MythPlayer::SetVideoParams
virtual void SetVideoParams(int w, int h, double fps, float aspect, bool ForceUpdate, int ReferenceFrames, FrameScanType=kScan_Ignore, const QString &codecName=QString())
Definition: mythplayer.cpp:324
MythPlayer::JumpChapter
void JumpChapter(int chapter)
Definition: mythplayer.cpp:910
MythVideoOutput::ReleaseFrame
virtual void ReleaseFrame(MythVideoFrame *Frame)
Releases a frame from the ready for decoding queue onto the queue of frames ready for display.
Definition: mythvideoout.cpp:400
DecoderBase::SetSeekSnap
void SetSeekSnap(uint64_t snap)
Definition: decoderbase.h:138
MythPlayer::GetNumChapters
virtual int GetNumChapters(void)
Definition: mythplayer.cpp:1810
DecoderBase::GetNumChapters
virtual int GetNumChapters(void)
Definition: decoderbase.h:155
MythCoreContext::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval=false)
Definition: mythcorecontext.cpp:910
kState_WatchingPreRecorded
@ kState_WatchingPreRecorded
Watching Pre-recorded is a TV only state for when we are watching a pre-existing recording.
Definition: tv.h:70
MythPlayer::m_jumpChapter
int m_jumpChapter
Definition: mythplayer.h:409
MythPlayer::InitFrameInterval
virtual void InitFrameInterval()
Definition: mythplayer.cpp:697
MythPlayer::GetError
QString GetError(void) const
Definition: mythplayer.cpp:1950
DecoderBase::SetWatchingRecording
virtual void SetWatchingRecording(bool mode)
Definition: decoderbase.cpp:81
DecoderBase::SetTranscoding
void SetTranscoding(bool value)
Definition: decoderbase.h:215
DecoderBase::GetFrame
virtual bool GetFrame(DecodeType Type, bool &Retry)=0
Demux, preprocess and possibly decode a frame of video/audio.
MythPlayerAVSync::ResetAVSyncClockBase
void ResetAVSyncClockBase()
Definition: mythplayeravsync.h:33
MythPlayer::kSeekToEndOffset
static const double kSeekToEndOffset
Definition: mythplayer.h:242
MythPlayerAVSync::InitAVSync
void InitAVSync()
Definition: mythplayeravsync.cpp:17
kLiveTVAutoExpire
@ kLiveTVAutoExpire
Definition: programtypes.h:196
MythPlayer::CreateDecoder
virtual void CreateDecoder(TestBufferVec &TestBuffer)
Definition: mythplayer.cpp:414
LiveTVChain::GetInputType
QString GetInputType(int pos=-1) const
Definition: livetvchain.cpp:698
MythPlayer::CalcMaxFFTime
virtual long long CalcMaxFFTime(long long ff, bool setjump=true) const
CalcMaxFFTime(ffframes): forward ffframes forward.
Definition: mythplayer.cpp:1447
ProgramInfo::GetChanID
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:373
livetvchain.h
ProgramInfo::QueryAutoExpire
AutoExpireType QueryAutoExpire(void) const
Returns "autoexpire" field from "recorded" table.
Definition: programinfo.cpp:3459
kVideoIsNull
@ kVideoIsNull
Definition: mythplayer.h:73
MythPlayer::SetKeyframeDistance
void SetKeyframeDistance(int keyframedistance)
Definition: mythplayer.cpp:319
MythMediaBuffer::IsBookmarkAllowed
virtual bool IsBookmarkAllowed(void)
Definition: mythmediabuffer.h:136
DecoderBase::UpdateFramesPlayed
virtual void UpdateFramesPlayed(void)
Definition: decoderbase.cpp:864
MythVideoOutput::DiscardFrame
virtual void DiscardFrame(MythVideoFrame *Frame)
Releases frame from any queue onto the queue of frames ready for decoding onto.
Definition: mythvideoout.cpp:427
MythPlayer::SetWatchingRecording
void SetWatchingRecording(bool mode)
Definition: mythplayer.cpp:123
ProgramInfo
Holds information on recordings and videos.
Definition: programinfo.h:67
MythPlayer::m_liveTV
bool m_liveTV
Definition: mythplayer.h:402
assert
#define assert(x)
Definition: audiooutputalsa.cpp:16
mythmiscutil.h
kAVSyncAudioPausedLiveTV
@ kAVSyncAudioPausedLiveTV
Definition: mythplayeravsync.h:17
MythPlayer::IsReallyNearEnd
bool IsReallyNearEnd(void) const
Returns true iff really near end of recording.
Definition: mythplayer.cpp:1524
MythPlayer::IsWatchingInprogress
bool IsWatchingInprogress(void) const
Definition: mythplayer.cpp:130
MythPlayer::m_decoderThreadPause
QWaitCondition m_decoderThreadPause
Definition: mythplayer.h:374
mythcorecontext.h
MythPlayer::m_fileChanged
bool m_fileChanged
Definition: mythplayer.h:490
MythPlayer::SetFramesPlayed
void SetFramesPlayed(uint64_t played)
Definition: mythplayer.cpp:562
MythPlayer::FileChangedCallback
void FileChangedCallback()
Definition: mythplayer.cpp:938
MythPlayer::m_maxReferenceFrames
int m_maxReferenceFrames
Number of reference frames used in the video stream.
Definition: mythplayer.h:439
cardutil.h
MythPlayer::WaitForSeek
void WaitForSeek(uint64_t frame, uint64_t seeksnap_wanted)
Definition: mythplayer.cpp:1615
MythPlayer::GetFreeVideoFrames
int GetFreeVideoFrames(void) const
Returns the number of frames available for decoding onto.
Definition: mythplayer.cpp:572
DecoderBase::SetRenderFormats
void SetRenderFormats(const VideoFrameTypes *RenderFormats)
Definition: decoderbase.cpp:35
MythPlayer::m_errorType
int m_errorType
Definition: mythplayer.h:401
avformatdecoder.h
setpriority
#define setpriority(x, y, z)
Definition: compat.h:130
MythPlayer::SetDisablePassThrough
void SetDisablePassThrough(bool disabled)
Definition: mythplayer.cpp:1994
MythPlayer::kInaccuracyEditor
static const double kInaccuracyEditor
Definition: mythplayer.h:240
MythPlayer::TranslatePositionMsToFrame
uint64_t TranslatePositionMsToFrame(std::chrono::milliseconds position, bool use_cutlist) const
Definition: mythplayer.h:256
MythPlayer::m_decodeOneFrame
bool m_decodeOneFrame
Definition: mythplayer.h:388
MythPlayer::SetPlaying
void SetPlaying(bool is_playing)
Definition: mythplayer.cpp:245
audiooutput.h
MythPlayer::m_transcoding
bool m_transcoding
Definition: mythplayer.h:404
ProgramInfo::IsVideo
bool IsVideo(void) const
Definition: programinfo.h:489
dummydecoder.h
mythavutil.h
MythPlayer::GetNextVideoFrame
MythVideoFrame * GetNextVideoFrame(void)
Removes a frame from the available queue for decoding onto.
Definition: mythplayer.cpp:588
MythPlayer::m_ffrewScale
float m_ffrewScale
scale skip for large gops
Definition: mythplayer.h:489
RemoteEncoder::FillPositionMap
void FillPositionMap(int64_t start, int64_t end, frm_pos_map_t &positionMap)
Definition: remoteencoder.cpp:268
MythMediaBuffer::Start
void Start(void)
Starts the read-ahead thread.
Definition: mythmediabuffer.cpp:617
AvFormatDecoder::CanHandle
static bool CanHandle(TestBufferVec &testbuf, const QString &filename)
Perform an av_probe_input_format on the passed data to see if we can decode it with this class.
Definition: avformatdecoder.cpp:829
MythPlayer::SetFrameRate
void SetFrameRate(double fps)
Definition: mythplayer.cpp:377
MythPlayer::ResetTotalDuration
void ResetTotalDuration(void)
Definition: mythplayer.cpp:1964
MythPlayer::m_totalLength
std::chrono::seconds m_totalLength
Definition: mythplayer.h:425
TC_AUDIO
@ TC_AUDIO
Definition: mythplayer.h:57
MythPlayer::SetFrameInterval
void SetFrameInterval(FrameScanType scan, double frame_period)
Definition: mythplayer.cpp:687
MythPlayer::m_decoderSeek
int64_t m_decoderSeek
Definition: mythplayer.h:381
mthread.h
kAudioMuted
@ kAudioMuted
Definition: mythplayer.h:74
MThread::isRunning
bool isRunning(void) const
Definition: mthread.cpp:263
MythPlayer::SetCommBreakMap
void SetCommBreakMap(const frm_dir_map_t &NewMap)
Definition: mythplayer.cpp:1725
PlayerContext
Definition: playercontext.h:49
MythPlayer::m_isDummy
bool m_isDummy
Definition: mythplayer.h:499
MythPlayer::m_videoDim
QSize m_videoDim
Video (input) buffer width & height.
Definition: mythplayer.h:438
MythPlayer::m_vidExitLock
QMutex m_vidExitLock
Definition: mythplayer.h:397
remoteencoder.h
AudioPlayer::GetStretchFactor
float GetStretchFactor(void) const
Definition: audioplayer.h:64
audioplayer.h
DecoderBase::SetDisablePassThrough
virtual void SetDisablePassThrough(bool disable)
Disables AC3/DTS pass through.
Definition: decoderbase.h:146
MythPlayer::FlagIsSet
bool FlagIsSet(PlayerFlags arg)
Definition: mythplayer.h:317
mythtimer.h
MythPlayer::m_videoAspect
float m_videoAspect
Video (input) Apect Ratio.
Definition: mythplayer.h:440
AudioPlayer::Pause
bool Pause(bool pause)
Definition: audioplayer.cpp:179
MythPlayer::DoFFRewSkip
virtual void DoFFRewSkip(void)
Definition: mythplayer.cpp:1167
MythPlayer::ForceSetupAudioStream
void ForceSetupAudioStream(void)
Definition: mythplayer.cpp:2000
mythcodeccontext.h
MythPlayer::kInaccuracyFull
static const double kInaccuracyFull
Definition: mythplayer.h:241
MythPlayer::JumpToFrame
virtual bool JumpToFrame(uint64_t frame)
Definition: mythplayer.cpp:889
MythPlayer::StopPlaying
virtual void StopPlaying(void)
Definition: mythplayer.cpp:944
MythPlayer::m_allPaused
bool m_allPaused
Definition: mythplayer.h:393
mythuiactions.h
MythPlayer::SaveTotalDuration
void SaveTotalDuration(void)
Definition: mythplayer.cpp:1956
DecoderBase::OpenFile
virtual int OpenFile(MythMediaBuffer *Buffer, bool novideo, TestBufferVec &testbuf)=0
ffrewScaleLowest
static float ffrewScaleLowest
Definition: mythplayer.cpp:1164
MythPlayer::IsInStillFrame
virtual bool IsInStillFrame() const
Definition: mythplayer.h:228
FrameScanType
FrameScanType
Definition: videoouttypes.h:94
LiveTVChain::HasPrev
bool HasPrev(void) const
Definition: livetvchain.h:62
MythPlayer::GetXDS
QString GetXDS(const QString &key) const
Definition: mythplayer.cpp:1718
myth_nice
bool myth_nice(int val)
Definition: mythmiscutil.cpp:656
PRIO_PROCESS
#define PRIO_PROCESS
Definition: compat.h:129
MythMediaBuffer::Peek
int Peek(void *Buffer, int Count)
Definition: mythmediabuffer.cpp:1170
MythVideoFrame
Definition: mythframe.h:87
MythPlayer::OpenDummy
void OpenDummy(void)
Definition: mythplayer.cpp:398
MythPlayer::m_playing
bool m_playing
Definition: mythplayer.h:394
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:885
PlayerContext::m_recorder
RemoteEncoder * m_recorder
Definition: playercontext.h:114
DecoderBase::Reset
virtual void Reset(bool reset_video_data, bool seek_reset, bool reset_file)
Definition: decoderbase.cpp:47
MythMediaBuffer::IsNearEnd
bool IsNearEnd(double Framerate, uint Frames) const
Definition: mythmediabuffer.cpp:412
DeleteMap::GetLastFrame
uint64_t GetLastFrame(void) const
Returns the number of the last frame in the video that is not in a cut sequence.
Definition: deletemap.cpp:862
MythVideoOutput::EnoughDecodedFrames
bool EnoughDecodedFrames()
Returns true iff there are plenty of decoded frames ready for display.
Definition: mythvideoout.cpp:297
LOC
#define LOC
Definition: mythplayer.cpp:57
MythPlayer::DecoderLoop
virtual void DecoderLoop(bool pause)
Definition: mythplayer.cpp:1098
DecoderBase::SetEofState
virtual void SetEofState(EofState eof)
Definition: decoderbase.h:132
MythPlayer::m_disablePassthrough
bool m_disablePassthrough
Definition: mythplayer.h:507
DummyDecoder
Definition: dummydecoder.h:10
mythmainwindow.h
DecoderBase::SetLiveTVMode
void SetLiveTVMode(bool live)
Definition: decoderbase.h:140
MythMediaBuffer::IsSeekingAllowed
virtual bool IsSeekingAllowed(void)
Definition: mythmediabuffer.h:135
MythPlayer::DoRewind
bool DoRewind(uint64_t frames, double inaccuracy)
Definition: mythplayer.cpp:1401
MythPlayer::kInaccuracyDefault
static const double kInaccuracyDefault
Definition: mythplayer.h:239
MythPlayer::FastForward
virtual bool FastForward(float seconds)
Definition: mythplayer.cpp:836
MythPlayer::SeekingDone
void SeekingDone()
DecoderBase::GetFramesRead
long long GetFramesRead(void) const
Definition: decoderbase.h:195
MythMediaBuffer::Pause
void Pause(void)
Pauses the read-ahead thread. Calls StopReads(void).
Definition: mythmediabuffer.cpp:690
DecoderBase::DoRewind
virtual bool DoRewind(long long desiredFrame, bool discardFrames=true)
Definition: decoderbase.cpp:554
DeleteMap::IsEditing
bool IsEditing(void) const
Definition: deletemap.h:41
MythPlayer::DoGetFrame
bool DoGetFrame(DecodeType DecodeType)
Get one frame from the decoder.
Definition: mythplayer.cpp:1286
MythPlayer::Play
bool Play(float speed=1.0, bool normal=true, bool unpauseaudio=true)
Definition: mythplayer.cpp:189
MythPlayer::m_playingWaitCond
QWaitCondition m_playingWaitCond
Definition: mythplayer.h:396
DecoderBase
Definition: decoderbase.h:121
MythVideoOutput::SetVideoFrameRate
virtual void SetVideoFrameRate(float VideoFrameRate)
Definition: mythvideoout.cpp:135
MythPlayer::m_renderFormats
const VideoFrameTypes * m_renderFormats
Definition: mythplayer.h:364
MythPlayer::m_killDecoder
bool volatile m_killDecoder
Definition: mythplayer.h:387
MythPlayer::ReleaseNextVideoFrame
virtual void ReleaseNextVideoFrame(MythVideoFrame *buffer, std::chrono::milliseconds timecode, bool wrap=true)
Places frame on the queue of frames ready for display.
Definition: mythplayer.cpp:598
uint
unsigned int uint
Definition: freesurround.h:24
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:902
millisecondsFromFloat
std::enable_if_t< std::is_floating_point_v< T >, std::chrono::milliseconds > millisecondsFromFloat(T value)
Helper function for convert a floating point number to a duration.
Definition: mythchrono.h:91
MythPlayer::m_renderOneFrame
bool m_renderOneFrame
Definition: mythplayer.h:389
tv_play.h
MythPlayer::DecoderStart
virtual void DecoderStart(bool start_paused)
Definition: mythplayer.cpp:1016
DecoderBase::SaveTotalFrames
void SaveTotalFrames(void)
Definition: decoderbase.cpp:1290
MythPlayer::Rewind
virtual bool Rewind(float seconds)
Definition: mythplayer.cpp:866
MythPlayer::GetCurrentChapter
virtual int GetCurrentChapter(void)
Definition: mythplayer.cpp:1817
MythPlayer::DiscardVideoFrame
void DiscardVideoFrame(MythVideoFrame *buffer)
Places frame in the available frames queue.
Definition: mythplayer.cpp:629