1 /* |
|
2 * Copyright (c) 2007-2009 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: Implements class CSPVideoCall which provides video call |
|
15 * functionality |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include <etelmm.h> |
|
21 #include <etel.h> |
|
22 #include <mccpcallobserver.h> |
|
23 #include <rmmcustomapi.h> |
|
24 |
|
25 #include "cspvideocall.h" |
|
26 #include "cspetelcallrequester.h" |
|
27 #include "cspetelcalleventmonitor.h" |
|
28 #include "cspetelcallstatusmonitor.h" |
|
29 #include "cspetelvideocallcapsmonitor.h" |
|
30 #include "csplogger.h" |
|
31 #include "csppanic.pan" |
|
32 #include "cspconsts.h" |
|
33 #include "mcspcommoninfo.h" |
|
34 |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // CSPVideoCall::NewL Two phased construction. |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 CSPVideoCall* CSPVideoCall::NewL( const TDesC& aName, |
|
41 RMobileLine& aLine, TBool aMobileOriginated, |
|
42 const CCCECallParameters& aParams, |
|
43 MCSPCommonInfo& aCommonInfo ) |
|
44 { |
|
45 CSPLOGSTRING(CSPOBJECT, "CSPVideoCall::NewL <"); |
|
46 |
|
47 CSPVideoCall* self = new (ELeave) CSPVideoCall( aLine, aMobileOriginated, |
|
48 aName, aCommonInfo ); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL( aParams ); |
|
51 CleanupStack::Pop( self ); |
|
52 CSPLOGSTRING(CSPOBJECT, "CSPVideoCall::NewL >"); |
|
53 return self; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------------------------- |
|
57 // CSPVideoCall::~CSPVideoCall |
|
58 // --------------------------------------------------------------------------- |
|
59 // |
|
60 CSPVideoCall::~CSPVideoCall() |
|
61 { |
|
62 CSPLOGSTRING(CSPOBJECT, "CSPVideoCall::~CSPVideoCall <"); |
|
63 // Stop monitoring events |
|
64 delete iConnectionHandler; |
|
65 delete iVideoCallCapsMonitor; |
|
66 |
|
67 CSPLOGSTRING(CSPOBJECT, "CSPVideoCall::~CSPVideoCall >"); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // CSPVideoCall::NotifyCallStateChanged |
|
72 // Notifies observers about state changes |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 void CSPVideoCall::NotifyCallStateChanged( |
|
76 MCCPCallObserver::TCCPCallState aState ) |
|
77 { |
|
78 CSPLOGSTRING2(CSPINT, "CSPVideoCall::NotifyCallStateChanged %d", aState); |
|
79 |
|
80 TInt errorCode( KErrNone ); |
|
81 iNextCallState = aState; |
|
82 |
|
83 if ( aState == MCCPCallObserver::ECCPStateConnected && |
|
84 iParams->CallType() == CCPCall::ECallTypeVideo && |
|
85 !iConnectionHandler->ConnectionInitialized() ) |
|
86 { |
|
87 // When connected message is received, call object must first open |
|
88 // the socket connection and loan data port |
|
89 CSPLOGSTRING(CSPINT, |
|
90 "CSPVideoCall::NotifyCallStateChanged initializing connection"); |
|
91 errorCode = iConnectionHandler->InitializeConnection(); |
|
92 |
|
93 __ASSERT_ALWAYS( errorCode == KErrNone, |
|
94 Panic( ECSPPanicDataConnectionInitError ) ); |
|
95 } |
|
96 else if ( aState == MCCPCallObserver::ECCPStateIdle && |
|
97 iParams->CallType() == CCPCall::ECallTypeVideo ) |
|
98 { |
|
99 // When idle message is received one can close the |
|
100 // socket connections. |
|
101 CSPLOGSTRING(CSPINT, |
|
102 "CSPVideoCall::NotifyCallStateChanged releasing connection"); |
|
103 iConnectionHandler->ReleaseConnection(); |
|
104 } |
|
105 |
|
106 // Connected notify is not sent for video call before connection has |
|
107 // been initialized. |
|
108 if ( aState == MCCPCallObserver::ECCPStateConnected && |
|
109 iParams->CallType() == CCPCall::ECallTypeVideo && |
|
110 !iConnectionHandler->ConnectionInitialized() ) |
|
111 { |
|
112 CSPLOGSTRING(CSPINT, |
|
113 "CSPVideoCall::NotifyCallStateChanged connection not initialized"); |
|
114 } |
|
115 else |
|
116 { |
|
117 CSPLOGSTRING(CSPINT, |
|
118 "CSPVideoCall::NotifyCallStateChanged notifying state change"); |
|
119 CSPCall::NotifyCallStateChanged( aState ); |
|
120 } |
|
121 |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // CSPVideoCall::NotifyCallStateChangedWithInband |
|
126 // Notifies observers about state changes |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 void CSPVideoCall::NotifyCallStateChangedWithInband( |
|
130 MCCPCallObserver::TCCPCallState aState ) |
|
131 { |
|
132 CSPLOGSTRING2(CSPINT, |
|
133 "CSPVideoCall::NotifyCallStateChangedWithInband %d", aState); |
|
134 iNextCallState = aState; |
|
135 |
|
136 CSPCall::NotifyCallStateChangedWithInband( aState ); |
|
137 } |
|
138 |
|
139 // --------------------------------------------------------------------------- |
|
140 // CSPVideoCall::ConnectionReady |
|
141 // --------------------------------------------------------------------------- |
|
142 // |
|
143 void CSPVideoCall::ConnectionReady( TName aDataPortName ) |
|
144 { |
|
145 CSPLOGSTRING3(CSPINT, "CSPVideoCall::ConnectionReady \ |
|
146 state = %d, next state: %d", iCallState, iNextCallState); |
|
147 |
|
148 // If still connecting |
|
149 if ( iNextCallState == MCCPCallObserver::ECCPStateConnected ) |
|
150 { |
|
151 NotifyCallEventOccurred( MCCPCallObserver::ECCPCSDataPortLoaned ); |
|
152 NotifyCallStateChanged( iNextCallState ); |
|
153 iCommonInfo.NotifyDataPortName( aDataPortName ); |
|
154 } |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CSPVideoCall::ConnectionEstablishingFailed |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 void CSPVideoCall::ConnectionEstablishingFailed(TInt /*aErr*/) |
|
162 { |
|
163 CSPLOGSTRING(CSPERROR, "CSPVideoCall::ConnectionEstablishingFailed"); |
|
164 CSPCall::NotifyErrorOccurred( ECCPErrorVideoCallSetupFailed ); |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CSPVideoCall::VideoCallCapsChanged |
|
169 // Receives data call caps changed notification from Etel data call caps monitor |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 void CSPVideoCall::DataCallCapsChanged( RMobileCall::TMobileCallDataCapsV1& aCaps ) |
|
173 { |
|
174 CSPLOGSTRING(CSPINT, "CSPVideoCall::DataCallCapsChanged"); |
|
175 if ( aCaps.iProtocolCaps == RMobileCall::KCapsIsdnMultimedia ) |
|
176 { |
|
177 CSPLOGSTRING(CSPINT, "CSPVideoCall::DataCallCapsChanged type=video"); |
|
178 iParams->SetCallType( CCPCall::ECallTypeVideo ); |
|
179 } |
|
180 else |
|
181 { |
|
182 CSPLOGSTRING(CSPINT, "CSPVideoCall::DataCallCapsChanged type=voice"); |
|
183 iParams->SetCallType( CCPCall::ECallTypeCSVoice ); |
|
184 } |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // Branches dial requests according to the flag. |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 TInt CSPVideoCall::DialFdnCond( TBool aFdnCheck ) |
|
192 { |
|
193 CSPLOGSTRING(CSPREQIN, "CSPVideoCall::DialFdnCond <"); |
|
194 TInt err(KErrNone); |
|
195 |
|
196 SetDefaultCallParameters(); |
|
197 |
|
198 // Update internal call params |
|
199 iCommonInfo.InitializeDataCallParameters( iDataCallParams ); |
|
200 |
|
201 // Set the call state to dialling |
|
202 if ( iCall.SubSessionHandle() ) |
|
203 { |
|
204 CSPLOGSTRING(CSPINT, "CSPVideoCall::DialFdnCond make request"); |
|
205 if ( aFdnCheck ) |
|
206 { |
|
207 err = iRequester->MakeDialRequest( |
|
208 iDataCallParamsPckg, iRemotePartyNumber ); |
|
209 } |
|
210 else |
|
211 { |
|
212 err = iRequester->MakeDialNoFdnCheckRequest( |
|
213 iDataCallParamsPckg, iRemotePartyNumber ); |
|
214 } |
|
215 |
|
216 if ( err != KErrNone ) |
|
217 { |
|
218 CSPLOGSTRING2(CSPERROR, |
|
219 "CSPVideoCall::DialFdnCond ERROR with Dial request: %d", err ); |
|
220 } |
|
221 } |
|
222 else |
|
223 { |
|
224 CSPLOGSTRING2(CSPERROR, "CSPVideoCall::DialFdnCond() ERROR with iCall session: %d", &iCall ); |
|
225 err = KErrGeneral; |
|
226 } |
|
227 |
|
228 CSPLOGSTRING(CSPINT, "CSPVideoCall::DialFdnCond() >"); |
|
229 return err; |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // From class MCCPCSCall |
|
234 // CSPVideoCall::SwitchAlternatingCall |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 TInt CSPVideoCall::SwitchAlternatingCall() |
|
238 { |
|
239 CSPLOGSTRING(CSPREQIN, "CSPVideoCall::GetMobileCallInfo"); |
|
240 return KErrNotSupported; |
|
241 } |
|
242 |
|
243 // --------------------------------------------------------------------------- |
|
244 // From class MCCPCSCall |
|
245 // CSPVideoCall::GetMobileDataCallCaps |
|
246 // --------------------------------------------------------------------------- |
|
247 // |
|
248 TInt CSPVideoCall::GetMobileDataCallCaps( TDes8& aCaps ) const |
|
249 { |
|
250 CSPLOGSTRING(CSPREQIN, "CSPVideoCall::GetMobileDataCallCaps"); |
|
251 return iVideoCallCapsMonitor->GetMobileDataCallCaps( aCaps ); |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // From class MCCPCall |
|
256 // CSPVideoCall::IsSecured |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 TBool CSPVideoCall::IsSecured() const |
|
260 { |
|
261 CSPLOGSTRING(CSPREQIN, "CSPVideoCall::IsSecured"); |
|
262 return CSPCall::IsSecured(); |
|
263 } |
|
264 |
|
265 // --------------------------------------------------------------------------- |
|
266 // CSPVideoCall::CSPVideoCall |
|
267 // --------------------------------------------------------------------------- |
|
268 // |
|
269 CSPVideoCall::CSPVideoCall( RMobileLine& aLine, |
|
270 TBool aMobileOriginated, |
|
271 const TDesC& aName, |
|
272 MCSPCommonInfo& aCommonInfo ) : |
|
273 CSPCall( aLine, aMobileOriginated, aName, |
|
274 aCommonInfo, EFalse ), |
|
275 iDataCallParams(), |
|
276 iDataCallParamsPckg (iDataCallParams) |
|
277 |
|
278 { |
|
279 CSPLOGSTRING(CSPOBJECT, "CSPVideoCall::CSPVideoCall"); |
|
280 } |
|
281 |
|
282 // --------------------------------------------------------------------------- |
|
283 // CSPVideoCall::ConstructL |
|
284 // Constructing CSPVideoCall for MT call. |
|
285 // --------------------------------------------------------------------------- |
|
286 // |
|
287 void CSPVideoCall::ConstructL( const CCCECallParameters& aParams ) |
|
288 { |
|
289 CSPLOGSTRING(CSPOBJECT, "CSPVideoCall::ConstructL <"); |
|
290 |
|
291 CSPCall::ConstructL( aParams ); |
|
292 |
|
293 iConnectionHandler = CSPVideoCallConnectionHandler::NewL( *this, iCall ); |
|
294 iVideoCallCapsMonitor = CSPEtelVideoCallCapsMonitor::NewL( *this, iCall ); |
|
295 iVideoCallCapsMonitor->StartMonitoring(); |
|
296 |
|
297 // Update call type info only for MT call. |
|
298 if ( !iMobileOriginated ) |
|
299 { |
|
300 CSPLOGSTRING(CSPOBJECT, "CSPVideoCall::ConstructL() selecting call type for MT call"); |
|
301 CCPCall::TCallType callType = SelectCallTypeFromProtocolCaps(); |
|
302 iParams->SetCallType( callType ); |
|
303 } |
|
304 |
|
305 // Filter out illegal requests |
|
306 if ( !CCPCall::ECallTypeVideo == iParams->CallType() ) |
|
307 { |
|
308 CSPLOGSTRING(CSPERROR, "CSPVideoCall::ConstructL() error invalid call type"); |
|
309 User::Leave( KErrArgument ); |
|
310 } |
|
311 |
|
312 CSPLOGSTRING(CSPOBJECT, "CSPVideoCall::ConstructL >"); |
|
313 } |
|
314 |
|
315 // ----------------------------------------------------------------------------- |
|
316 // Set default call parameters. |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 void CSPVideoCall::SetDefaultCallParameters() |
|
320 { |
|
321 // Set common call default parameters |
|
322 iDataCallParams.iSpeakerControl = RMobileCall::EMonitorSpeakerControlAlwaysOn; |
|
323 iDataCallParams.iSpeakerVolume = RMobileCall::EMonitorSpeakerVolumeMedium; |
|
324 iDataCallParams.iInterval = KCSPDefaultInterval; |
|
325 iDataCallParams.iWaitForDialTone = RMobileCall::EDialToneNoWait; |
|
326 iDataCallParams.iIdRestrict = RMobileCall::EIdRestrictDefault; |
|
327 iDataCallParams.iAutoRedial = KCSPDefaultAutoRedial; |
|
328 // Set video call parameters |
|
329 iDataCallParams.iService = RMobileCall::EServiceDataCircuitSync; |
|
330 iDataCallParams.iSpeed = RMobileCall::ESpeed64000; |
|
331 iDataCallParams.iProtocol = RMobileCall::EProtocolIsdnMultimedia; |
|
332 iDataCallParams.iQoS = RMobileCall::EQoSTransparent; |
|
333 iDataCallParams.iRLPVersion = RMobileCall::ERLPNotRequested; |
|
334 iDataCallParams.iModemToMSWindowSize = 0x00; |
|
335 iDataCallParams.iMSToModemWindowSize = 0x00; |
|
336 iDataCallParams.iAckTimer = 0x00; |
|
337 iDataCallParams.iRetransmissionAttempts = 0x00; |
|
338 iDataCallParams.iResequencingPeriod = 0x00; |
|
339 iDataCallParams.iV42bisReq = RMobileCall::EV42bisNeitherDirection; |
|
340 iDataCallParams.iV42bisCodewordsNum = 0x00; |
|
341 iDataCallParams.iV42bisMaxStringLength = 0x00; |
|
342 iDataCallParams.iUseEdge = EFalse; |
|
343 } |
|
344 |
|
345 // --------------------------------------------------------------------------- |
|
346 // CSPVideoCall::SelectCallTypeFromProtocolCaps |
|
347 // --------------------------------------------------------------------------- |
|
348 // |
|
349 CCPCall::TCallType CSPVideoCall::SelectCallTypeFromProtocolCaps() |
|
350 { |
|
351 CSPLOGSTRING(CSPREQIN, "CSPVideoCall::SelectCallTypeFromProtocolCaps <"); |
|
352 |
|
353 iVideoCallCapsMonitor->UpdateProtocolCaps(); |
|
354 TUint protocolCaps = iVideoCallCapsMonitor->GetProtocolCaps(); |
|
355 CCPCall::TCallType callType; |
|
356 |
|
357 if ( protocolCaps == RMobileCall::KCapsIsdnMultimedia ) |
|
358 { |
|
359 callType = CCPCall::ECallTypeVideo; |
|
360 } |
|
361 else |
|
362 { |
|
363 callType = CCPCall::ECallTypeCSVoice; |
|
364 } |
|
365 CSPLOGSTRING2(CSPINT, "CSPVideoCall::SelectCallTypeFromProtocolCaps >\ |
|
366 call type: %d", callType ); |
|
367 |
|
368 return callType; |
|
369 } |
|
370 |
|
371 |
|
372 // End of File |
|