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 <QtCore/qnumeric.h>
21 #include <utility>
22 
23 // MythTV headers
24 #include "mthread.h"
25 #include "mythconfig.h"
26 #include "mythplayer.h"
27 #include "DetectLetterbox.h"
28 #include "audioplayer.h"
29 #include "programinfo.h"
30 #include "mythcorecontext.h"
31 #include "livetvchain.h"
32 #include "avformatdecoder.h"
33 #include "dummydecoder.h"
34 #include "tv_play.h"
35 #include "mythlogging.h"
36 #include "mythmiscutil.h"
37 #include "audiooutput.h"
38 #include "cardutil.h"
39 #include "mythavutil.h"
40 #include "jitterometer.h"
41 #include "mythtimer.h"
42 #include "mythuiactions.h"
43 #include "io/mythmediabuffer.h"
44 #include "tv_actions.h"
46 #include "mythvideooutnull.h"
47 #include "mythcodeccontext.h"
48 
49 // MythUI headers
50 #include <mythmainwindow.h>
51 
52 extern "C" {
53 #include "libavcodec/avcodec.h"
54 }
55 
56 #include "remoteencoder.h"
57 
58 #if ! HAVE_ROUND
59 #define round(x) ((int) ((x) + 0.5))
60 #endif
61 
62 static unsigned dbg_ident(const MythPlayer* /*player*/);
63 
64 #define LOC QString("Player(%1): ").arg(dbg_ident(this),0,36)
65 
68 
69 // Exact frame seeking, no inaccuracy allowed.
70 const double MythPlayer::kInaccuracyNone = 0;
71 
72 // By default, when seeking, snap to a keyframe if the keyframe's
73 // distance from the target frame is less than 10% of the total seek
74 // distance.
75 const double MythPlayer::kInaccuracyDefault = 0.1;
76 
77 // Allow greater inaccuracy (50%) in the cutlist editor (unless the
78 // editor seek distance is set to 1 frame or 1 keyframe).
79 const double MythPlayer::kInaccuracyEditor = 0.5;
80 
81 // Any negative value means completely inexact, i.e. seek to the
82 // keyframe that is closest to the target.
83 const double MythPlayer::kInaccuracyFull = -1.0;
84 
86  : m_playerCtx(Context),
87  m_playerFlags(Flags),
88  // CC608/708
89  m_cc608(this), m_cc708(this),
90  // Audio
91  m_audio(this, (Flags & kAudioMuted) != 0)
92 {
93  m_playerThread = QThread::currentThread();
94 #ifdef Q_OS_ANDROID
95  m_playerThreadId = gettid();
96 #endif
99 
102  m_clearSavedPosition = gCoreContext->GetNumSetting("ClearSavedPosition", 1);
103  m_endExitPrompt = gCoreContext->GetNumSetting("EndOfRecordingExitPrompt");
104 
105  // Get VBI page number
106  QString mypage = gCoreContext->GetSetting("VBIpageNr", "888");
107  bool valid = false;
108  uint tmp = mypage.toInt(&valid, 16);
109  m_ttPageNum = (valid) ? tmp : m_ttPageNum;
111 }
112 
114 {
115  QMutexLocker lock2(&m_vidExitLock);
116 
117  SetDecoder(nullptr);
118 
119  delete m_decoderThread;
120  m_decoderThread = nullptr;
121 
122  delete m_videoOutput;
123  m_videoOutput = nullptr;
124 }
125 
127 {
128  m_watchingRecording = mode;
129  if (m_decoder)
131 }
132 
134 {
136 }
137 
139 {
140  m_bufferPauseLock.lock();
141  if (m_playerCtx->m_buffer)
142  {
145  }
146  m_bufferPaused = true;
147  m_bufferPauseLock.unlock();
148 }
149 
151 {
152  m_bufferPauseLock.lock();
153  if (m_playerCtx->m_buffer)
155  m_bufferPaused = false;
156  m_bufferPauseLock.unlock();
157 }
158 
160 {
161  while (!m_pauseLock.tryLock(100))
162  {
163  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Waited 100ms to get pause lock.");
165  }
166  bool already_paused = m_allPaused;
167  if (already_paused)
168  {
169  m_pauseLock.unlock();
170  return already_paused;
171  }
172  m_nextPlaySpeed = 0.0;
173  m_nextNormalSpeed = false;
174  PauseVideo();
175  m_audio.Pause(true);
176  PauseDecoder();
177  PauseBuffer();
178  if (!m_decoderPaused)
179  PauseDecoder(); // Retry in case audio only stream
181  {
184  else if (m_videoOutput && !FlagIsSet(kVideoIsNull))
186  }
187  m_pauseLock.unlock();
189  return already_paused;
190 }
191 
192 bool MythPlayer::Play(float speed, bool normal, bool unpauseaudio)
193 {
194  m_pauseLock.lock();
195  LOG(VB_PLAYBACK, LOG_INFO, LOC +
196  QString("Play(%1, normal %2, unpause audio %3)")
197  .arg(speed,5,'f',1).arg(normal).arg(unpauseaudio));
198 
199  if (m_deleteMap.IsEditing())
200  {
201  LOG(VB_GENERAL, LOG_ERR, LOC + "Ignoring Play(), in edit mode.");
202  m_pauseLock.unlock();
203  return false;
204  }
205 
207 
209  UnpauseBuffer();
210  UnpauseDecoder();
211  if (unpauseaudio)
212  m_audio.Pause(false);
213  UnpauseVideo();
214  m_allPaused = false;
215  m_nextPlaySpeed = speed;
216  m_nextNormalSpeed = normal;
217  m_pauseLock.unlock();
219  return true;
220 }
221 
223 {
224  m_videoPauseLock.lock();
225  m_needNewPauseFrame = true;
226  m_videoPaused = true;
227  m_videoPauseLock.unlock();
228 }
229 
231 {
232  m_videoPauseLock.lock();
233  m_videoPaused = false;
234  m_videoPauseLock.unlock();
235 }
236 
238 {
240  if (!m_playerCtx)
241  return;
242 
243  m_playerCtx->LockPlayingInfo(__FILE__, __LINE__);
244  m_playerCtx->SetPlayingInfo(&pginfo);
245  m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
246 }
247 
248 void MythPlayer::SetPlaying(bool is_playing)
249 {
250  QMutexLocker locker(&m_playingLock);
251 
252  m_playing = is_playing;
253 
254  m_playingWaitCond.wakeAll();
255 }
256 
257 bool MythPlayer::IsPlaying(std::chrono::milliseconds wait_in_msec, bool wait_for) const
258 {
259  QMutexLocker locker(&m_playingLock);
260 
261  if (wait_in_msec != 0ms)
262  return m_playing;
263 
264  MythTimer t;
265  t.start();
266 
267  while ((wait_for != m_playing) && (t.elapsed() < wait_in_msec))
268  {
269  m_playingWaitCond.wait(
270  &m_playingLock, std::max(0ms,wait_in_msec - t.elapsed()).count());
271  }
272 
273  return m_playing;
274 }
275 
277 {
278  if (!m_playerCtx)
279  return false;
280 
281  if (!m_decoder)
282  {
283  LOG(VB_GENERAL, LOG_ERR, LOC + "Cannot create a video renderer without a decoder.");
284  return false;
285  }
286 
289 
290  if (!m_videoOutput)
291  {
292  LOG(VB_GENERAL, LOG_ERR, LOC + "Couldn't create VideoOutput instance. Exiting..");
293  SetErrored(tr("Failed to initialize video output"));
294  return false;
295  }
296 
297  return true;
298 }
299 
300 void MythPlayer::ReinitVideo(bool ForceUpdate)
301 {
302 
303  bool aspect_only = false;
304  {
305  QMutexLocker locker(&m_vidExitLock);
306  m_videoOutput->SetVideoFrameRate(static_cast<float>(m_videoFrameRate));
307  float aspect = (m_forcedVideoAspect > 0) ? m_forcedVideoAspect : m_videoAspect;
309  m_decoder->GetVideoCodecID(), aspect_only,
310  m_maxReferenceFrames, ForceUpdate))
311  {
312  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to Reinitialize Video. Exiting..");
313  SetErrored(tr("Failed to reinitialize video output"));
314  return;
315  }
316  }
317 
318  if (!aspect_only)
319  ClearAfterSeek();
320 }
321 
322 void MythPlayer::SetKeyframeDistance(int keyframedistance)
323 {
324  m_keyframeDist = (keyframedistance > 0) ? static_cast<uint>(keyframedistance) : m_keyframeDist;
325 }
326 
327 void MythPlayer::SetVideoParams(int width, int height, double fps,
328  float aspect, bool ForceUpdate,
329  int ReferenceFrames, FrameScanType /*scan*/, const QString& codecName)
330 {
331  bool paramsChanged = ForceUpdate;
332 
333  if (width >= 0 && height >= 0)
334  {
335  paramsChanged = true;
336  m_videoDim = m_videoDispDim = QSize(width, height);
337  m_videoAspect = aspect > 0.0F ? aspect : static_cast<float>(width) / height;
338  }
339 
340  if (!qIsNaN(fps) && fps > 0.0 && fps < 121.0)
341  {
342  paramsChanged = true;
343  m_videoFrameRate = fps;
344  if (m_ffrewSkip != 0 && m_ffrewSkip != 1)
345  {
346  UpdateFFRewSkip();
347  }
348  else
349  {
350  float temp_speed = (m_playSpeed == 0.0F) ?
353  1.0 / (m_videoFrameRate * static_cast<double>(temp_speed)));
354  }
355  }
356 
357  if (!codecName.isEmpty())
358  {
359  m_codecName = codecName;
360  paramsChanged = true;
361  }
362 
363  if (ReferenceFrames > 0)
364  {
365  m_maxReferenceFrames = ReferenceFrames;
366  paramsChanged = true;
367  }
368 
369  if (!paramsChanged)
370  return;
371 
372  if (m_videoOutput)
373  ReinitVideo(ForceUpdate);
374 
375  if (IsErrored())
376  return;
377 }
378 
379 
380 void MythPlayer::SetFrameRate(double fps)
381 {
382  m_videoFrameRate = fps;
383  float temp_speed = (m_playSpeed == 0.0F) ? m_audio.GetStretchFactor() : m_playSpeed;
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)
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'")
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")
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_videoOutput)
608  m_videoOutput->ReleaseFrame(buffer);
609 
610  // FIXME need to handle this in the correct place in the main thread (DVD stills?)
611  //if (m_allPaused)
612  // CheckAspectRatio(buffer);
613 }
614 
619 {
620  if (m_videoOutput)
621  m_videoOutput->DiscardFrame(buffer);
622 }
623 
637 void MythPlayer::DiscardVideoFrames(bool KeyFrame, bool Flushed)
638 {
639  if (m_videoOutput)
640  m_videoOutput->DiscardFrames(KeyFrame, Flushed);
641 }
642 
644 {
645  EofState eof = GetEof();
646  if (eof != kEofStateNone && !m_allPaused)
647  return true;
648  if (GetEditMode())
649  return false;
650  if (m_liveTV)
651  return false;
653  return true;
654  return false;
655 }
656 
658 {
659  if (m_videoOutput)
660  m_videoOutput->DeLimboFrame(frame);
661 }
662 
664 {
665  if (enable)
667  else
669 }
670 
672 {
673  if (m_decoder)
675  m_frameInterval = microsecondsFromFloat(1000000.0 * frame_period / m_fpsMultiplier);
676 
677  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("SetFrameInterval Interval:%1 Speed:%2 Scan:%3 (Multiplier: %4)")
678  .arg(m_frameInterval.count()).arg(static_cast<double>(m_playSpeed)).arg(ScanTypeToString(scan)).arg(m_fpsMultiplier));
679 }
680 
682 {
683  // try to get preferential scheduling, but ignore if we fail to.
684  myth_nice(-19);
685 }
686 
687 void MythPlayer::SetBuffering(bool new_buffering)
688 {
689  if (!m_buffering && new_buffering)
690  {
691  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Waiting for video buffers...");
692  m_buffering = true;
693  m_bufferingStart = QTime::currentTime();
694  m_bufferingLastMsg = QTime::currentTime();
695  }
696  else if (m_buffering && !new_buffering)
697  {
698  m_buffering = false;
699  }
700 }
701 
702 // For debugging playback set this to increase the timeout so that
703 // playback does not fail if stepping through code.
704 // Set PREBUFFERDEBUG to any value and you will get 30 minutes.
705 static bool preBufferDebug = qEnvironmentVariableIsSet("PREBUFFERDEBUG");
706 
708 {
709  if (!m_videoOutput)
710  return false;
711 
712  if (!(min_buffers ? (m_videoOutput->ValidVideoFrames() >= min_buffers) :
714  {
715  SetBuffering(true);
716 
717  // This piece of code is to address the problem, when starting
718  // Live TV, of jerking and stuttering. Without this code
719  // that could go on forever, but is cured by a pause and play.
720  // This code inserts a brief pause and play when the potential
721  // for the jerking is detected.
722 
723  bool watchingTV = IsWatchingInprogress();
724  if ((m_liveTV || watchingTV) && !FlagIsSet(kMusicChoice))
725  {
726  uint64_t frameCount = GetCurrentFrameCount();
727  uint64_t framesLeft = frameCount - m_framesPlayed;
728  auto margin = static_cast<uint64_t>(m_videoFrameRate * 3);
729  if (framesLeft < margin)
730  {
732  {
733  LOG(VB_PLAYBACK, LOG_NOTICE, LOC + "Pause to allow live tv catch up");
734  LOG(VB_PLAYBACK, LOG_NOTICE, LOC + QString("Played: %1 Avail: %2 Buffered: %3 Margin: %4")
735  .arg(m_framesPlayed).arg(frameCount)
736  .arg(m_videoOutput->ValidVideoFrames()).arg(margin));
737  }
738  }
739  }
740 
741  std::this_thread::sleep_for(m_frameInterval / 8);
742  auto waited_for = std::chrono::milliseconds(m_bufferingStart.msecsTo(QTime::currentTime()));
743  auto last_msg = std::chrono::milliseconds(m_bufferingLastMsg.msecsTo(QTime::currentTime()));
744  if (last_msg > 100ms && !FlagIsSet(kMusicChoice))
745  {
746  if (++m_bufferingCounter == 10)
747  LOG(VB_GENERAL, LOG_NOTICE, LOC +
748  "To see more buffering messages use -v playback");
749  if (m_bufferingCounter >= 10)
750  {
751  LOG(VB_PLAYBACK, LOG_NOTICE, LOC +
752  QString("Waited %1ms for video buffers %2")
753  .arg(waited_for.count()).arg(m_videoOutput->GetFrameStatus()));
754  }
755  else
756  {
757  LOG(VB_GENERAL, LOG_NOTICE, LOC +
758  QString("Waited %1ms for video buffers %2")
759  .arg(waited_for.count()).arg(m_videoOutput->GetFrameStatus()));
760  }
761  m_bufferingLastMsg = QTime::currentTime();
763  && gCoreContext->GetBoolSetting("MusicChoiceEnabled", false))
764  {
766  LOG(VB_GENERAL, LOG_NOTICE, LOC + "Music Choice program detected - disabling AV Sync.");
768  }
769  if (waited_for > 7s && m_audio.IsBufferAlmostFull()
770  && !FlagIsSet(kMusicChoice))
771  {
772  // We are likely to enter this condition
773  // if the audio buffer was too full during GetFrame in AVFD
774  LOG(VB_GENERAL, LOG_NOTICE, LOC + "Resetting audio buffer");
775  m_audio.Reset();
776  }
777  // Finish audio pause for sync after 1 second
778  // in case of infrequent video frames (e.g. music choice)
779  if (m_avSync.GetAVSyncAudioPause() && waited_for > 1s)
781  }
782  std::chrono::milliseconds msecs { 500ms };
783  if (preBufferDebug)
784  msecs = 30min;
785  if ((waited_for > msecs) && !m_videoOutput->EnoughFreeFrames())
786  {
787  LOG(VB_GENERAL, LOG_NOTICE, LOC +
788  "Timed out waiting for frames, and"
789  "\n\t\t\tthere are not enough free frames. "
790  "Discarding buffered frames.");
791  // This call will result in some ugly frames, but allows us
792  // to recover from serious problems if frames get leaked.
793  DiscardVideoFrames(true, true);
794  }
795  msecs = 30s;
796  if (preBufferDebug)
797  msecs = 30min;
798  if (waited_for > msecs) // 30 seconds for internet streamed media
799  {
800  LOG(VB_GENERAL, LOG_ERR, LOC +
801  "Waited too long for decoder to fill video buffers. Exiting..");
802  SetErrored(tr("Video frame buffering failed too many times."));
803  }
804  return false;
805  }
806 
808  m_audio.Pause(false);
809  SetBuffering(false);
810  return true;
811 }
812 
814 {
815  m_vidExitLock.lock();
816  delete m_videoOutput;
817  m_videoOutput = nullptr;
818  m_vidExitLock.unlock();
819 }
820 
821 bool MythPlayer::FastForward(float seconds)
822 {
823  if (!m_videoOutput)
824  return false;
825 
826  if (m_ffTime <= 0)
827  {
828  float current = ComputeSecs(m_framesPlayed, true);
829  float dest = current + seconds;
830  float length = ComputeSecs(m_totalFrames, true);
831 
832  if (dest > length)
833  {
834  auto msec = millisecondsFromFloat(seconds * 1000);
835  int64_t pos = TranslatePositionMsToFrame(msec, false);
836  if (CalcMaxFFTime(pos) < 0)
837  return true;
838  // Reach end of recording, go to 1 or 3s before the end
839  dest = (m_liveTV || IsWatchingInprogress()) ? -3.0 : -1.0;
840  }
841  uint64_t target = FindFrame(dest, true);
842  m_ffTime = target - m_framesPlayed;
843  }
844  return m_ffTime > CalcMaxFFTime(m_ffTime, false);
845 }
846 
847 bool MythPlayer::Rewind(float seconds)
848 {
849  if (!m_videoOutput)
850  return false;
851 
852  if (m_rewindTime <= 0)
853  {
854  float current = ComputeSecs(m_framesPlayed, true);
855  float dest = current - seconds;
856  if (dest < 0)
857  {
858  auto msec = millisecondsFromFloat(seconds * 1000);
859  int64_t pos = TranslatePositionMsToFrame(msec, false);
860  if (CalcRWTime(pos) < 0)
861  return true;
862  dest = 0;
863  }
864  uint64_t target = FindFrame(dest, true);
865  m_rewindTime = m_framesPlayed - target;
866  }
867  return (uint64_t)m_rewindTime >= m_framesPlayed;
868 }
869 
870 bool MythPlayer::JumpToFrame(uint64_t frame)
871 {
872  if (!m_videoOutput)
873  return false;
874 
875  bool ret = false;
876  m_ffTime = m_rewindTime = 0;
877  if (frame > m_framesPlayed)
878  {
879  m_ffTime = frame - m_framesPlayed;
880  ret = m_ffTime > CalcMaxFFTime(m_ffTime, false);
881  }
882  else if (frame < m_framesPlayed)
883  {
884  m_rewindTime = m_framesPlayed - frame;
885  ret = m_ffTime > CalcMaxFFTime(m_ffTime, false);
886  }
887  return ret;
888 }
889 
890 
891 void MythPlayer::JumpChapter(int chapter)
892 {
893  if (m_jumpChapter == 0)
894  m_jumpChapter = chapter;
895 }
896 
897 void MythPlayer::ResetPlaying(bool resetframes)
898 {
899  ClearAfterSeek();
900  m_ffrewSkip = 1;
901  if (resetframes)
902  m_framesPlayed = 0;
903  if (m_decoder)
904  {
905  m_decoder->Reset(true, true, true);
906  if (m_decoder->IsErrored())
907  SetErrored("Unable to reset video decoder");
908  }
909 }
910 
912 {
913  bool last = !(m_playerCtx->m_tvchain->HasNext());
914  SetWatchingRecording(last);
915 }
916 
917 // This is called from decoder thread. Set an indicator that will
918 // be checked and actioned in the player thread.
920 {
921  LOG(VB_PLAYBACK, LOG_INFO, LOC + "FileChangedCallback");
922  m_fileChanged = true;
923 }
924 
926 {
927  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("StopPlaying - begin"));
928  m_playerThread->setPriority(QThread::NormalPriority);
929 #ifdef Q_OS_ANDROID
930  setpriority(PRIO_PROCESS, m_playerThreadId, 0);
931 #endif
932 
933  emit CheckCallbacks();
934  DecoderEnd();
935  VideoEnd();
936  AudioEnd();
937 
938  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("StopPlaying - end"));
939 }
940 
942 {
944 }
945 
947 {
948  m_decoderPauseLock.lock();
950  {
951  m_decoderPaused = true;
952  m_decoderThreadPause.wakeAll();
953  m_decoderPauseLock.unlock();
954  return m_decoderPaused;
955  }
956 
957  int tries = 0;
958  m_pauseDecoder = true;
959  while (m_decoderThread && !m_killDecoder && (tries++ < 100) &&
961  {
962  emit CheckCallbacks();
963  LOG(VB_GENERAL, LOG_WARNING, LOC + "Waited 100ms for decoder to pause");
964  }
965  m_pauseDecoder = false;
966  m_decoderPauseLock.unlock();
967  return m_decoderPaused;
968 }
969 
971 {
972  m_decoderPauseLock.lock();
973 
975  {
976  m_decoderPaused = false;
977  m_decoderThreadUnpause.wakeAll();
978  m_decoderPauseLock.unlock();
979  return;
980  }
981 
982  if (!IsInStillFrame())
983  {
984  int tries = 0;
985  m_unpauseDecoder = true;
986  while (m_decoderThread && !m_killDecoder && (tries++ < 100) &&
988  {
989  emit CheckCallbacks();
990  LOG(VB_GENERAL, LOG_WARNING, LOC + "Waited 100ms for decoder to unpause");
991  }
992  m_unpauseDecoder = false;
993  }
994  m_decoderPauseLock.unlock();
995 }
996 
997 void MythPlayer::DecoderStart(bool start_paused)
998 {
999  if (m_decoderThread)
1000  {
1001  if (m_decoderThread->isRunning())
1002  {
1003  LOG(VB_GENERAL, LOG_ERR, LOC + "Decoder thread already running");
1004  }
1005  delete m_decoderThread;
1006  }
1007 
1008  m_killDecoder = false;
1009  m_decoderPaused = start_paused;
1010  m_decoderThread = new MythDecoderThread(this, start_paused);
1011  if (m_decoderThread)
1013 }
1014 
1016 {
1017  PauseDecoder();
1018  SetPlaying(false);
1019  // Ensure any hardware frames are released (after pausing the decoder) to
1020  // allow the decoder to exit cleanly
1021  DiscardVideoFrames(true, true);
1022 
1023  m_killDecoder = true;
1024  int tries = 0;
1025  while (m_decoderThread && !m_decoderThread->wait(100ms) && (tries++ < 50))
1026  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1027  "Waited 100ms for decoder loop to stop");
1028 
1030  LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to stop decoder loop.");
1031  else
1032  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Exited decoder loop.");
1033  SetDecoder(nullptr);
1034 }
1035 
1037 {
1039  {
1040  if (m_pauseDecoder)
1041  PauseDecoder();
1042  if (m_unpauseDecoder)
1043  UnpauseDecoder();
1044  }
1045 }
1046 
1049 {
1052 
1053  if (!m_decoderChangeLock.tryLock(50))
1054  return kEofStateNone;
1055 
1057  m_decoderChangeLock.unlock();
1058  return eof;
1059 }
1060 
1062 {
1064  {
1065  if (m_decoder)
1066  m_decoder->SetEofState(eof);
1067  return;
1068  }
1069 
1070  if (!m_decoderChangeLock.tryLock(50))
1071  return;
1072 
1073  if (m_decoder)
1074  m_decoder->SetEofState(eof);
1075  m_decoderChangeLock.unlock();
1076 }
1078 
1079 void MythPlayer::DecoderLoop(bool pause)
1080 {
1081  if (pause)
1082  PauseDecoder();
1083 
1084  while (!m_killDecoder && !IsErrored())
1085  {
1087 
1089  {
1090  std::this_thread::sleep_for(1ms);
1091  continue;
1092  }
1093 
1095  {
1096  if (!m_decoderChangeLock.tryLock(1))
1097  continue;
1098  if (m_decoder)
1099  {
1100  m_forcePositionMapSync = false;
1102  }
1103  m_decoderChangeLock.unlock();
1104  }
1105 
1106  if (m_decoderSeek >= 0)
1107  {
1108  if (!m_decoderChangeLock.tryLock(1))
1109  continue;
1110  if (m_decoder)
1111  {
1112  m_decoderSeekLock.lock();
1113  if (((uint64_t)m_decoderSeek < m_framesPlayed) && m_decoder)
1115  else if (m_decoder)
1117  m_decoderSeek = -1;
1118  m_decoderSeekLock.unlock();
1119  }
1120  m_decoderChangeLock.unlock();
1121  }
1122 
1123  bool obey_eof = (GetEof() != kEofStateNone) &&
1125  if (m_isDummy || ((m_decoderPaused || m_ffrewSkip == 0 || obey_eof) &&
1126  !m_decodeOneFrame))
1127  {
1128  std::this_thread::sleep_for(1ms);
1129  continue;
1130  }
1131 
1134 
1135  DecoderGetFrame(dt);
1136  m_decodeOneFrame = false;
1137  }
1138 
1139  // Clear any wait conditions
1141  m_decoderSeek = -1;
1142 }
1143 
1145 {
1146  if (!m_decoder)
1147  return false;
1148 
1149  if (m_ffrewSkip > 0)
1150  {
1151  long long delta = m_decoder->GetFramesRead() - m_framesPlayed;
1152  long long real_skip = CalcMaxFFTime(m_ffrewSkip - m_ffrewAdjust + delta) - delta;
1153  long long target_frame = m_decoder->GetFramesRead() + real_skip;
1154  if (real_skip >= 0)
1155  {
1156  m_decoder->DoFastForward(target_frame, false);
1157  }
1158  long long seek_frame = m_decoder->GetFramesRead();
1159  m_ffrewAdjust = seek_frame - target_frame;
1160  }
1161  else if (CalcRWTime(-m_ffrewSkip) >= 0)
1162  {
1164  }
1166 }
1167 
1169 {
1170  long long cur_frame = m_decoder->GetFramesPlayed();
1171  bool toBegin = -cur_frame > m_ffrewSkip + m_ffrewAdjust;
1172  long long real_skip = (toBegin) ? -cur_frame : m_ffrewSkip + m_ffrewAdjust;
1173  long long target_frame = cur_frame + real_skip;
1174  bool ret = m_decoder->DoRewind(target_frame, false);
1175  long long seek_frame = m_decoder->GetFramesPlayed();
1176  m_ffrewAdjust = target_frame - seek_frame;
1177  return ret;
1178 }
1179 
1180 bool MythPlayer::DecoderGetFrame(DecodeType decodetype, bool unsafe)
1181 {
1182  bool ret = false;
1183  if (!m_videoOutput)
1184  return false;
1185 
1186  // Wait for frames to be available for decoding onto
1187  int tries = 0;
1188  while (!unsafe && (!m_videoOutput->EnoughFreeFrames() || m_audio.IsBufferAlmostFull()))
1189  {
1191  return false;
1192 
1193  if (++tries > 10)
1194  {
1195  if (++m_videobufRetries >= 2000)
1196  {
1197  LOG(VB_GENERAL, LOG_ERR, LOC +
1198  "Decoder timed out waiting for free video buffers.");
1199  // We've tried for 20 seconds now, give up so that we don't
1200  // get stuck permanently in this state
1201  SetErrored("Decoder timed out waiting for free video buffers.");
1202  }
1203  return false;
1204  }
1205  std::this_thread::sleep_for(1ms);
1206  }
1207  m_videobufRetries = 0;
1208 
1209  if (!m_decoderChangeLock.tryLock(5))
1210  return false;
1212  {
1213  m_decoderChangeLock.unlock();
1214  return false;
1215  }
1216 
1217  if (m_ffrewSkip == 1 || m_decodeOneFrame)
1218  ret = DoGetFrame(decodetype);
1219  else if (m_ffrewSkip != 0)
1220  ret = DecoderGetFrameFFREW();
1221  m_decoderChangeLock.unlock();
1222  return ret;
1223 }
1224 
1239 {
1240  bool ret = false;
1241  QElapsedTimer timeout;
1242  timeout.start();
1243  bool retry = true;
1244  // retry for a maximum of 5 seconds
1245  while (retry && !m_pauseDecoder && !m_killDecoder && !timeout.hasExpired(5000))
1246  {
1247  retry = false;
1248  ret = m_decoder->GetFrame(Type, retry);
1249  if (retry)
1250  {
1251  m_decoderChangeLock.unlock();
1252  QThread::usleep(10000);
1253  m_decoderChangeLock.lock();
1254  }
1255  }
1256 
1257  if (timeout.hasExpired(5000))
1258  return false;
1259  return ret;
1260 }
1261 
1262 void MythPlayer::WrapTimecode(std::chrono::milliseconds &timecode, TCTypes tc_type)
1263 {
1264  timecode += m_tcWrap[tc_type];
1265 }
1266 
1267 bool MythPlayer::PrepareAudioSample(std::chrono::milliseconds &timecode)
1268 {
1269  WrapTimecode(timecode, TC_AUDIO);
1270  return false;
1271 }
1272 
1274 {
1275  uint64_t bookmark = 0;
1276 
1279  bookmark = 0;
1280  else
1281  {
1282  m_playerCtx->LockPlayingInfo(__FILE__, __LINE__);
1283  if (const ProgramInfo *pi = m_playerCtx->m_playingInfo)
1284  {
1285  bookmark = pi->QueryBookmark();
1286  // Disable progstart if the program has a cutlist.
1287  if (bookmark == 0 && !pi->HasCutlist())
1288  bookmark = pi->QueryProgStart();
1289  if (bookmark == 0)
1290  bookmark = pi->QueryLastPlayPos();
1291  }
1292  m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
1293  }
1294 
1295  return bookmark;
1296 }
1297 
1299 {
1300  bool skip_changed = false;
1301 
1302  float temp_speed = (m_playSpeed == 0.0F) ?
1304  if (m_playSpeed >= 0.0F && m_playSpeed <= 3.0F)
1305  {
1306  skip_changed = (m_ffrewSkip != 1);
1307  if (m_decoder)
1309  m_frameInterval = microsecondsFromFloat((1000000.0 / m_videoFrameRate / static_cast<double>(temp_speed))
1310  / m_fpsMultiplier);
1311  m_ffrewSkip = static_cast<int>(m_playSpeed != 0.0F);
1312  }
1313  else
1314  {
1315  skip_changed = true;
1316  m_frameInterval = 200000us;
1317  m_frameInterval = (fabs(m_playSpeed) >= 3.0F) ? 133466us : m_frameInterval;
1318  m_frameInterval = (fabs(m_playSpeed) >= 5.0F) ? 133466us : m_frameInterval;
1319  m_frameInterval = (fabs(m_playSpeed) >= 8.0F) ? 250250us : m_frameInterval;
1320  m_frameInterval = (fabs(m_playSpeed) >= 10.0F) ? 133466us : m_frameInterval;
1321  m_frameInterval = (fabs(m_playSpeed) >= 16.0F) ? 187687us : m_frameInterval;
1322  m_frameInterval = (fabs(m_playSpeed) >= 20.0F) ? 150150us : m_frameInterval;
1323  m_frameInterval = (fabs(m_playSpeed) >= 30.0F) ? 133466us : m_frameInterval;
1324  m_frameInterval = (fabs(m_playSpeed) >= 60.0F) ? 133466us : m_frameInterval;
1325  m_frameInterval = (fabs(m_playSpeed) >= 120.0F) ? 133466us : m_frameInterval;
1326  m_frameInterval = (fabs(m_playSpeed) >= 180.0F) ? 133466us : m_frameInterval;
1327  float ffw_fps = fabs(static_cast<double>(m_playSpeed)) * m_videoFrameRate;
1328  float dis_fps = 1000000.0F / m_frameInterval.count();
1329  m_ffrewSkip = (int)ceil(ffw_fps / dis_fps);
1331  m_ffrewAdjust = 0;
1332  }
1333 
1334  return skip_changed;
1335 }
1336 
1338 {
1339  float last_speed = m_playSpeed;
1343 
1344  bool skip_changed = UpdateFFRewSkip();
1345 
1346  if (skip_changed && m_videoOutput)
1347  {
1349  if (m_playSpeed != 0.0F && !(last_speed == 0.0F && m_ffrewSkip == 1))
1351  }
1352 
1353  LOG(VB_PLAYBACK, LOG_INFO, LOC + "Play speed: " +
1354  QString("rate: %1 speed: %2 skip: %3 => new interval %4")
1355  .arg(m_videoFrameRate).arg(static_cast<double>(m_playSpeed))
1356  .arg(m_ffrewSkip).arg(m_frameInterval.count()));
1357 
1358  if (m_videoOutput)
1359  m_videoOutput->SetVideoFrameRate(static_cast<float>(m_videoFrameRate));
1360 
1362  {
1365  }
1366 }
1367 
1368 bool MythPlayer::DoRewind(uint64_t frames, double inaccuracy)
1369 {
1371  return false;
1372 
1373  uint64_t number = frames + 1;
1374  uint64_t desiredFrame = (m_framesPlayed > number) ? m_framesPlayed - number : 0;
1375 
1376  m_limitKeyRepeat = false;
1377  if (desiredFrame < m_videoFrameRate)
1378  m_limitKeyRepeat = true;
1379 
1380  uint64_t seeksnap_wanted = UINT64_MAX;
1381  if (inaccuracy != kInaccuracyFull)
1382  seeksnap_wanted = frames * inaccuracy;
1383  ClearBeforeSeek(frames);
1384  WaitForSeek(desiredFrame, seeksnap_wanted);
1385  m_rewindTime = 0;
1386  ClearAfterSeek();
1387  return true;
1388 }
1389 
1395 long long MythPlayer::CalcRWTime(long long rw) const
1396 {
1397  bool hasliveprev = (m_liveTV && m_playerCtx->m_tvchain &&
1399 
1400  if (!hasliveprev || ((int64_t)m_framesPlayed >= rw))
1401  {
1402  return rw;
1403  }
1404 
1405  auto seconds = secondsFromFloat((m_framesPlayed - rw) / m_videoFrameRate);
1406  m_playerCtx->m_tvchain->JumpToNext(false, seconds);
1407 
1408  return -1;
1409 }
1410 
1415 long long MythPlayer::CalcMaxFFTime(long long ffframes, bool setjump) const
1416 {
1417  float maxtime = 1.0;
1418  bool islivetvcur = (m_liveTV && m_playerCtx->m_tvchain &&
1420 
1421  if (m_liveTV || IsWatchingInprogress())
1422  maxtime = 3.0;
1423 
1424  long long ret = ffframes;
1425  float ff = ComputeSecs(ffframes, true);
1426  float secsPlayed = ComputeSecs(m_framesPlayed, true);
1427  float secsWritten = ComputeSecs(m_totalFrames, true);
1428 
1429  m_limitKeyRepeat = false;
1430 
1431  if (m_liveTV && !islivetvcur && m_playerCtx->m_tvchain)
1432  {
1433  // recording has completed, totalFrames will always be up to date
1434  if ((ffframes + m_framesPlayed > m_totalFrames) && setjump)
1435  {
1436  ret = -1;
1437  // Number of frames to be skipped is from the end of the current segment
1438  auto seconds = secondsFromFloat((m_totalFrames - m_framesPlayed - ffframes)
1439  / m_videoFrameRate);
1440  m_playerCtx->m_tvchain->JumpToNext(true, seconds);
1441  }
1442  }
1443  else if (islivetvcur || IsWatchingInprogress())
1444  {
1445  if ((ff + secsPlayed) > secsWritten)
1446  {
1447  // If we attempt to seek past the last known duration,
1448  // check for up to date data
1449  long long framesWritten = m_playerCtx->m_recorder->GetFramesWritten();
1450 
1451  secsWritten = ComputeSecs(framesWritten, true);
1452  }
1453 
1454  float behind = secsWritten - secsPlayed;
1455 
1456  if (behind < maxtime) // if we're close, do nothing
1457  ret = 0;
1458  else if (behind - ff <= maxtime)
1459  {
1460  auto msec = millisecondsFromFloat(1000 * (secsWritten - maxtime));
1461  ret = TranslatePositionMsToFrame(msec, true) - m_framesPlayed;
1462  }
1463 
1464  if (behind < maxtime * 3)
1465  m_limitKeyRepeat = true;
1466  }
1467  else if (IsPaused())
1468  {
1469  uint64_t lastFrame =
1471  if (m_framesPlayed + ffframes >= lastFrame)
1472  ret = lastFrame - 1 - m_framesPlayed;
1473  }
1474  else
1475  {
1476  float secsMax = secsWritten - 2.F * maxtime;
1477  if (secsMax <= 0.F)
1478  ret = 0;
1479  else if (secsMax < secsPlayed + ff)
1480  {
1481  auto msec = millisecondsFromFloat(1000 * secsMax);
1482  ret = TranslatePositionMsToFrame(msec, true) - m_framesPlayed;
1483  }
1484  }
1485 
1486  return ret;
1487 }
1488 
1496 {
1497  if (!m_videoOutput || !m_decoder)
1498  return false;
1499 
1500  return m_playerCtx->m_buffer->IsNearEnd(
1502 }
1503 
1507 {
1508  if (!m_playerCtx)
1509  return false;
1510 
1511  m_playerCtx->LockPlayingInfo(__FILE__, __LINE__);
1513  !m_decoder)
1514  {
1515  m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
1516  return false;
1517  }
1518  m_playerCtx->UnlockPlayingInfo(__FILE__, __LINE__);
1519 
1520  auto margin = (long long)(m_videoFrameRate * 2);
1521  margin = (long long) (margin * m_audio.GetStretchFactor());
1522  bool watchingTV = IsWatchingInprogress();
1523 
1524  uint64_t framesRead = m_framesPlayed;
1525  uint64_t framesLeft = 0;
1526 
1528  {
1529  if (framesRead >= m_deleteMap.GetLastFrame())
1530  return true;
1531  uint64_t frameCount = GetCurrentFrameCount();
1532  framesLeft = (frameCount > framesRead) ? frameCount - framesRead : 0;
1533  return (framesLeft < (uint64_t)margin);
1534  }
1535 
1536  if (!m_liveTV && !watchingTV)
1537  return false;
1538 
1540  return false;
1541 
1542  if (m_playerCtx->m_recorder)
1543  {
1544  framesLeft =
1546 
1547  // if it looks like we are near end, get an updated GetFramesWritten()
1548  if (framesLeft < (uint64_t)margin)
1549  framesLeft = m_playerCtx->m_recorder->GetFramesWritten() - framesRead;
1550  }
1551 
1552  return (framesLeft < (uint64_t)margin);
1553 }
1554 
1555 bool MythPlayer::DoFastForward(uint64_t frames, double inaccuracy)
1556 {
1558  return false;
1559 
1560  uint64_t number = (frames ? frames - 1 : 0);
1561  uint64_t desiredFrame = m_framesPlayed + number;
1562 
1563  if (!m_deleteMap.IsEditing() && IsInDelete(desiredFrame))
1564  {
1565  uint64_t endcheck = m_deleteMap.GetLastFrame();
1566  if (desiredFrame > endcheck)
1567  desiredFrame = endcheck;
1568  }
1569 
1570  uint64_t seeksnap_wanted = UINT64_MAX;
1571  if (inaccuracy != kInaccuracyFull)
1572  seeksnap_wanted = frames * inaccuracy;
1573  ClearBeforeSeek(frames);
1574  WaitForSeek(desiredFrame, seeksnap_wanted);
1575  m_ffTime = 0;
1576  ClearAfterSeek(false);
1577  return true;
1578 }
1579 
1580 void MythPlayer::DoJumpToFrame(uint64_t frame, double inaccuracy)
1581 {
1582  if (frame > m_framesPlayed)
1583  DoFastForward(frame - m_framesPlayed, inaccuracy);
1584  else
1585  DoRewind(m_framesPlayed - frame, inaccuracy);
1586 }
1587 
1588 void MythPlayer::WaitForSeek(uint64_t frame, uint64_t seeksnap_wanted)
1589 {
1590  if (!m_decoder)
1591  return;
1592 
1594  m_decoder->SetSeekSnap(seeksnap_wanted);
1595 
1596  bool islivetvcur = (m_liveTV && m_playerCtx->m_tvchain &&
1598 
1599  uint64_t max = GetCurrentFrameCount();
1600  if (islivetvcur || IsWatchingInprogress())
1601  {
1602  max = (uint64_t)m_playerCtx->m_recorder->GetFramesWritten();
1603  }
1604  if (frame >= max)
1605  frame = max - 1;
1606 
1607  m_decoderSeekLock.lock();
1608  m_decoderSeek = frame;
1609  m_decoderSeekLock.unlock();
1610 
1611  int count = 0;
1612  bool needclear = false;
1613  while (m_decoderSeek >= 0)
1614  {
1615  // Waiting blocks the main UI thread but the decoder may
1616  // have initiated a callback into the UI thread to create
1617  // certain resources. Ensure the callback is processed.
1618  // Ideally MythPlayer should be fully event driven and these
1619  // calls wouldn't be necessary.
1620  emit CheckCallbacks();
1621 
1622  // Wait a little
1623  std::this_thread::sleep_for(50ms);
1624 
1625  // provide some on screen feedback if seeking is slow
1626  count++;
1627  if (!(count % 3) && !m_hasFullPositionMap)
1628  {
1629  emit SeekingSlow(count);
1630  needclear = true;
1631  }
1632  }
1633  if (needclear)
1634  emit SeekingComplete();
1635 }
1636 
1649 void MythPlayer::ClearAfterSeek(bool clearvideobuffers)
1650 {
1651  LOG(VB_PLAYBACK, LOG_INFO, LOC + QString("ClearAfterSeek(%1)")
1652  .arg(clearvideobuffers));
1653 
1654  if (clearvideobuffers && m_videoOutput)
1656 
1657  std::chrono::milliseconds savedTC = m_tcWrap[TC_AUDIO];
1658 
1659  m_tcWrap.fill(0ms);
1660  m_tcWrap[TC_AUDIO] = savedTC;
1661  m_audio.Reset();
1662 
1663  emit RequestResetCaptions();
1667  m_needNewPauseFrame = true;
1668 
1669  m_avSync.InitAVSync();
1670 }
1671 
1679 // NOLINTNEXTLINE(readability-convert-member-functions-to-static)
1680 void MythPlayer::ClearBeforeSeek(uint64_t Frames)
1681 {
1682 #ifdef USING_MEDIACODEC
1683  LOG(VB_PLAYBACK, LOG_DEBUG, LOC + QString("ClearBeforeSeek: decoder %1 frames %2 recording %3 livetv %4")
1685 
1686  if ((Frames < 2) || !m_videoOutput /*|| !(m_liveTV || m_watchingRecording)*/)
1687  return;
1688 
1689  m_decoderChangeLock.lock();
1691  m_decoderChangeLock.unlock();
1692  if (codec_is_mediacodec(codec))
1693  m_videoOutput->DiscardFrames(true, true);
1694 #else
1695  Q_UNUSED(Frames);
1696 #endif
1697 }
1698 
1699 bool MythPlayer::IsInDelete(uint64_t frame)
1700 {
1701  return m_deleteMap.IsInDelete(frame);
1702 }
1703 
1705 {
1707 }
1708 
1709 QString MythPlayer::GetEncodingType(void) const
1710 {
1711  if (m_decoder)
1713  return QString();
1714 }
1715 
1717 {
1718  if (m_decoder)
1719  return m_decoder->GetRawAudioState();
1720  return false;
1721 }
1722 
1723 QString MythPlayer::GetXDS(const QString &key) const
1724 {
1725  if (!m_decoder)
1726  return QString();
1727  return m_decoder->GetXDS(key);
1728 }
1729 
1731 {
1733  m_forcePositionMapSync = true;
1734 }
1735 
1736 // Returns the total frame count, as totalFrames for a completed
1737 // recording, or the most recent frame count from the recorder for
1738 // live TV or an in-progress recording.
1740 {
1741  uint64_t result = m_totalFrames;
1742  if (IsWatchingInprogress())
1744  return result;
1745 }
1746 
1747 // Finds the frame number associated with the given time offset. A
1748 // positive offset or +0.0F indicate offset from the beginning. A
1749 // negative offset or -0.0F indicate offset from the end. Limit the
1750 // result to within bounds of the video.
1751 uint64_t MythPlayer::FindFrame(float offset, bool use_cutlist) const
1752 {
1753  bool islivetvcur = (m_liveTV && m_playerCtx->m_tvchain &&
1755  std::chrono::milliseconds length_ms = TranslatePositionFrameToMs(m_totalFrames, use_cutlist);
1756  std::chrono::milliseconds position_ms = 0ms;
1757  auto offset_ms = std::chrono::milliseconds(llroundf(fabsf(offset) * 1000));
1758 
1759  if (signbit(offset))
1760  {
1761  // Always get an updated totalFrame value for in progress recordings
1762  if (islivetvcur || IsWatchingInprogress())
1763  {
1764  uint64_t framesWritten = m_playerCtx->m_recorder->GetFramesWritten();
1765 
1766  if (m_totalFrames < framesWritten)
1767  {
1768  // Known duration is less than what the backend reported, use new value
1769  length_ms =
1770  TranslatePositionFrameToMs(framesWritten, use_cutlist);
1771  }
1772  }
1773  position_ms = (offset_ms > length_ms) ? 0ms : length_ms - offset_ms;
1774  }
1775  else
1776  {
1777  position_ms = offset_ms;
1778  if (offset_ms > length_ms)
1779  {
1780  // Make sure we have an updated totalFrames
1781  if ((islivetvcur || IsWatchingInprogress()) &&
1782  (length_ms < offset_ms))
1783  {
1784  long long framesWritten =
1786 
1787  length_ms =
1788  TranslatePositionFrameToMs(framesWritten, use_cutlist);
1789  }
1790  position_ms = std::min(position_ms, length_ms);
1791  }
1792  }
1793  return TranslatePositionMsToFrame(position_ms, use_cutlist);
1794 }
1795 
1796 // If position == -1, it signifies that we are computing the current
1797 // duration of an in-progress recording. In this case, we fetch the
1798 // current frame rate and frame count from the recorder.
1799 std::chrono::milliseconds MythPlayer::TranslatePositionFrameToMs(uint64_t position,
1800  bool use_cutlist) const
1801 {
1802  float frameRate = GetFrameRate();
1803  if (position == UINT64_MAX &&
1805  {
1806  float recorderFrameRate = m_playerCtx->m_recorder->GetFrameRate();
1807  if (recorderFrameRate > 0)
1808  frameRate = recorderFrameRate;
1809  position = m_playerCtx->m_recorder->GetFramesWritten();
1810  }
1811  return m_deleteMap.TranslatePositionFrameToMs(position, frameRate,
1812  use_cutlist);
1813 }
1814 
1816 {
1817  if (m_decoder)
1818  return m_decoder->GetNumChapters();
1819  return 0;
1820 }
1821 
1823 {
1824  if (m_decoder)
1826  return 0;
1827 }
1828 
1829 void MythPlayer::GetChapterTimes(QList<std::chrono::seconds> &times)
1830 {
1831  if (m_decoder)
1832  m_decoder->GetChapterTimes(times);
1833 }
1834 
1835 bool MythPlayer::DoJumpChapter(int chapter)
1836 {
1837  int64_t desiredFrame = -1;
1838  int total = GetNumChapters();
1839  int current = GetCurrentChapter();
1840 
1841  if (chapter < 0 || chapter > total)
1842  {
1843 
1844  if (chapter < 0)
1845  {
1846  chapter = current -1;
1847  if (chapter < 0) chapter = 0;
1848  }
1849  else if (chapter > total)
1850  {
1851  chapter = current + 1;
1852  if (chapter > total) chapter = total;
1853  }
1854  }
1855 
1856  desiredFrame = GetChapter(chapter);
1857  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1858  QString("DoJumpChapter: current %1 want %2 (frame %3)")
1859  .arg(current).arg(chapter).arg(desiredFrame));
1860 
1861  if (desiredFrame < 0)
1862  {
1863  LOG(VB_PLAYBACK, LOG_ERR, LOC + QString("DoJumpChapter failed."));
1864  m_jumpChapter = 0;
1865  return false;
1866  }
1867 
1868  DoJumpToFrame(desiredFrame, kInaccuracyNone);
1869  m_jumpChapter = 0;
1870  return true;
1871 }
1872 
1873 int64_t MythPlayer::GetChapter(int chapter)
1874 {
1875  if (m_decoder)
1876  return m_decoder->GetChapter(chapter);
1877  return 0;
1878 }
1879 
1884 {
1885  m_totalDecoderPause = true;
1886  PauseDecoder();
1887 
1888  {
1889  while (!m_decoderChangeLock.tryLock(10))
1890  LOG(VB_GENERAL, LOG_INFO, LOC + "Waited 10ms for decoder lock");
1891  delete m_decoder;
1892  m_decoder = dec;
1893  if (m_decoder)
1895  m_decoderChangeLock.unlock();
1896  }
1897  // reset passthrough override
1898  m_disablePassthrough = false;
1900  m_totalDecoderPause = false;
1901 }
1902 
1903 bool MythPlayer::PosMapFromEnc(uint64_t start,
1904  frm_pos_map_t &posMap,
1905  frm_pos_map_t &durMap)
1906 {
1907  // Reads only new positionmap entries from encoder
1908  if (!(m_liveTV || (m_playerCtx->m_recorder &&
1910  return false;
1911 
1912  // if livetv, and we're not the last entry, don't get it from the encoder
1913  if (HasTVChainNext())
1914  return false;
1915 
1916  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1917  QString("Filling position map from %1 to %2") .arg(start).arg("end"));
1918 
1919  m_playerCtx->m_recorder->FillPositionMap(start, -1, posMap);
1920  m_playerCtx->m_recorder->FillDurationMap(start, -1, durMap);
1921 
1922  return true;
1923 }
1924 
1925 void MythPlayer::SetErrored(const QString &reason)
1926 {
1927  QMutexLocker locker(&m_errorLock);
1928 
1929  if (m_videoOutput)
1931 
1932  if (m_errorMsg.isEmpty())
1933  {
1934  m_errorMsg = reason;
1935  }
1936  else
1937  {
1938  LOG(VB_GENERAL, LOG_ERR, LOC + QString("%1").arg(reason));
1939  }
1940 }
1941 
1943 {
1944  QMutexLocker locker(&m_errorLock);
1945 
1946  m_errorMsg = QString();
1947 }
1948 
1949 bool MythPlayer::IsErrored(void) const
1950 {
1951  QMutexLocker locker(&m_errorLock);
1952  return !m_errorMsg.isEmpty();
1953 }
1954 
1955 QString MythPlayer::GetError(void) const
1956 {
1957  QMutexLocker locker(&m_errorLock);
1958  return m_errorMsg;
1959 }
1960 
1962 {
1963  if (!m_decoder)
1964  return;
1965 
1967 }
1968 
1970 {
1971  if (!m_decoder)
1972  return;
1973 
1975 }
1976 
1978 {
1979  if (!m_decoder)
1980  return;
1981 
1983 }
1984 
1986 {
1987  if (m_decoder && m_audio.HasAudioOut())
1988  {
1989  float stretch = m_audio.GetStretchFactor();
1990  m_disablePassthrough |= (stretch < 0.99F) || (stretch > 1.01F);
1991  LOG(VB_PLAYBACK, LOG_INFO, LOC +
1992  QString("Stretch Factor %1, %2 passthru ")
1994  .arg((m_disablePassthrough) ? "disable" : "allow"));
1996  }
1997 }
1998 
2000 {
2001  if (m_decoder && m_audio.HasAudioOut())
2003 }
2004 
2006 {
2007  if (m_decoder && m_audio.HasAudioOut())
2009 }
2010 
2011 static unsigned dbg_ident(const MythPlayer *player)
2012 {
2013  static QMutex s_dbgLock;
2014  static unsigned s_dbgNextIdent = 0;
2015  using DbgMapType = QHash<const MythPlayer*, unsigned>;
2016  static DbgMapType s_dbgIdent;
2017 
2018  QMutexLocker locker(&s_dbgLock);
2019  DbgMapType::iterator it = s_dbgIdent.find(player);
2020  if (it != s_dbgIdent.end())
2021  return *it;
2022  return s_dbgIdent[player] = s_dbgNextIdent++;
2023 }
MythPlayer::IsNearEnd
bool IsNearEnd(void)
Returns true iff near end of recording.
Definition: mythplayer.cpp:1506
DeleteMap::SetPlayerContext
void SetPlayerContext(PlayerContext *ctx)
Definition: deletemap.h:31
DecoderBase::GetCurrentChapter
virtual int GetCurrentChapter(long long)
Definition: decoderbase.h:155
kLiveTVAutoExpire
@ kLiveTVAutoExpire
Definition: programtypes.h:239
kDecodeAV
@ kDecodeAV
Definition: decoderbase.h:52
MythPlayer::m_buffering
bool m_buffering
Definition: mythplayer.h:449
DecoderBase::DoFastForward
virtual bool DoFastForward(long long desiredFrame, bool discardFrames=true)
Skips ahead or rewinds to desiredFrame.
Definition: decoderbase.cpp:710
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:2011
PlayerContext::GetState
TVState GetState(void) const
Definition: playercontext.cpp:333
MythPlayer::m_enableForcedSubtitles
bool m_enableForcedSubtitles
Definition: mythplayer.h:464
LiveTVChain::GetCurPos
int GetCurPos(void) const
Definition: livetvchain.h:54
MythPlayer::m_errorLock
QMutex m_errorLock
Definition: mythplayer.h:400
MThread::start
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
Definition: mthread.cpp:286
hardwareprofile.smolt.timeout
float timeout
Definition: smolt.py:103
kDecoderProbeBufferSize
const int kDecoderProbeBufferSize
Definition: decoderbase.h:22
MythPlayer::m_videoPaused
bool m_videoPaused
Definition: mythplayer.h:393
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:184
DecoderBase::GetFramesPlayed
long long GetFramesPlayed(void) const
Definition: decoderbase.h:204
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:245
MythPlayer::m_watchingRecording
bool m_watchingRecording
Definition: mythplayer.h:404
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:616
RemoteEncoder::GetRecorderNumber
int GetRecorderNumber(void) const
Definition: remoteencoder.cpp:61
MythPlayer::SetEof
void SetEof(EofState eof)
Definition: mythplayer.cpp:1061
MythPlayer::m_inJumpToProgramPause
bool m_inJumpToProgramPause
Definition: mythplayer.h:386
AudioPlayer::Reset
void Reset(void)
Definition: audioplayer.cpp:83
MythPlayer::UpdateFFRewSkip
bool UpdateFFRewSkip(void)
Definition: mythplayer.cpp:1298
MythPlayer::m_bufferPaused
bool m_bufferPaused
Definition: mythplayer.h:392
MythPlayer::m_commBreakMap
CommBreakMap m_commBreakMap
Definition: mythplayer.h:476
DecoderBase::GetEof
EofState GetEof(void)
Definition: decoderbase.h:135
MythPlayer::ChangeSpeed
virtual void ChangeSpeed(void)
Definition: mythplayer.cpp:1337
MythPlayer::m_decoderThread
MythDecoderThread * m_decoderThread
Definition: mythplayer.h:368
MythPlayer::m_cc608
CC608Reader m_cc608
Definition: mythplayer.h:469
DeleteMap::TrackerReset
void TrackerReset(uint64_t frame)
Resets the internal state tracker.
Definition: deletemap.cpp:806
kEofStateNone
@ kEofStateNone
Definition: decoderbase.h:69
MythPlayer::m_bufferingCounter
int m_bufferingCounter
Definition: mythplayer.h:503
PlayerContext::SetPlayingInfo
void SetPlayingInfo(const ProgramInfo *info)
assign programinfo to the context
Definition: playercontext.cpp:502
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:240
LiveTVChain::HasNext
bool HasNext(void) const
Definition: livetvchain.cpp:405
MythPlayer::CheckCallbacks
void CheckCallbacks()
MythPlayer::m_ffrewAdjust
int m_ffrewAdjust
Definition: mythplayer.h:490
MythPlayer::m_decoderThreadUnpause
QWaitCondition m_decoderThreadUnpause
Definition: mythplayer.h:377
kCodec_NONE
@ kCodec_NONE
Definition: mythcodecid.h:14
MythPlayer::UnpauseBuffer
void UnpauseBuffer(void)
Definition: mythplayer.cpp:150
MythPlayer::SeekingSlow
void SeekingSlow(int Count)
MythPlayer::m_avSync
MythPlayerAVSync m_avSync
Definition: mythplayer.h:431
MythPlayer::DecoderPauseCheck
virtual void DecoderPauseCheck(void)
Definition: mythplayer.cpp:1036
MythPlayer::m_playSpeed
float m_playSpeed
Definition: mythplayer.h:485
MythVideoOutput::FreeVideoFrames
int FreeVideoFrames()
Returns number of frames available for decoding onto.
Definition: mythvideoout.cpp:281
MythPlayer::m_frameInterval
std::chrono::microseconds m_frameInterval
always adjusted for play_speed
Definition: mythplayer.h:487
kMusicChoice
@ kMusicChoice
Definition: mythplayer.h:74
RemoteEncoder::FillDurationMap
void FillDurationMap(int64_t start, int64_t end, frm_pos_map_t &durationMap)
Definition: remoteencoder.cpp:293
MythVideoOutput::GetError
VideoErrorState GetError() const
Definition: mythvideoout.cpp:257
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:303
MythPlayer::CheckTVChain
void CheckTVChain()
Definition: mythplayer.cpp:911
MythPlayer::m_totalDecoderPause
bool m_totalDecoderPause
Definition: mythplayer.h:384
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:895
MythPlayer::m_nextNormalSpeed
bool m_nextNormalSpeed
Definition: mythplayer.h:492
CardUtil::SetStartChannel
static bool SetStartChannel(uint inputid, const QString &channum)
Definition: cardutil.cpp:1612
MythPlayer::PrebufferEnoughFrames
virtual bool PrebufferEnoughFrames(int min_buffers=0)
Definition: mythplayer.cpp:707
MythPlayer::m_totalDuration
std::chrono::seconds m_totalDuration
Definition: mythplayer.h:428
CommBreakMap::SetTracker
void SetTracker(uint64_t framesPlayed)
Definition: commbreakmap.cpp:66
MythPlayer::PrepareAudioSample
virtual bool PrepareAudioSample(std::chrono::milliseconds &timecode)
Definition: mythplayer.cpp:1267
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:424
MythPlayer::IsPaused
bool IsPaused(void) const
Definition: mythplayer.h:151
MythPlayer::m_decoderSeekLock
QMutex m_decoderSeekLock
Definition: mythplayer.h:379
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:374
MythPlayer::m_forcePositionMapSync
bool m_forcePositionMapSync
Definition: mythplayer.h:477
MythPlayer::HasReachedEof
virtual bool HasReachedEof(void) const
Definition: mythplayer.cpp:643
MythPlayer::AudioEnd
virtual void AudioEnd(void)
Definition: mythplayer.cpp:941
TC_VIDEO
@ TC_VIDEO
Definition: mythplayer.h:54
MythCoreContext::IsDatabaseIgnored
bool IsDatabaseIgnored(void) const
/brief Returns true if database is being ignored.
Definition: mythcorecontext.cpp:896
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
arg
arg(title).arg(filename).arg(doDelete))
ProgramInfo::GetChannelSchedulingID
QString GetChannelSchedulingID(void) const
This is the unique programming identifier of a channel.
Definition: programinfo.h:381
AudioPlayer::SetStretchFactor
void SetStretchFactor(float factor)
Definition: audioplayer.cpp:369
MythPlayer::m_ffrewSkip
int m_ffrewSkip
Definition: mythplayer.h:489
frm_dir_map_t
QMap< uint64_t, MarkTypes > frm_dir_map_t
Frame # -> Mark map.
Definition: programtypes.h:82
FrameScanType
FrameScanType
Definition: videoouttypes.h:94
MythPlayer::syncWithAudioStretch
void syncWithAudioStretch()
Definition: mythplayer.cpp:1985
MythPlayer::m_errorMsg
QString m_errorMsg
Reason why NVP exited with a error.
Definition: mythplayer.h:401
MythPlayer::m_bufferPauseLock
QMutex m_bufferPauseLock
Definition: mythplayer.h:380
AudioPlayer::CheckFormat
void CheckFormat(void)
Definition: audioplayer.cpp:172
DecoderBase::IsErrored
bool IsErrored() const
Definition: decoderbase.h:225
AudioPlayer::IsBufferAlmostFull
bool IsBufferAlmostFull(void)
Definition: audioplayer.cpp:493
MythPlayer::SaveTotalFrames
void SaveTotalFrames(void)
Definition: mythplayer.cpp:1977
MythPlayer::IsErrored
bool IsErrored(void) const
Definition: mythplayer.cpp:1949
MythPlayer::m_normalSpeed
bool m_normalSpeed
Definition: mythplayer.h:493
RemoteEncoder::GetFramesWritten
long long GetFramesWritten(void)
Returns number of frames written to disk by TVRec's RecorderBase instance.
Definition: remoteencoder.cpp:193
CC608Reader::SetTTPageNum
void SetTTPageNum(int page)
Definition: cc608reader.h:85
MythPlayer::GetFrameRate
float GetFrameRate(void) const
Definition: mythplayer.h:133
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:697
LOG
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
Definition: mythlogging.h:23
MythMediaBuffer::GetSafeFilename
QString GetSafeFilename(void)
Definition: mythmediabuffer.cpp:1736
MythPlayer::GetCurrentFrameCount
uint64_t GetCurrentFrameCount(void) const
Definition: mythplayer.cpp:1739
MythPlayer::IsPlaying
bool IsPlaying(std::chrono::milliseconds wait_in_msec=0ms, bool wait_for=true) const
Definition: mythplayer.cpp:257
AudioPlayer::HasAudioOut
bool HasAudioOut(void) const
Definition: audioplayer.h:54
VBIMode::Parse
static uint Parse(const QString &vbiformat)
Definition: tv.h:16
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
mythplayer.h
MythPlayer::m_pauseLock
QMutex m_pauseLock
Definition: mythplayer.h:382
MythVideoOutput::SetFramesPlayed
virtual void SetFramesPlayed(long long FramesPlayed)
Definition: mythvideoout.cpp:242
MythPlayer::CalcRWTime
long long CalcRWTime(long long rw) const
CalcRWTime(rw): rewind rw frames back.
Definition: mythplayer.cpp:1395
PlayerFlags
PlayerFlags
Definition: mythplayer.h:62
MythPlayer::GetEof
EofState GetEof(void) const
Definition: mythplayer.cpp:1048
MythPlayer::Pause
bool Pause(void)
Definition: mythplayer.cpp:159
MythPlayer
Definition: mythplayer.h:83
RemoteEncoder::IsValidRecorder
bool IsValidRecorder(void) const
Definition: remoteencoder.cpp:56
MythPlayer::GetBookmark
virtual uint64_t GetBookmark(void)
Definition: mythplayer.cpp:1273
DecoderBase::GetVideoCodecID
virtual MythCodecID GetVideoCodecID(void) const =0
MythPlayer::m_nextPlaySpeed
float m_nextPlaySpeed
Definition: mythplayer.h:484
MythPlayer::m_bufferingLastMsg
QTime m_bufferingLastMsg
Definition: mythplayer.h:451
MythPlayer::SeekingComplete
void SeekingComplete()
CommBreakMap::SetMap
void SetMap(const frm_dir_map_t &newMap, uint64_t framesPlayed)
Definition: commbreakmap.cpp:130
hardwareprofile.scan.scan
def scan(profile, smoonURL, gate)
Definition: scan.py:57
MythDate::current
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
Definition: mythdate.cpp:10
MythPlayer::m_videoPauseLock
QMutex m_videoPauseLock
Definition: mythplayer.h:381
MythPlayer::SetErrored
void SetErrored(const QString &reason)
Definition: mythplayer.cpp:1925
MythPlayer::GetEncodingType
QString GetEncodingType(void) const
Definition: mythplayer.cpp:1709
MythPlayer::DiscardVideoFrames
void DiscardVideoFrames(bool KeyFrame, bool Flushed)
Places frames in the available frames queue.
Definition: mythplayer.cpp:637
MythPlayer::m_needNewPauseFrame
bool m_needNewPauseFrame
Definition: mythplayer.h:391
MythMediaBuffer::GetStopReads
bool GetStopReads(void) const
Definition: mythmediabuffer.cpp:1767
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:840
MythPlayer::SetDecoder
void SetDecoder(DecoderBase *dec)
Sets the stream decoder, deleting any existing recorder.
Definition: mythplayer.cpp:1883
tmp
static guint32 * tmp
Definition: goom_core.cpp:31
MythPlayer::kInaccuracyNone
static const double kInaccuracyNone
Definition: mythplayer.h:241
MythVideoOutput::SetPrebuffering
void SetPrebuffering(bool Normal)
Sets whether to use a normal number of buffers or fewer buffers.
Definition: mythvideoout.cpp:263
MythPlayerAVSync::ResetAVSyncForLiveTV
bool ResetAVSyncForLiveTV(AudioPlayer *Audio)
Definition: mythplayeravsync.cpp:55
MythPlayer::ResetErrored
void ResetErrored(void)
Definition: mythplayer.cpp:1942
DecoderBase::GetChapter
virtual long long GetChapter(int)
Definition: decoderbase.h:157
MythPlayer::HasTVChainNext
bool HasTVChainNext(void) const
Definition: mythplayer.cpp:1704
MythPlayer::GetRawAudioState
bool GetRawAudioState(void) const
Definition: mythplayer.cpp:1716
MythPlayer::~MythPlayer
~MythPlayer() override
Definition: mythplayer.cpp:113
EofState
EofState
Definition: decoderbase.h:67
mythdecoderthread.h
MythPlayer::m_audio
AudioPlayer m_audio
Definition: mythplayer.h:473
DecoderBase::GetChapterTimes
virtual void GetChapterTimes(QList< std::chrono::seconds > &)
Definition: decoderbase.h:156
MythCodecID
MythCodecID
Definition: mythcodecid.h:10
MythPlayer::PauseChanged
void PauseChanged(bool Paused)
DecoderBase::SaveTotalDuration
void SaveTotalDuration(void)
Definition: decoderbase.cpp:1241
MythMediaBuffer::GetFilename
QString GetFilename(void) const
Definition: mythmediabuffer.cpp:1728
MythPlayer::UnpauseVideo
void UnpauseVideo(void)
Definition: mythplayer.cpp:230
MythPlayer::m_decoder
DecoderBase * m_decoder
Definition: mythplayer.h:363
MythPlayer::ComputeSecs
float ComputeSecs(uint64_t position, bool use_cutlist) const
Definition: mythplayer.h:273
RemoteEncoder::GetCachedFramesWritten
long long GetCachedFramesWritten(void) const
Return value last returned by GetFramesWritten().
Definition: remoteencoder.h:41
MythPlayer::m_framesPlayed
uint64_t m_framesPlayed
Definition: mythplayer.h:425
MythPlayer::m_rewindTime
long long m_rewindTime
Definition: mythplayer.h:429
DecoderBase::ForceSetupAudioStream
virtual void ForceSetupAudioStream(void)
Definition: decoderbase.h:147
MythPlayer::kNightModeBrightenssAdjustment
static const int kNightModeBrightenssAdjustment
Definition: mythplayer.h:239
programinfo.h
mythvideooutnull.h
MythPlayer::GetChapter
virtual int64_t GetChapter(int chapter)
Definition: mythplayer.cpp:1873
mythlogging.h
codec_is_mediacodec
#define codec_is_mediacodec(id)
Definition: mythcodecid.h:323
MythVideoOutput::ValidVideoFrames
virtual int ValidVideoFrames() const
Returns number of frames that are fully decoded.
Definition: mythvideoout.cpp:275
CommBreakMap::ResetLastSkip
void ResetLastSkip(void)
Definition: commbreakmap.cpp:26
MythPlayer::m_ffTime
long long m_ffTime
If m_ffTime>0, number of frames to seek forward.
Definition: mythplayer.h:420
MythMediaBuffer::WaitForPause
void WaitForPause(void)
Waits for Pause(void) to take effect.
Definition: mythmediabuffer.cpp:711
AudioPlayer::DeleteOutput
void DeleteOutput(void)
Definition: audioplayer.cpp:92
kScan_Progressive
@ kScan_Progressive
Definition: videoouttypes.h:100
MythPlayer::ClearBeforeSeek
void ClearBeforeSeek(uint64_t Frames)
Discard video frames prior to seeking.
Definition: mythplayer.cpp:1680
PlayerContext::m_playingInfo
ProgramInfo * m_playingInfo
Currently playing info.
Definition: playercontext.h:116
tv_actions.h
MythPlayer::m_tcWrap
tctype_arr m_tcWrap
Definition: mythplayer.h:496
MythPlayer::DecoderGetFrame
bool DecoderGetFrame(DecodeType decodetype, bool unsafe=false)
Definition: mythplayer.cpp:1180
MythPlayer::SetPlayingInfo
void SetPlayingInfo(const ProgramInfo &pginfo)
Definition: mythplayer.cpp:237
MythVideoOutput::ClearAfterSeek
virtual void ClearAfterSeek()
Tells video output to toss decoded buffers due to a seek.
Definition: mythvideoout.cpp:269
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:463
MythVideoOutput::DeLimboFrame
virtual void DeLimboFrame(MythVideoFrame *Frame)
Releases a frame for reuse if it is in limbo.
Definition: mythvideoout.cpp:400
RemoteEncoder::GetFrameRate
float GetFrameRate(void)
Returns recordering frame rate set by nvr.
Definition: remoteencoder.cpp:158
hardwareprofile.i18n.t
t
Definition: i18n.py:36
PlayerContext::LockPlayingInfo
void LockPlayingInfo(const char *file, int line) const
Definition: playercontext.cpp:233
MythPlayer::FindFrame
uint64_t FindFrame(float offset, bool use_cutlist) const
Definition: mythplayer.cpp:1751
MythPlayer::m_bookmarkSeek
uint64_t m_bookmarkSeek
Definition: mythplayer.h:413
MythVideoFrame::m_timecode
std::chrono::milliseconds m_timecode
Definition: mythframe.h:131
DecoderBase::GetfpsMultiplier
int GetfpsMultiplier(void) const
Definition: decoderbase.h:262
MythPlayer::DoJumpChapter
virtual bool DoJumpChapter(int chapter)
Definition: mythplayer.cpp:1835
MythVideoOutput::GetFrameStatus
QString GetFrameStatus() const
Returns string with status of each frame for debugging.
Definition: mythvideoout.cpp:306
MythPlayer::SetDuration
void SetDuration(std::chrono::seconds duration)
Definition: mythplayer.cpp:393
MythPlayer::m_videoOutput
MythVideoOutput * m_videoOutput
Definition: mythplayer.h:365
MythPlayer::m_hasFullPositionMap
bool m_hasFullPositionMap
Definition: mythplayer.h:406
MythPlayer::IsInDelete
bool IsInDelete(uint64_t frame)
Definition: mythplayer.cpp:1699
MythPlayer::m_clearSavedPosition
int m_clearSavedPosition
Definition: mythplayer.h:414
PlayerContext::m_buffer
MythMediaBuffer * m_buffer
Definition: playercontext.h:115
MythPlayer::MythDecoderThread
friend class MythDecoderThread
Definition: mythplayer.h:91
MythPlayer::MythPlayer
MythPlayer(PlayerContext *Context, PlayerFlags Flags=kNoFlags)
Definition: mythplayer.cpp:85
ScanTypeToString
QString ScanTypeToString(FrameScanType Scan)
Definition: videoouttypes.h:211
DecodeType
DecodeType
Definition: decoderbase.h:47
MythPlayer::m_decoderPauseLock
QMutex m_decoderPauseLock
Definition: mythplayer.h:378
MythPlayerAVSync::GetAVSyncAudioPause
bool GetAVSyncAudioPause() const
Definition: mythplayeravsync.cpp:45
MythVideoOutput::GetNextFreeFrame
virtual MythVideoFrame * GetNextFreeFrame()
Blocks until it is possible to return a frame for decoding onto.
Definition: mythvideoout.cpp:387
MythPlayer::InitVideo
virtual bool InitVideo(void)
Definition: mythplayer.cpp:276
MythPlayer::WrapTimecode
void WrapTimecode(std::chrono::milliseconds &timecode, TCTypes tc_type)
Definition: mythplayer.cpp:1262
MythPlayer::PauseVideo
void PauseVideo(void)
Definition: mythplayer.cpp:222
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:570
DecoderBase::ResetTotalDuration
void ResetTotalDuration(void)
Definition: decoderbase.h:259
MythPlayer::ClearAfterSeek
void ClearAfterSeek(bool clearvideobuffers=true)
This is to support seeking...
Definition: mythplayer.cpp:1649
MythPlayer::m_bufferingStart
QTime m_bufferingStart
Definition: mythplayer.h:450
MythPlayer::m_ttPageNum
int m_ttPageNum
VBI page to display when in PAL vbimode.
Definition: mythplayer.h:456
MythPlayer::SetBuffering
void SetBuffering(bool new_buffering)
Definition: mythplayer.cpp:687
MythPlayer::PauseDecoder
bool PauseDecoder(void)
Definition: mythplayer.cpp:946
DeleteMap::LoadMap
void LoadMap(const QString &undoMessage="")
Loads the delete map from the database.
Definition: deletemap.cpp:737
TCTypes
TCTypes
Timecode types.
Definition: mythplayer.h:52
MythPlayer::m_totalFrames
uint64_t m_totalFrames
Definition: mythplayer.h:426
hardwareprofile.smolt.long
long
Definition: smolt.py:76
MythPlayer::ResetPlaying
virtual void ResetPlaying(bool resetframes=true)
Definition: mythplayer.cpp:897
MythPlayerAVSync::SetAVSyncMusicChoice
void SetAVSyncMusicChoice(AudioPlayer *Audio)
Definition: mythplayeravsync.cpp:64
MythPlayer::m_videoFrameRate
double m_videoFrameRate
Video (input) Frame Rate (often inaccurate)
Definition: mythplayer.h:436
get_encoding_type
QString get_encoding_type(MythCodecID codecid)
Definition: mythcodecid.cpp:475
MythVideoOutput::GetFramesPlayed
virtual long long GetFramesPlayed()
Definition: mythvideoout.cpp:247
TestBufferVec
std::vector< char > TestBufferVec
Definition: decoderbase.h:23
DecoderBase::GetXDS
virtual QString GetXDS(const QString &) const
Definition: decoderbase.h:249
jitterometer.h
MythPlayer::m_playerCtx
PlayerContext * m_playerCtx
Definition: mythplayer.h:367
DecoderBase::GetFPS
virtual double GetFPS(void) const
Definition: decoderbase.h:198
MythPlayer::m_forcedVideoAspect
float m_forcedVideoAspect
Definition: mythplayer.h:443
MythPlayer::m_videoDispDim
QSize m_videoDispDim
Video (input) width & height.
Definition: mythplayer.h:439
MythPlayer::DeLimboFrame
void DeLimboFrame(MythVideoFrame *frame)
Definition: mythplayer.cpp:657
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:428
MythPlayer::m_codecName
QString m_codecName
Codec Name - used by playback profile.
Definition: mythplayer.h:438
AvFormatDecoder
A decoder for media files.
Definition: avformatdecoder.h:85
MythPlayer::PosMapFromEnc
bool PosMapFromEnc(uint64_t start, frm_pos_map_t &posMap, frm_pos_map_t &durMap)
Definition: mythplayer.cpp:1903
MythPlayer::m_latestVideoTimecode
std::chrono::milliseconds m_latestVideoTimecode
Definition: mythplayer.h:430
MythPlayer::m_disableForcedSubtitles
bool m_disableForcedSubtitles
Definition: mythplayer.h:465
MythMediaBuffer::LiveMode
bool LiveMode(void) const
Returns true if this RingBuffer has been assigned a LiveTVChain.
Definition: mythmediabuffer.cpp:1787
MythPlayer::m_keyframeDist
uint m_keyframeDist
Video (input) Number of frames between key frames (often inaccurate)
Definition: mythplayer.h:446
preBufferDebug
static bool preBufferDebug
Definition: mythplayer.cpp:705
MythPlayer::RequestResetCaptions
void RequestResetCaptions()
MythPlayer::m_pauseDecoder
bool m_pauseDecoder
Definition: mythplayer.h:387
MythPlayer::GetEditMode
bool GetEditMode(void) const
Definition: mythplayer.h:316
MythPlayer::EnableForcedSubtitles
void EnableForcedSubtitles(bool enable)
Definition: mythplayer.cpp:663
MythPlayer::GetChapterTimes
virtual void GetChapterTimes(QList< std::chrono::seconds > &times)
Definition: mythplayer.cpp:1829
MythPlayer::m_fpsMultiplier
int m_fpsMultiplier
used to detect changes
Definition: mythplayer.h:488
uint
unsigned int uint
Definition: compat.h:140
MythPlayer::m_endExitPrompt
int m_endExitPrompt
Definition: mythplayer.h:415
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition: mythcorecontext.cpp:60
MythPlayer::m_unpauseDecoder
bool m_unpauseDecoder
Definition: mythplayer.h:388
MythPlayer::m_playerFlags
PlayerFlags m_playerFlags
Definition: mythplayer.h:373
MythPlayer::UnpauseDecoder
void UnpauseDecoder(void)
Definition: mythplayer.cpp:970
MythPlayer::m_playingLock
QMutex m_playingLock
Definition: mythplayer.h:399
MythPlayer::PauseBuffer
void PauseBuffer(void)
Definition: mythplayer.cpp:138
MythPlayer::m_deleteMap
DeleteMap m_deleteMap
Definition: mythplayer.h:479
PlayerContext::m_tvchain
LiveTVChain * m_tvchain
Definition: playercontext.h:114
DecoderBase::GetRawAudioState
virtual bool GetRawAudioState(void) const
Definition: decoderbase.h:192
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition: mythcorecontext.cpp:932
MythPlayer::m_vbiMode
uint m_vbiMode
VBI decoder to use.
Definition: mythplayer.h:455
MythPlayer::VideoEnd
virtual void VideoEnd(void)
Definition: mythplayer.cpp:813
MythPlayer::DoFastForward
bool DoFastForward(uint64_t frames, double inaccuracy)
Definition: mythplayer.cpp:1555
MythPlayer::m_playerThread
QThread * m_playerThread
Definition: mythplayer.h:369
MythPlayer::m_limitKeyRepeat
bool m_limitKeyRepeat
Definition: mythplayer.h:407
MythPlayer::DecoderGetFrameREW
virtual bool DecoderGetFrameREW(void)
Definition: mythplayer.cpp:1168
MythPlayer::DecoderEnd
virtual void DecoderEnd(void)
Definition: mythplayer.cpp:1015
mythmediabuffer.h
DecoderBase::SyncPositionMap
virtual bool SyncPositionMap(void)
Updates the position map used for skipping frames.
Definition: decoderbase.cpp:322
MythPlayer::ReinitVideo
virtual void ReinitVideo(bool ForceUpdate)
Definition: mythplayer.cpp:300
frm_pos_map_t
QMap< long long, long long > frm_pos_map_t
Frame # -> File offset map.
Definition: programtypes.h:46
MythPlayer::TranslatePositionFrameToMs
std::chrono::milliseconds TranslatePositionFrameToMs(uint64_t position, bool use_cutlist) const
Definition: mythplayer.cpp:1799
MythVideoOutput::EnoughFreeFrames
bool EnoughFreeFrames()
Returns true iff enough frames are available to decode onto.
Definition: mythvideoout.cpp:287
MythPlayer::m_decoderPaused
bool m_decoderPaused
Definition: mythplayer.h:385
MythPlayer::DoJumpToFrame
void DoJumpToFrame(uint64_t frame, double inaccuracy)
Definition: mythplayer.cpp:1580
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:327
MythPlayer::JumpChapter
void JumpChapter(int chapter)
Definition: mythplayer.cpp:891
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:394
DecoderBase::SetSeekSnap
void SetSeekSnap(uint64_t snap)
Definition: decoderbase.h:137
MythPlayer::GetNumChapters
virtual int GetNumChapters(void)
Definition: mythplayer.cpp:1815
DecoderBase::GetNumChapters
virtual int GetNumChapters(void)
Definition: decoderbase.h:154
MythCoreContext::GetBoolSetting
bool GetBoolSetting(const QString &key, bool defaultval=false)
Definition: mythcorecontext.cpp:926
MythPlayer::m_jumpChapter
int m_jumpChapter
Definition: mythplayer.h:410
MythPlayer::InitFrameInterval
virtual void InitFrameInterval()
Definition: mythplayer.cpp:681
MythPlayer::GetError
QString GetError(void) const
Definition: mythplayer.cpp:1955
DecoderBase::SetWatchingRecording
virtual void SetWatchingRecording(bool mode)
Definition: decoderbase.cpp:82
kState_WatchingPreRecorded
@ kState_WatchingPreRecorded
Watching Pre-recorded is a TV only state for when we are watching a pre-existing recording.
Definition: tv.h:67
DecoderBase::SetTranscoding
void SetTranscoding(bool value)
Definition: decoderbase.h:223
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.cpp:40
MythPlayerAVSync::InitAVSync
void InitAVSync()
Definition: mythplayeravsync.cpp:17
kDecodeVideo
@ kDecodeVideo
Definition: decoderbase.h:50
MythPlayer::CreateDecoder
virtual void CreateDecoder(TestBufferVec &TestBuffer)
Definition: mythplayer.cpp:414
LiveTVChain::GetInputType
QString GetInputType(int pos=-1) const
Definition: livetvchain.cpp:695
MythPlayer::CalcMaxFFTime
virtual long long CalcMaxFFTime(long long ff, bool setjump=true) const
CalcMaxFFTime(ffframes): forward ffframes forward.
Definition: mythplayer.cpp:1415
ProgramInfo::GetChanID
uint GetChanID(void) const
This is the unique key used in the database to locate tuning information.
Definition: programinfo.h:370
livetvchain.h
ProgramInfo::QueryAutoExpire
AutoExpireType QueryAutoExpire(void) const
Returns "autoexpire" field from "recorded" table.
Definition: programinfo.cpp:3276
kVideoIsNull
@ kVideoIsNull
Definition: mythplayer.h:71
MythPlayer::SetKeyframeDistance
void SetKeyframeDistance(int keyframedistance)
Definition: mythplayer.cpp:322
MythMediaBuffer::IsBookmarkAllowed
virtual bool IsBookmarkAllowed(void)
Definition: mythmediabuffer.h:127
DecoderBase::UpdateFramesPlayed
virtual void UpdateFramesPlayed(void)
Definition: decoderbase.cpp:876
MythVideoOutput::DiscardFrame
virtual void DiscardFrame(MythVideoFrame *Frame)
Releases frame from any queue onto the queue of frames ready for decoding onto.
Definition: mythvideoout.cpp:421
MythPlayer::SetWatchingRecording
void SetWatchingRecording(bool mode)
Definition: mythplayer.cpp:126
ProgramInfo
Holds information on recordings and videos.
Definition: programinfo.h:67
MythPlayer::m_liveTV
bool m_liveTV
Definition: mythplayer.h:403
kEofStateImmediate
@ kEofStateImmediate
Definition: decoderbase.h:71
assert
#define assert(x)
Definition: audiooutputalsa.cpp:18
mythmiscutil.h
MythPlayer::IsReallyNearEnd
bool IsReallyNearEnd(void) const
Returns true iff really near end of recording.
Definition: mythplayer.cpp:1495
MythPlayer::IsWatchingInprogress
bool IsWatchingInprogress(void) const
Definition: mythplayer.cpp:133
MythPlayer::m_decoderThreadPause
QWaitCondition m_decoderThreadPause
Definition: mythplayer.h:376
mythcorecontext.h
MythPlayer::m_fileChanged
bool m_fileChanged
Definition: mythplayer.h:491
MythPlayer::SetFramesPlayed
void SetFramesPlayed(uint64_t played)
Definition: mythplayer.cpp:562
MythPlayer::FileChangedCallback
void FileChangedCallback()
Definition: mythplayer.cpp:919
MythPlayer::m_maxReferenceFrames
int m_maxReferenceFrames
Number of reference frames used in the video stream.
Definition: mythplayer.h:441
cardutil.h
MythPlayer::WaitForSeek
void WaitForSeek(uint64_t frame, uint64_t seeksnap_wanted)
Definition: mythplayer.cpp:1588
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:36
MythPlayer::m_errorType
int m_errorType
Definition: mythplayer.h:402
avformatdecoder.h
setpriority
#define setpriority(x, y, z)
Definition: compat.h:204
TC_AUDIO
@ TC_AUDIO
Definition: mythplayer.h:55
MythPlayer::SetDisablePassThrough
void SetDisablePassThrough(bool disabled)
Definition: mythplayer.cpp:1999
MythPlayer::kInaccuracyEditor
static const double kInaccuracyEditor
Definition: mythplayer.h:243
MythPlayer::TranslatePositionMsToFrame
uint64_t TranslatePositionMsToFrame(std::chrono::milliseconds position, bool use_cutlist) const
Definition: mythplayer.h:258
MythPlayer::m_decodeOneFrame
bool m_decodeOneFrame
Definition: mythplayer.h:390
MythPlayer::SetPlaying
void SetPlaying(bool is_playing)
Definition: mythplayer.cpp:248
audiooutput.h
MythPlayer::m_transcoding
bool m_transcoding
Definition: mythplayer.h:405
ProgramInfo::IsVideo
bool IsVideo(void) const
Definition: programinfo.h:482
dummydecoder.h
mythavutil.h
MythPlayer::GetNextVideoFrame
MythVideoFrame * GetNextVideoFrame(void)
Removes a frame from the available queue for decoding onto.
Definition: mythplayer.cpp:588
RemoteEncoder::FillPositionMap
void FillPositionMap(int64_t start, int64_t end, frm_pos_map_t &positionMap)
Definition: remoteencoder.cpp:267
MythMediaBuffer::Start
void Start(void)
Starts the read-ahead thread.
Definition: mythmediabuffer.cpp:610
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:843
MythPlayer::SetFrameRate
void SetFrameRate(double fps)
Definition: mythplayer.cpp:380
MythPlayer::ResetTotalDuration
void ResetTotalDuration(void)
Definition: mythplayer.cpp:1969
MythPlayer::m_totalLength
std::chrono::seconds m_totalLength
Definition: mythplayer.h:427
MythPlayer::SetFrameInterval
void SetFrameInterval(FrameScanType scan, double frame_period)
Definition: mythplayer.cpp:671
MythPlayer::m_decoderSeek
int64_t m_decoderSeek
Definition: mythplayer.h:383
mthread.h
kAudioMuted
@ kAudioMuted
Definition: mythplayer.h:72
MThread::isRunning
bool isRunning(void) const
Definition: mthread.cpp:266
MythPlayer::SetCommBreakMap
void SetCommBreakMap(const frm_dir_map_t &NewMap)
Definition: mythplayer.cpp:1730
PlayerContext
Definition: playercontext.h:48
MythPlayer::m_isDummy
bool m_isDummy
Definition: mythplayer.h:500
MythPlayer::m_videoDim
QSize m_videoDim
Video (input) buffer width & height.
Definition: mythplayer.h:440
MythPlayer::m_vidExitLock
QMutex m_vidExitLock
Definition: mythplayer.h:398
remoteencoder.h
AudioPlayer::GetStretchFactor
float GetStretchFactor(void) const
Definition: audioplayer.h:66
audioplayer.h
DecoderBase::SetDisablePassThrough
virtual void SetDisablePassThrough(bool disable)
Disables AC3/DTS pass through.
Definition: decoderbase.h:145
mythtimer.h
MythPlayer::m_videoAspect
float m_videoAspect
Video (input) Apect Ratio.
Definition: mythplayer.h:442
AudioPlayer::Pause
bool Pause(bool pause)
Definition: audioplayer.cpp:178
MythPlayer::ForceSetupAudioStream
void ForceSetupAudioStream(void)
Definition: mythplayer.cpp:2005
MythPlayer::DecoderGetFrameFFREW
virtual bool DecoderGetFrameFFREW(void)
Definition: mythplayer.cpp:1144
mythcodeccontext.h
MythPlayer::kInaccuracyFull
static const double kInaccuracyFull
Definition: mythplayer.h:244
MythPlayer::JumpToFrame
virtual bool JumpToFrame(uint64_t frame)
Definition: mythplayer.cpp:870
MythPlayer::StopPlaying
virtual void StopPlaying(void)
Definition: mythplayer.cpp:925
MythPlayer::m_allPaused
bool m_allPaused
Definition: mythplayer.h:394
mythuiactions.h
MythPlayer::SaveTotalDuration
void SaveTotalDuration(void)
Definition: mythplayer.cpp:1961
DecoderBase::OpenFile
virtual int OpenFile(MythMediaBuffer *Buffer, bool novideo, TestBufferVec &testbuf)=0
MythPlayer::m_decoderChangeLock
QMutex m_decoderChangeLock
Definition: mythplayer.h:364
MythPlayer::IsInStillFrame
virtual bool IsInStillFrame() const
Definition: mythplayer.h:231
LiveTVChain::HasPrev
bool HasPrev(void) const
Definition: livetvchain.h:61
MythPlayer::GetXDS
QString GetXDS(const QString &key) const
Definition: mythplayer.cpp:1723
myth_nice
bool myth_nice(int val)
Definition: mythmiscutil.cpp:704
PRIO_PROCESS
#define PRIO_PROCESS
Definition: compat.h:203
MythMediaBuffer::Peek
int Peek(void *Buffer, int Count)
Definition: mythmediabuffer.cpp:1164
MythVideoFrame
Definition: mythframe.h:88
MythPlayer::OpenDummy
void OpenDummy(void)
Definition: mythplayer.cpp:398
MythPlayer::m_playing
bool m_playing
Definition: mythplayer.h:395
MythCoreContext::SaveSetting
void SaveSetting(const QString &key, int newValue)
Definition: mythcorecontext.cpp:901
PlayerContext::m_recorder
RemoteEncoder * m_recorder
Definition: playercontext.h:113
DecoderBase::Reset
virtual void Reset(bool reset_video_data, bool seek_reset, bool reset_file)
Definition: decoderbase.cpp:48
MythMediaBuffer::IsNearEnd
bool IsNearEnd(double Framerate, uint Frames) const
Definition: mythmediabuffer.cpp:405
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:855
MythVideoOutput::EnoughDecodedFrames
bool EnoughDecodedFrames()
Returns true iff there are plenty of decoded frames ready for display.
Definition: mythvideoout.cpp:294
LOC
#define LOC
Definition: mythplayer.cpp:64
MythPlayer::DecoderLoop
virtual void DecoderLoop(bool pause)
Definition: mythplayer.cpp:1079
DecoderBase::SetEofState
virtual void SetEofState(EofState eof)
Definition: decoderbase.h:131
MythPlayer::m_disablePassthrough
bool m_disablePassthrough
Definition: mythplayer.h:508
DummyDecoder
Definition: dummydecoder.h:9
mythmainwindow.h
DecoderBase::SetLiveTVMode
void SetLiveTVMode(bool live)
Definition: decoderbase.h:139
FlagIsSet
#define FlagIsSet(arg)
Definition: mythplayer.h:77
MythMediaBuffer::IsSeekingAllowed
virtual bool IsSeekingAllowed(void)
Definition: mythmediabuffer.h:126
MythPlayer::DoRewind
bool DoRewind(uint64_t frames, double inaccuracy)
Definition: mythplayer.cpp:1368
MythPlayer::kInaccuracyDefault
static const double kInaccuracyDefault
Definition: mythplayer.h:242
MythPlayer::FastForward
virtual bool FastForward(float seconds)
Definition: mythplayer.cpp:821
DecoderBase::GetFramesRead
long long GetFramesRead(void) const
Definition: decoderbase.h:203
MythMediaBuffer::Pause
void Pause(void)
Pauses the read-ahead thread. Calls StopReads(void).
Definition: mythmediabuffer.cpp:683
DecoderBase::DoRewind
virtual bool DoRewind(long long desiredFrame, bool discardFrames=true)
Definition: decoderbase.cpp:555
DeleteMap::IsEditing
bool IsEditing(void) const
Definition: deletemap.h:40
MythPlayer::DoGetFrame
bool DoGetFrame(DecodeType DecodeType)
Get one frame from the decoder.
Definition: mythplayer.cpp:1238
MythPlayer::Play
bool Play(float speed=1.0, bool normal=true, bool unpauseaudio=true)
Definition: mythplayer.cpp:192
MythPlayer::m_playingWaitCond
QWaitCondition m_playingWaitCond
Definition: mythplayer.h:397
DecoderBase
Definition: decoderbase.h:120
MythVideoOutput::SetVideoFrameRate
virtual void SetVideoFrameRate(float VideoFrameRate)
Definition: mythvideoout.cpp:134
MythPlayer::m_renderFormats
const VideoFrameTypes * m_renderFormats
Definition: mythplayer.h:366
MythPlayer::m_killDecoder
bool volatile m_killDecoder
Definition: mythplayer.h:389
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
MythCoreContext::GetSetting
QString GetSetting(const QString &key, const QString &defaultval="")
Definition: mythcorecontext.cpp:918
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
tv_play.h
MythPlayer::DecoderStart
virtual void DecoderStart(bool start_paused)
Definition: mythplayer.cpp:997
DecoderBase::SaveTotalFrames
void SaveTotalFrames(void)
Definition: decoderbase.cpp:1249
MythPlayer::Rewind
virtual bool Rewind(float seconds)
Definition: mythplayer.cpp:847
MythPlayer::GetCurrentChapter
virtual int GetCurrentChapter(void)
Definition: mythplayer.cpp:1822
MythPlayer::DiscardVideoFrame
void DiscardVideoFrame(MythVideoFrame *buffer)
Places frame in the available frames queue.
Definition: mythplayer.cpp:618