Parent: [c2b48d] (diff)

Child: [9cb9e4] (diff)

Download this file

linnsongcast.hxx    153 lines (131 with data), 4.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/* Copyright (C) 2006-2016 J.F.Dockes
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA
*/
#ifndef _LINNSONGCAST_H_X_INCLUDED_
#define _LINNSONGCAST_H_X_INCLUDED_
#include <string>
#include <vector>
#include "libupnpp/control/device.hxx"
#include "libupnpp/control/ohsender.hxx"
#include "libupnpp/control/ohreceiver.hxx"
#include "libupnpp/control/ohproduct.hxx"
/**
* Helper functions for dealing with Linn Songcast Sender and Receiver
* UPnP services. These deal with plumbing set up, and do not touch the
* audio stream at all.
*/
namespace UPnPClient {
namespace Songcast {
/**
* Search the device for a Sender service and, if found, create and
* return a service object.
*/
extern OHSNH senderService(DVCH dev);
/**
* Find device with given name (try friendly, then uuid), and
* return the result of senderService()
*/
extern OHSNH getSender(const std::string& nm, std::string& reason);
/** Everything you need to know about a Sender */
struct SenderState {
std::string nm;
std::string UDN;
std::string uri;
std::string meta;
std::string reason;
bool has_sender;
OHPRH prod;
OHSNH sender;
SenderState() : has_sender(false) { }
void reset() {
nm = UDN = uri = meta = reason = std::string();
has_sender = false;
sender.reset();
}
};
/** Retrieve the Sender service status for device nm (friendly or uuid)
*
* @param live if true, if the service is found, the 'sender'
* field will hold a handle to it on return
*/
extern void getSenderState(const std::string& nm, SenderState& st,
bool live = true);
/** Retrieve status data for all found Senders */
extern void listSenders(std::vector<SenderState>& vscs);
/** Everything you need to know about a Receiver */
struct ReceiverState {
enum SCState {SCRS_GENERROR, SCRS_NOOH, SCRS_NOTRECEIVER,
SCRS_STOPPED, SCRS_PLAYING
};
SCState state;
int receiverSourceIndex;
std::string nm;
std::string UDN;
std::string uri;
std::string meta;
std::string reason;
OHPRH prod;
OHRCH rcv;
ReceiverState()
: state(SCRS_GENERROR), receiverSourceIndex(-1) {
}
void reset() {
state = ReceiverState::SCRS_GENERROR;
receiverSourceIndex = -1;
nm = UDN = uri = meta = reason = std::string();
prod.reset();
rcv.reset();
}
};
/** Set the source index for the renderer nm (friendly or uuid)
*
* @param nm friendly name or uuid of the UPnP media renderer
* @param sourceindex index of the source
*
*/
extern bool setSourceIndex(const std::string& rdrnm, int sourceindex);
/** Set the source index by name for the renderer nm (friendly or uuid)
*
* @param nm friendly name or uuid of the UPnP media renderer
* @param name name of the source
*
*/
extern bool setSourceIndexByName(const std::string& rdrnm,
const std::string& name);
/** Retrieve the Receiver service status for device nm (friendly or uuid)
*
* @param live if true, if the service is found, the 'prod' and 'rcv'
* field will hold Service handles on return
*/
extern void getReceiverState(const std::string& nm, ReceiverState& st,
bool live = true);
/** Get status for all found Receiver services */
extern void listReceivers(std::vector<ReceiverState>& vscs);
extern bool setReceiverPlaying(ReceiverState st,
const std::string& uri,
const std::string& meta);
extern bool stopReceiver(ReceiverState st);
extern void setReceiversFromSender(const std::string& sendernm,
const std::vector<std::string>&
rcvnms);
extern void setReceiversFromReceiver(const std::string& rcvnm,
const std::vector<std::string>&
rcvnms);
extern void stopReceivers(const std::vector<std::string>& rcvnms);
}
}
#endif /* _LINNSONGCAST_H_X_INCLUDED_ */