1 /*
2  *  Copyright (c) 2006 elupus (Joakim Plate)
3  *  Copyright (C) 2006-2018 Team Kodi
4  *  This file is part of Kodi - https://kodi.tv
5  *
6  *  SPDX-License-Identifier: GPL-2.0-or-later
7  *  See LICENSES/README.md for more information.
8  */
9 
10 #pragma once
11 
12 #include "cores/IPlayer.h"
13 #include "guilib/DispResource.h"
14 #include "threads/SystemClock.h"
15 #include "utils/logtypes.h"
16 
17 #include <string>
18 
19 class PLT_MediaController;
20 class CGUIDialogBusy;
21 
22 namespace XbmcThreads { class EndTime; }
23 
24 
25 namespace UPNP
26 {
27 
28 class CUPnPPlayerController;
29 
30 class CUPnPPlayer
31   : public IPlayer, public IRenderLoop
32 {
33 public:
34   CUPnPPlayer(IPlayerCallback& callback, const char* uuid);
35   ~CUPnPPlayer() override;
36 
37   bool OpenFile(const CFileItem& file, const CPlayerOptions& options) override;
38   bool QueueNextFile(const CFileItem &file) override;
39   bool CloseFile(bool reopen = false) override;
40   bool IsPlaying() const override;
41   void Pause() override;
HasVideo()42   bool HasVideo() const override { return false; }
HasAudio()43   bool HasAudio() const override { return false; }
44   void Seek(bool bPlus, bool bLargeStep, bool bChapterOverride) override;
45   void SeekPercentage(float fPercent = 0) override;
46   void SetVolume(float volume) override;
47 
GetChapterCount()48   int GetChapterCount() override { return 0; }
GetChapter()49   int GetChapter() override { return -1; }
50   void GetChapterName(std::string& strChapterName, int chapterIdx = -1) override { }
SeekChapter(int iChapter)51   int SeekChapter(int iChapter) override { return -1; }
52 
53   void SeekTime(int64_t iTime = 0) override;
54   void SetSpeed(float speed = 0) override;
55 
IsCaching()56   bool IsCaching() const override { return false; }
GetCacheLevel()57   int GetCacheLevel() const override { return -1; }
58   void DoAudioWork() override;
59   bool OnAction(const CAction &action) override;
60 
61   void FrameMove() override;
62 
63   int PlayFile(const CFileItem& file, const CPlayerOptions& options, CGUIDialogBusy*& dialog, XbmcThreads::EndTime& timeout);
64 
65 private:
66   bool IsPaused() const;
67   int64_t GetTime();
68   int64_t GetTotalTime();
69   float GetPercentage();
70 
71   PLT_MediaController* m_control;
72   CUPnPPlayerController* m_delegate;
73   std::string m_current_uri;
74   std::string m_current_meta;
75   bool m_started;
76   bool m_stopremote;
77   XbmcThreads::EndTime m_updateTimer;
78 
79   Logger m_logger;
80 };
81 
82 } /* namespace UPNP */
83