libupnpp  0.16.0
A C++ wrapper for the Portable UPnP reference library
avtransport.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 _AVTRANSPORT_HXX_INCLUDED_
19 #define _AVTRANSPORT_HXX_INCLUDED_
20 
21 #include <string>
22 
23 #include "libupnpp/control/cdircontent.hxx"
24 #include "libupnpp/control/service.hxx"
25 
26 namespace UPnPClient {
27 
28 class AVTransport;
29 class UPnPDeviceDesc;
30 class UPnPServiceDesc;
31 
32 typedef std::shared_ptr<AVTransport> AVTH;
33 
38 class UPNPP_API AVTransport : public Service {
39 public:
40 
42  AVTransport(const UPnPDeviceDesc& dev, const UPnPServiceDesc& srv)
43  : Service(dev, srv) {
44  }
45  AVTransport() {}
46  virtual ~AVTransport() {}
47 
48  int setAVTransportURI(const std::string& uri, const std::string& metadata,
49  int instanceID=0)
50  {
51  return setURI(uri, metadata, instanceID, false);
52  }
53 
54  int setNextAVTransportURI(const std::string& uri, const std::string& md,
55  int instanceID=0)
56  {
57  return setURI(uri, md, instanceID, true);
58  }
59 
60 
61  enum PlayMode {PM_Unknown, PM_Normal, PM_Shuffle, PM_RepeatOne,
62  PM_RepeatAll, PM_Random, PM_Direct1
63  };
64  int setPlayMode(PlayMode pm, int instanceID=0);
65 
66  struct MediaInfo {
67  int nrtracks;
68  int mduration; // seconds
69  std::string cururi;
70  UPnPDirObject curmeta;
71  std::string nexturi;
72  UPnPDirObject nextmeta;
73  std::string pbstoragemed;
74  std::string rcstoragemed;
75  std::string ws;
76  };
77  int getMediaInfo(MediaInfo& info, int instanceID=0);
78 
79  enum TransportState {Unknown, Stopped, Playing, Transitioning,
80  PausedPlayback, PausedRecording, Recording,
81  NoMediaPresent
82  };
83  enum TransportStatus {TPS_Unknown, TPS_Ok, TPS_Error};
84  struct TransportInfo {
85  TransportState tpstate;
86  TransportStatus tpstatus;
87  int curspeed;
88  };
89  int getTransportInfo(TransportInfo& info, int instanceID=0);
90 
91  struct PositionInfo {
92  int track;
93  int trackduration; // secs
94  UPnPDirObject trackmeta;
95  std::string trackuri;
96  int reltime;
97  int abstime;
98  int relcount;
99  int abscount;
100  };
101  int getPositionInfo(PositionInfo& info, int instanceID=0);
102 
104  std::string playmedia;
105  std::string recmedia;
106  std::string recqualitymodes;
107  };
108  int getDeviceCapabilities(DeviceCapabilities& info, int instanceID=0);
109 
111  PlayMode playmode;
112  std::string recqualitymode;
113  };
114  int getTransportSettings(TransportSettings& info, int instanceID=0);
115 
116  int stop(int instanceID=0);
117  int pause(int instanceID=0);
118  int play(int speed = 1, int instanceID = 0);
119 
120  enum SeekMode {SEEK_TRACK_NR, SEEK_ABS_TIME, SEEK_REL_TIME, SEEK_ABS_COUNT,
121  SEEK_REL_COUNT, SEEK_CHANNEL_FREQ, SEEK_TAPE_INDEX,
122  SEEK_FRAME
123  };
124  // Target in seconds for times.
125  int seek(SeekMode mode, int target, int instanceID=0);
126 
127  // These are for multitrack medium like a CD. No meaning for electronic
128  // tracks where set(next)AVTransportURI() is used
129  int next(int instanceID=0);
130  int previous(int instanceID=0);
131 
132  enum TransportActions {TPA_Next = 1, TPA_Pause = 2, TPA_Play = 4,
133  TPA_Previous = 8, TPA_Seek = 16, TPA_Stop = 32
134  };
135  int getCurrentTransportActions(int& actions, int instanceID=0);
136 
138  static bool isAVTService(const std::string& st);
139  virtual bool serviceTypeMatch(const std::string& tp);
140 
141 protected:
142  /* My service type string */
143  static const std::string SType;
144 
145  int setURI(const std::string& uri, const std::string& metadata,
146  int instanceID, bool next);
147  int CTAStringToBits(const std::string& actions, int& iacts);
148 
149 private:
150  void UPNPP_LOCAL evtCallback(
151  const std::unordered_map<std::string, std::string>&);
152  void UPNPP_LOCAL registerCallback();
153 };
154 
155 } // namespace UPnPClient
156 
157 #endif /* _AVTRANSPORT_HXX_INCLUDED_ */
Definition: service.hxx:82
Definition: avtransport.hxx:103
Definition: avtransport.hxx:91
AVTransport Service client class.
Definition: avtransport.hxx:38
Definition: avtransport.hxx:66
Definition: avtransport.hxx:110
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
AVTransport(const UPnPDeviceDesc &dev, const UPnPServiceDesc &srv)
Construct by copying data from device and service objects.
Definition: avtransport.hxx:42
UPnP Description phase: interpreting the device description which we downloaded from the URL obtained...
Definition: avlastchg.cxx:27
Definition: avtransport.hxx:84