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 "libupnpp/config.h"
22 
23 #include <unordered_map>
24 #include <string> // for string
25 #include <vector> // for vector
26 
27 #include "libupnpp/control/service.hxx"
28 #include "libupnpp/control/cdircontent.hxx"
29 
30 
31 namespace UPnPClient {
32 
33 class OHPlaylist;
34 class UPnPDeviceDesc;
35 class UPnPServiceDesc;
36 
37 typedef std::shared_ptr<OHPlaylist> OHPLH;
38 
43 class OHPlaylist : public Service {
44 public:
45 
46  OHPlaylist(const UPnPDeviceDesc& device, const UPnPServiceDesc& service)
47  : Service(device, service) {
48  }
49  OHPlaylist() {}
50  virtual ~OHPlaylist() {}
51 
53  static bool isOHPlService(const std::string& st);
54  virtual bool serviceTypeMatch(const std::string& tp);
55 
56  int play();
57  int pause();
58  int stop();
59  int next();
60  int previous();
61  int setRepeat(bool onoff);
62  int repeat(bool *on);
63  int setShuffle(bool onoff);
64  int shuffle(bool *on);
65  int seekSecondAbsolute(int value);
66  int seekSecondRelative(int value);
67  int seekId(int value);
68  int seekIndex(int value);
69  enum TPState {TPS_Unknown, TPS_Buffering, TPS_Paused, TPS_Playing,
70  TPS_Stopped
71  };
72  int transportState(TPState *tps);
73  int id(int *value);
74  int read(int id, std::string* uri, UPnPDirObject *dirent);
75 
76  struct TrackListEntry {
77  int id;
78  std::string url;
79  UPnPDirObject dirent;
80  void clear() {
81  id = -1;
82  url.clear();
83  dirent.clear();
84  }
85  };
86  int readList(const std::vector<int>& ids,
87  std::vector<TrackListEntry>* entsp);
88 
89  int insert(int afterid, const std::string& uri, const std::string& didl,
90  int *nid);
91  int deleteId(int id);
92  int deleteAll();
93  int tracksMax(int *);
94  int idArray(std::vector<int> *ids, int *tokp);
95  int idArrayChanged(int token, bool *changed);
96  int protocolInfo(std::string *proto);
97 
98  static int stringToTpState(const std::string& va, TPState *tpp);
99 
100 protected:
101  /* My service type string */
102  static const std::string SType;
103 
104 private:
105  void evtCallback(const std::unordered_map<std::string, std::string>&);
106  void registerCallback();
107 };
108 
109 } // namespace UPnPClient
110 
111 #endif /* _OHPLAYLIST_HXX_INCLUDED_ */
Service()
Empty object.
Definition: service.cxx:127
virtual bool serviceTypeMatch(const std::string &tp)
Perform a comparison to the service type string for this specific service.
Definition: ohplaylist.cxx:53
static bool isOHPlService(const std::string &st)
Test service type from discovery message.
Definition: ohplaylist.cxx:48
Definition: service.hxx:73
OHPlaylist Service client class.
Definition: ohplaylist.hxx:43
Definition: ohplaylist.hxx:76
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:28