|
1 /* |
|
2 * Copyright (c) 2002-2004 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: Mcc EventHandler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "mmccevent.h" |
|
23 #include "mmccinterface.h" |
|
24 #include "mmccevents.h" |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 |
|
28 // EXTERNAL FUNCTION PROTOTYPES |
|
29 |
|
30 // CONSTANTS |
|
31 |
|
32 // MACROS |
|
33 |
|
34 // LOCAL CONSTANTS AND MACROS |
|
35 |
|
36 // MODULE DATA STRUCTURES |
|
37 |
|
38 // LOCAL FUNCTION PROTOTYPES |
|
39 |
|
40 // FORWARD DECLARATIONS |
|
41 |
|
42 // ============================= LOCAL FUNCTIONS =============================== |
|
43 |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMccEvent::CMccEvent |
|
49 // C++ default constructor can NOT contain any code, that |
|
50 // might leave. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CMccEvent::CMccEvent( RMMFController& aController, MMccCtrlObserver& aCallback ) |
|
54 : CActive( EPriorityStandard ), |
|
55 iController( aController ), |
|
56 iEventCallBack( aCallback ), |
|
57 iMessageDest( KMccControllerUidInterface ) |
|
58 { |
|
59 CActiveScheduler::Add( this ); |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CMccEvent::ConstructL |
|
64 // Symbian 2nd phase constructor can leave. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 void CMccEvent::ConstructL() |
|
68 { |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CMccEvent::NewL |
|
73 // Static constructor. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CMccEvent* CMccEvent::NewL( RMMFController& aController, |
|
77 MMccCtrlObserver& aObserver ) |
|
78 { |
|
79 CMccEvent* self = new (ELeave) CMccEvent( aController, aObserver ); |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop( self ); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CMccEvent::~CMccEvent |
|
88 // Destructor |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CMccEvent::~CMccEvent() |
|
92 { |
|
93 if( IsActive() ) |
|
94 { |
|
95 Cancel(); |
|
96 } |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CMccEvent::RequestEventNotification |
|
101 // Requests for event from Controller plugin and starts event listening loop. |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 void CMccEvent::RequestEventNotification() |
|
105 { |
|
106 if ( !IsActive() ) |
|
107 { |
|
108 iController.CustomCommandAsync( iMessageDest, |
|
109 ERequestEventNotification, |
|
110 KNullDesC8, |
|
111 KNullDesC8, |
|
112 iPackage, |
|
113 iStatus); |
|
114 |
|
115 SetActive(); |
|
116 } |
|
117 else |
|
118 { |
|
119 // Something is very wrong here |
|
120 } |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CMccEvent::DoCancel |
|
125 // From CActive Implements cancellation of an outstanding request. |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CMccEvent::DoCancel() |
|
129 { |
|
130 iController.CustomCommandSync( iMessageDest, EMccCancel, |
|
131 KNullDesC8, KNullDesC8 ); |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CMccEvent::RunL |
|
136 // From CActive Handles an active object’s request completion event. |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CMccEvent::RunL() |
|
140 { |
|
141 if ( KErrNone == iStatus.Int() ) |
|
142 { |
|
143 TMccEvent event = iPackage(); |
|
144 |
|
145 switch( event.iEventType ) |
|
146 { |
|
147 //HandleMccMediaEvent |
|
148 case KMccRtcpReceived: |
|
149 case KMccDtmfReceived: |
|
150 case KMccDtmfControl: |
|
151 case KMccStreamPlaying: |
|
152 case KMccStreamBuffering: |
|
153 case KMccStreamIdle: |
|
154 case KMccLinkCreated: |
|
155 case KMccMediaQualityStatus: |
|
156 case KMccResourceNotAvailable: |
|
157 case KMccTranscodeCancelled: |
|
158 case KMccTranscodeInProgress: |
|
159 case KMccTranscodeCompleted: |
|
160 case KMccMasterKeyStaled: |
|
161 HandleMccMediaEvent( event ); |
|
162 break; |
|
163 |
|
164 //HandleMccErrorEvent |
|
165 case KMccStreamError: |
|
166 case KMccStreamMMFEvent: |
|
167 HandleMccErrorEvent( event ); |
|
168 break; |
|
169 |
|
170 //HandleMccStateChangeEvent |
|
171 case KMccStreamPrepared: |
|
172 case KMccStreamStarted: |
|
173 case KMccStreamPaused: |
|
174 case KMccStreamResumed: |
|
175 case KMccStreamStopped: |
|
176 case KMccStreamClosed: |
|
177 HandleMccStateChangeEvent( event ); |
|
178 break; |
|
179 |
|
180 //HandleMccInactivityEvent |
|
181 case KMccInactivityEvent: |
|
182 HandleMccInactivityEvent( event ); |
|
183 break; |
|
184 |
|
185 //HandleMccActivityEvent |
|
186 case KMccActivityEvent: |
|
187 HandleMccActivityEvent( event ); |
|
188 break; |
|
189 |
|
190 case KMccUnknownMediaReceived: |
|
191 HandleMccUnknownMediaEvent( event ); |
|
192 break; |
|
193 |
|
194 default: |
|
195 break; |
|
196 } |
|
197 |
|
198 RequestEventNotification(); |
|
199 } |
|
200 else |
|
201 { |
|
202 User::Leave( iStatus.Int() ); |
|
203 } |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CMccEvent::RunError |
|
208 // From CActive Handles |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 TInt CMccEvent::RunError( TInt /*aError*/ ) |
|
212 { |
|
213 return KErrNone; |
|
214 } |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CMccEvent::HandleMccMediaEvent |
|
218 // |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 void CMccEvent::HandleMccMediaEvent( const TMccEvent& aEvent ) |
|
222 { |
|
223 iEventCallBack.MccEventReceived( aEvent ); |
|
224 } |
|
225 |
|
226 // ----------------------------------------------------------------------------- |
|
227 // CMccEvent::HandleMccStateChangeEvent |
|
228 // |
|
229 // ----------------------------------------------------------------------------- |
|
230 // |
|
231 void CMccEvent::HandleMccStateChangeEvent( const TMccEvent& aEvent ) |
|
232 { |
|
233 if ( aEvent.iErrorCode ) |
|
234 { |
|
235 HandleMccErrorEvent( aEvent ); |
|
236 return; |
|
237 } |
|
238 switch ( aEvent.iEventType ) |
|
239 { |
|
240 case KMccStreamPrepared: |
|
241 iEventCallBack.MccMediaPrepared( aEvent.iSessionId, aEvent.iLinkId, |
|
242 aEvent.iStreamId, aEvent.iEndpointId ); |
|
243 break; |
|
244 case KMccStreamStarted: |
|
245 iEventCallBack.MccMediaStarted( aEvent.iSessionId, aEvent.iLinkId, |
|
246 aEvent.iStreamId, aEvent.iEndpointId ); |
|
247 break; |
|
248 case KMccStreamPaused: |
|
249 iEventCallBack.MccMediaPaused( aEvent.iSessionId, aEvent.iLinkId, |
|
250 aEvent.iStreamId, aEvent.iEndpointId ); |
|
251 break; |
|
252 case KMccStreamResumed: |
|
253 iEventCallBack.MccMediaResumed( aEvent.iSessionId, aEvent.iLinkId, |
|
254 aEvent.iStreamId, aEvent.iEndpointId ); |
|
255 break; |
|
256 case KMccStreamStopped: |
|
257 iEventCallBack.MccMediaStopped( aEvent.iSessionId, aEvent.iLinkId, |
|
258 aEvent.iStreamId, aEvent.iEndpointId ); |
|
259 break; |
|
260 default: |
|
261 break; |
|
262 } |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CMccEvent::HandleMccInactivityEvent |
|
267 // |
|
268 // ----------------------------------------------------------------------------- |
|
269 // |
|
270 void CMccEvent::HandleMccInactivityEvent( const TMccEvent& aEvent ) |
|
271 { |
|
272 iEventCallBack.MccMediaInactive( aEvent.iSessionId, |
|
273 aEvent.iLinkId, |
|
274 aEvent.iStreamId, |
|
275 aEvent.iEndpointId ); |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CMccEvent::HandleMccActivityEvent |
|
280 // |
|
281 // ----------------------------------------------------------------------------- |
|
282 // |
|
283 void CMccEvent::HandleMccActivityEvent( const TMccEvent& aEvent ) |
|
284 { |
|
285 iEventCallBack.MccMediaActive( aEvent.iSessionId, |
|
286 aEvent.iLinkId, |
|
287 aEvent.iStreamId, |
|
288 aEvent.iEndpointId ); |
|
289 } |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // CMccEvent::HandleMccErrorEvent |
|
293 // |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 void CMccEvent::HandleMccErrorEvent( const TMccEvent& aEvent ) |
|
297 { |
|
298 iEventCallBack.MccCtrlError( aEvent.iErrorCode, |
|
299 aEvent.iSessionId, |
|
300 aEvent.iLinkId, |
|
301 aEvent.iStreamId, |
|
302 aEvent.iEndpointId ); |
|
303 } |
|
304 |
|
305 // ----------------------------------------------------------------------------- |
|
306 // CMccEvent::HandleMccUnknownMediaEvent |
|
307 // |
|
308 // ----------------------------------------------------------------------------- |
|
309 // |
|
310 void CMccEvent::HandleMccUnknownMediaEvent( const TMccEvent& aEvent ) |
|
311 { |
|
312 iEventCallBack.UnknownMediaReceived( aEvent.iSessionId, aEvent.iLinkId, |
|
313 aEvent.iStreamId, aEvent.iEndpointId, TUint8( aEvent.iErrorCode ) ); |
|
314 } |