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