[Windows] Remove redundant DirectSound error codes
[xbmc.git] / xbmc / application / ApplicationPlayer.cpp
bloba222557677846638ec711470385f0e3dec759fad
1 /*
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.
7 */
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"
22 #include <mutex>
24 using namespace KODI;
25 using namespace std::chrono_literals;
27 std::shared_ptr<const IPlayer> CApplicationPlayer::GetInternal() const
29 std::unique_lock<CCriticalSection> lock(m_playerLock);
30 return m_pPlayer;
33 std::shared_ptr<IPlayer> CApplicationPlayer::GetInternal()
35 std::unique_lock<CCriticalSection> lock(m_playerLock);
36 return m_pPlayer;
39 void CApplicationPlayer::ClosePlayer()
41 m_nextItem.pItem.reset();
42 std::shared_ptr<IPlayer> player = GetInternal();
43 if (player)
45 CloseFile();
46 ResetPlayer();
50 void CApplicationPlayer::ResetPlayer()
52 // we need to do this directly on the member
53 std::unique_lock<CCriticalSection> lock(m_playerLock);
54 m_pPlayer.reset();
57 void CApplicationPlayer::CloseFile(bool reopen)
59 std::shared_ptr<IPlayer> player = GetInternal();
60 if (player)
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);
69 if (!m_pPlayer)
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();
79 if (player)
81 return player->m_name;
83 return "";
86 bool CApplicationPlayer::OpenFile(const CFileItem& item, const CPlayerOptions& options,
87 const CPlayerCoreFactory &factory,
88 const std::string &playerName, IPlayerCallback& callback)
90 // get player type
91 std::string newPlayer;
92 if (!playerName.empty())
93 newPlayer = playerName;
94 else
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))
105 needToClose = true;
107 if (player->m_name != newPlayer)
108 needToClose = true;
110 if (player->m_type != "video" && player->m_type != "remote")
111 needToClose = true;
113 if (needToClose)
115 m_nextItem.pItem = std::make_shared<CFileItem>(item);
116 m_nextItem.options = options;
117 m_nextItem.playerName = newPlayer;
118 m_nextItem.callback = &callback;
120 CloseFile();
121 if (player->m_name != newPlayer)
123 std::unique_lock<CCriticalSection> lock(m_playerLock);
124 m_pPlayer.reset();
126 return true;
129 else if (player && player->m_name != newPlayer)
131 CloseFile();
133 std::unique_lock<CCriticalSection> lock(m_playerLock);
134 m_pPlayer.reset();
135 player.reset();
139 if (!player)
141 CreatePlayer(factory, newPlayer, callback);
142 player = GetInternal();
143 if (!player)
144 return false;
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();
156 return ret;
159 void CApplicationPlayer::OpenNext(const CPlayerCoreFactory &factory)
161 if (m_nextItem.pItem)
163 OpenFile(*m_nextItem.pItem, m_nextItem.options,
164 factory,
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();
179 if (player)
180 return player->GetChapter();
181 else
182 return -1;
185 int CApplicationPlayer::GetChapterCount() const
187 const std::shared_ptr<const IPlayer> player = GetInternal();
188 if (player)
189 return player->GetChapterCount();
190 else
191 return 0;
194 void CApplicationPlayer::GetChapterName(std::string& strChapterName, int chapterIdx) const
196 const std::shared_ptr<const IPlayer> player = GetInternal();
197 if (player)
198 player->GetChapterName(strChapterName, chapterIdx);
201 int64_t CApplicationPlayer::GetChapterPos(int chapterIdx) const
203 const std::shared_ptr<const IPlayer> player = GetInternal();
204 if (player)
205 return player->GetChapterPos(chapterIdx);
207 return -1;
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();
284 if (player)
286 player->Pause();
290 void CApplicationPlayer::SetMute(bool bOnOff)
292 std::shared_ptr<IPlayer> player = GetInternal();
293 if (player)
294 player->SetMute(bOnOff);
297 void CApplicationPlayer::SetVolume(float volume)
299 std::shared_ptr<IPlayer> player = GetInternal();
300 if (player)
301 player->SetVolume(volume);
304 void CApplicationPlayer::Seek(bool bPlus, bool bLargeStep, bool bChapterOverride)
306 std::shared_ptr<IPlayer> player = GetInternal();
307 if (player)
308 player->Seek(bPlus, bLargeStep, bChapterOverride);
311 void CApplicationPlayer::SeekPercentage(float fPercent)
313 std::shared_ptr<IPlayer> player = GetInternal();
314 if (player)
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();
339 if (player)
340 player->SeekTime(iTime);
343 void CApplicationPlayer::SeekTimeRelative(int64_t iTime)
345 std::shared_ptr<IPlayer> player = GetInternal();
346 if (player)
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();
360 if (player)
361 return CDataCacheCore::GetInstance().GetPlayTime();
362 else
363 return 0;
366 int64_t CApplicationPlayer::GetMinTime() const
368 std::shared_ptr<const IPlayer> player = GetInternal();
369 if (player)
370 return CDataCacheCore::GetInstance().GetMinTime();
371 else
372 return 0;
375 int64_t CApplicationPlayer::GetMaxTime() const
377 std::shared_ptr<const IPlayer> player = GetInternal();
378 if (player)
379 return CDataCacheCore::GetInstance().GetMaxTime();
380 else
381 return 0;
384 time_t CApplicationPlayer::GetStartTime() const
386 std::shared_ptr<const IPlayer> player = GetInternal();
387 if (player)
388 return CDataCacheCore::GetInstance().GetStartTime();
389 else
390 return 0;
393 int64_t CApplicationPlayer::GetTotalTime() const
395 std::shared_ptr<const IPlayer> player = GetInternal();
396 if (player)
398 int64_t total = CDataCacheCore::GetInstance().GetMaxTime() - CDataCacheCore::GetInstance().GetMinTime();
399 return total;
401 else
402 return 0;
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();
420 if (!player)
422 return MenuType::NONE;
424 return player->GetSupportedMenuType();
427 int CApplicationPlayer::GetCacheLevel() const
429 std::shared_ptr<const IPlayer> player = GetInternal();
430 if (player)
431 return player->GetCacheLevel();
432 else
433 return 0;
436 int CApplicationPlayer::GetSubtitleCount() const
438 const std::shared_ptr<const IPlayer> player = GetInternal();
439 if (player)
440 return player->GetSubtitleCount();
441 else
442 return 0;
445 int CApplicationPlayer::GetAudioStream()
447 if (!m_audioStreamUpdate.IsTimePast())
448 return m_iAudioStream;
450 std::shared_ptr<IPlayer> player = GetInternal();
451 if (player)
453 m_iAudioStream = player->GetAudioStream();
454 m_audioStreamUpdate.Set(1000ms);
455 return m_iAudioStream;
457 else
458 return 0;
461 int CApplicationPlayer::GetSubtitle()
463 if (!m_subtitleStreamUpdate.IsTimePast())
464 return m_iSubtitleStream;
466 std::shared_ptr<IPlayer> player = GetInternal();
467 if (player)
469 m_iSubtitleStream = player->GetSubtitle();
470 m_subtitleStreamUpdate.Set(1000ms);
471 return m_iSubtitleStream;
473 else
474 return 0;
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();
492 if (player)
493 return player->HasTeletextCache();
494 else
495 return false;
498 std::shared_ptr<TextCacheStruct_t> CApplicationPlayer::GetTeletextCache()
500 std::shared_ptr<IPlayer> player = GetInternal();
501 if (player)
502 return player->GetTeletextCache();
503 else
504 return {};
507 float CApplicationPlayer::GetPercentage() const
509 std::shared_ptr<const IPlayer> player = GetInternal();
510 if (player)
512 float fPercent = CDataCacheCore::GetInstance().GetPlayPercentage();
513 return std::max(0.0f, std::min(fPercent, 100.0f));
515 else
516 return 0.0;
519 float CApplicationPlayer::GetCachePercentage() const
521 std::shared_ptr<const IPlayer> player = GetInternal();
522 if (player)
523 return player->GetCachePercentage();
524 else
525 return 0.0;
528 void CApplicationPlayer::SetSpeed(float speed)
530 std::shared_ptr<IPlayer> player = GetInternal();
531 if (player)
532 player->SetSpeed(speed);
535 void CApplicationPlayer::SetTempo(float tempo)
537 std::shared_ptr<IPlayer> player = GetInternal();
538 if (player)
539 player->SetTempo(tempo);
542 void CApplicationPlayer::FrameAdvance(int frames)
544 std::shared_ptr<IPlayer> player = GetInternal();
545 if (player)
546 player->FrameAdvance(frames);
549 std::string CApplicationPlayer::GetPlayerState()
551 std::shared_ptr<IPlayer> player = GetInternal();
552 if (player)
553 return player->GetPlayerState();
554 else
555 return "";
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();
573 if (player)
574 player->OnNothingToQueueNotify();
577 void CApplicationPlayer::GetVideoStreamInfo(int streamId, VideoStreamInfo& info) const
579 const std::shared_ptr<const IPlayer> player = GetInternal();
580 if (player)
581 player->GetVideoStreamInfo(streamId, info);
584 void CApplicationPlayer::GetAudioStreamInfo(int index, AudioStreamInfo& info) const
586 const std::shared_ptr<const IPlayer> player = GetInternal();
587 if (player)
588 player->GetAudioStreamInfo(index, info);
591 int CApplicationPlayer::GetPrograms(std::vector<ProgramInfo> &programs)
593 int ret = 0;
594 std::shared_ptr<IPlayer> player = GetInternal();
595 if (player)
596 ret = player->GetPrograms(programs);
597 return ret;
600 void CApplicationPlayer::SetProgram(int progId)
602 std::shared_ptr<IPlayer> player = GetInternal();
603 if (player)
604 player->SetProgram(progId);
607 int CApplicationPlayer::GetProgramsCount() const
609 int ret = 0;
610 const std::shared_ptr<const IPlayer> player = GetInternal();
611 if (player)
612 ret = player->GetProgramsCount();
613 return ret;
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();
625 if (player)
626 return player->GetAudioStreamCount();
627 else
628 return 0;
631 int CApplicationPlayer::GetVideoStream()
633 if (!m_videoStreamUpdate.IsTimePast())
634 return m_iVideoStream;
636 std::shared_ptr<IPlayer> player = GetInternal();
637 if (player)
639 m_iVideoStream = player->GetVideoStream();
640 m_videoStreamUpdate.Set(1000ms);
641 return m_iVideoStream;
643 else
644 return 0;
647 int CApplicationPlayer::GetVideoStreamCount() const
649 const std::shared_ptr<const IPlayer> player = GetInternal();
650 if (player)
651 return player->GetVideoStreamCount();
652 else
653 return 0;
656 void CApplicationPlayer::SetAudioStream(int iStream)
658 std::shared_ptr<IPlayer> player = GetInternal();
659 if (player)
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();
670 if (player)
671 player->GetSubtitleStreamInfo(index, info);
674 void CApplicationPlayer::SetSubtitle(int iStream)
676 std::shared_ptr<IPlayer> player = GetInternal();
677 if (player)
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();
688 if (player)
690 player->SetSubtitleVisible(bVisible);
694 void CApplicationPlayer::SetSubtitleVerticalPosition(int value, bool save)
696 std::shared_ptr<IPlayer> player = GetInternal();
697 if (player)
699 player->SetSubtitleVerticalPosition(value, save);
703 void CApplicationPlayer::SetTime(int64_t time)
705 std::shared_ptr<IPlayer> player = GetInternal();
706 if (player)
707 return player->SetTime(time);
710 void CApplicationPlayer::SetTotalTime(int64_t time)
712 std::shared_ptr<IPlayer> player = GetInternal();
713 if (player)
714 player->SetTotalTime(time);
717 void CApplicationPlayer::SetVideoStream(int iStream)
719 std::shared_ptr<IPlayer> player = GetInternal();
720 if (player)
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();
731 if (player)
732 player->AddSubtitle(strSubPath);
735 void CApplicationPlayer::SetSubTitleDelay(float fValue)
737 std::shared_ptr<IPlayer> player = GetInternal();
738 if (player)
739 player->SetSubTitleDelay(fValue);
742 void CApplicationPlayer::SetAVDelay(float fValue)
744 std::shared_ptr<IPlayer> player = GetInternal();
745 if (player)
746 player->SetAVDelay(fValue);
749 void CApplicationPlayer::SetDynamicRangeCompression(long drc)
751 std::shared_ptr<IPlayer> player = GetInternal();
752 if (player)
753 player->SetDynamicRangeCompression(drc);
756 void CApplicationPlayer::LoadPage(int p, int sp, unsigned char* buffer)
758 std::shared_ptr<IPlayer> player = GetInternal();
759 if (player)
760 player->LoadPage(p, sp, buffer);
763 void CApplicationPlayer::GetAudioCapabilities(std::vector<IPlayerAudioCaps>& caps) const
765 const std::shared_ptr<const IPlayer> player = GetInternal();
766 if (player)
767 player->GetAudioCapabilities(caps);
770 void CApplicationPlayer::GetSubtitleCapabilities(std::vector<IPlayerSubtitleCaps>& caps) const
772 const std::shared_ptr<const IPlayer> player = GetInternal();
773 if (player)
774 player->GetSubtitleCapabilities(caps);
777 int CApplicationPlayer::SeekChapter(int iChapter)
779 std::shared_ptr<IPlayer> player = GetInternal();
780 if (player)
781 return player->SeekChapter(iChapter);
782 else
783 return 0;
786 void CApplicationPlayer::SetPlaySpeed(float speed)
788 std::shared_ptr<IPlayer> player = GetInternal();
789 if (!player)
790 return;
792 if (!IsPlayingAudio() && !IsPlayingVideo())
793 return ;
795 SetSpeed(speed);
798 float CApplicationPlayer::GetPlaySpeed() const
800 std::shared_ptr<const IPlayer> player = GetInternal();
801 if (player)
803 return CDataCacheCore::GetInstance().GetSpeed();
805 else
806 return 0;
809 float CApplicationPlayer::GetPlayTempo() const
811 std::shared_ptr<const IPlayer> player = GetInternal();
812 if (player)
814 return CDataCacheCore::GetInstance().GetTempo();
816 else
817 return 0;
820 bool CApplicationPlayer::SupportsTempo() const
822 const std::shared_ptr<const IPlayer> player = GetInternal();
823 if (player)
824 return player->SupportsTempo();
825 else
826 return false;
829 void CApplicationPlayer::FrameMove()
831 std::shared_ptr<IPlayer> player = GetInternal();
832 if (player)
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();
843 if (player)
844 player->Render(clear, alpha, gui);
847 void CApplicationPlayer::FlushRenderer()
849 std::shared_ptr<IPlayer> player = GetInternal();
850 if (player)
851 player->FlushRenderer();
854 void CApplicationPlayer::SetRenderViewMode(int mode, float zoom, float par, float shift, bool stretch)
856 std::shared_ptr<IPlayer> player = GetInternal();
857 if (player)
858 player->SetRenderViewMode(mode, zoom, par, shift, stretch);
861 float CApplicationPlayer::GetRenderAspectRatio() const
863 const std::shared_ptr<const IPlayer> player = GetInternal();
864 if (player)
865 return player->GetRenderAspectRatio();
866 else
867 return 1.0;
870 bool CApplicationPlayer::GetRects(CRect& source, CRect& dest, CRect& view) const
872 const std::shared_ptr<const IPlayer> player{GetInternal()};
873 if (player)
875 player->GetRects(source, dest, view);
876 return true;
878 else
879 return false;
882 unsigned int CApplicationPlayer::GetOrientation() const
884 const std::shared_ptr<const IPlayer> player{GetInternal()};
885 if (player)
886 return player->GetOrientation();
887 else
888 return 0;
891 void CApplicationPlayer::TriggerUpdateResolution()
893 std::shared_ptr<IPlayer> player = GetInternal();
894 if (player)
895 player->TriggerUpdateResolution();
898 bool CApplicationPlayer::IsRenderingVideo() const
900 const std::shared_ptr<const IPlayer> player = GetInternal();
901 if (player)
902 return player->IsRenderingVideo();
903 else
904 return false;
907 bool CApplicationPlayer::IsRenderingGuiLayer() const
909 const std::shared_ptr<const IPlayer> player = GetInternal();
910 if (player)
911 return CServiceBroker::GetDataCacheCore().GetGuiRender();
912 else
913 return false;
916 bool CApplicationPlayer::IsRenderingVideoLayer() const
918 const std::shared_ptr<const IPlayer> player = GetInternal();
919 if (player)
920 return CServiceBroker::GetDataCacheCore().GetVideoRender();
921 else
922 return false;
925 bool CApplicationPlayer::Supports(EINTERLACEMETHOD method) const
927 const std::shared_ptr<const IPlayer> player = GetInternal();
928 if (player)
929 return player->Supports(method);
930 else
931 return false;
934 EINTERLACEMETHOD CApplicationPlayer::GetDeinterlacingMethodDefault() const
936 const std::shared_ptr<const IPlayer> player = GetInternal();
937 if (player)
938 return player->GetDeinterlacingMethodDefault();
939 else
940 return EINTERLACEMETHOD::VS_INTERLACEMETHOD_NONE;
943 bool CApplicationPlayer::Supports(ESCALINGMETHOD method) const
945 const std::shared_ptr<const IPlayer> player = GetInternal();
946 if (player)
947 return player->Supports(method);
948 else
949 return false;
952 bool CApplicationPlayer::Supports(ERENDERFEATURE feature) const
954 const std::shared_ptr<const IPlayer> player = GetInternal();
955 if (player)
956 return player->Supports(feature);
957 else
958 return false;
961 unsigned int CApplicationPlayer::RenderCaptureAlloc()
963 std::shared_ptr<IPlayer> player = GetInternal();
964 if (player)
965 return player->RenderCaptureAlloc();
966 else
967 return 0;
970 void CApplicationPlayer::RenderCapture(unsigned int captureId, unsigned int width, unsigned int height, int flags)
972 std::shared_ptr<IPlayer> player = GetInternal();
973 if (player)
974 player->RenderCapture(captureId, width, height, flags);
977 void CApplicationPlayer::RenderCaptureRelease(unsigned int captureId)
979 std::shared_ptr<IPlayer> player = GetInternal();
980 if (player)
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();
987 if (player)
988 return player->RenderCaptureGetPixels(captureId, millis, buffer, size);
989 else
990 return false;
993 bool CApplicationPlayer::IsExternalPlaying() const
995 const std::shared_ptr<const IPlayer> player = GetInternal();
996 if (player)
998 if (player->IsPlaying() && player->m_type == "external")
999 return true;
1001 return false;
1004 bool CApplicationPlayer::IsRemotePlaying() const
1006 const std::shared_ptr<const IPlayer> player = GetInternal();
1007 if (player)
1009 if (player->IsPlaying() && player->m_type == "remote")
1010 return true;
1012 return false;
1015 std::string CApplicationPlayer::GetName() const
1017 const std::shared_ptr<const IPlayer> player = GetInternal();
1018 if (player)
1020 return player->m_name;
1022 return {};
1025 CVideoSettings CApplicationPlayer::GetVideoSettings() const
1027 std::shared_ptr<const IPlayer> player = GetInternal();
1028 if (player)
1030 return player->GetVideoSettings();
1032 return CVideoSettings();
1035 void CApplicationPlayer::SetVideoSettings(CVideoSettings& settings)
1037 std::shared_ptr<IPlayer> player = GetInternal();
1038 if (player)
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());
1058 if (vp)
1059 vp->SetUpdateStreamDetails();
1062 bool CApplicationPlayer::HasGameAgent() const
1064 const std::shared_ptr<const IPlayer> player = GetInternal();
1065 if (player)
1066 return player->HasGameAgent();
1068 return false;
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);