libupnpp  0.16.0
A C++ wrapper for the Portable UPnP reference library
ohplaylist.hxx
1 /* Copyright (C) 2006-2016 J.F.Dockes
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
16  * 02110-1301 USA
17  */
18 #ifndef _OHPLAYLIST_HXX_INCLUDED_
19 #define _OHPLAYLIST_HXX_INCLUDED_
20 
21 #include <unordered_map>
22 #include <string>
23 #include <vector>
24 
25 #include "libupnpp/control/service.hxx"
26 #include "libupnpp/control/cdircontent.hxx"
27 
28 
29 namespace UPnPClient {
30 
31 class OHPlaylist;
32 class UPnPDeviceDesc;
33 class UPnPServiceDesc;
34 
35 typedef std::shared_ptr<OHPlaylist> OHPLH;
36 
41 class UPNPP_API OHPlaylist : public Service {
42 public:
43 
44  OHPlaylist(const UPnPDeviceDesc& device, const UPnPServiceDesc& service)
45  : Service(device, service) {
46  }
47  OHPlaylist() {}
48  virtual ~OHPlaylist() {}
49 
51  static bool isOHPlService(const std::string& st);
52  virtual bool serviceTypeMatch(const std::string& tp);
53 
54  int play();
55  int pause();
56  int stop();
57  int next();
58  int previous();
59  int setRepeat(bool onoff);
60  int repeat(bool *on);
61  int setShuffle(bool onoff);
62  int shuffle(bool *on);
63  int seekSecondAbsolute(int value);
64  int seekSecondRelative(int value);
65  int seekId(int value);
66  int seekIndex(int value);
67  enum TPState {TPS_Unknown, TPS_Buffering, TPS_Paused, TPS_Playing,
68  TPS_Stopped
69  };
70  int transportState(TPState *tps);
71  int id(int *value);
72  int read(int id, std::string* uri, UPnPDirObject *dirent);
73 
74  struct TrackListEntry {
75  int id;
76  std::string url;
77  UPnPDirObject dirent;
78  void clear() {
79  id = -1;
80  url.clear();
81  dirent.clear();
82  }
83  };
84  int readList(const std::vector<int>& ids,
85  std::vector<TrackListEntry>* entsp);
86 
87  int insert(int afterid, const std::string& uri, const std::string& didl,
88  int *nid);
89  int deleteId(int id);
90  int deleteAll();
91  int tracksMax(int *);
92  int idArray(std::vector<int> *ids, int *tokp);
93  int idArrayChanged(int token, bool *changed);
94  int protocolInfo(std::string *proto);
95 
96  static int stringToTpState(const std::string& va, TPState *tpp);
97 
98 protected:
99  /* My service type string */
100  static const std::string SType;
101 
102 private:
103  void UPNPP_LOCAL evtCallback(
104  const std::unordered_map<std::string, std::string>&);
105  void UPNPP_LOCAL registerCallback();
106 };
107 
108 } // namespace UPnPClient
109 
110 #endif /* _OHPLAYLIST_HXX_INCLUDED_ */
Definition: service.hxx:82
OHPlaylist Service client class.
Definition: ohplaylist.hxx:41
Definition: ohplaylist.hxx:74
Data holder for a UPnP service, parsed from the device XML description.
Definition: description.hxx:46
UPnP Media Server directory entry, converted from XML data.
Definition: cdircontent.hxx:62
Data holder for a UPnP device, parsed from the XML description obtained during discovery.
Definition: description.hxx:142
UPnP Description phase: interpreting the device description which we downloaded from the URL obtained...
Definition: avlastchg.cxx:27