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"
20 #include "video/VideoFileItemClassify.h"
25 using namespace std::chrono_literals
;
27 std::shared_ptr
<const IPlayer
> CApplicationPlayer::GetInternal() const
29 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
33 std::shared_ptr
<IPlayer
> CApplicationPlayer::GetInternal()
35 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
39 void CApplicationPlayer::ClosePlayer()
41 m_nextItem
.pItem
.reset();
42 std::shared_ptr
<IPlayer
> player
= GetInternal();
50 void CApplicationPlayer::ResetPlayer()
52 // we need to do this directly on the member
53 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
57 void CApplicationPlayer::CloseFile(bool reopen
)
59 std::shared_ptr
<IPlayer
> player
= GetInternal();
62 player
->CloseFile(reopen
);
66 void CApplicationPlayer::CreatePlayer(const CPlayerCoreFactory
&factory
, const std::string
&player
, IPlayerCallback
& callback
)
68 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
71 CDataCacheCore::GetInstance().Reset();
72 m_pPlayer
= factory
.CreatePlayer(player
, callback
);
76 std::string
CApplicationPlayer::GetCurrentPlayer() const
78 std::shared_ptr
<const IPlayer
> player
= GetInternal();
81 return player
->m_name
;
86 bool CApplicationPlayer::OpenFile(const CFileItem
& item
, const CPlayerOptions
& options
,
87 const CPlayerCoreFactory
&factory
,
88 const std::string
&playerName
, IPlayerCallback
& callback
)
91 std::string newPlayer
;
92 if (!playerName
.empty())
93 newPlayer
= playerName
;
95 newPlayer
= factory
.GetDefaultPlayer(item
);
97 // check if we need to close current player
98 // VideoPlayer can open a new file while playing
99 std::shared_ptr
<IPlayer
> player
= GetInternal();
100 if (player
&& player
->IsPlaying())
102 bool needToClose
= false;
104 if (item
.IsDiscImage() || VIDEO::IsDVDFile(item
))
107 if (player
->m_name
!= newPlayer
)
110 if (player
->m_type
!= "video" && player
->m_type
!= "remote")
115 m_nextItem
.pItem
= std::make_shared
<CFileItem
>(item
);
116 m_nextItem
.options
= options
;
117 m_nextItem
.playerName
= newPlayer
;
118 m_nextItem
.callback
= &callback
;
121 if (player
->m_name
!= newPlayer
)
123 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
129 else if (player
&& player
->m_name
!= newPlayer
)
133 std::unique_lock
<CCriticalSection
> lock(m_playerLock
);
141 CreatePlayer(factory
, newPlayer
, callback
);
142 player
= GetInternal();
147 bool ret
= player
->OpenFile(item
, options
);
149 m_nextItem
.pItem
.reset();
151 // reset caching timers
152 m_audioStreamUpdate
.SetExpired();
153 m_videoStreamUpdate
.SetExpired();
154 m_subtitleStreamUpdate
.SetExpired();
159 void CApplicationPlayer::OpenNext(const CPlayerCoreFactory
&factory
)
161 if (m_nextItem
.pItem
)
163 OpenFile(*m_nextItem
.pItem
, m_nextItem
.options
,
165 m_nextItem
.playerName
, *m_nextItem
.callback
);
166 m_nextItem
.pItem
.reset();
170 bool CApplicationPlayer::HasPlayer() const
172 std::shared_ptr
<const IPlayer
> player
= GetInternal();
173 return player
!= nullptr;
176 int CApplicationPlayer::GetChapter() const
178 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
180 return player
->GetChapter();
185 int CApplicationPlayer::GetChapterCount() const
187 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
189 return player
->GetChapterCount();
194 void CApplicationPlayer::GetChapterName(std::string
& strChapterName
, int chapterIdx
) const
196 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
198 player
->GetChapterName(strChapterName
, chapterIdx
);
201 int64_t CApplicationPlayer::GetChapterPos(int chapterIdx
) const
203 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
205 return player
->GetChapterPos(chapterIdx
);
210 bool CApplicationPlayer::HasAudio() const
212 std::shared_ptr
<const IPlayer
> player
= GetInternal();
213 return (player
&& player
->HasAudio());
216 bool CApplicationPlayer::HasVideo() const
218 std::shared_ptr
<const IPlayer
> player
= GetInternal();
219 return (player
&& player
->HasVideo());
222 bool CApplicationPlayer::HasGame() const
224 std::shared_ptr
<const IPlayer
> player
= GetInternal();
225 return (player
&& player
->HasGame());
228 PLAYLIST::Id
CApplicationPlayer::GetPreferredPlaylist() const
230 if (IsPlayingVideo())
231 return PLAYLIST::Id::TYPE_VIDEO
;
233 if (IsPlayingAudio())
234 return PLAYLIST::Id::TYPE_MUSIC
;
236 return PLAYLIST::Id::TYPE_NONE
;
239 bool CApplicationPlayer::HasRDS() const
241 std::shared_ptr
<const IPlayer
> player
= GetInternal();
242 return (player
&& player
->HasRDS());
245 bool CApplicationPlayer::IsPaused() const
247 return (GetPlaySpeed() == 0);
250 bool CApplicationPlayer::IsPlaying() const
252 std::shared_ptr
<const IPlayer
> player
= GetInternal();
253 return (player
&& player
->IsPlaying());
256 bool CApplicationPlayer::IsPausedPlayback() const
258 return (IsPlaying() && (GetPlaySpeed() == 0));
261 bool CApplicationPlayer::IsPlayingAudio() const
263 return (IsPlaying() && !HasVideo() && HasAudio());
266 bool CApplicationPlayer::IsPlayingVideo() const
268 return (IsPlaying() && HasVideo());
271 bool CApplicationPlayer::IsPlayingGame() const
273 return (IsPlaying() && HasGame());
276 bool CApplicationPlayer::IsPlayingRDS() const
278 return (IsPlaying() && HasRDS());
281 void CApplicationPlayer::Pause()
283 std::shared_ptr
<IPlayer
> player
= GetInternal();
290 void CApplicationPlayer::SetMute(bool bOnOff
)
292 std::shared_ptr
<IPlayer
> player
= GetInternal();
294 player
->SetMute(bOnOff
);
297 void CApplicationPlayer::SetVolume(float volume
)
299 std::shared_ptr
<IPlayer
> player
= GetInternal();
301 player
->SetVolume(volume
);
304 void CApplicationPlayer::Seek(bool bPlus
, bool bLargeStep
, bool bChapterOverride
)
306 std::shared_ptr
<IPlayer
> player
= GetInternal();
308 player
->Seek(bPlus
, bLargeStep
, bChapterOverride
);
311 void CApplicationPlayer::SeekPercentage(float fPercent
)
313 std::shared_ptr
<IPlayer
> player
= GetInternal();
315 player
->SeekPercentage(fPercent
);
318 bool CApplicationPlayer::IsPassthrough() const
320 std::shared_ptr
<const IPlayer
> player
= GetInternal();
321 return (player
&& player
->IsPassthrough());
324 bool CApplicationPlayer::CanSeek() const
326 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
327 return (player
&& player
->CanSeek());
330 bool CApplicationPlayer::SeekScene(Direction seekDirection
)
332 std::shared_ptr
<IPlayer
> player
= GetInternal();
333 return (player
&& player
->SeekScene(seekDirection
));
336 void CApplicationPlayer::SeekTime(int64_t iTime
)
338 std::shared_ptr
<IPlayer
> player
= GetInternal();
340 player
->SeekTime(iTime
);
343 void CApplicationPlayer::SeekTimeRelative(int64_t iTime
)
345 std::shared_ptr
<IPlayer
> player
= GetInternal();
348 // use relative seeking if implemented by player
349 if (!player
->SeekTimeRelative(iTime
))
351 int64_t abstime
= GetTime() + iTime
;
352 player
->SeekTime(abstime
);
357 int64_t CApplicationPlayer::GetTime() const
359 std::shared_ptr
<const IPlayer
> player
= GetInternal();
361 return CDataCacheCore::GetInstance().GetPlayTime();
366 int64_t CApplicationPlayer::GetMinTime() const
368 std::shared_ptr
<const IPlayer
> player
= GetInternal();
370 return CDataCacheCore::GetInstance().GetMinTime();
375 int64_t CApplicationPlayer::GetMaxTime() const
377 std::shared_ptr
<const IPlayer
> player
= GetInternal();
379 return CDataCacheCore::GetInstance().GetMaxTime();
384 time_t CApplicationPlayer::GetStartTime() const
386 std::shared_ptr
<const IPlayer
> player
= GetInternal();
388 return CDataCacheCore::GetInstance().GetStartTime();
393 int64_t CApplicationPlayer::GetTotalTime() const
395 std::shared_ptr
<const IPlayer
> player
= GetInternal();
398 int64_t total
= CDataCacheCore::GetInstance().GetMaxTime() - CDataCacheCore::GetInstance().GetMinTime();
405 bool CApplicationPlayer::IsCaching() const
407 std::shared_ptr
<const IPlayer
> player
= GetInternal();
408 return (player
&& player
->IsCaching());
411 bool CApplicationPlayer::IsInMenu() const
413 std::shared_ptr
<const IPlayer
> player
= GetInternal();
414 return (player
&& player
->IsInMenu());
417 MenuType
CApplicationPlayer::GetSupportedMenuType() const
419 std::shared_ptr
<const IPlayer
> player
= GetInternal();
422 return MenuType::NONE
;
424 return player
->GetSupportedMenuType();
427 int CApplicationPlayer::GetCacheLevel() const
429 std::shared_ptr
<const IPlayer
> player
= GetInternal();
431 return player
->GetCacheLevel();
436 int CApplicationPlayer::GetSubtitleCount() const
438 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
440 return player
->GetSubtitleCount();
445 int CApplicationPlayer::GetAudioStream()
447 if (!m_audioStreamUpdate
.IsTimePast())
448 return m_iAudioStream
;
450 std::shared_ptr
<IPlayer
> player
= GetInternal();
453 m_iAudioStream
= player
->GetAudioStream();
454 m_audioStreamUpdate
.Set(1000ms
);
455 return m_iAudioStream
;
461 int CApplicationPlayer::GetSubtitle()
463 if (!m_subtitleStreamUpdate
.IsTimePast())
464 return m_iSubtitleStream
;
466 std::shared_ptr
<IPlayer
> player
= GetInternal();
469 m_iSubtitleStream
= player
->GetSubtitle();
470 m_subtitleStreamUpdate
.Set(1000ms
);
471 return m_iSubtitleStream
;
477 bool CApplicationPlayer::GetSubtitleVisible() const
479 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
480 return player
&& player
->GetSubtitleVisible();
483 bool CApplicationPlayer::CanPause() const
485 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
486 return (player
&& player
->CanPause());
489 bool CApplicationPlayer::HasTeletextCache() const
491 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
493 return player
->HasTeletextCache();
498 std::shared_ptr
<TextCacheStruct_t
> CApplicationPlayer::GetTeletextCache()
500 std::shared_ptr
<IPlayer
> player
= GetInternal();
502 return player
->GetTeletextCache();
507 float CApplicationPlayer::GetPercentage() const
509 std::shared_ptr
<const IPlayer
> player
= GetInternal();
512 float fPercent
= CDataCacheCore::GetInstance().GetPlayPercentage();
513 return std::max(0.0f
, std::min(fPercent
, 100.0f
));
519 float CApplicationPlayer::GetCachePercentage() const
521 std::shared_ptr
<const IPlayer
> player
= GetInternal();
523 return player
->GetCachePercentage();
528 void CApplicationPlayer::SetSpeed(float speed
)
530 std::shared_ptr
<IPlayer
> player
= GetInternal();
532 player
->SetSpeed(speed
);
535 void CApplicationPlayer::SetTempo(float tempo
)
537 std::shared_ptr
<IPlayer
> player
= GetInternal();
539 player
->SetTempo(tempo
);
542 void CApplicationPlayer::FrameAdvance(int frames
)
544 std::shared_ptr
<IPlayer
> player
= GetInternal();
546 player
->FrameAdvance(frames
);
549 std::string
CApplicationPlayer::GetPlayerState()
551 std::shared_ptr
<IPlayer
> player
= GetInternal();
553 return player
->GetPlayerState();
558 bool CApplicationPlayer::QueueNextFile(const CFileItem
&file
)
560 std::shared_ptr
<IPlayer
> player
= GetInternal();
561 return (player
&& player
->QueueNextFile(file
));
564 bool CApplicationPlayer::SetPlayerState(const std::string
& state
)
566 std::shared_ptr
<IPlayer
> player
= GetInternal();
567 return (player
&& player
->SetPlayerState(state
));
570 void CApplicationPlayer::OnNothingToQueueNotify()
572 std::shared_ptr
<IPlayer
> player
= GetInternal();
574 player
->OnNothingToQueueNotify();
577 void CApplicationPlayer::GetVideoStreamInfo(int streamId
, VideoStreamInfo
& info
) const
579 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
581 player
->GetVideoStreamInfo(streamId
, info
);
584 void CApplicationPlayer::GetAudioStreamInfo(int index
, AudioStreamInfo
& info
) const
586 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
588 player
->GetAudioStreamInfo(index
, info
);
591 int CApplicationPlayer::GetPrograms(std::vector
<ProgramInfo
> &programs
)
594 std::shared_ptr
<IPlayer
> player
= GetInternal();
596 ret
= player
->GetPrograms(programs
);
600 void CApplicationPlayer::SetProgram(int progId
)
602 std::shared_ptr
<IPlayer
> player
= GetInternal();
604 player
->SetProgram(progId
);
607 int CApplicationPlayer::GetProgramsCount() const
610 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
612 ret
= player
->GetProgramsCount();
616 bool CApplicationPlayer::OnAction(const CAction
&action
)
618 std::shared_ptr
<IPlayer
> player
= GetInternal();
619 return (player
&& player
->OnAction(action
));
622 int CApplicationPlayer::GetAudioStreamCount() const
624 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
626 return player
->GetAudioStreamCount();
631 int CApplicationPlayer::GetVideoStream()
633 if (!m_videoStreamUpdate
.IsTimePast())
634 return m_iVideoStream
;
636 std::shared_ptr
<IPlayer
> player
= GetInternal();
639 m_iVideoStream
= player
->GetVideoStream();
640 m_videoStreamUpdate
.Set(1000ms
);
641 return m_iVideoStream
;
647 int CApplicationPlayer::GetVideoStreamCount() const
649 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
651 return player
->GetVideoStreamCount();
656 void CApplicationPlayer::SetAudioStream(int iStream
)
658 std::shared_ptr
<IPlayer
> player
= GetInternal();
661 player
->SetAudioStream(iStream
);
662 m_iAudioStream
= iStream
;
663 m_audioStreamUpdate
.Set(1000ms
);
667 void CApplicationPlayer::GetSubtitleStreamInfo(int index
, SubtitleStreamInfo
& info
) const
669 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
671 player
->GetSubtitleStreamInfo(index
, info
);
674 void CApplicationPlayer::SetSubtitle(int iStream
)
676 std::shared_ptr
<IPlayer
> player
= GetInternal();
679 player
->SetSubtitle(iStream
);
680 m_iSubtitleStream
= iStream
;
681 m_subtitleStreamUpdate
.Set(1000ms
);
685 void CApplicationPlayer::SetSubtitleVisible(bool bVisible
)
687 std::shared_ptr
<IPlayer
> player
= GetInternal();
690 player
->SetSubtitleVisible(bVisible
);
694 void CApplicationPlayer::SetSubtitleVerticalPosition(int value
, bool save
)
696 std::shared_ptr
<IPlayer
> player
= GetInternal();
699 player
->SetSubtitleVerticalPosition(value
, save
);
703 void CApplicationPlayer::SetTime(int64_t time
)
705 std::shared_ptr
<IPlayer
> player
= GetInternal();
707 return player
->SetTime(time
);
710 void CApplicationPlayer::SetTotalTime(int64_t time
)
712 std::shared_ptr
<IPlayer
> player
= GetInternal();
714 player
->SetTotalTime(time
);
717 void CApplicationPlayer::SetVideoStream(int iStream
)
719 std::shared_ptr
<IPlayer
> player
= GetInternal();
722 player
->SetVideoStream(iStream
);
723 m_iVideoStream
= iStream
;
724 m_videoStreamUpdate
.Set(1000ms
);
728 void CApplicationPlayer::AddSubtitle(const std::string
& strSubPath
)
730 std::shared_ptr
<IPlayer
> player
= GetInternal();
732 player
->AddSubtitle(strSubPath
);
735 void CApplicationPlayer::SetSubTitleDelay(float fValue
)
737 std::shared_ptr
<IPlayer
> player
= GetInternal();
739 player
->SetSubTitleDelay(fValue
);
742 void CApplicationPlayer::SetAVDelay(float fValue
)
744 std::shared_ptr
<IPlayer
> player
= GetInternal();
746 player
->SetAVDelay(fValue
);
749 void CApplicationPlayer::SetDynamicRangeCompression(long drc
)
751 std::shared_ptr
<IPlayer
> player
= GetInternal();
753 player
->SetDynamicRangeCompression(drc
);
756 void CApplicationPlayer::LoadPage(int p
, int sp
, unsigned char* buffer
)
758 std::shared_ptr
<IPlayer
> player
= GetInternal();
760 player
->LoadPage(p
, sp
, buffer
);
763 void CApplicationPlayer::GetAudioCapabilities(std::vector
<IPlayerAudioCaps
>& caps
) const
765 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
767 player
->GetAudioCapabilities(caps
);
770 void CApplicationPlayer::GetSubtitleCapabilities(std::vector
<IPlayerSubtitleCaps
>& caps
) const
772 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
774 player
->GetSubtitleCapabilities(caps
);
777 int CApplicationPlayer::SeekChapter(int iChapter
)
779 std::shared_ptr
<IPlayer
> player
= GetInternal();
781 return player
->SeekChapter(iChapter
);
786 void CApplicationPlayer::SetPlaySpeed(float speed
)
788 std::shared_ptr
<IPlayer
> player
= GetInternal();
792 if (!IsPlayingAudio() && !IsPlayingVideo())
798 float CApplicationPlayer::GetPlaySpeed() const
800 std::shared_ptr
<const IPlayer
> player
= GetInternal();
803 return CDataCacheCore::GetInstance().GetSpeed();
809 float CApplicationPlayer::GetPlayTempo() const
811 std::shared_ptr
<const IPlayer
> player
= GetInternal();
814 return CDataCacheCore::GetInstance().GetTempo();
820 bool CApplicationPlayer::SupportsTempo() const
822 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
824 return player
->SupportsTempo();
829 void CApplicationPlayer::FrameMove()
831 std::shared_ptr
<IPlayer
> player
= GetInternal();
834 if (CDataCacheCore::GetInstance().IsPlayerStateChanged())
835 // CApplicationMessenger would be overhead because we are already in gui thread
836 CServiceBroker::GetGUI()->GetWindowManager().SendMessage(GUI_MSG_NOTIFY_ALL
, 0, 0, GUI_MSG_STATE_CHANGED
);
840 void CApplicationPlayer::Render(bool clear
, uint32_t alpha
, bool gui
)
842 std::shared_ptr
<IPlayer
> player
= GetInternal();
844 player
->Render(clear
, alpha
, gui
);
847 void CApplicationPlayer::FlushRenderer()
849 std::shared_ptr
<IPlayer
> player
= GetInternal();
851 player
->FlushRenderer();
854 void CApplicationPlayer::SetRenderViewMode(int mode
, float zoom
, float par
, float shift
, bool stretch
)
856 std::shared_ptr
<IPlayer
> player
= GetInternal();
858 player
->SetRenderViewMode(mode
, zoom
, par
, shift
, stretch
);
861 float CApplicationPlayer::GetRenderAspectRatio() const
863 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
865 return player
->GetRenderAspectRatio();
870 bool CApplicationPlayer::GetRects(CRect
& source
, CRect
& dest
, CRect
& view
) const
872 const std::shared_ptr
<const IPlayer
> player
{GetInternal()};
875 player
->GetRects(source
, dest
, view
);
882 unsigned int CApplicationPlayer::GetOrientation() const
884 const std::shared_ptr
<const IPlayer
> player
{GetInternal()};
886 return player
->GetOrientation();
891 void CApplicationPlayer::TriggerUpdateResolution()
893 std::shared_ptr
<IPlayer
> player
= GetInternal();
895 player
->TriggerUpdateResolution();
898 bool CApplicationPlayer::IsRenderingVideo() const
900 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
902 return player
->IsRenderingVideo();
907 bool CApplicationPlayer::IsRenderingGuiLayer() const
909 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
911 return CServiceBroker::GetDataCacheCore().GetGuiRender();
916 bool CApplicationPlayer::IsRenderingVideoLayer() const
918 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
920 return CServiceBroker::GetDataCacheCore().GetVideoRender();
925 bool CApplicationPlayer::Supports(EINTERLACEMETHOD method
) const
927 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
929 return player
->Supports(method
);
934 EINTERLACEMETHOD
CApplicationPlayer::GetDeinterlacingMethodDefault() const
936 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
938 return player
->GetDeinterlacingMethodDefault();
940 return EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE
;
943 bool CApplicationPlayer::Supports(ESCALINGMETHOD method
) const
945 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
947 return player
->Supports(method
);
952 bool CApplicationPlayer::Supports(ERENDERFEATURE feature
) const
954 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
956 return player
->Supports(feature
);
961 unsigned int CApplicationPlayer::RenderCaptureAlloc()
963 std::shared_ptr
<IPlayer
> player
= GetInternal();
965 return player
->RenderCaptureAlloc();
970 void CApplicationPlayer::RenderCapture(unsigned int captureId
, unsigned int width
, unsigned int height
, int flags
)
972 std::shared_ptr
<IPlayer
> player
= GetInternal();
974 player
->RenderCapture(captureId
, width
, height
, flags
);
977 void CApplicationPlayer::RenderCaptureRelease(unsigned int captureId
)
979 std::shared_ptr
<IPlayer
> player
= GetInternal();
981 player
->RenderCaptureRelease(captureId
);
984 bool CApplicationPlayer::RenderCaptureGetPixels(unsigned int captureId
, unsigned int millis
, uint8_t *buffer
, unsigned int size
)
986 std::shared_ptr
<IPlayer
> player
= GetInternal();
988 return player
->RenderCaptureGetPixels(captureId
, millis
, buffer
, size
);
993 bool CApplicationPlayer::IsExternalPlaying() const
995 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
998 if (player
->IsPlaying() && player
->m_type
== "external")
1004 bool CApplicationPlayer::IsRemotePlaying() const
1006 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
1009 if (player
->IsPlaying() && player
->m_type
== "remote")
1015 std::string
CApplicationPlayer::GetName() const
1017 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
1020 return player
->m_name
;
1025 CVideoSettings
CApplicationPlayer::GetVideoSettings() const
1027 std::shared_ptr
<const IPlayer
> player
= GetInternal();
1030 return player
->GetVideoSettings();
1032 return CVideoSettings();
1035 void CApplicationPlayer::SetVideoSettings(CVideoSettings
& settings
)
1037 std::shared_ptr
<IPlayer
> player
= GetInternal();
1040 return player
->SetVideoSettings(settings
);
1044 CSeekHandler
& CApplicationPlayer::GetSeekHandler()
1046 return m_seekHandler
;
1049 const CSeekHandler
& CApplicationPlayer::GetSeekHandler() const
1051 return m_seekHandler
;
1054 void CApplicationPlayer::SetUpdateStreamDetails()
1056 std::shared_ptr
<IPlayer
> player
= GetInternal();
1057 CVideoPlayer
* vp
= dynamic_cast<CVideoPlayer
*>(player
.get());
1059 vp
->SetUpdateStreamDetails();
1062 bool CApplicationPlayer::HasGameAgent() const
1064 const std::shared_ptr
<const IPlayer
> player
= GetInternal();
1066 return player
->HasGameAgent();
1071 int CApplicationPlayer::GetSubtitleDelay() const
1073 // converts subtitle delay to a percentage
1074 const auto& advSettings
= CServiceBroker::GetSettingsComponent()->GetAdvancedSettings();
1075 const auto delay
= this->GetVideoSettings().m_SubtitleDelay
;
1076 const auto range
= advSettings
->m_videoSubsDelayRange
;
1077 return static_cast<int>(0.5f
+ (delay
+ range
) / (2.f
* range
) * 100.0f
);
1080 int CApplicationPlayer::GetAudioDelay() const
1082 // converts audio delay to a percentage
1083 const auto& advSettings
= CServiceBroker::GetSettingsComponent()->GetAdvancedSettings();
1084 const auto delay
= this->GetVideoSettings().m_AudioDelay
;
1085 const auto range
= advSettings
->m_videoAudioDelayRange
;
1086 return static_cast<int>(0.5f
+ (delay
+ range
) / (2.f
* range
) * 100.0f
);