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: Audio policy implementation for upnp remote plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 #ifndef C_UPNPAUDIOPOLICY_H |
|
24 #define C_UPNPAUDIOPOLICY_H |
|
25 |
|
26 |
|
27 #include <mmf/server/sounddevice.h> // for MDevSoundObserver |
|
28 |
|
29 // FORWARD DECLARATIONS |
|
30 class MUPnPAudioPolicyObserver; |
|
31 class CMMFBuffer; |
|
32 class CMMFDevSound; |
|
33 |
|
34 /** |
|
35 * A class that implements audio policy for upnp playback plugin. |
|
36 * It registers for DevSound for a vrtual playback handle and is |
|
37 * able to receive notifications from MMF. The purpose for this |
|
38 * is to pause upnp playback when <br> |
|
39 * - local playback begins <br> |
|
40 * - there is an incoming call <br> |
|
41 * |
|
42 * @lib upnpmusicplugins.lib |
|
43 * @since S60 v3.1 |
|
44 */ |
|
45 class CUPnPAudioPolicy |
|
46 : public CBase, |
|
47 public MDevSoundObserver |
|
48 { |
|
49 |
|
50 private: |
|
51 |
|
52 /** |
|
53 * State of audiopolicy |
|
54 * |
|
55 * @since Series 60 3.1 |
|
56 */ |
|
57 enum TAudioPolicyState |
|
58 { |
|
59 EStateUninitialised, // waiting initialise devSound, can not be used |
|
60 EStatePlaying, // audiopolicy initialized and playback started |
|
61 EStateStopped, // playback stopped |
|
62 }; |
|
63 |
|
64 public: // public services |
|
65 |
|
66 /** |
|
67 * constructor |
|
68 * @param aPlaybackMachine the playback states engine |
|
69 */ |
|
70 static CUPnPAudioPolicy* NewL( |
|
71 MUPnPAudioPolicyObserver& aObserver ); |
|
72 |
|
73 /** |
|
74 * destructor |
|
75 */ |
|
76 CUPnPAudioPolicy::~CUPnPAudioPolicy(); |
|
77 |
|
78 /** |
|
79 * request for start playback |
|
80 */ |
|
81 void PlayL(); |
|
82 |
|
83 /** |
|
84 * indicate playback stops |
|
85 */ |
|
86 void Stop(); |
|
87 |
|
88 protected: // MDevSoundObserver |
|
89 |
|
90 /** |
|
91 * see MDevSoundObserver |
|
92 */ |
|
93 void InitializeComplete( TInt aError ); |
|
94 |
|
95 /** |
|
96 * see MDevSoundObserver |
|
97 */ |
|
98 void ToneFinished( TInt aError ); |
|
99 |
|
100 /** |
|
101 * see MDevSoundObserver |
|
102 */ |
|
103 void BufferToBeFilled( CMMFBuffer* aBuffer ); |
|
104 |
|
105 /** |
|
106 * see MDevSoundObserver |
|
107 */ |
|
108 void PlayError( TInt aError ); |
|
109 |
|
110 /** |
|
111 * see MDevSoundObserver |
|
112 */ |
|
113 void BufferToBeEmptied( CMMFBuffer* aBuffer ); |
|
114 |
|
115 /** |
|
116 * see MDevSoundObserver |
|
117 */ |
|
118 void RecordError( TInt aError ); |
|
119 |
|
120 /** |
|
121 * see MDevSoundObserver |
|
122 */ |
|
123 void ConvertError( TInt aError ); |
|
124 |
|
125 /** |
|
126 * see MDevSoundObserver |
|
127 */ |
|
128 void DeviceMessage( TUid aMessageType, const TDesC8& aMsg ); |
|
129 |
|
130 /** |
|
131 * see MDevSoundObserver |
|
132 */ |
|
133 void SendEventToClient( const TMMFEvent& aEvent ); |
|
134 |
|
135 private: // private methods |
|
136 |
|
137 /** |
|
138 * default constructor |
|
139 * @param aPlaybackMachine the playback states engine |
|
140 */ |
|
141 CUPnPAudioPolicy( |
|
142 MUPnPAudioPolicyObserver& aObserver ); |
|
143 |
|
144 /** |
|
145 * 2nd phase constructor |
|
146 */ |
|
147 void ConstructL(); |
|
148 |
|
149 private: // data |
|
150 |
|
151 /** |
|
152 * the playback states engine |
|
153 */ |
|
154 MUPnPAudioPolicyObserver& iObserver; |
|
155 |
|
156 /** |
|
157 * DevSound component for MMF access |
|
158 */ |
|
159 CMMFDevSound* iDevSound; |
|
160 |
|
161 /** |
|
162 * Current AudioPolicy state |
|
163 */ |
|
164 TAudioPolicyState iAudioPolicyState; |
|
165 |
|
166 }; |
|
167 |
|
168 /** |
|
169 * Callback interface for audio policy class |
|
170 */ |
|
171 class MUPnPAudioPolicyObserver |
|
172 { |
|
173 |
|
174 public: |
|
175 |
|
176 /** |
|
177 * A conflict was found between simultaneously playing audio |
|
178 * resources. This means that this instance is active and |
|
179 * meanwhile another party starts using audio resources in |
|
180 * a way that has been defined to be illegal. The observer |
|
181 * is expected to take apropriate actions after receiving |
|
182 * this event - notifying the playback framework, which will |
|
183 * then clear all resources and inform user. |
|
184 * |
|
185 * @param aError error to be issued to playback framework |
|
186 */ |
|
187 virtual void AudioConflict( TInt aError ) = 0; |
|
188 |
|
189 }; |
|
190 |
|
191 #endif // C_UPNPAUDIOPOLICY_H |
|