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