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