Mercurial > projects > hoofbaby
comparison deps/Platinum/Source/Devices/MediaRenderer/PltMediaController.h @ 0:3425707ddbf6
Initial import (hopefully this mercurial stuff works...)
author | fraserofthenight |
---|---|
date | Mon, 06 Jul 2009 08:06:28 -0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:3425707ddbf6 |
---|---|
1 /***************************************************************** | |
2 | | |
3 | Platinum - AV Media Controller (Media Renderer Control Point) | |
4 | | |
5 | Copyright (c) 2004-2008, Plutinosoft, LLC. | |
6 | All rights reserved. | |
7 | http://www.plutinosoft.com | |
8 | | |
9 | This program is free software; you can redistribute it and/or | |
10 | modify it under the terms of the GNU General Public License | |
11 | as published by the Free Software Foundation; either version 2 | |
12 | of the License, or (at your option) any later version. | |
13 | | |
14 | OEMs, ISVs, VARs and other distributors that combine and | |
15 | distribute commercially licensed software with Platinum software | |
16 | and do not wish to distribute the source code for the commercially | |
17 | licensed software under version 2, or (at your option) any later | |
18 | version, of the GNU General Public License (the "GPL") must enter | |
19 | into a commercial license agreement with Plutinosoft, LLC. | |
20 | | |
21 | This program is distributed in the hope that it will be useful, | |
22 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
24 | GNU General Public License for more details. | |
25 | | |
26 | You should have received a copy of the GNU General Public License | |
27 | along with this program; see the file LICENSE.txt. If not, write to | |
28 | the Free Software Foundation, Inc., | |
29 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
30 | http://www.gnu.org/licenses/gpl-2.0.html | |
31 | | |
32 ****************************************************************/ | |
33 | |
34 #ifndef _PLT_MEDIA_CONTROLLER_H_ | |
35 #define _PLT_MEDIA_CONTROLLER_H_ | |
36 | |
37 /*---------------------------------------------------------------------- | |
38 | includes | |
39 +---------------------------------------------------------------------*/ | |
40 #include "PltCtrlPoint.h" | |
41 | |
42 /*---------------------------------------------------------------------- | |
43 | Defines | |
44 +---------------------------------------------------------------------*/ | |
45 typedef NPT_List<NPT_String> PLT_StringList; | |
46 | |
47 struct PLT_DeviceCapabilities { | |
48 PLT_StringList play_media; | |
49 PLT_StringList rec_media; | |
50 PLT_StringList rec_quality_modes; | |
51 }; | |
52 | |
53 struct PLT_MediaInfo { | |
54 NPT_UInt32 num_tracks; | |
55 NPT_TimeStamp media_duration; | |
56 NPT_String cur_uri; | |
57 NPT_String cur_metadata; | |
58 NPT_String next_uri; | |
59 NPT_String next_metadata; | |
60 NPT_String play_medium; | |
61 NPT_String rec_medium; | |
62 NPT_String write_status; | |
63 }; | |
64 | |
65 struct PLT_PositionInfo { | |
66 NPT_UInt32 track; | |
67 NPT_TimeStamp track_duration; | |
68 NPT_String track_metadata; | |
69 NPT_String track_uri; | |
70 NPT_TimeStamp rel_time; | |
71 NPT_TimeStamp abs_time; | |
72 NPT_Int32 rel_count; | |
73 NPT_Int32 abs_count; | |
74 }; | |
75 | |
76 struct PLT_TransportInfo { | |
77 NPT_String cur_transport_state; | |
78 NPT_String cur_transport_status; | |
79 NPT_String cur_speed; | |
80 }; | |
81 | |
82 struct PLT_TransportSettings { | |
83 NPT_String play_mode; | |
84 NPT_String rec_quality_mode; | |
85 }; | |
86 | |
87 struct PLT_ConnectionInfo { | |
88 NPT_UInt32 rcs_id; | |
89 NPT_UInt32 avtransport_id; | |
90 NPT_String protocol_info; | |
91 NPT_String peer_connection_mgr; | |
92 NPT_UInt32 peer_connection_id; | |
93 NPT_String direction; | |
94 NPT_String status; | |
95 }; | |
96 | |
97 /*---------------------------------------------------------------------- | |
98 | PLT_MediaControllerDelegate class | |
99 +---------------------------------------------------------------------*/ | |
100 class PLT_MediaControllerDelegate | |
101 { | |
102 public: | |
103 virtual ~PLT_MediaControllerDelegate() {} | |
104 | |
105 virtual bool OnMRAdded(PLT_DeviceDataReference& /* device */) { return true; } | |
106 virtual void OnMRRemoved(PLT_DeviceDataReference& /* device */) {} | |
107 virtual void OnMRStateVariablesChanged(PLT_Service* /* service */, | |
108 NPT_List<PLT_StateVariable*>* /* vars */) {} | |
109 | |
110 // AVTransport | |
111 virtual void OnGetCurrentTransportActionsResult( | |
112 NPT_Result /* res */, | |
113 PLT_DeviceDataReference& /* device */, | |
114 PLT_StringList* /* actions */, | |
115 void* /* userdata */) {} | |
116 | |
117 virtual void OnGetDeviceCapabilitiesResult( | |
118 NPT_Result /* res */, | |
119 PLT_DeviceDataReference& /* device */, | |
120 PLT_DeviceCapabilities* /* capabilities */, | |
121 void* /* userdata */) {} | |
122 | |
123 virtual void OnGetMediaInfoResult( | |
124 NPT_Result /* res */, | |
125 PLT_DeviceDataReference& /* device */, | |
126 PLT_MediaInfo* /* info */, | |
127 void* /* userdata */) {} | |
128 | |
129 virtual void OnGetPositionInfoResult( | |
130 NPT_Result /* res */, | |
131 PLT_DeviceDataReference& /* device */, | |
132 PLT_PositionInfo* /* info */, | |
133 void* /* userdata */) {} | |
134 | |
135 virtual void OnGetTransportInfoResult( | |
136 NPT_Result /* res */, | |
137 PLT_DeviceDataReference& /* device */, | |
138 PLT_TransportInfo* /* info */, | |
139 void* /* userdata */) {} | |
140 | |
141 virtual void OnGetTransportSettingsResult( | |
142 NPT_Result /* res */, | |
143 PLT_DeviceDataReference& /* device */, | |
144 PLT_TransportSettings* /* settings */, | |
145 void* /* userdata */) {} | |
146 | |
147 virtual void OnNextResult( | |
148 NPT_Result /* res */, | |
149 PLT_DeviceDataReference& /* device */, | |
150 void* /* userdata */) {} | |
151 | |
152 virtual void OnPauseResult( | |
153 NPT_Result /* res */, | |
154 PLT_DeviceDataReference& /* device */, | |
155 void* /* userdata */) {} | |
156 | |
157 virtual void OnPlayResult( | |
158 NPT_Result /* res */, | |
159 PLT_DeviceDataReference& /* device */, | |
160 void* /* userdata */) {} | |
161 | |
162 virtual void OnPreviousResult( | |
163 NPT_Result /* res */, | |
164 PLT_DeviceDataReference& /* device */, | |
165 void* /* userdata */) {} | |
166 | |
167 virtual void OnSeekResult( | |
168 NPT_Result /* res */, | |
169 PLT_DeviceDataReference& /* device */, | |
170 void* /* userdata */) {} | |
171 | |
172 virtual void OnSetAVTransportURIResult( | |
173 NPT_Result /* res */, | |
174 PLT_DeviceDataReference& /* device */, | |
175 void* /* userdata */) {} | |
176 | |
177 virtual void OnSetPlayModeResult( | |
178 NPT_Result /* res */, | |
179 PLT_DeviceDataReference& /* device */, | |
180 void* /* userdata */) {} | |
181 | |
182 virtual void OnStopResult( | |
183 NPT_Result /* res */, | |
184 PLT_DeviceDataReference& /* device */, | |
185 void* /* userdata */) {} | |
186 | |
187 // ConnectionManager | |
188 virtual void OnGetCurrentConnectionIDsResult( | |
189 NPT_Result /* res */, | |
190 PLT_DeviceDataReference& /* device */, | |
191 PLT_StringList* /* ids */, | |
192 void* /* userdata */) {} | |
193 | |
194 virtual void OnGetCurrentConnectionInfoResult( | |
195 NPT_Result /* res */, | |
196 PLT_DeviceDataReference& /* device */, | |
197 PLT_ConnectionInfo* /* info */, | |
198 void* /* userdata */) {} | |
199 | |
200 virtual void OnGetProtocolInfoResult( | |
201 NPT_Result /* res */, | |
202 PLT_DeviceDataReference& /* device */, | |
203 PLT_StringList* /* sources */, | |
204 PLT_StringList* /* sinks */, | |
205 void* /* userdata */) {} | |
206 }; | |
207 | |
208 /*---------------------------------------------------------------------- | |
209 | PLT_MediaController class | |
210 +---------------------------------------------------------------------*/ | |
211 class PLT_MediaController : public PLT_CtrlPointListener | |
212 { | |
213 public: | |
214 PLT_MediaController(PLT_CtrlPointReference& ctrl_point, | |
215 PLT_MediaControllerDelegate* delegate = NULL); | |
216 virtual ~PLT_MediaController(); | |
217 | |
218 // public methods | |
219 virtual void SetDelegate(PLT_MediaControllerDelegate* delegate) { | |
220 m_Delegate = delegate; | |
221 } | |
222 | |
223 // PLT_CtrlPointListener methods | |
224 virtual NPT_Result OnDeviceAdded(PLT_DeviceDataReference& device); | |
225 virtual NPT_Result OnDeviceRemoved(PLT_DeviceDataReference& device); | |
226 virtual NPT_Result OnActionResponse(NPT_Result res, PLT_ActionReference& action, void* userdata); | |
227 virtual NPT_Result OnEventNotify(PLT_Service* service, NPT_List<PLT_StateVariable*>* vars); | |
228 | |
229 // AVTransport | |
230 NPT_Result GetCurrentTransportActions(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata); | |
231 NPT_Result GetDeviceCapabilities(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata); | |
232 NPT_Result GetMediaInfo(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata); | |
233 NPT_Result GetPositionInfo(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata); | |
234 NPT_Result GetTransportInfo(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata); | |
235 NPT_Result GetTransportSettings(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata); | |
236 NPT_Result Next(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata); | |
237 NPT_Result Pause(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata); | |
238 NPT_Result Play(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, NPT_String speed, void* userdata); | |
239 NPT_Result Previous(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata); | |
240 NPT_Result Seek(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, NPT_String unit, NPT_String target, void* userdata); | |
241 NPT_Result SetAVTransportURI(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, const char* uri, const char* metadata, void* userdata); | |
242 NPT_Result SetPlayMode(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, NPT_String new_play_mode, void* userdata); | |
243 NPT_Result Stop(PLT_DeviceDataReference& device, NPT_UInt32 instance_id, void* userdata); | |
244 | |
245 // ConnectionManager | |
246 NPT_Result GetCurrentConnectionIDs(PLT_DeviceDataReference& device, void* userdata); | |
247 NPT_Result GetCurrentConnectionInfo(PLT_DeviceDataReference& device, NPT_UInt32 connection_id, void* userdata); | |
248 NPT_Result GetProtocolInfo(PLT_DeviceDataReference& device, void* userdata); | |
249 | |
250 private: | |
251 NPT_Result FindActionDesc(PLT_DeviceDataReference& device, | |
252 const char* service_type, | |
253 const char* action_name, | |
254 PLT_ActionDesc*& action_desc); | |
255 | |
256 NPT_Result CreateAction(PLT_DeviceDataReference& device, | |
257 const char* service_type, | |
258 const char* action_name, | |
259 PLT_ActionReference& action); | |
260 | |
261 NPT_Result CallAVTransportAction(PLT_ActionReference& action, | |
262 NPT_UInt32 instance_id, | |
263 void* userdata = NULL); | |
264 | |
265 NPT_Result OnGetCurrentTransportActionsResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata); | |
266 NPT_Result OnGetDeviceCapabilitiesResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata); | |
267 NPT_Result OnGetMediaInfoResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata); | |
268 NPT_Result OnGetPositionInfoResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata); | |
269 NPT_Result OnGetTransportInfoResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata); | |
270 NPT_Result OnGetTransportSettingsResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata); | |
271 | |
272 NPT_Result OnGetCurrentConnectionIDsResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata); | |
273 NPT_Result OnGetCurrentConnectionInfoResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata); | |
274 NPT_Result OnGetProtocolInfoResponse(NPT_Result res, PLT_DeviceDataReference& device, PLT_ActionReference& action, void* userdata); | |
275 | |
276 static void ParseCSV(const char* csv, PLT_StringList& values) { | |
277 const char* start = csv; | |
278 const char* p = start; | |
279 | |
280 // look for the , character | |
281 while (*p) { | |
282 if (*p == ',') { | |
283 NPT_String val(start, (int)(p-start)); | |
284 val.Trim(' '); | |
285 values.Add(val); | |
286 start = p + 1; | |
287 } | |
288 p++; | |
289 } | |
290 | |
291 // last one | |
292 NPT_String last(start, (int)(p-start)); | |
293 last.Trim(' '); | |
294 if (last.GetLength()) { | |
295 values.Add(last); | |
296 } | |
297 } | |
298 | |
299 private: | |
300 PLT_CtrlPointReference m_CtrlPoint; | |
301 PLT_MediaControllerDelegate* m_Delegate; | |
302 NPT_List<PLT_DeviceDataReference> m_MediaRenderers; | |
303 }; | |
304 | |
305 #endif /* _PLT_MEDIA_CONTROLLER_H_ */ |