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