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