2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
9 #include "ApplicationPlayer.h"
11 #include "ServiceBroker.h"
12 #include "cores/DataCacheCore.h"
13 #include "cores/IPlayer.h"
14 #include "cores/VideoPlayer/VideoPlayer.h"
15 #include "cores/playercorefactory/PlayerCoreFactory.h"
16 #include "guilib/GUIComponent.h"
17 #include "guilib/GUIWindowManager.h"
18 #include "settings/AdvancedSettings.h"
19 #include "settings/SettingsComponent.h"
23 using namespace std::chrono_literals
;
25 std::shared_ptr
<const IPlayer
> CApplicationPlayer::GetInternal() const
27 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
31 std::shared_ptr
<IPlayer
> CApplicationPlayer::GetInternal()
33 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
37 void CApplicationPlayer::ClosePlayer()
39 m_nextItem
.pItem
.reset();
40 std::shared_ptr
<IPlayer
> player
= GetInternal();
48 void CApplicationPlayer::ResetPlayer()
50 // we need to do this directly on the member
51 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
55 void CApplicationPlayer::CloseFile(bool reopen
)
57 std::shared_ptr
<IPlayer
> player
= GetInternal();
60 player
->CloseFile(reopen
);
64 void CApplicationPlayer::CreatePlayer(const CPlayerCoreFactory
&factory
, const std::string
&player
, IPlayerCallback
& callback
)
66 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
69 CDataCacheCore::GetInstance().Reset();
70 m_pPlayer
= factory
.CreatePlayer(player
, callback
);
74 std::string
CApplicationPlayer::GetCurrentPlayer() const
76 std::shared_ptr
<const IPlayer
> player
= GetInternal();
79 return player
->m_name
;
84 bool CApplicationPlayer::OpenFile(const CFileItem
& item
, const CPlayerOptions
& options
,
85 const CPlayerCoreFactory
&factory
,
86 const std::string
&playerName
, IPlayerCallback
& callback
)
89 std::string newPlayer
;
90 if (!playerName
.empty())
91 newPlayer
= playerName
;
93 newPlayer
= factory
.GetDefaultPlayer(item
);
95 // check if we need to close current player
96 // VideoPlayer can open a new file while playing
97 std::shared_ptr
<IPlayer
> player
= GetInternal();
98 if (player
&& player
->IsPlaying())
100 bool needToClose
= false;
102 if (item
.IsDiscImage() || item
.IsDVDFile())
105 if (player
->m_name
!= newPlayer
)
108 if (player
->m_type
!= "video" && player
->m_type
!= "remote")
113 m_nextItem
.pItem
= std::make_shared
<CFileItem
>(item
);
114 m_nextItem
.options
= options
;
115 m_nextItem
.playerName
= newPlayer
;
116 m_nextItem
.callback
= &callback
;
119 if (player
->m_name
!= newPlayer
)
121 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
127 else if (player
&& player
->m_name
!= newPlayer
)
131 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
139 CreatePlayer(factory
, newPlayer
, callback
);
140 player
= GetInternal();
145 bool ret
= player
->OpenFile(item
, options
);
147 m_nextItem
.pItem
.reset();
149 // reset caching timers
150 m_audioStreamUpdate
.SetExpired();
151 m_videoStreamUpdate
.SetExpired();
152 m_subtitleStreamUpdate
.SetExpired();
157 void CApplicationPlayer::OpenNext(const CPlayerCoreFactory
&factory
)
159 if (m_nextItem
.pItem
)
161 OpenFile(*m_nextItem
.pItem
, m_nextItem
.options
,
163 m_nextItem
.playerName
, *m_nextItem
.callback
);
164 m_nextItem
.pItem
.reset();
168 bool CApplicationPlayer::HasPlayer() const
170 std::shared_ptr
<const IPlayer
> player
= GetInternal();
171 return player
!= nullptr;
174 int CApplicationPlayer::GetChapter() const
176 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
178 return player
->GetChapter();
183 int CApplicationPlayer::GetChapterCount() const
185 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
187 return player
->GetChapterCount();
192 void CApplicationPlayer::GetChapterName(std::string
& strChapterName
, int chapterIdx
) const
194 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
196 player
->GetChapterName(strChapterName
, chapterIdx
);
199 int64_t CApplicationPlayer::GetChapterPos(int chapterIdx
) const
201 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
203 return player
->GetChapterPos(chapterIdx
);
208 bool CApplicationPlayer::HasAudio() const
210 std::shared_ptr
<const IPlayer
> player
= GetInternal();
211 return (player
&& player
->HasAudio());
214 bool CApplicationPlayer::HasVideo() const
216 std::shared_ptr
<const IPlayer
> player
= GetInternal();
217 return (player
&& player
->HasVideo());
220 bool CApplicationPlayer::HasGame() const
222 std::shared_ptr
<const IPlayer
> player
= GetInternal();
223 return (player
&& player
->HasGame());
226 PLAYLIST::Id
CApplicationPlayer::GetPreferredPlaylist() const
228 if (IsPlayingVideo())
229 return PLAYLIST::TYPE_VIDEO
;
231 if (IsPlayingAudio())
232 return PLAYLIST::TYPE_MUSIC
;
234 return PLAYLIST::TYPE_NONE
;
237 bool CApplicationPlayer::HasRDS() const
239 std::shared_ptr
<const IPlayer
> player
= GetInternal();
240 return (player
&& player
->HasRDS());
243 bool CApplicationPlayer::IsPaused() const
245 return (GetPlaySpeed() == 0);
248 bool CApplicationPlayer::IsPlaying() const
250 std::shared_ptr
<const IPlayer
> player
= GetInternal();
251 return (player
&& player
->IsPlaying());
254 bool CApplicationPlayer::IsPausedPlayback() const
256 return (IsPlaying() && (GetPlaySpeed() == 0));
259 bool CApplicationPlayer::IsPlayingAudio() const
261 return (IsPlaying() && !HasVideo() && HasAudio());
264 bool CApplicationPlayer::IsPlayingVideo() const
266 return (IsPlaying() && HasVideo());
269 bool CApplicationPlayer::IsPlayingGame() const
271 return (IsPlaying() && HasGame());
274 bool CApplicationPlayer::IsPlayingRDS() const
276 return (IsPlaying() && HasRDS());
279 void CApplicationPlayer::Pause()
281 std::shared_ptr
<IPlayer
> player
= GetInternal();
288 void CApplicationPlayer::SetMute(bool bOnOff
)
290 std::shared_ptr
<IPlayer
> player
= GetInternal();
292 player
->SetMute(bOnOff
);
295 void CApplicationPlayer::SetVolume(float volume
)
297 std::shared_ptr
<IPlayer
> player
= GetInternal();
299 player
->SetVolume(volume
);
302 void CApplicationPlayer::Seek(bool bPlus
, bool bLargeStep
, bool bChapterOverride
)
304 std::shared_ptr
<IPlayer
> player
= GetInternal();
306 player
->Seek(bPlus
, bLargeStep
, bChapterOverride
);
309 void CApplicationPlayer::SeekPercentage(float fPercent
)
311 std::shared_ptr
<IPlayer
> player
= GetInternal();
313 player
->SeekPercentage(fPercent
);
316 bool CApplicationPlayer::IsPassthrough() const
318 std::shared_ptr
<const IPlayer
> player
= GetInternal();
319 return (player
&& player
->IsPassthrough());
322 bool CApplicationPlayer::CanSeek() const
324 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
325 return (player
&& player
->CanSeek());
328 bool CApplicationPlayer::SeekScene(bool bPlus
)
330 std::shared_ptr
<IPlayer
> player
= GetInternal();
331 return (player
&& player
->SeekScene(bPlus
));
334 void CApplicationPlayer::SeekTime(int64_t iTime
)
336 std::shared_ptr
<IPlayer
> player
= GetInternal();
338 player
->SeekTime(iTime
);
341 void CApplicationPlayer::SeekTimeRelative(int64_t iTime
)
343 std::shared_ptr
<IPlayer
> player
= GetInternal();
346 // use relative seeking if implemented by player
347 if (!player
->SeekTimeRelative(iTime
))
349 int64_t abstime
= GetTime() + iTime
;
350 player
->SeekTime(abstime
);
355 int64_t CApplicationPlayer::GetTime() const
357 std::shared_ptr
<const IPlayer
> player
= GetInternal();
359 return CDataCacheCore::GetInstance().GetPlayTime();
364 int64_t CApplicationPlayer::GetMinTime() const
366 std::shared_ptr
<const IPlayer
> player
= GetInternal();
368 return CDataCacheCore::GetInstance().GetMinTime();
373 int64_t CApplicationPlayer::GetMaxTime() const
375 std::shared_ptr
<const IPlayer
> player
= GetInternal();
377 return CDataCacheCore::GetInstance().GetMaxTime();
382 time_t CApplicationPlayer::GetStartTime() const
384 std::shared_ptr
<const IPlayer
> player
= GetInternal();
386 return CDataCacheCore::GetInstance().GetStartTime();
391 int64_t CApplicationPlayer::GetTotalTime() const
393 std::shared_ptr
<const IPlayer
> player
= GetInternal();
396 int64_t total
= CDataCacheCore::GetInstance().GetMaxTime() - CDataCacheCore::GetInstance().GetMinTime();
403 bool CApplicationPlayer::IsCaching() const
405 std::shared_ptr
<const IPlayer
> player
= GetInternal();
406 return (player
&& player
->IsCaching());
409 bool CApplicationPlayer::IsInMenu() const
411 std::shared_ptr
<const IPlayer
> player
= GetInternal();
412 return (player
&& player
->IsInMenu());
415 MenuType
CApplicationPlayer::GetSupportedMenuType() const
417 std::shared_ptr
<const IPlayer
> player
= GetInternal();
420 return MenuType::NONE
;
422 return player
->GetSupportedMenuType();
425 int CApplicationPlayer::GetCacheLevel() const
427 std::shared_ptr
<const IPlayer
> player
= GetInternal();
429 return player
->GetCacheLevel();
434 int CApplicationPlayer::GetSubtitleCount() const
436 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
438 return player
->GetSubtitleCount();
443 int CApplicationPlayer::GetAudioStream()
445 if (!m_audioStreamUpdate
.IsTimePast())
446 return m_iAudioStream
;
448 std::shared_ptr
<IPlayer
> player
= GetInternal();
451 m_iAudioStream
= player
->GetAudioStream();
452 m_audioStreamUpdate
.Set(1000ms
);
453 return m_iAudioStream
;
459 int CApplicationPlayer::GetSubtitle()
461 if (!m_subtitleStreamUpdate
.IsTimePast())
462 return m_iSubtitleStream
;
464 std::shared_ptr
<IPlayer
> player
= GetInternal();
467 m_iSubtitleStream
= player
->GetSubtitle();
468 m_subtitleStreamUpdate
.Set(1000ms
);
469 return m_iSubtitleStream
;
475 bool CApplicationPlayer::GetSubtitleVisible() const
477 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
478 return player
&& player
->GetSubtitleVisible();
481 bool CApplicationPlayer::CanPause() const
483 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
484 return (player
&& player
->CanPause());
487 bool CApplicationPlayer::HasTeletextCache() const
489 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
491 return player
->HasTeletextCache();
496 std::shared_ptr
<TextCacheStruct_t
> CApplicationPlayer::GetTeletextCache()
498 std::shared_ptr
<IPlayer
> player
= GetInternal();
500 return player
->GetTeletextCache();
505 float CApplicationPlayer::GetPercentage() const
507 std::shared_ptr
<const IPlayer
> player
= GetInternal();
510 float fPercent
= CDataCacheCore::GetInstance().GetPlayPercentage();
511 return std::max(0.0f
, std::min(fPercent
, 100.0f
));
517 float CApplicationPlayer::GetCachePercentage() const
519 std::shared_ptr
<const IPlayer
> player
= GetInternal();
521 return player
->GetCachePercentage();
526 void CApplicationPlayer::SetSpeed(float speed
)
528 std::shared_ptr
<IPlayer
> player
= GetInternal();
530 player
->SetSpeed(speed
);
533 void CApplicationPlayer::SetTempo(float tempo
)
535 std::shared_ptr
<IPlayer
> player
= GetInternal();
537 player
->SetTempo(tempo
);
540 void CApplicationPlayer::FrameAdvance(int frames
)
542 std::shared_ptr
<IPlayer
> player
= GetInternal();
544 player
->FrameAdvance(frames
);
547 std::string
CApplicationPlayer::GetPlayerState()
549 std::shared_ptr
<IPlayer
> player
= GetInternal();
551 return player
->GetPlayerState();
556 bool CApplicationPlayer::QueueNextFile(const CFileItem
&file
)
558 std::shared_ptr
<IPlayer
> player
= GetInternal();
559 return (player
&& player
->QueueNextFile(file
));
562 bool CApplicationPlayer::SetPlayerState(const std::string
& state
)
564 std::shared_ptr
<IPlayer
> player
= GetInternal();
565 return (player
&& player
->SetPlayerState(state
));
568 void CApplicationPlayer::OnNothingToQueueNotify()
570 std::shared_ptr
<IPlayer
> player
= GetInternal();
572 player
->OnNothingToQueueNotify();
575 void CApplicationPlayer::GetVideoStreamInfo(int streamId
, VideoStreamInfo
& info
) const
577 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
579 player
->GetVideoStreamInfo(streamId
, info
);
582 void CApplicationPlayer::GetAudioStreamInfo(int index
, AudioStreamInfo
& info
) const
584 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
586 player
->GetAudioStreamInfo(index
, info
);
589 int CApplicationPlayer::GetPrograms(std::vector
<ProgramInfo
> &programs
)
592 std::shared_ptr
<IPlayer
> player
= GetInternal();
594 ret
= player
->GetPrograms(programs
);
598 void CApplicationPlayer::SetProgram(int progId
)
600 std::shared_ptr
<IPlayer
> player
= GetInternal();
602 player
->SetProgram(progId
);
605 int CApplicationPlayer::GetProgramsCount() const
608 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
610 ret
= player
->GetProgramsCount();
614 bool CApplicationPlayer::OnAction(const CAction
&action
)
616 std::shared_ptr
<IPlayer
> player
= GetInternal();
617 return (player
&& player
->OnAction(action
));
620 int CApplicationPlayer::GetAudioStreamCount() const
622 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
624 return player
->GetAudioStreamCount();
629 int CApplicationPlayer::GetVideoStream()
631 if (!m_videoStreamUpdate
.IsTimePast())
632 return m_iVideoStream
;
634 std::shared_ptr
<IPlayer
> player
= GetInternal();
637 m_iVideoStream
= player
->GetVideoStream();
638 m_videoStreamUpdate
.Set(1000ms
);
639 return m_iVideoStream
;
645 int CApplicationPlayer::GetVideoStreamCount() const
647 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
649 return player
->GetVideoStreamCount();
654 void CApplicationPlayer::SetAudioStream(int iStream
)
656 std::shared_ptr
<IPlayer
> player
= GetInternal();
659 player
->SetAudioStream(iStream
);
660 m_iAudioStream
= iStream
;
661 m_audioStreamUpdate
.Set(1000ms
);
665 void CApplicationPlayer::GetSubtitleStreamInfo(int index
, SubtitleStreamInfo
& info
) const
667 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
669 player
->GetSubtitleStreamInfo(index
, info
);
672 void CApplicationPlayer::SetSubtitle(int iStream
)
674 std::shared_ptr
<IPlayer
> player
= GetInternal();
677 player
->SetSubtitle(iStream
);
678 m_iSubtitleStream
= iStream
;
679 m_subtitleStreamUpdate
.Set(1000ms
);
683 void CApplicationPlayer::SetSubtitleVisible(bool bVisible
)
685 std::shared_ptr
<IPlayer
> player
= GetInternal();
688 player
->SetSubtitleVisible(bVisible
);
692 void CApplicationPlayer::SetSubtitleVerticalPosition(int value
, bool save
)
694 std::shared_ptr
<IPlayer
> player
= GetInternal();
697 player
->SetSubtitleVerticalPosition(value
, save
);
701 void CApplicationPlayer::SetTime(int64_t time
)
703 std::shared_ptr
<IPlayer
> player
= GetInternal();
705 return player
->SetTime(time
);
708 void CApplicationPlayer::SetTotalTime(int64_t time
)
710 std::shared_ptr
<IPlayer
> player
= GetInternal();
712 player
->SetTotalTime(time
);
715 void CApplicationPlayer::SetVideoStream(int iStream
)
717 std::shared_ptr
<IPlayer
> player
= GetInternal();
720 player
->SetVideoStream(iStream
);
721 m_iVideoStream
= iStream
;
722 m_videoStreamUpdate
.Set(1000ms
);
726 void CApplicationPlayer::AddSubtitle(const std::string
& strSubPath
)
728 std::shared_ptr
<IPlayer
> player
= GetInternal();
730 player
->AddSubtitle(strSubPath
);
733 void CApplicationPlayer::SetSubTitleDelay(float fValue
)
735 std::shared_ptr
<IPlayer
> player
= GetInternal();
737 player
->SetSubTitleDelay(fValue
);
740 void CApplicationPlayer::SetAVDelay(float fValue
)
742 std::shared_ptr
<IPlayer
> player
= GetInternal();
744 player
->SetAVDelay(fValue
);
747 void CApplicationPlayer::SetDynamicRangeCompression(long drc
)
749 std::shared_ptr
<IPlayer
> player
= GetInternal();
751 player
->SetDynamicRangeCompression(drc
);
754 void CApplicationPlayer::LoadPage(int p
, int sp
, unsigned char* buffer
)
756 std::shared_ptr
<IPlayer
> player
= GetInternal();
758 player
->LoadPage(p
, sp
, buffer
);
761 void CApplicationPlayer::GetAudioCapabilities(std::vector
<int>& audioCaps
) const
763 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
765 player
->GetAudioCapabilities(audioCaps
);
768 void CApplicationPlayer::GetSubtitleCapabilities(std::vector
<int>& subCaps
) const
770 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
772 player
->GetSubtitleCapabilities(subCaps
);
775 int CApplicationPlayer::SeekChapter(int iChapter
)
777 std::shared_ptr
<IPlayer
> player
= GetInternal();
779 return player
->SeekChapter(iChapter
);
784 void CApplicationPlayer::SetPlaySpeed(float speed
)
786 std::shared_ptr
<IPlayer
> player
= GetInternal();
790 if (!IsPlayingAudio() && !IsPlayingVideo())
796 float CApplicationPlayer::GetPlaySpeed() const
798 std::shared_ptr
<const IPlayer
> player
= GetInternal();
801 return CDataCacheCore::GetInstance().GetSpeed();
807 float CApplicationPlayer::GetPlayTempo() const
809 std::shared_ptr
<const IPlayer
> player
= GetInternal();
812 return CDataCacheCore::GetInstance().GetTempo();
818 bool CApplicationPlayer::SupportsTempo() const
820 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
822 return player
->SupportsTempo();
827 void CApplicationPlayer::FrameMove()
829 std::shared_ptr
<IPlayer
> player
= GetInternal();
832 if (CDataCacheCore::GetInstance().IsPlayerStateChanged())
833 // CApplicationMessenger would be overhead because we are already in gui thread
834 CServiceBroker::GetGUI()->GetWindowManager().SendMessage(GUI_MSG_NOTIFY_ALL
, 0, 0, GUI_MSG_STATE_CHANGED
);
838 void CApplicationPlayer::Render(bool clear
, uint32_t alpha
, bool gui
)
840 std::shared_ptr
<IPlayer
> player
= GetInternal();
842 player
->Render(clear
, alpha
, gui
);
845 void CApplicationPlayer::FlushRenderer()
847 std::shared_ptr
<IPlayer
> player
= GetInternal();
849 player
->FlushRenderer();
852 void CApplicationPlayer::SetRenderViewMode(int mode
, float zoom
, float par
, float shift
, bool stretch
)
854 std::shared_ptr
<IPlayer
> player
= GetInternal();
856 player
->SetRenderViewMode(mode
, zoom
, par
, shift
, stretch
);
859 float CApplicationPlayer::GetRenderAspectRatio() const
861 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
863 return player
->GetRenderAspectRatio();
868 void CApplicationPlayer::TriggerUpdateResolution()
870 std::shared_ptr
<IPlayer
> player
= GetInternal();
872 player
->TriggerUpdateResolution();
875 bool CApplicationPlayer::IsRenderingVideo() const
877 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
879 return player
->IsRenderingVideo();
884 bool CApplicationPlayer::IsRenderingGuiLayer() const
886 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
888 return CServiceBroker::GetDataCacheCore().GetGuiRender();
893 bool CApplicationPlayer::IsRenderingVideoLayer() const
895 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
897 return CServiceBroker::GetDataCacheCore().GetVideoRender();
902 bool CApplicationPlayer::Supports(EINTERLACEMETHOD method
) const
904 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
906 return player
->Supports(method
);
911 EINTERLACEMETHOD
CApplicationPlayer::GetDeinterlacingMethodDefault() const
913 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
915 return player
->GetDeinterlacingMethodDefault();
917 return EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE
;
920 bool CApplicationPlayer::Supports(ESCALINGMETHOD method
) const
922 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
924 return player
->Supports(method
);
929 bool CApplicationPlayer::Supports(ERENDERFEATURE feature
) const
931 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
933 return player
->Supports(feature
);
938 unsigned int CApplicationPlayer::RenderCaptureAlloc()
940 std::shared_ptr
<IPlayer
> player
= GetInternal();
942 return player
->RenderCaptureAlloc();
947 void CApplicationPlayer::RenderCapture(unsigned int captureId
, unsigned int width
, unsigned int height
, int flags
)
949 std::shared_ptr
<IPlayer
> player
= GetInternal();
951 player
->RenderCapture(captureId
, width
, height
, flags
);
954 void CApplicationPlayer::RenderCaptureRelease(unsigned int captureId
)
956 std::shared_ptr
<IPlayer
> player
= GetInternal();
958 player
->RenderCaptureRelease(captureId
);
961 bool CApplicationPlayer::RenderCaptureGetPixels(unsigned int captureId
, unsigned int millis
, uint8_t *buffer
, unsigned int size
)
963 std::shared_ptr
<IPlayer
> player
= GetInternal();
965 return player
->RenderCaptureGetPixels(captureId
, millis
, buffer
, size
);
970 bool CApplicationPlayer::IsExternalPlaying() const
972 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
975 if (player
->IsPlaying() && player
->m_type
== "external")
981 bool CApplicationPlayer::IsRemotePlaying() const
983 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
986 if (player
->IsPlaying() && player
->m_type
== "remote")
992 std::string
CApplicationPlayer::GetName() const
994 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
997 return player
->m_name
;
1002 CVideoSettings
CApplicationPlayer::GetVideoSettings() const
1004 std::shared_ptr
<const IPlayer
> player
= GetInternal();
1007 return player
->GetVideoSettings();
1009 return CVideoSettings();
1012 void CApplicationPlayer::SetVideoSettings(CVideoSettings
& settings
)
1014 std::shared_ptr
<IPlayer
> player
= GetInternal();
1017 return player
->SetVideoSettings(settings
);
1021 CSeekHandler
& CApplicationPlayer::GetSeekHandler()
1023 return m_seekHandler
;
1026 const CSeekHandler
& CApplicationPlayer::GetSeekHandler() const
1028 return m_seekHandler
;
1031 void CApplicationPlayer::SetUpdateStreamDetails()
1033 std::shared_ptr
<IPlayer
> player
= GetInternal();
1034 CVideoPlayer
* vp
= dynamic_cast<CVideoPlayer
*>(player
.get());
1036 vp
->SetUpdateStreamDetails();
1039 bool CApplicationPlayer::HasGameAgent() const
1041 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
1043 return player
->HasGameAgent();
1048 int CApplicationPlayer::GetSubtitleDelay() const
1050 // converts subtitle delay to a percentage
1051 const auto& advSettings
= CServiceBroker::GetSettingsComponent()->GetAdvancedSettings();
1052 const auto delay
= this->GetVideoSettings().m_SubtitleDelay
;
1053 const auto range
= advSettings
->m_videoSubsDelayRange
;
1054 return static_cast<int>(0.5f
+ (delay
+ range
) / (2.f
* range
) * 100.0f
);
1057 int CApplicationPlayer::GetAudioDelay() const
1059 // converts audio delay to a percentage
1060 const auto& advSettings
= CServiceBroker::GetSettingsComponent()->GetAdvancedSettings();
1061 const auto delay
= this->GetVideoSettings().m_AudioDelay
;
1062 const auto range
= advSettings
->m_videoAudioDelayRange
;
1063 return static_cast<int>(0.5f
+ (delay
+ range
) / (2.f
* range
) * 100.0f
);