kodi
UPnPPlayer.h
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 "threads/SystemClock.h"
14 #include "threads/Thread.h"
15 #include "utils/logtypes.h"
16 
17 #include <memory>
18 #include <string>
19 
21 
22 namespace UPNP
23 {
24 
25 class CUPnPPlayerController;
26 
27 class CUPnPPlayer : public IPlayer, public CThread
28 {
29 public:
30  CUPnPPlayer(IPlayerCallback& callback, const char* uuid);
31  ~CUPnPPlayer() override;
32 
33  bool OpenFile(const CFileItem& file, const CPlayerOptions& options) override;
34  bool QueueNextFile(const CFileItem &file) override;
35  bool CloseFile(bool reopen = false) override;
36  bool IsPlaying() const override;
37  void Pause() override;
38  bool HasVideo() const override { return m_hasVideo; }
39  bool HasAudio() const override { return m_hasAudio; }
40  void Seek(bool bPlus, bool bLargeStep, bool bChapterOverride) override;
41  void SeekPercentage(float fPercent = 0) override;
42  void SetVolume(float volume) override;
43 
44  int SeekChapter(int iChapter) override { return -1; }
45 
46  void SeekTime(int64_t iTime = 0) override;
47  void SetSpeed(float speed = 0) override;
48 
49  bool IsCaching() const override { return false; }
50  int GetCacheLevel() const override { return -1; }
51  bool OnAction(const CAction &action) override;
52 
53  int PlayFile(const CFileItem& file,
54  const CPlayerOptions& options,
55  XbmcThreads::EndTime<>& timeout);
56 
57 private:
58  bool IsPaused() const;
59  int64_t GetTime();
60  int64_t GetTotalTime();
61  float GetPercentage();
62 
63  // implementation of CThread
64  void Process() override;
65  void OnExit() override;
66 
67  PLT_MediaController* m_control = nullptr;
68  std::unique_ptr<CUPnPPlayerController> m_delegate;
69  std::string m_current_uri;
70  std::string m_current_meta;
71  bool m_started = false;
72  bool m_stopremote = false;
73  bool m_hasVideo{false};
74  bool m_hasAudio{false};
75  XbmcThreads::EndTime<> m_updateTimer;
76 
77  Logger m_logger;
78 };
79 
80 } /* namespace UPNP */
Definition: Thread.h:44
Definition: SystemClock.h:31
Definition: PltMediaController.h:243
Definition: IPlayer.h:87
Definition: UPnPPlayer.h:27
Class encapsulating information regarding a particular user action to be sent to windows and controls...
Definition: Action.h:21
Definition: IPlayerCallback.h:18
Definition: UPnP.cpp:118
Definition: IPlayer.h:31
Represents a file on a share.
Definition: FileItem.h:102