|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class for retrieving and selecting media renderers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef C_UPNPVALUESTATEMACHINE_H |
|
24 #define C_UPNPVALUESTATEMACHINE_H |
|
25 |
|
26 // INCLUDES |
|
27 #include <e32base.h> |
|
28 #include <mpxplaybackframeworkdefs.h> |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 class CUPnPMusicPlayer; |
|
32 class MUPnPAVRenderingSession; |
|
33 |
|
34 |
|
35 |
|
36 /** |
|
37 * Class for handling playback state machine functionality |
|
38 * |
|
39 * @lib upnpmusicplugins.lib |
|
40 * @since S60 v3.1 |
|
41 */ |
|
42 class CUPnPValueStateMachine : public CBase |
|
43 { |
|
44 |
|
45 public: // construction / destruction |
|
46 |
|
47 /** |
|
48 * Static 1st phase constructor |
|
49 * |
|
50 * @since Series 60 3.1 |
|
51 * @param aParent the parent plugin instance |
|
52 * @param aRenderingSession for playback commands |
|
53 */ |
|
54 static CUPnPValueStateMachine* NewL( |
|
55 CUPnPMusicPlayer& aParent, |
|
56 MUPnPAVRenderingSession& aRenderingSession ); |
|
57 |
|
58 /** |
|
59 * Destructor |
|
60 * |
|
61 * @since Series 60 3.1 |
|
62 */ |
|
63 virtual ~CUPnPValueStateMachine(); |
|
64 |
|
65 public: // datatypes used in this class |
|
66 |
|
67 /** |
|
68 * current type of operation |
|
69 */ |
|
70 enum TOperationType |
|
71 { |
|
72 EOperationNone, // no operation going on |
|
73 EOperationValue, // value get |
|
74 EOperationSet, // value set |
|
75 EOperationDurationQuery, // internal duration query |
|
76 EOperationPositionQuery, // internal position query |
|
77 EOperationVolumeQuery, // internal volume query |
|
78 EOperationMute // internal mute |
|
79 }; |
|
80 |
|
81 /** |
|
82 * An internal operation class |
|
83 */ |
|
84 class TOperation |
|
85 { |
|
86 public: |
|
87 /** construction */ |
|
88 TOperation( TOperationType aType ) |
|
89 : iType( aType ) {} |
|
90 TOperation( TOperationType aType, TInt aValue ) |
|
91 : iType( aType ) |
|
92 , iValue( aValue ) {} |
|
93 TOperation( TMPXPlaybackProperty aProperty, TInt aValue ) |
|
94 : iType( EOperationSet ) |
|
95 , iProperty( aProperty ) |
|
96 , iValue( aValue ) {} |
|
97 TOperation( TMPXPlaybackProperty aProperty ) |
|
98 : iType( EOperationValue ) |
|
99 , iProperty( aProperty ) {} |
|
100 |
|
101 /** setters */ |
|
102 void operator=( TOperationType aType ) |
|
103 { |
|
104 iType = aType; |
|
105 } |
|
106 void Set( TMPXPlaybackProperty aProperty, TInt aValue ) |
|
107 { |
|
108 iType = EOperationSet; |
|
109 iProperty = aProperty; |
|
110 iValue = aValue; |
|
111 } |
|
112 void Set( TMPXPlaybackProperty aProperty ) |
|
113 { |
|
114 iType = EOperationValue; |
|
115 iProperty = aProperty; |
|
116 } |
|
117 void Reset() |
|
118 { |
|
119 iType = EOperationNone; |
|
120 } |
|
121 /** comparision */ |
|
122 TBool operator==( TOperationType aType ) |
|
123 { |
|
124 return ( iType == aType ); |
|
125 } |
|
126 TBool Compare( TOperationType aType, TMPXPlaybackProperty aProperty ) |
|
127 { |
|
128 return ( iType == aType && iProperty == aProperty ); |
|
129 } |
|
130 TBool None() |
|
131 { |
|
132 return ( iType == EOperationNone ); |
|
133 } |
|
134 /** identifies the operation type */ |
|
135 TOperationType iType; |
|
136 /** playback property, if op == Value or Set */ |
|
137 TMPXPlaybackProperty iProperty; |
|
138 /** playback property value, if op == Set */ |
|
139 TInt iValue; |
|
140 }; |
|
141 |
|
142 /** |
|
143 * A result of validation query. |
|
144 * Indicates what to do with a Value- or a Set- call |
|
145 */ |
|
146 enum TValidationResult |
|
147 { |
|
148 EHandle, // handle the call in value state machine |
|
149 EHandleStatic, // handle the call statically in v.s.m. |
|
150 EErrorNotReady, // async error (KErrNotReady) |
|
151 EErrorNotSupported, // async error (KErrNotSupported) |
|
152 EIgnore // do absolutely nothing |
|
153 }; |
|
154 |
|
155 public: // services |
|
156 |
|
157 /** |
|
158 * A method to copy some static renderer-specific values from |
|
159 * another instance of a state machine. Note that one instance is |
|
160 * track specific, so track specific cached values are NOT copied, |
|
161 * (track duration etc.) but renderer specific values are copied |
|
162 * (volume etc) |
|
163 * @param aOther another instance to copy values from |
|
164 */ |
|
165 void CopyValues( const CUPnPValueStateMachine& aOther ); |
|
166 |
|
167 /** |
|
168 * See CMPXPlaybackPlugin |
|
169 */ |
|
170 void SetL( TMPXPlaybackProperty aProperty, TInt aValue ); |
|
171 |
|
172 /** |
|
173 * See CMPXPlaybackPlugin |
|
174 */ |
|
175 void ValueL( TMPXPlaybackProperty aProperty ); |
|
176 |
|
177 /** |
|
178 * See MUPnPRenderiongSessionObserver |
|
179 */ |
|
180 void VolumeResult( TInt aError, TInt aVolumeLevel, |
|
181 TBool aActionResponse ); |
|
182 |
|
183 /** |
|
184 * See MUPnPRenderiongSessionObserver |
|
185 */ |
|
186 void MuteResult( TInt aError, TBool aMute, TBool aActionResponse ); |
|
187 |
|
188 /** |
|
189 * See MUPnPRenderiongSessionObserver |
|
190 */ |
|
191 void PositionInfoResult( TInt aStatus, const TDesC8& aTrackPosition, |
|
192 const TDesC8& aTrackLength ); |
|
193 |
|
194 /** |
|
195 * Initiates a duration request, which will be reported to |
|
196 * the plugin observer as a change event |
|
197 */ |
|
198 void DurationQueryL(); |
|
199 |
|
200 /** |
|
201 * Initiates a position request |
|
202 */ |
|
203 void PositionQueryL(); |
|
204 |
|
205 /** |
|
206 * Initiates a volume request, which will be reported to |
|
207 * the plugin observer as a change event |
|
208 */ |
|
209 void VolumeQueryL(); |
|
210 |
|
211 /** |
|
212 * Initiates an internal mute request, which will not be reported. |
|
213 * @param aMute if other than zero, mute will be activated |
|
214 */ |
|
215 void MuteRequestL( TInt aMute ); |
|
216 |
|
217 /** |
|
218 * Validates a Value- or Set- call with given property in given |
|
219 * player state. There will be a result indicating what to do with |
|
220 * the call. |
|
221 * @param aProperty the property to be either get or set |
|
222 * @param aSetting true if setting the value, false if getting |
|
223 * @param aPlayerState state of the player plugin |
|
224 * @param aIsReady is remote device to gíve playback information |
|
225 * @return result of validation |
|
226 */ |
|
227 static TValidationResult ValidatePropertyInState( |
|
228 TMPXPlaybackProperty aProperty, |
|
229 TBool aSetting, |
|
230 TInt aPlayerState, |
|
231 TBool aIsReady ); |
|
232 |
|
233 /** |
|
234 * A static version of Value query - this one is capable of handling |
|
235 * some fixed Value queries that do not need network resources |
|
236 */ |
|
237 static void ValueStatic( |
|
238 TMPXPlaybackProperty aProperty, |
|
239 MMPXPlaybackPluginObserver& aPlaybackObs ); |
|
240 |
|
241 /** |
|
242 * Cancels any ongoing operation |
|
243 * (actually it just resets the state so the result will be ignored |
|
244 * and not reported) |
|
245 */ |
|
246 void Cancel(); |
|
247 |
|
248 private: |
|
249 |
|
250 /** |
|
251 * Private default constructor |
|
252 * |
|
253 * @since Series 60 3.1 |
|
254 * @param aParent the parent plugin instance |
|
255 * @param aRenderingSession for playback commands |
|
256 */ |
|
257 CUPnPValueStateMachine( |
|
258 CUPnPMusicPlayer& aParent, |
|
259 MUPnPAVRenderingSession& aRenderingSession ); |
|
260 |
|
261 /** |
|
262 * Checks if operations are in the queue, and executes |
|
263 */ |
|
264 void CheckOperationInQueueL(); |
|
265 |
|
266 /** |
|
267 * Check if given property are in queue |
|
268 * @param aProperty property to be searched |
|
269 * @return Etrue if found |
|
270 */ |
|
271 TBool FoundFromQueue( TMPXPlaybackProperty aProperty ); |
|
272 |
|
273 private: // data |
|
274 |
|
275 /** |
|
276 * Parent plugin instance |
|
277 */ |
|
278 CUPnPMusicPlayer& iParent; |
|
279 |
|
280 /** |
|
281 * Rendering session |
|
282 */ |
|
283 MUPnPAVRenderingSession& iRendererSession; |
|
284 |
|
285 /** |
|
286 * currently ongoing operation |
|
287 */ |
|
288 TOperation iCurrentOperation; |
|
289 |
|
290 /** |
|
291 * queue of operations pending |
|
292 */ |
|
293 RArray<TOperation> iOperationQueue; |
|
294 |
|
295 /** |
|
296 * current renderer volume level. |
|
297 * cached internally to avoid unnecessary message traffic. |
|
298 */ |
|
299 TInt iRendererVolume; |
|
300 |
|
301 /** |
|
302 * current renderer muted state (1 = muted, 0 = normal) |
|
303 * cached internally to avoid unnecessary message traffic. |
|
304 */ |
|
305 TInt iRendererMuted; |
|
306 |
|
307 }; |
|
308 |
|
309 |
|
310 #endif // C_UPNPVALUESTATEMACHINE_H |
|
311 |