|
1 /* |
|
2 * Copyright (c) 2004-2006 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <pv_plugin_interfaces.h> |
|
20 #include <pv_2way_symbian_interface.h> |
|
21 #include <pv_2way_h324m_interface.h> |
|
22 #include <pv_mp4_h263_enc_extension_interface_symbian.h> |
|
23 #include <pv_audio_output_control_interface.h> |
|
24 #include <pv_2way_factory.h> |
|
25 #include "mvtprotocolhandler.h" |
|
26 #include "cdatasinkproxy.h" |
|
27 #include "cdatasourceproxy.h" |
|
28 #include "csessionhandler.h" |
|
29 #include "ccommserver.h" |
|
30 #include "ch324confighandler.h" |
|
31 #include "cvideoconfighandler.h" |
|
32 #include "caudioconfighandler.h" |
|
33 |
|
34 #define DEBUG_CFG_BB_LOOPBACK 0 |
|
35 #define DEBUG_CFG_PV_LOOPBACK 0 |
|
36 #ifdef _DEBUG |
|
37 # define __IF_DEBUG(t) {RDebug::t;} |
|
38 #else |
|
39 # define __IF_DEBUG(t) |
|
40 #endif |
|
41 |
|
42 const TInt KVtProtoMultiplexingDelay = 150; |
|
43 const TInt EVtGet324CtrlInterface = 15; |
|
44 const TInt EVtGetH263EncInterface = 24; |
|
45 // ----------------------------------------------------------------------------- |
|
46 // TSessionHandler::TSessionHandler |
|
47 // Constructor. |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 TSessionHandler::TSessionHandler(MVtProtocolHandler* aProtocolHandler) : iProtocolHandler(aProtocolHandler) |
|
51 { |
|
52 __IF_DEBUG(Print(_L("VTProto: TSessionHandler::TSessionHandler<"))); |
|
53 __IF_DEBUG(Print(_L("VTProto: TSessionHandler::TSessionHandler>"))); |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // TSessionHandler::CommandCompletedL |
|
58 // Handle an event that has been generated. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void TSessionHandler::CommandCompletedL(const CPVCmdResponse& aResponse) |
|
62 { |
|
63 __IF_DEBUG(Print(_L("VTProto: TSessionHandler::CommandCompletedL<"))); |
|
64 TVtCommandType cmdType = (TVtCommandType)aResponse.GetCmdType(); |
|
65 TInt cmdId = (TInt)aResponse.GetCmdId(); |
|
66 TInt cmdResponse = aResponse.GetCmdStatus(); |
|
67 TVtCommandResponse commandRsp(cmdType, cmdId, cmdResponse); |
|
68 iProtocolHandler->HandleSessionCommandEventL(commandRsp); |
|
69 __IF_DEBUG(Print(_L("VTProto: TSessionHandler::CommandCompletedL>"))); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // TSessionHandler::HandleInformationalEventL |
|
74 // Handle an informational event that has been generated. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void TSessionHandler::HandleInformationalEventL(const CPVAsyncInformationalEvent& aEvent) |
|
78 { |
|
79 __IF_DEBUG(Print(_L("VTProto: TSessionHandler::HandleInformationalEventL<"))); |
|
80 const TUint8* buffer = aEvent.GetLocalBuffer(); |
|
81 TInt eventType = aEvent.GetEventType(); |
|
82 TVtIndicationEvent vtEvent(eventType, buffer); |
|
83 iProtocolHandler->HandleSessionInformationalEventL(vtEvent); |
|
84 __IF_DEBUG(Print(_L("VTProto: TSessionHandler::HandleInformationalEventL>"))); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // TSessionHandler::HandleErrorEventL |
|
89 // Handle an error event that has been generated. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void TSessionHandler::HandleErrorEventL(const CPVAsyncErrorEvent& aEvent) |
|
93 { |
|
94 __IF_DEBUG(Print(_L("VTProto: TSessionHandler::HandleErrorEventL<"))); |
|
95 TVtErrorEvent event(aEvent.GetEventType()); |
|
96 iProtocolHandler->HandleSessionErrorEventL(event); |
|
97 __IF_DEBUG(Print(_L("VTProto: TSessionHandler::HandleErrorEventL>"))); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CSessionCommand::CSessionCommand |
|
102 // Constructor. |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 CSessionCommand::CSessionCommand(TSessionHandler* aSessionHandler, MPV2WaySymbianInterface* aPv2Way) |
|
106 : iPv2Way(aPv2Way), iSessionHandler(aSessionHandler) |
|
107 { |
|
108 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::CSessionCommand<"))); |
|
109 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::CSessionCommand>"))); |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CSessionCommand::~CSessionComman |
|
114 // Destructor. |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 CSessionCommand::~CSessionCommand() |
|
118 { |
|
119 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::~CSessionCommand<"))); |
|
120 delete iVideoSource; |
|
121 delete iDisplaySink; |
|
122 delete iSessionHandler; |
|
123 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::~CSessionCommand>"))); |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CSessionCommand::ConnectToProtocolL |
|
128 // This function can be invoked only in the ESetup state. |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 TInt CSessionCommand::ConnectToProtocolL(MCommServer* aComm) |
|
132 { |
|
133 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::ConnectToProtocolL"))); |
|
134 TPVConnectOptions connectOptions; |
|
135 connectOptions.iLoopbackMode = PV_LOOPBACK_NONE; |
|
136 #ifdef _DEBUG |
|
137 if ( DEBUG_CFG_BB_LOOPBACK ) |
|
138 { |
|
139 connectOptions.iLoopbackMode = PV_LOOPBACK_COMM; |
|
140 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::ConnectToProtocolL Loopback COMM"))); |
|
141 } |
|
142 else if ( DEBUG_CFG_PV_LOOPBACK ) |
|
143 { |
|
144 connectOptions.iLoopbackMode = PV_LOOPBACK_MUX; |
|
145 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::ConnectToProtocolL Loopback MUX"))); |
|
146 } |
|
147 else |
|
148 { |
|
149 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::ConnectToProtocolL Loopback NONE"))); |
|
150 } |
|
151 #endif |
|
152 CCommServer* commServer = static_cast<CCommServer*>(aComm); |
|
153 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::ConnectToProtocolL commServer %d"), commServer)); |
|
154 return iPv2Way->ConnectL(connectOptions, commServer->iComm); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // CSessionCommand::DisconnectFromProtocolL |
|
159 // The Disconnect call is valid only when invoked in the EConnecting, and |
|
160 // EConnected states. |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 TInt CSessionCommand::DisconnectFromProtocolL() |
|
164 { |
|
165 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::DisconnectFromProtocolL"))); |
|
166 return iPv2Way->DisconnectL(); |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // CSessionCommand::ResetProtocolL |
|
171 // This function is valid only in the ESetup and EInitializing state. |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 TInt CSessionCommand::ResetProtocolL() |
|
175 { |
|
176 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::ResetProtocolL"))); |
|
177 return iPv2Way->ResetL(); |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CSessionCommand::InitProtocolL |
|
182 // This function is valid only in the EIdle state. |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 TInt CSessionCommand::InitProtocolL(TVtInitInfo& aInitInfo) |
|
186 { |
|
187 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::InitProtocolL"))); |
|
188 CPV2WayInitInfo initInfo; |
|
189 initInfo.iMultiplexingDelayMs = KVtProtoMultiplexingDelay; |
|
190 |
|
191 if (aInitInfo.iAMRWBOn) |
|
192 { |
|
193 initInfo.iIncomingAudioFormats. |
|
194 Append((TDesC8 *)&KVtAudioMIMETypeAMRWBIF2); |
|
195 |
|
196 initInfo.iOutgoingAudioFormats. |
|
197 Append((TDesC8 *)&KVtAudioMIMETypeAMRWBIF2); |
|
198 } |
|
199 |
|
200 initInfo.iIncomingAudioFormats. |
|
201 Append((TDesC8 *)&KVtAudioMIMETypeAMRIF2); |
|
202 |
|
203 initInfo.iOutgoingAudioFormats. |
|
204 Append((TDesC8 *)&KVtAudioMIMETypeAMRIF2); |
|
205 |
|
206 initInfo.iIncomingVideoFormats. |
|
207 Append( (TDesC8 *) &KVtVideoMIMETypeH264 ); |
|
208 |
|
209 initInfo.iOutgoingVideoFormats. |
|
210 Append( (TDesC8 *) &KVtVideoMIMETypeH264 ); |
|
211 |
|
212 if (!aInitInfo.iDisableMpeg4) |
|
213 { |
|
214 initInfo.iIncomingVideoFormats. |
|
215 Append((TDesC8 *)&KVtVideoMIMETypeM4V); |
|
216 |
|
217 initInfo.iOutgoingVideoFormats. |
|
218 Append((TDesC8 *)&KVtVideoMIMETypeM4V); |
|
219 } |
|
220 |
|
221 initInfo.iIncomingVideoFormats. |
|
222 Append((TDesC8 *)&KVtVideoMIMETypeH263); |
|
223 |
|
224 initInfo.iOutgoingVideoFormats. |
|
225 Append((TDesC8 *)&KVtVideoMIMETypeH263); |
|
226 |
|
227 return iPv2Way->InitL(initInfo); |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CSessionCommand::AddVideoSinkL |
|
232 // Allows an application to provide a media sink for rendering an incoming media bitstream in a |
|
233 // logical channel of communication with the peer. |
|
234 // ----------------------------------------------------------------------------- |
|
235 // |
|
236 TInt CSessionCommand::AddVideoSinkL(const TUint aChannelId, MVTVideoSink& aDataSink) |
|
237 { |
|
238 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::AddVideoSinkL"))); |
|
239 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::AddVideoSinkL aChannelId %d"), aChannelId)); |
|
240 iDisplaySink =CDisplaySinkProxy::NewL(&aDataSink); |
|
241 return iPv2Way->AddDataSinkL(aChannelId, *iDisplaySink); |
|
242 } |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // CSessionCommand::AddVideoSourceL |
|
246 // Allows an application to provide a media source to be associated with a logical channel |
|
247 // of communication with the peer. |
|
248 // ----------------------------------------------------------------------------- |
|
249 // |
|
250 TInt CSessionCommand::AddVideoSourceL(const TUint aChannelId, MVTVideoSource& aDataSource) |
|
251 { |
|
252 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::AddVideoSourceL"))); |
|
253 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::AddVideoSourceL aChannelId %d"), aChannelId)); |
|
254 iVideoSource = CVideoSourceProxy::NewL(&aDataSource); |
|
255 return iPv2Way->AddDataSourceL(aChannelId, *iVideoSource); |
|
256 } |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CSessionCommand::AddAudioSourceL |
|
260 // Allows an application to provide a media source to be associated with a logical channel |
|
261 // of communication with the peer. |
|
262 // ----------------------------------------------------------------------------- |
|
263 // |
|
264 TInt CSessionCommand::AddAudioSourceL(const TUint aChannelId, MVTAudioSource &aDataSource) |
|
265 { |
|
266 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::AddAudioSourceL"))); |
|
267 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::AddAudioSourceL aChannelId %d"), aChannelId)); |
|
268 CAudioSourceProxy* audioSourceProxy = static_cast<CAudioSourceProxy*>(&aDataSource); |
|
269 return iPv2Way->AddDataSourceL(aChannelId, *(audioSourceProxy->iAudioSource)); |
|
270 } |
|
271 |
|
272 // ----------------------------------------------------------------------------- |
|
273 // CSessionCommand::AddAudioSinkL |
|
274 // Allows an application to provide a media sink for rendering an incoming media bitstream in a |
|
275 // logical channel of communication with the peer. |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 TInt CSessionCommand::AddAudioSinkL(const TUint aChannelId, MVTAudioSink &aDataSink) |
|
279 { |
|
280 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::AddAudioSinkL"))); |
|
281 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::AddAudioSinkL aChannelId %d"), aChannelId)); |
|
282 CAudioSinkProxy* audioSinkProxy = static_cast<CAudioSinkProxy*>(&aDataSink); |
|
283 return iPv2Way->AddDataSinkL(aChannelId, *(audioSinkProxy->iAudioSink)); |
|
284 } |
|
285 |
|
286 // ----------------------------------------------------------------------------- |
|
287 // CSessionCommand::PauseVideoL |
|
288 // For an incoming track (MVTVideoSink) this function pauses sending |
|
289 // media to the sink (output device) and stops the sink. |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 TInt CSessionCommand::PauseVideoL(MVTVideoSource& aTrack) |
|
293 { |
|
294 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::PauseVideoL"))); |
|
295 if (&aTrack == iVideoSource->VideoSource()) |
|
296 { |
|
297 return iPv2Way->PauseL(*iVideoSource); |
|
298 } |
|
299 return KErrNone; |
|
300 } |
|
301 |
|
302 // ----------------------------------------------------------------------------- |
|
303 // CSessionCommand::PauseVideoL |
|
304 // For an incoming track (MVtVideoSink) this function pauses sending |
|
305 // media to the sink (output device) and stops the sink. |
|
306 // ----------------------------------------------------------------------------- |
|
307 // |
|
308 TInt CSessionCommand::PauseVideoL(MVTVideoSink& aTrack) |
|
309 { |
|
310 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::PauseVideoL"))); |
|
311 if (&aTrack == iDisplaySink->DisplaySink()) |
|
312 { |
|
313 return iPv2Way->PauseL(*iDisplaySink); |
|
314 } |
|
315 return KErrNone; |
|
316 } |
|
317 |
|
318 // ----------------------------------------------------------------------------- |
|
319 // CSessionCommand::PauseAudioL |
|
320 // For an incoming track (MVTAudioSource) this function pauses sending |
|
321 // media to the sink (output device) and stops the sink. |
|
322 // ----------------------------------------------------------------------------- |
|
323 // |
|
324 TInt CSessionCommand::PauseAudioL(MVTAudioSource& aTrack) |
|
325 { |
|
326 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::PauseAudioL"))); |
|
327 CAudioSourceProxy* audioSourceProxy = static_cast<CAudioSourceProxy*>(&aTrack); |
|
328 return iPv2Way->PauseL(*(audioSourceProxy->iAudioSource)); |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CSessionCommand::ResumeVideoL |
|
333 // Resume a previously paused incoming or outgoing track. |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 TInt CSessionCommand::ResumeVideoL(MVTVideoSource& aTrack) |
|
337 { |
|
338 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::ResumeVideoL"))); |
|
339 if (&aTrack == iVideoSource->VideoSource()) |
|
340 { |
|
341 return iPv2Way->ResumeL(*iVideoSource); |
|
342 } |
|
343 return KErrNone; |
|
344 } |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // CSessionCommand::ResumeVideoL |
|
348 // Resume a previously paused incoming or outgoing track. |
|
349 // ----------------------------------------------------------------------------- |
|
350 // |
|
351 TInt CSessionCommand::ResumeVideoL(MVTVideoSink& aTrack) |
|
352 { |
|
353 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::ResumeVideoL"))); |
|
354 if (&aTrack == iDisplaySink->DisplaySink()) |
|
355 { |
|
356 return iPv2Way->ResumeL(*iDisplaySink); |
|
357 } |
|
358 return KErrNone; |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // CSessionCommand::ResumeAudioL |
|
363 // Resume a previously paused incoming or outgoing track. |
|
364 // ----------------------------------------------------------------------------- |
|
365 // |
|
366 TInt CSessionCommand::ResumeAudioL(MVTAudioSource& aTrack) |
|
367 { |
|
368 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::ResumeAudioL"))); |
|
369 CAudioSourceProxy* audioSourceProxy = static_cast<CAudioSourceProxy*>(&aTrack); |
|
370 return iPv2Way->ResumeL(*(audioSourceProxy->iAudioSource)); |
|
371 } |
|
372 |
|
373 // ----------------------------------------------------------------------------- |
|
374 // CSessionCommand::CancelAllCommandsL |
|
375 // This API is to allow the user to cancel all pending requests. |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 TInt CSessionCommand::CancelAllCommandsL( ) |
|
379 { |
|
380 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::CancelAllCommandsL"))); |
|
381 return iPv2Way->CancelAllCommandsL(); |
|
382 } |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CSessionCommand::GetProtocolInterfaceL |
|
386 // This API is to allow for extensibility of the protocol interface. |
|
387 // ----------------------------------------------------------------------------- |
|
388 // |
|
389 TInt CSessionCommand::GetProtocolInterfaceL(TVtConfigType aType, MVtProtocolCommand*& aProtocolCommand) |
|
390 { |
|
391 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::GetProtocolInterfaceL<"))); |
|
392 TInt commandId = 0; |
|
393 if (aType == EVtH324Config) |
|
394 { |
|
395 CH324ConfigCommand* H324ConfigCommand = new (ELeave)CH324ConfigCommand(); |
|
396 commandId = iPv2Way->QueryInterfaceL( |
|
397 KPVUidH324ConfigInterface, |
|
398 ( MPVInterface*& ) H324ConfigCommand->PVH324ConfigInterface(), |
|
399 ( void* ) EVtGet324CtrlInterface ); |
|
400 |
|
401 aProtocolCommand = H324ConfigCommand; |
|
402 } |
|
403 else if (aType == EVtVideoEncoderConfig) |
|
404 { |
|
405 CVideoConfigCommand* videoConfigCommand = new (ELeave)CVideoConfigCommand(); |
|
406 commandId = iPv2Way->QueryInterfaceL( |
|
407 KPVUidVidEncConfigInterface, |
|
408 ( MPVInterface*& ) videoConfigCommand->PVVideoEncoderInterface(), |
|
409 ( void* ) EVtGetH263EncInterface ); |
|
410 |
|
411 aProtocolCommand = videoConfigCommand; |
|
412 } |
|
413 else |
|
414 { |
|
415 ; |
|
416 } |
|
417 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::GetProtocolInterfaceL aType %d, aProtocolCommand %d>"), aType, aProtocolCommand)); |
|
418 return commandId; |
|
419 } |
|
420 |
|
421 // ----------------------------------------------------------------------------- |
|
422 // CSessionCommand::DeleteProtocolInterfaceL |
|
423 // This APIis to be used to release an interface that was previously obtained using |
|
424 // ----------------------------------------------------------------------------- |
|
425 // |
|
426 TInt CSessionCommand::DeleteProtocolInterfaceL(TVtConfigType aType, MVtProtocolCommand* aProtocolCommand) |
|
427 { |
|
428 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::DeleteProtocolInterfaceL<"))); |
|
429 TInt commandId = 0; |
|
430 if (aType == EVtH324Config) |
|
431 { |
|
432 CH324ConfigCommand* H324ConfigCommand = static_cast<CH324ConfigCommand*>(aProtocolCommand); |
|
433 commandId = iPv2Way->ReleaseInterfaceL(H324ConfigCommand->PVH324ConfigInterface()); |
|
434 delete H324ConfigCommand; |
|
435 } |
|
436 else if (aType == EVtVideoEncoderConfig) |
|
437 { |
|
438 CVideoConfigCommand* videoConfigCommand = static_cast<CVideoConfigCommand*>(aProtocolCommand); |
|
439 commandId = iPv2Way->ReleaseInterfaceL(videoConfigCommand->PVVideoEncoderInterface()); |
|
440 delete videoConfigCommand; |
|
441 } |
|
442 else |
|
443 { |
|
444 ; |
|
445 } |
|
446 __IF_DEBUG(Print(_L("VTProto: CSessionCommand::DeleteProtocolInterfaceL aType, aProtocolCommand %d>"), aType, aProtocolCommand)); |
|
447 return commandId; |
|
448 } |
|
449 |
|
450 // end of file |