1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "tavsrc.h" |
|
17 #include "tavsrcUtils.h" |
|
18 #include "tavsrcSock.h" |
|
19 #include "tavsrcController.h" |
|
20 #include "tavsrcStreamer.h" |
|
21 |
|
22 #include <es_sock.h> |
|
23 #include <bt_sock.h> |
|
24 #include <bluetoothav.h> |
|
25 #include <btsdp.h> |
|
26 #include <flogger.h> |
|
27 #include <btmanclient.h> |
|
28 #include <remconinterfaceselector.h> |
|
29 #include <remconcoreapitarget.h> |
|
30 #include <remcontrackinfotarget.h> |
|
31 #include <remconabsvoltarget.h> |
|
32 #include <remconmediainformationtargetobserver.h> |
|
33 #include <remconinterfaceselector.h> |
|
34 #include <remconaddress.h> |
|
35 #include <bacline.h> |
|
36 #ifdef DBAWARE |
|
37 #include "tavsrcmtupdaterdatabaseaware.h" |
|
38 #else |
|
39 #include "tavsrcmtupdaterdatabaseunaware.h" |
|
40 #endif |
|
41 #include "tavsrcAbsoluteVolume.h" |
|
42 |
|
43 #ifdef __WINS__ |
|
44 static const TSize KMainConsole(75,30); |
|
45 static const TSize KLogConsole(75,30); |
|
46 #else |
|
47 static const TSize KMainConsole(KConsFullScreen,KConsFullScreen); |
|
48 static const TSize KLogConsole(KConsFullScreen,KConsFullScreen); |
|
49 #endif |
|
50 |
|
51 using namespace SymbianBluetoothAV; |
|
52 using namespace SymbianSBC; |
|
53 |
|
54 void CAVTestApp::PreventLowPowerModes() |
|
55 { |
|
56 // Prevent any other application from setting to low power mode |
|
57 TInt err = iPhy.PreventLowPowerModes(EAnyLowPowerMode); |
|
58 __LOG(_L("Low power mode prevented, result %d\n"), err); |
|
59 } |
|
60 |
|
61 void CAVTestApp::AllowLowPowerModes() |
|
62 { |
|
63 // Allow any other application to set to low power mode |
|
64 TInt err = iPhy.AllowLowPowerModes(EAnyLowPowerMode); |
|
65 __LOG(_L("Low power mode allowed, result %d\n"), err); |
|
66 } |
|
67 |
|
68 void CAVTestApp::EchoStorm() |
|
69 { |
|
70 //UPF test |
|
71 //connect phy |
|
72 CBluetoothPhysicalLinks* phys = NULL; |
|
73 TRAP_IGNORE(phys = CBluetoothPhysicalLinks::NewL(*this, iSockServ)); |
|
74 if (phys) |
|
75 { |
|
76 phys->CreateConnection(iDevAddr); |
|
77 } |
|
78 } |
|
79 |
|
80 void CAVTestApp::HandleCreateConnectionCompleteL(TInt /*aErr*/) |
|
81 { |
|
82 TBuf8<32> echo; |
|
83 RSocket sock; |
|
84 |
|
85 sock.Open(iSockServ, _L("L2CAP")); |
|
86 TL2CAPSockAddr addr; |
|
87 addr.SetBTAddr(iDevAddr); |
|
88 addr.SetPort(1); |
|
89 |
|
90 TRequestStatus status; |
|
91 |
|
92 __LOG(_L("Connecting l2cap")); |
|
93 sock.Connect(addr, status); |
|
94 User::WaitForRequest(status); |
|
95 |
|
96 echo.SetMax(); |
|
97 echo.Fill('!'); |
|
98 __LOG(_L("Echooing")); |
|
99 FOREVER |
|
100 { |
|
101 sock.Ioctl(KL2CAPEchoRequestIoctl, status, &echo, KSolBtL2CAP); |
|
102 User::WaitForRequest(status); |
|
103 } |
|
104 } |
|
105 |
|
106 void CAVTestApp::HandleDisconnectCompleteL(TInt /*aErr*/) |
|
107 { |
|
108 } |
|
109 |
|
110 void CAVTestApp::HandleDisconnectAllCompleteL(TInt /*aErr*/) |
|
111 { |
|
112 } |
|
113 |
|
114 void CAVTestApp::CreateStreamerL(RSocketArray aSockets) |
|
115 { |
|
116 __LOG(_L("Creating new streamer\n")); |
|
117 iStreamer = CActiveStreamer::NewL(aSockets,iLogConsole->Console(), *this, iDisplayMode, iPreloadFile); |
|
118 __LOG(_L("OK\n")); |
|
119 } |
|
120 |
|
121 void CAVTestApp::Abort() |
|
122 { |
|
123 __PRINT(_L("\n (!ABORT!) Enter remote SEID to ABORT")); |
|
124 TInt seid = TTavsrcUtils::GetIntFromUser(iActiveConsole->Console()); |
|
125 __PRINT(_L("\n")); |
|
126 __LOG(_L("Aborting SEID &d...\n"),seid); |
|
127 iGavdp.AbortStream(TSEID(seid, EFalse)); |
|
128 } |
|
129 |
|
130 void CAVTestApp::SendSecurityControl() |
|
131 { |
|
132 __PRINT(_L("\n Enter remote SEID to Send Security Control")); |
|
133 TInt seid = TTavsrcUtils::GetIntFromUser(iActiveConsole->Console()); |
|
134 __PRINT(_L("\n")); |
|
135 __LOG(_L("Sending security control to SEID %d...\n"),seid); |
|
136 |
|
137 TBuf8<20> secBuf(_L8("Danger!\n")); |
|
138 |
|
139 iGavdp.SendSecurityControl(TSEID(seid, EFalse), secBuf); |
|
140 } |
|
141 |
|
142 void CAVTestApp::GetCapabilities() |
|
143 { |
|
144 if (!iLocalReconfigure) // Don't change the remote SEID if we're reconfiguring |
|
145 { |
|
146 if (iAutoStream) |
|
147 { |
|
148 // start at first in shortlisted sep array |
|
149 iCurrentSEID = iShortlistedSEIDs[0]; |
|
150 iShortlistedSEIDs.Remove(0); // so next time around, take head again |
|
151 } |
|
152 else |
|
153 { |
|
154 __PRINT(_L("\n Enter remote SEID to get caps for")); |
|
155 iCurrentSEID = TSEID(TTavsrcUtils::GetIntFromUser(iActiveConsole->Console()), EFalse); |
|
156 } |
|
157 } |
|
158 |
|
159 __PRINT(_L("\n")); |
|
160 __LOG(_L("Getting Capabilities for SEID %d...\n"),iCurrentSEID.Value()); |
|
161 |
|
162 iSEPCapabilities.ResetAndDestroy(); //clear what's already there |
|
163 |
|
164 // we're interested in all caps as we are *TEST CODE* |
|
165 // some GCs should only register interest in the capabilities they might select |
|
166 TAvdtpServiceCategories caps; |
|
167 caps.SetCapability(EAllServiceCategories); |
|
168 |
|
169 iGavdp.GetRemoteSEPCapabilities(iCurrentSEID, caps); |
|
170 } |
|
171 |
|
172 |
|
173 void CAVTestApp::GAVDP_SEPCapability(TAvdtpServiceCapability* aCapability) |
|
174 { |
|
175 TInt err; |
|
176 PrettyPrint(*aCapability); |
|
177 |
|
178 // we own cap, stash it in our RPointerArray for owning and later use |
|
179 err = iSEPCapabilities.Append(aCapability); |
|
180 |
|
181 if(err == KErrNone) |
|
182 { |
|
183 // check if remote does SBC |
|
184 if (aCapability->Category() == EServiceCategoryMediaCodec) |
|
185 { |
|
186 if (static_cast<TAvdtpMediaCodecCapabilities*>(aCapability)->MediaCodecType() == EAudioCodecSBC) |
|
187 { |
|
188 iChosenSEP = ETrue; |
|
189 __LOG(_L("Found remote suitable SEP with SEID %d\n"), iCurrentSEID.SEID()); |
|
190 } |
|
191 } |
|
192 } |
|
193 else |
|
194 { |
|
195 delete aCapability; |
|
196 } |
|
197 } |
|
198 |
|
199 |
|
200 void CAVTestApp::GAVDP_SEPDiscoveryComplete() |
|
201 { |
|
202 // complete the operation |
|
203 iOperations->EndOperation(KTavsrcOpDiscoverSEPs, KErrNone); |
|
204 |
|
205 __LOG(_L("GAVDP:SEP Discovery complete.\n")); |
|
206 |
|
207 if (iAutoStream) |
|
208 { |
|
209 // go through all the shortlisted SEPs to find the SBC one |
|
210 GetCapabilities(); |
|
211 } |
|
212 TestMenu(); |
|
213 } |
|
214 |
|
215 void CAVTestApp::GAVDP_SEPCapabilityComplete() |
|
216 { |
|
217 // complete the operation |
|
218 iOperations->EndOperation(KTavsrcOpGetCapabilities, KErrNone); |
|
219 |
|
220 __LOG(_L("GAVDP:SEP has no more capabilities.\n")); |
|
221 |
|
222 if ((iAutoStream && iChosenSEP) || iLocalReconfigure) |
|
223 { |
|
224 // configure iCurrentSEID |
|
225 TRAPD(err, ConfigureSEPL()); |
|
226 if (err != KErrNone) |
|
227 { |
|
228 __LOG(_L("Error configuring remote SEP: %d\n"), err); |
|
229 } |
|
230 } |
|
231 else if (iAutoStream && !iShortlistedSEIDs.Count()) |
|
232 { |
|
233 __LOG(_L("Error: Remote does not have SBC codec available\n")); |
|
234 } |
|
235 else if (iAutoStream) |
|
236 { |
|
237 //try next sep |
|
238 GetCapabilities(); |
|
239 } |
|
240 TestMenu(); |
|
241 } |
|
242 |
|
243 void CAVTestApp::GAVDP_ConnectConfirm(const TBTDevAddr& aAddr) |
|
244 { |
|
245 // complete the operation |
|
246 iOperations->EndOperation(KTavsrcOpConnect, KErrNone); |
|
247 |
|
248 // update our tiny state... |
|
249 iGavdpState = ESigConnected; |
|
250 |
|
251 // hack :o) |
|
252 iDevAddr = aAddr; |
|
253 __LOG(_L("Signalling channel connected = GAVDP ready\n")); |
|
254 |
|
255 // Open RBTPhysicalLinkAdapter for prevention of low power modes during streaming |
|
256 TInt err = iPhy.Open(iSockServ, iDevAddr); |
|
257 __LOG(_L("Opened iPhy, result %d\n"), err); |
|
258 |
|
259 TestMenu(); |
|
260 } |
|
261 |
|
262 void CAVTestApp::GAVDP_SEPDiscovered(const TAvdtpSEPInfo& aSEPInfo) |
|
263 { |
|
264 // this test code at present doesnt "remember" the SEPs |
|
265 switch (aSEPInfo.MediaType()) |
|
266 { |
|
267 case EAvdtpMediaTypeAudio: |
|
268 __LOG(_L("Audio")); |
|
269 break; |
|
270 case EAvdtpMediaTypeVideo: |
|
271 __LOG(_L("Video")); |
|
272 break; |
|
273 case EAvdtpMediaTypeMultimedia: |
|
274 __LOG(_L("Multimedia")); |
|
275 break; |
|
276 } |
|
277 |
|
278 if (aSEPInfo.IsSink()) |
|
279 { |
|
280 __LOG(_L(" Sink")); |
|
281 } |
|
282 else |
|
283 { |
|
284 __LOG(_L(" Source")); |
|
285 } |
|
286 |
|
287 __LOG(_L(" SEP (SEID %d)"), aSEPInfo.SEID().Value()); |
|
288 |
|
289 if (aSEPInfo.InUse()) |
|
290 { |
|
291 __LOG(_L("[In use]")); |
|
292 } |
|
293 |
|
294 // as we intend streaming audio, we need a free audio sink sep |
|
295 if (aSEPInfo.MediaType()==EAvdtpMediaTypeAudio && aSEPInfo.IsSink() && !aSEPInfo.InUse()) |
|
296 { |
|
297 __LOG(_L("<-- Shortlisted SEP")); |
|
298 (void)iShortlistedSEIDs.Append(aSEPInfo.SEID()); |
|
299 } |
|
300 |
|
301 __LOG(_L("\n")); |
|
302 TestMenu(); |
|
303 } |
|
304 |
|
305 |
|
306 void CAVTestApp::GAVDP_AbortStreamConfirm() |
|
307 { |
|
308 // complete the operation |
|
309 iOperations->EndOperation(KTavsrcOpAbort, KErrNone); |
|
310 |
|
311 __LOG(_L("GAVDP:Aborted\n")); |
|
312 delete iStreamer; |
|
313 iStreamer = NULL; |
|
314 |
|
315 AllowLowPowerModes(); |
|
316 |
|
317 TestMenu(); |
|
318 } |
|
319 |
|
320 void CAVTestApp::GAVDP_SecurityControlConfirm(const TDesC8& aResponseData) |
|
321 { |
|
322 // complete the operation |
|
323 iOperations->EndOperation(KTavsrcOpContentProtection, KErrNone); |
|
324 |
|
325 __LOG(_L("GAVDP:Security control complete\n")); |
|
326 __LOG(_L("GAVDP:Security control rsp=%S\n"), &aResponseData); |
|
327 |
|
328 TestMenu(); |
|
329 } |
|
330 |
|
331 void CAVTestApp::GAVDP_StartStreamsConfirm() |
|
332 { |
|
333 // complete the operation |
|
334 iOperations->EndOperation(KTavsrcOpStartStreams, KErrNone); |
|
335 |
|
336 __LOG(_L("GAVDP: StartStreamConfirm: now ready for use\n")); |
|
337 |
|
338 RThread().SetPriority(EPriorityRealTime); |
|
339 |
|
340 if (iLocalReconfigure) |
|
341 { |
|
342 iStreamer->ReStream(); |
|
343 iStreamState = EStreaming; |
|
344 |
|
345 iOperations->EndOperation(KTavsrcOpStream, KErrNone); |
|
346 iLocalReconfigure = EFalse; |
|
347 } |
|
348 else if (iAutoStream) |
|
349 { |
|
350 //this maynot be true as SNK can be INT (but tavsrc only looks for remote SNKs) |
|
351 iStreamer->Stream(CurrentSEIDIsSink()); |
|
352 iStreamState = EStreaming; |
|
353 |
|
354 iOperations->EndOperation(KTavsrcOpStream, KErrNone); |
|
355 } |
|
356 |
|
357 iAutoStream = EFalse; // done |
|
358 iLocalReconfigure = EFalse; |
|
359 |
|
360 PreventLowPowerModes(); |
|
361 |
|
362 TestMenu(); |
|
363 } |
|
364 |
|
365 void CAVTestApp::GAVDP_SuspendStreamsConfirm() |
|
366 { |
|
367 // complete the operation |
|
368 iOperations->EndOperation(KTavsrcOpSuspendStreams, KErrNone); |
|
369 |
|
370 iGavdpState = ESuspended; |
|
371 |
|
372 __LOG(_L("Suspending stream!\n")); |
|
373 iStreamer->Suspend(); |
|
374 iStreamState = EPaused; |
|
375 |
|
376 // we might be doing a reconfigure due to a request from the streamer |
|
377 if (iLocalReconfigure) |
|
378 { |
|
379 GetCapabilities(); |
|
380 } |
|
381 |
|
382 AllowLowPowerModes(); |
|
383 |
|
384 TestMenu(); |
|
385 } |
|
386 |
|
387 void CAVTestApp::GAVDP_ConfigurationConfirm() |
|
388 { |
|
389 // complete the operation |
|
390 if (iRegisteringLocalSEP) |
|
391 { |
|
392 __LOG(_L("SEP [SEID %d]: Local Configuration complete\n"), iCurrentSEID.SEID()); |
|
393 iOperations->EndOperation(KTavsrcOpRegisterSEP, KErrNone); |
|
394 |
|
395 iRegisteringLocalSEP = EFalse; |
|
396 |
|
397 // time to listen now SEP registered, ignore error, logged in Listen() |
|
398 Listen(); |
|
399 } |
|
400 else |
|
401 { |
|
402 __LOG(_L("SEP [SEID %d]: Remote Configuration complete\n"), iCurrentSEID.SEID()); |
|
403 iOperations->EndOperation(KTavsrcOpConfigureSEP, KErrNone); |
|
404 |
|
405 // we might be doing a reconfigure due to a request from the streamer |
|
406 if (iLocalReconfigure) |
|
407 { |
|
408 StartStreams(); |
|
409 } |
|
410 // if we;re doing autoCSR stuff we choose to go straight to open |
|
411 else if (iAutoStream) |
|
412 { |
|
413 CreateBearers(); |
|
414 } |
|
415 } |
|
416 |
|
417 TestMenu(); |
|
418 } |
|
419 |
|
420 void CAVTestApp::GAVDP_Error(TInt aError, const TDesC8& /*aErrorData*/) |
|
421 { |
|
422 __LOG(_L("GAVDP: **Error**: %d:\n"), aError); |
|
423 |
|
424 // complete the outstanding operation with an error |
|
425 iOperations->EndOperation(0, aError); |
|
426 |
|
427 switch (aError) |
|
428 { |
|
429 case KErrAvdtpBaseError-KErrAvdtpRequestTimeout: |
|
430 { |
|
431 __LOG(_L("AVDTP Request timed out\n")); |
|
432 break; |
|
433 } |
|
434 case -6305: |
|
435 case KErrDisconnected: |
|
436 { |
|
437 iPhy.Close(); |
|
438 __LOG(_L("Closed iPhy\n")); |
|
439 |
|
440 __LOG(_L("Signalling disconnected\nTest code is going to Re-listen...\n")); |
|
441 aError = Listen(); |
|
442 |
|
443 iAutoStream = EFalse; |
|
444 if (iStreamer) |
|
445 { |
|
446 iStreamer->Stop(); |
|
447 } |
|
448 iStreamState = EStopped; |
|
449 |
|
450 // reset the state |
|
451 iOperations->EndOperation(KTavsrcOpDisconnectSrc, aError); |
|
452 break; |
|
453 } |
|
454 |
|
455 // Errors we can't match to a specific command |
|
456 case EAvdtpBadHeaderFormat: |
|
457 case EAvdtpBadLength: |
|
458 case EAvdtpBadACPSEID: |
|
459 case EAvdtpBadPayloadFormat: |
|
460 case EAvdtpNotSupportedCommand: |
|
461 case EAvdtpBadState: |
|
462 { |
|
463 __LOG(_L("Couldn't determine operation that caused error\n")); |
|
464 break; |
|
465 } |
|
466 |
|
467 // Errors on SetConfig/Reconfig |
|
468 case EAvdtpSEPInUse: |
|
469 case EAvdtpSepNotInUse: |
|
470 case EAvdtpBadServCategory: |
|
471 case EAvdtpInvalidCapabilities: |
|
472 case EAvdtpBadRecoveryType: |
|
473 case EAvdtpBadMediaTransportFormat: |
|
474 case EAvdtpBadReportingFormat: |
|
475 case EAvdtpBadRecoveryFormat: |
|
476 case EAvdtpBadRohcFormat: |
|
477 case EAvdtpBadCpFormat: |
|
478 case EAvdtpBadMultiplexingFormat: |
|
479 case EAvdtpUnsupportedConfiguration: |
|
480 case EGavdpBadService: |
|
481 case EGavdpInsufficientResource: |
|
482 case EA2dpInvalidCodec: |
|
483 case EA2dpNotSupportedCodec: |
|
484 case EA2dpInvalidSamplingFrequency: |
|
485 case EA2dpNotSupportedSamplingFrequency: |
|
486 case EA2dpInvalidChannelMode: |
|
487 case EA2dpNotSupportedChannelMode: |
|
488 case EA2dpInvalidSubbands: |
|
489 case EA2dpNotSupportedSubbands: |
|
490 case EA2dpInvalidAllocationMethod: |
|
491 case EA2dpNotSupportedAllocationMethod: |
|
492 case EA2dpInvalidMinimumBitPoolValue: |
|
493 case EA2dpNotSupportedMinimumBitPoolValue: |
|
494 case EA2dpInvalidMaximumBitPoolValue: |
|
495 case EA2dpNotSupportedMaximumBitPoolValue: |
|
496 case EA2dpInvalidLayer: |
|
497 case EA2dpNotSupportedLayer: |
|
498 case EA2dpNotSupportedCRC: |
|
499 case EA2dpNotSupportedMPF: |
|
500 case EA2dpNotSupportedVBR: |
|
501 case EA2dpInvalidBitRate: |
|
502 case EA2dpNotSupportedBitRate: |
|
503 case EA2dpInvalidObjectType: |
|
504 case EA2dpNotSupportedObjectType: |
|
505 case EA2dpInvalidChannels: |
|
506 case EA2dpNotSupportedChannels: |
|
507 case EA2dpInvalidVersion: |
|
508 case EA2dpNotSupportedVersion: |
|
509 case EA2dpNotSupportedSUL: |
|
510 case EA2dpInvalidBlockLength: |
|
511 case EA2dpInvalidCPType: |
|
512 case EA2dpInvalidCPFormat: |
|
513 { |
|
514 __LOG(_L("Error setting configuration\n")); |
|
515 break; |
|
516 }; |
|
517 } |
|
518 |
|
519 TestMenu(); |
|
520 } |
|
521 |
|
522 // passive gubbins |
|
523 void CAVTestApp::GAVDP_ConfigurationStartIndication(TSEID aLocalSEID, TSEID aRemoteSEID) |
|
524 { |
|
525 // ah - remote is attempting to confuigure us |
|
526 // we need to set our state |
|
527 __LOG(_L("Remote SEP [SEID %d] is configuring Local SEP [SEID %d]\n"), aRemoteSEID.Value(), aLocalSEID.Value()); |
|
528 |
|
529 |
|
530 // the seid has already been checked, but we could see which of our endpoints this refers to |
|
531 iGavdpState = ERemoteReconfiguring; |
|
532 iCurrentSEID = aRemoteSEID; |
|
533 iCurrentLocalSEID = aLocalSEID; |
|
534 } |
|
535 |
|
536 TInt CAVTestApp::GAVDP_ConfigurationIndication(TAvdtpServiceCapability* aCapability) |
|
537 { |
|
538 // the new capability proposed by remote |
|
539 __LOG(_L("Configuration proposed: category %d\n"), aCapability->Category()); |
|
540 |
|
541 // for this test code we currently accept everything |
|
542 //** A REAL GC SHOULD THINK ABOUT WHAT THE REMOTE IS PROPOSING |
|
543 PrettyPrint(*aCapability); |
|
544 |
|
545 TInt ret = KErrNone; |
|
546 if (aCapability->Category() == EServiceCategoryRecovery) |
|
547 { |
|
548 TAvdtpRecoveryCapabilities* recCap = static_cast<TAvdtpRecoveryCapabilities*>(aCapability); |
|
549 if (static_cast<TInt>(recCap->RecoveryType()) == 0xff) |
|
550 { |
|
551 ret = ConvertToSymbianError::AvdtpError(EAvdtpBadRecoveryType); |
|
552 } |
|
553 |
|
554 } |
|
555 |
|
556 |
|
557 if (ret == KErrNone) |
|
558 { |
|
559 delete aCapability; |
|
560 } |
|
561 |
|
562 return ret; |
|
563 } |
|
564 |
|
565 |
|
566 TInt CAVTestApp::GAVDP_ConfigurationEndIndication() |
|
567 { |
|
568 // just accept all we saw |
|
569 __LOG(_L("GAVDP: Remote configuration proposals now finished")); |
|
570 __LOG(_L(" - we are replying that all is OK\n")); |
|
571 |
|
572 // real GC should think about what remote has said!! |
|
573 |
|
574 return KErrNone; |
|
575 } |
|
576 |
|
577 TInt CAVTestApp::GAVDP_StartIndication(TSEID aLocalSEID) |
|
578 { |
|
579 __LOG(_L("Start indication for Local SEID %d\n"), aLocalSEID.SEID()); |
|
580 TInt err = KErrNone; |
|
581 |
|
582 if(iStreamer) |
|
583 { |
|
584 __LOG(_L("Starting streamer (passively!)\n")); |
|
585 |
|
586 TBool sink = EFalse; |
|
587 |
|
588 for (TInt i=0; i<iLocallyRegisteredSEPs.Count(); i++) |
|
589 { |
|
590 // see if we are being a sink or source |
|
591 if (aLocalSEID==iLocallyRegisteredSEPs[i].SEID()) |
|
592 { |
|
593 sink = iLocallyRegisteredSEPs[i].IsSink(); |
|
594 } |
|
595 } |
|
596 iCurrentLocalSEID = aLocalSEID; |
|
597 iStreamer->Stream(sink); |
|
598 iStreamState = EStreaming; |
|
599 |
|
600 iOperations->EndOperation(KTavsrcOpStream, KErrNone); |
|
601 |
|
602 PreventLowPowerModes(); |
|
603 } |
|
604 else |
|
605 { |
|
606 __LOG(_L("No streamer! Rejecting start\n")); |
|
607 err = KErrNotReady; |
|
608 } |
|
609 TestMenu(); |
|
610 return err; |
|
611 } |
|
612 |
|
613 void CAVTestApp::GAVDP_AbortIndication(TSEID aSEID) |
|
614 { |
|
615 __LOG(_L("GAVDP:Stream %d ABORTED by peer\n"), aSEID.SEID()); |
|
616 |
|
617 iOperations->EndOperation(KTavsrcOpAbort, KErrNone); |
|
618 |
|
619 delete iStreamer; |
|
620 iStreamer = NULL; |
|
621 |
|
622 iPhy.Close(); |
|
623 __LOG(_L("Closed iPhy\n")); |
|
624 |
|
625 TestMenu(); |
|
626 } |
|
627 |
|
628 void CAVTestApp::GAVDP_ReleaseIndication(TSEID aSEID) |
|
629 { |
|
630 __LOG(_L("GAVDP:Stream %d RELEASED by peer\n"), aSEID.SEID()); |
|
631 |
|
632 AllowLowPowerModes(); |
|
633 } |
|
634 |
|
635 |
|
636 TInt CAVTestApp::GAVDP_SuspendIndication(TSEID aSEID) |
|
637 { |
|
638 __LOG(_L("GAVDP:Stream %d SUSPENDED by peer\n"), aSEID.SEID()); |
|
639 |
|
640 iStreamer->Suspend(); |
|
641 // should ask the streamer object what SEID it is streaming really |
|
642 |
|
643 // as test code we always consume this for now |
|
644 iOperations->EndOperation(KTavsrcOpSuspendStreams, KErrNone); |
|
645 |
|
646 AllowLowPowerModes(); |
|
647 |
|
648 TestMenu(); |
|
649 return KErrNone; |
|
650 } |
|
651 |
|
652 TInt CAVTestApp::GAVDP_SecurityControlIndication(TSEID aSEID, TDes8& aSecurityData) |
|
653 { |
|
654 __LOG(_L("GAVDP:Got security control data length %d for SEID %d\n"), aSecurityData.Length(), aSEID.Value()); |
|
655 |
|
656 TBool identical = TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(), _L("Security control data: respond identically?")); |
|
657 if (!identical) |
|
658 { |
|
659 aSecurityData[0]^='!'; |
|
660 } |
|
661 |
|
662 return KErrNone; |
|
663 } |
|
664 |
|
665 void CAVTestApp::GAVDP_BearerReady(RSocket aNewSocket, const TAvdtpSockAddr& aAddr) |
|
666 { |
|
667 // wrap socket with active wrapper... |
|
668 __LOG(_L("Got a bearer, for session %d\n"), aAddr.Session()); |
|
669 |
|
670 // we'll make a streamer now (easy way to keep this socket) |
|
671 // set the PHY to be AV friendly! |
|
672 switch(aAddr.Session()) |
|
673 { |
|
674 case EMedia: |
|
675 { |
|
676 iPendingSockets[0] = aNewSocket; |
|
677 |
|
678 // complete the operation |
|
679 iOperations->EndOperation(KTavsrcOpCreateBearers, KErrNone); |
|
680 |
|
681 iGavdpState = EOpen; |
|
682 |
|
683 // all bearers ready! |
|
684 __LOG(_L("Got all bearers, can now start\n")); |
|
685 |
|
686 RBTPhysicalLinkAdapter phy; |
|
687 |
|
688 // AV sockets don't foward opts yet so use addr version |
|
689 TInt err = phy.Open(iSockServ, iDevAddr); |
|
690 TUint16 packets = EPacketsDH1|EPacketsDH3|EPacketsDH5; |
|
691 err = phy.RequestChangeSupportedPacketTypes(packets); |
|
692 __LOG(_L("Modified PHY, result %d\n"), err); |
|
693 TRAP(err, CreateStreamerL(iPendingSockets)); //FIXME arrange array better for different #bearers |
|
694 if(err) |
|
695 { |
|
696 __LOG(_L("Creating streamer failed with err %d, closing socket\n"), err); |
|
697 aNewSocket.Close(); |
|
698 } |
|
699 |
|
700 if (iAutoStream) |
|
701 { |
|
702 StartStreams(); |
|
703 } |
|
704 // but not start streaming until manually started |
|
705 |
|
706 TestMenu(); |
|
707 break; |
|
708 } |
|
709 case EReporting: |
|
710 { |
|
711 iPendingSockets[1] = aNewSocket; |
|
712 #ifdef CHANNEL_BINDING_DEBUG_CHECK |
|
713 TInt err(KErrNone); |
|
714 // Create the active socket reader |
|
715 TRAP(err,iRepReader = CActiveSockReader::NewL(iPendingSockets[1], EReporting)); |
|
716 if (err != KErrNone) |
|
717 { |
|
718 __LOG(_L("Creating active socket reader failed with error %d"),err); |
|
719 } |
|
720 else |
|
721 { |
|
722 iRepReader->Start(); |
|
723 } |
|
724 // Create the active socket writer |
|
725 TRAP(err,iRepWriter = CActiveSockWriter::NewL(iPendingSockets[1], EReporting)); |
|
726 if (err != KErrNone) |
|
727 { |
|
728 __LOG(_L("Creating active socket writer failed with error %d"),err); |
|
729 } |
|
730 else |
|
731 { |
|
732 iRepWriter->Send(); |
|
733 } |
|
734 #endif |
|
735 } |
|
736 break; |
|
737 |
|
738 case ERecovery: |
|
739 { |
|
740 iPendingSockets[2] = aNewSocket; |
|
741 #ifdef CHANNEL_BINDING_DEBUG_CHECK |
|
742 TInt err(KErrNone); |
|
743 // Create the active socket reader |
|
744 TRAP(err,iRecvReader = CActiveSockReader::NewL(iPendingSockets[2], ERecovery)); |
|
745 if (err != KErrNone) |
|
746 { |
|
747 __LOG(_L("Creating active socket reader failed with error %d"),err); |
|
748 } |
|
749 else |
|
750 { |
|
751 iRecvReader->Start(); |
|
752 } |
|
753 // Create the active socket writer |
|
754 TRAP(err,iRecvWriter = CActiveSockWriter::NewL(iPendingSockets[2], ERecovery)); |
|
755 if (err != KErrNone) |
|
756 { |
|
757 __LOG(_L("Creating active socket writer failed with error %d"),err); |
|
758 } |
|
759 else |
|
760 { |
|
761 iRecvWriter->Send(); |
|
762 } |
|
763 #endif |
|
764 } |
|
765 break; |
|
766 default: |
|
767 __DEBUGGER(); |
|
768 break; |
|
769 } |
|
770 } |
|
771 |
|
772 void CAVTestApp::PrettyPrint(TAvdtpServiceCapability& aCapability) |
|
773 { |
|
774 __LOG(_L("Capability = ")); |
|
775 |
|
776 switch (aCapability.Category()) |
|
777 { |
|
778 case EServiceCategoryMediaTransport: |
|
779 __LOG(_L("Media Transport\n")); |
|
780 break; |
|
781 |
|
782 case EServiceCategoryReporting: |
|
783 __LOG(_L("Reporting\n")); |
|
784 break; |
|
785 |
|
786 case EServiceCategoryRecovery: |
|
787 __LOG(_L("Recovery\n")); |
|
788 break; |
|
789 |
|
790 case EServiceCategoryContentProtection: |
|
791 __LOG(_L("Content Protection: Type %d\n"), static_cast<TAvdtpContentProtectionCapabilities&>(aCapability).ContentProtectionType()); |
|
792 break; |
|
793 |
|
794 case EServiceCategoryHeaderCompression: |
|
795 __LOG(_L("Header Compression\n")); |
|
796 break; |
|
797 |
|
798 case EServiceCategoryMultiplexing: |
|
799 __LOG(_L("Multiplexing\n")); |
|
800 break; |
|
801 |
|
802 case EServiceCategoryMediaCodec: |
|
803 __LOG(_L("Media Codec\n-----------\n")); |
|
804 // print name of codec |
|
805 TAvdtpMediaCodecCapabilities& codecCaps = static_cast<TAvdtpMediaCodecCapabilities&>(aCapability); |
|
806 switch (codecCaps.MediaType()) |
|
807 { |
|
808 case EAvdtpMediaTypeAudio: |
|
809 __LOG(_L("Audio:")); |
|
810 break; |
|
811 case EAvdtpMediaTypeVideo: |
|
812 __LOG(_L("Video:")); |
|
813 break; |
|
814 case EAvdtpMediaTypeMultimedia: |
|
815 __LOG(_L("Multimedia:")); |
|
816 break; |
|
817 } |
|
818 |
|
819 if (codecCaps.MediaCodecType() == EAudioCodecSBC) |
|
820 { |
|
821 __LOG(_L("SBC\n")); |
|
822 |
|
823 TSBCCodecCapabilities& sbcCaps = static_cast<TSBCCodecCapabilities&>(aCapability); |
|
824 __LOG(_L("Sampling frequencies: ")); |
|
825 if (sbcCaps.SamplingFrequencies() & E48kHz) __LOG(_L("48kHz ")); |
|
826 if (sbcCaps.SamplingFrequencies() & E44100Hz) __LOG(_L("44.1kHz ")); |
|
827 if (sbcCaps.SamplingFrequencies() & E32kHz) __LOG(_L("32kHz ")); |
|
828 if (sbcCaps.SamplingFrequencies() & E16kHz) __LOG(_L("16kHz")); |
|
829 __LOG(_L("\nChannel modes: ")); |
|
830 if (sbcCaps.ChannelModes() & EMono) __LOG(_L("Mono ")); |
|
831 if (sbcCaps.ChannelModes() & EStereo) __LOG(_L("Stereo ")); |
|
832 if (sbcCaps.ChannelModes() & EJointStereo) __LOG(_L("JointStereo ")); |
|
833 if (sbcCaps.ChannelModes() & EDualChannel) __LOG(_L("DualChannel")); |
|
834 __LOG(_L("\nBlockLengths: ")); |
|
835 if (sbcCaps.BlockLengths() & EBlockLenFour) __LOG(_L("4 ")); |
|
836 if (sbcCaps.BlockLengths() & EBlockLenEight) __LOG(_L("8 ")); |
|
837 if (sbcCaps.BlockLengths() & EBlockLenTwelve) __LOG(_L("12 ")); |
|
838 if (sbcCaps.BlockLengths() & EBlockLenSixteen) __LOG(_L("16")); |
|
839 __LOG(_L("\nSubbands: ")); |
|
840 if (sbcCaps.Subbands() & EFourSubbands) __LOG(_L("4 ")); |
|
841 if (sbcCaps.Subbands() & EEightSubbands) __LOG(_L("8")); |
|
842 __LOG(_L("\nAllocation: ")); |
|
843 if (sbcCaps.AllocationMethods() & ELoudness) __LOG(_L("Loudness ")); |
|
844 if (sbcCaps.AllocationMethods() & ESNR) __LOG(_L("SNR")); |
|
845 __LOG(_L("\nMinBitpool: %d"), sbcCaps.MinBitpoolValue()); |
|
846 __LOG(_L("\nMaxBitpool: %d\n"), sbcCaps.MaxBitpoolValue()); |
|
847 } |
|
848 else |
|
849 { |
|
850 TNonSBCCodecCapabilities& nonSbcCaps = static_cast<TNonSBCCodecCapabilities&>(aCapability); |
|
851 TPtrC8 codecData = nonSbcCaps.CodecData(); |
|
852 |
|
853 switch (codecCaps.MediaCodecType()) |
|
854 { |
|
855 case EAudioCodecMPEG12Audio: |
|
856 __LOG(_L("MPEG1,2 Audio\n")); |
|
857 __LOG(_L("Manually parsing caps of length %d\n"), codecData.Length()); |
|
858 __LOG(_L("Layers: ")); |
|
859 if (codecData[0] & 0x80) __LOG(_L("mp1")); |
|
860 if (codecData[0] & 0x40) __LOG(_L("mp2")); |
|
861 if (codecData[0] & 0x20) __LOG(_L("mp3")); |
|
862 __LOG(_L("\nCRC protection: ")); |
|
863 codecData[0] & 0x10 ? __LOG(_L("yes")) : __LOG(_L("no")); |
|
864 __LOG(_L("\nChannel modes: ")); |
|
865 if (codecData[0] & 0x08) __LOG(_L("Mono ")); |
|
866 if (codecData[0] & 0x04) __LOG(_L("DualChannel ")); |
|
867 if (codecData[0] & 0x02) __LOG(_L("Stereo ")); |
|
868 if (codecData[0] & 0x01) __LOG(_L("JointStereo")); |
|
869 __LOG(_L("\nMPF: %d"), codecData[1] & 0x40 ? 1 : 0); |
|
870 __LOG(_L("\nSampling frequencies: ")); |
|
871 if (codecData[1] & 0x20) __LOG(_L("16kHz ")); |
|
872 if (codecData[1] & 0x10) __LOG(_L("22.05kHz ")); |
|
873 if (codecData[1] & 0x08) __LOG(_L("24kHz ")); |
|
874 if (codecData[1] & 0x04) __LOG(_L("32kHz ")); |
|
875 if (codecData[1] & 0x02) __LOG(_L("44.1kHz ")); |
|
876 if (codecData[1] & 0x01) __LOG(_L("48kHz")); |
|
877 __LOG(_L("\nVBR: ")); |
|
878 codecData[2] & 0x80 ? __LOG(_L("yes")) : __LOG(_L("no")); |
|
879 __LOG(_L("\nBit rate index: %b\n"), codecData[3]+((codecData[2] & 0x7f)<<8)); |
|
880 break; |
|
881 case EAudioCodecMPEG24AAC: |
|
882 __LOG(_L("MPEG 2,4 AAC\n")); |
|
883 __LOG(_L("Not parsing caps of length %d\n"), nonSbcCaps.CodecData().Length()); |
|
884 break; |
|
885 case EAudioCodecATRAC: |
|
886 __LOG(_L("ATRAC\n")); |
|
887 __LOG(_L("Not parsing caps of length %d\n"), nonSbcCaps.CodecData().Length()); |
|
888 break; |
|
889 |
|
890 default: |
|
891 __LOG(_L("Unknown codec, Type %d\n"), codecCaps.MediaCodecType()); |
|
892 } |
|
893 } |
|
894 } |
|
895 } |
|
896 |
|
897 TInt CAVTestApp::Listen() |
|
898 { |
|
899 TInt err = iGavdp.Listen(); |
|
900 __LOG(_L("Listening (result %d)\n"), err); |
|
901 return err; |
|
902 } |
|
903 |
|
904 void CAVTestApp::StartStreams() |
|
905 { |
|
906 iGavdpState = EOpen; |
|
907 TSEID seid; |
|
908 |
|
909 if (iAutoStream) |
|
910 { |
|
911 seid = iCurrentSEID; |
|
912 } |
|
913 else |
|
914 { |
|
915 __PRINT(_L("\n Enter remote SEID to start streaming")); |
|
916 seid = TSEID(TTavsrcUtils::GetIntFromUser(iActiveConsole->Console()),EFalse); |
|
917 } |
|
918 |
|
919 __PRINT(_L("\n")); |
|
920 __LOG(_L("Starting remoteSEP %d streaming...\n"),seid.SEID()); |
|
921 |
|
922 iGavdp.StartStream(seid); |
|
923 } |
|
924 |
|
925 void CAVTestApp::SuspendStreams() |
|
926 { |
|
927 TSEID seid; |
|
928 |
|
929 if (iAutoStream) |
|
930 { |
|
931 seid = iCurrentSEID; |
|
932 } |
|
933 else |
|
934 { |
|
935 __PRINT(_L("\n Enter remote SEID to suspend streaming")); |
|
936 seid = TSEID(TTavsrcUtils::GetIntFromUser(iActiveConsole->Console()),EFalse); |
|
937 } |
|
938 |
|
939 __PRINT(_L("\n")); |
|
940 __LOG(_L("Suspending remoteSEP %d streaming...\n"),seid.SEID()); |
|
941 |
|
942 iGavdp.SuspendStream(seid); |
|
943 iGavdpState = EOpen; |
|
944 } |
|
945 |
|
946 TSBCCodecCapabilities CAVTestApp::InteractiveSBCMediaCodecConfig(TSBCCodecCapabilities& caps) |
|
947 { |
|
948 TSBCCodecCapabilities res; |
|
949 |
|
950 TSBCSamplingFrequencyBitmask freqs = caps.SamplingFrequencies(); |
|
951 TBool resp = EFalse; |
|
952 |
|
953 if (freqs) |
|
954 { |
|
955 __PRINT(_L("\nFreqs: Remote Supports: ")); |
|
956 if (freqs & E48kHz && !resp) |
|
957 { |
|
958 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("48kHz Use")); |
|
959 if (resp) |
|
960 { |
|
961 res.SetSamplingFrequencies(E48kHz); |
|
962 } |
|
963 } |
|
964 if (freqs & E44100Hz && !resp) |
|
965 { |
|
966 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\n44.1kHz Use")); |
|
967 if (resp) |
|
968 { |
|
969 res.SetSamplingFrequencies(E44100Hz); |
|
970 } |
|
971 } |
|
972 if (freqs & E32kHz && !resp) |
|
973 { |
|
974 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\n32kHz Use")); |
|
975 if (resp) |
|
976 { |
|
977 res.SetSamplingFrequencies(E32kHz); |
|
978 } |
|
979 } |
|
980 if (freqs & E16kHz && !resp) |
|
981 { |
|
982 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\n16kHz Use")); |
|
983 if (resp) |
|
984 { |
|
985 res.SetSamplingFrequencies(E16kHz); |
|
986 } |
|
987 } |
|
988 } |
|
989 |
|
990 resp = EFalse; |
|
991 TSBCChannelModeBitmask chmodes = caps.ChannelModes(); |
|
992 if (chmodes) |
|
993 { |
|
994 __PRINT(_L("\nChModes: remote supports:")); |
|
995 if (chmodes & EJointStereo && !resp) |
|
996 { |
|
997 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nJointStereo Use")); |
|
998 if (resp) |
|
999 { |
|
1000 res.SetChannelModes(EJointStereo); |
|
1001 } |
|
1002 } |
|
1003 if (chmodes & EStereo && !resp) |
|
1004 { |
|
1005 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nStereo Use")); |
|
1006 if (resp) |
|
1007 { |
|
1008 res.SetChannelModes(EStereo); |
|
1009 } |
|
1010 } |
|
1011 if (chmodes & EDualChannel && !resp) |
|
1012 { |
|
1013 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nDual Ch Use")); |
|
1014 if (resp) |
|
1015 { |
|
1016 res.SetChannelModes(EDualChannel); |
|
1017 } |
|
1018 } |
|
1019 if (chmodes & EMono && !resp) |
|
1020 { |
|
1021 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nMono Use")); |
|
1022 if (resp) |
|
1023 { |
|
1024 res.SetChannelModes(EMono); |
|
1025 } |
|
1026 } |
|
1027 } |
|
1028 |
|
1029 TSBCBlockLengthBitmask blockLens = caps.BlockLengths(); |
|
1030 resp = EFalse; |
|
1031 |
|
1032 if (blockLens) |
|
1033 { |
|
1034 __PRINT(_L("\nBlockLens: remote supports:")); |
|
1035 if (blockLens & EBlockLenFour && !resp) |
|
1036 { |
|
1037 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\n4 Use")); |
|
1038 if (resp) |
|
1039 { |
|
1040 res.SetBlockLengths(EBlockLenFour); |
|
1041 } |
|
1042 } |
|
1043 if (blockLens & EBlockLenEight && !resp) |
|
1044 { |
|
1045 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\n8 Use")); |
|
1046 if (resp) |
|
1047 { |
|
1048 res.SetBlockLengths(EBlockLenEight); |
|
1049 } |
|
1050 } |
|
1051 if (blockLens & EBlockLenTwelve && !resp) |
|
1052 { |
|
1053 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\n12 Use")); |
|
1054 if (resp) |
|
1055 { |
|
1056 res.SetBlockLengths(EBlockLenTwelve); |
|
1057 } |
|
1058 } |
|
1059 if (blockLens & EBlockLenSixteen && !resp) |
|
1060 { |
|
1061 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\n16 Use")); |
|
1062 if (resp) |
|
1063 { |
|
1064 res.SetBlockLengths(EBlockLenSixteen); |
|
1065 } |
|
1066 } |
|
1067 } |
|
1068 |
|
1069 resp = EFalse; |
|
1070 TSBCSubbandsBitmask subbands = caps.Subbands(); |
|
1071 if (subbands) |
|
1072 { |
|
1073 __PRINT(_L("\nSubbands: remote supports:")); |
|
1074 if (subbands & EFourSubbands && !resp) |
|
1075 { |
|
1076 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\n4 Use")); |
|
1077 if (resp) |
|
1078 { |
|
1079 res.SetSubbands(EFourSubbands); |
|
1080 } |
|
1081 } |
|
1082 if (subbands & EEightSubbands && !resp) |
|
1083 { |
|
1084 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\n8 Use")); |
|
1085 if (resp) |
|
1086 { |
|
1087 res.SetSubbands(EEightSubbands); |
|
1088 } |
|
1089 } |
|
1090 } |
|
1091 |
|
1092 |
|
1093 resp = EFalse; |
|
1094 TSBCAllocationMethodBitmask allocs = caps.AllocationMethods(); |
|
1095 if (allocs) |
|
1096 { |
|
1097 __PRINT(_L("\nAllocation methods: remote supports:")); |
|
1098 if (allocs & ESNR && !resp) |
|
1099 { |
|
1100 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nSNR Use")); |
|
1101 if (resp) |
|
1102 { |
|
1103 res.SetAllocationMethods(ESNR); |
|
1104 } |
|
1105 } |
|
1106 if (allocs & ELoudness && !resp) |
|
1107 { |
|
1108 resp=TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nLoudness Use")); |
|
1109 if (resp) |
|
1110 { |
|
1111 res.SetAllocationMethods(ELoudness); |
|
1112 } |
|
1113 } |
|
1114 } |
|
1115 |
|
1116 // cat2 test |
|
1117 //res.SetSamplingFrequencies(freqs); |
|
1118 //res.SetBlockLengths(4); |
|
1119 //res.SetSubbands(1); |
|
1120 //res.SetAllocMethods(1); |
|
1121 |
|
1122 // set bitpool to whatever they said - ok to set range - see 4.3.2.6 A2DP |
|
1123 res.SetMaxBitpoolValue(caps.MaxBitpoolValue()); |
|
1124 res.SetMinBitpoolValue(caps.MinBitpoolValue()); |
|
1125 |
|
1126 //dodgy iWish needs to select one |
|
1127 //res.SetMinBitpoolValue(42); |
|
1128 //res.SetMaxBitpoolValue(42); |
|
1129 |
|
1130 return res; |
|
1131 } |
|
1132 |
|
1133 TBool CAVTestApp::CurrentSEIDIsSink() |
|
1134 { |
|
1135 TBool sink = EFalse; |
|
1136 TUint localSEPIndex = iCurrentLocalSEID.Value(); |
|
1137 |
|
1138 //Get the current local SEP index in iLocallyRegisteredSEPs, by screening out flags |
|
1139 localSEPIndex &= 0x3f; |
|
1140 |
|
1141 sink = iLocallyRegisteredSEPs[localSEPIndex-1].IsSink(); |
|
1142 |
|
1143 return sink; |
|
1144 } |
|
1145 |
|
1146 void CAVTestApp::ConfigureSEPL() |
|
1147 { |
|
1148 TInt res; |
|
1149 |
|
1150 // user for test code gets to choose "right" local sep to connect to remote sep |
|
1151 TSEID localSEPtoUse(1, ETrue); // settings for iAutoStream |
|
1152 if (!iAutoStream) |
|
1153 { |
|
1154 __PRINT(_L("Choose local SEP to use for Stream")); |
|
1155 localSEPtoUse.Set(TTavsrcUtils::GetIntFromUser(iActiveConsole->Console())); // it *is* local |
|
1156 } |
|
1157 //Record the SEID of chosen local SEP |
|
1158 iCurrentLocalSEID = localSEPtoUse; |
|
1159 |
|
1160 TSEID remoteSEPtoUse = iCurrentSEID; // settings for iAutoStream |
|
1161 if (!iAutoStream) |
|
1162 { |
|
1163 __PRINT(_L("\nChoose remote SEP to use for Stream")); |
|
1164 remoteSEPtoUse.Set(TTavsrcUtils::GetIntFromUser(iActiveConsole->Console())); |
|
1165 |
|
1166 if (remoteSEPtoUse != iCurrentSEID) |
|
1167 { |
|
1168 __PRINT(_L("\nWARNING: Do not have the capabilities of the selected remote SEP, ")); |
|
1169 __PRINT(_L("\nthis may lead to sending incorrect configuration information. To")); |
|
1170 __PRINT(_L("\nfix this Get Capabilities for selected remote SEP first and then")); |
|
1171 if (!TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(), |
|
1172 _L("\nconfigure. \nDo you still wish to continue this configuration?"))) |
|
1173 { |
|
1174 User::Leave(KErrAbort); |
|
1175 } |
|
1176 } |
|
1177 } |
|
1178 |
|
1179 // we have to choose which of our seps to bind with the remote |
|
1180 // this test code assumes the local SEP to use has SEID 1. |
|
1181 // real code would have better code to fathom a good binding based on caps etc |
|
1182 res = iGavdp.BeginConfiguringRemoteSEP(remoteSEPtoUse, localSEPtoUse); |
|
1183 |
|
1184 __LOG(_L("Begin configuring remote SEP returned %d\n"), res); |
|
1185 User::LeaveIfError(res); |
|
1186 |
|
1187 for (TInt index=0; index<iSEPCapabilities.Count(); index++) |
|
1188 { |
|
1189 TAvdtpServiceCapability* cap = iSEPCapabilities[index]; |
|
1190 |
|
1191 TAvdtpServiceCategory cat = cap->Category(); |
|
1192 |
|
1193 TBool use = EFalse; |
|
1194 |
|
1195 if (cat==EServiceCategoryMediaTransport) |
|
1196 { |
|
1197 if (iAutoStream) |
|
1198 { |
|
1199 use = ETrue; |
|
1200 } |
|
1201 else |
|
1202 { |
|
1203 use = (TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nSEP Does Media Transport - use?"))); |
|
1204 } |
|
1205 if (use) |
|
1206 { |
|
1207 res = iGavdp.AddSEPCapability(*cap); |
|
1208 __LOG(_L("completed: %d"),res); |
|
1209 } |
|
1210 } |
|
1211 if (cat==EServiceCategoryReporting) |
|
1212 { |
|
1213 if (iAutoStream) |
|
1214 { |
|
1215 use = /*ETrue*/EFalse; |
|
1216 } |
|
1217 else |
|
1218 { |
|
1219 use = TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nSEP Does Reporting - use?")); |
|
1220 } |
|
1221 if (use) |
|
1222 { |
|
1223 res = iGavdp.AddSEPCapability(*cap); |
|
1224 __LOG(_L("completed: %d"),res); |
|
1225 } |
|
1226 } |
|
1227 if (cat==EServiceCategoryRecovery) |
|
1228 { |
|
1229 if (iAutoStream) |
|
1230 { |
|
1231 use = /*ETrue*/EFalse; |
|
1232 } |
|
1233 else |
|
1234 { |
|
1235 use = (TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nSEP Does Recovery - use?"))); |
|
1236 } |
|
1237 if (use) |
|
1238 { |
|
1239 res = iGavdp.AddSEPCapability(*cap); |
|
1240 __LOG(_L("completed: %d"),res); |
|
1241 } |
|
1242 } |
|
1243 |
|
1244 if (cat==EServiceCategoryContentProtection) |
|
1245 { |
|
1246 if (iAutoStream) |
|
1247 { |
|
1248 use = EFalse; |
|
1249 } |
|
1250 else |
|
1251 { |
|
1252 use = (TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nSEP Does Content Protection - use?"))); |
|
1253 } |
|
1254 |
|
1255 if (use) |
|
1256 { |
|
1257 res = iGavdp.AddSEPCapability(*cap); |
|
1258 __LOG(_L("completed: %d"),res); |
|
1259 } |
|
1260 } |
|
1261 |
|
1262 if (cat==EServiceCategoryMediaCodec) |
|
1263 { |
|
1264 if (iAutoStream) |
|
1265 { |
|
1266 use = ETrue; |
|
1267 } |
|
1268 else |
|
1269 { |
|
1270 use = (TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nConfigure Media Codec?"))); |
|
1271 } |
|
1272 |
|
1273 if (use) |
|
1274 { |
|
1275 if (static_cast<TBluetoothAudioCodecType>(static_cast<TAvdtpMediaCodecCapabilities*>(cap)->MediaCodecType())==EAudioCodecSBC) |
|
1276 { |
|
1277 const TSBCCodecCapabilities& available = *static_cast<TSBCCodecCapabilities*>(cap); |
|
1278 TSBCCodecCapabilities cfg; |
|
1279 |
|
1280 if (iAutoStream || TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(),_L("\nAutomatically Configure Media Codec?"))) |
|
1281 { |
|
1282 // we might be doing a reconfigure due to a request from the streamer |
|
1283 if (iLocalReconfigure) |
|
1284 { |
|
1285 cfg = iReconfigInfo; |
|
1286 } |
|
1287 else |
|
1288 { |
|
1289 // CSR board ignores the configuration |
|
1290 // which makes playlisting quite easy |
|
1291 // will need to fix this to playlist to boards that do care |
|
1292 TInt err, numChannels, chMode, numSubbands, blkLen, bitPool, freq, allocMethod; |
|
1293 err = TTavsrcUtils::GetCodecSettingsFromSBCFile(iFilename, chMode, numChannels, numSubbands, blkLen, bitPool, freq, allocMethod); |
|
1294 |
|
1295 if (err != KErrNone) |
|
1296 { |
|
1297 __LOG(_L("Problem accessing SBC file: %d\n"), err); |
|
1298 __LOG(_L("Warning - Codec settings not obtained\n")); |
|
1299 } |
|
1300 else |
|
1301 { |
|
1302 TSBCSubbandsBitmask subbands = numSubbands == 8 ? EEightSubbands : EFourSubbands; |
|
1303 TSBCAllocationMethodBitmask alloc = allocMethod == 0 ? ELoudness : ESNR; |
|
1304 |
|
1305 TSBCSamplingFrequencyBitmask freqs(0); |
|
1306 if (freq == 48000) freqs = E48kHz; |
|
1307 else if (freq == 44100) freqs = E44100Hz; // note else if now as only select one |
|
1308 else if (freq == 32000) freqs = E32kHz; |
|
1309 else if (freq == 16000) freqs = E16kHz; |
|
1310 |
|
1311 TSBCChannelModeBitmask chs(0); // set it to anything to prevent warning |
|
1312 if (chMode == 0) chs=EMono; |
|
1313 else if (chMode == 1) chs=EDualChannel; |
|
1314 else if (chMode == 2) chs=EStereo; |
|
1315 else if (chMode == 3) chs=EJointStereo; |
|
1316 |
|
1317 TSBCBlockLengthBitmask blkLens(0); // set it to anything to prevent warning |
|
1318 if (blkLen == 4) blkLens = EBlockLenFour; |
|
1319 else if (blkLen == 8) blkLens = EBlockLenEight; |
|
1320 else if (blkLen == 12) blkLens = EBlockLenTwelve; |
|
1321 else if (blkLen == 16) blkLens = EBlockLenSixteen; |
|
1322 |
|
1323 cfg.SetSamplingFrequencies(freqs); |
|
1324 cfg.SetChannelModes(chs); |
|
1325 cfg.SetBlockLengths(blkLens); |
|
1326 cfg.SetSubbands(subbands); |
|
1327 cfg.SetAllocationMethods(alloc); |
|
1328 |
|
1329 } |
|
1330 } |
|
1331 |
|
1332 // use the available bitpool |
|
1333 cfg.SetMaxBitpoolValue(available.MaxBitpoolValue()); |
|
1334 cfg.SetMinBitpoolValue(available.MinBitpoolValue()); |
|
1335 } |
|
1336 else if (use && !iAutoStream) |
|
1337 { |
|
1338 cfg = InteractiveSBCMediaCodecConfig(*static_cast<TSBCCodecCapabilities*>(cap)); |
|
1339 } |
|
1340 |
|
1341 |
|
1342 res = iGavdp.AddSEPCapability(cfg); |
|
1343 __LOG(_L("Add SEP Capability completed: %d"),res); |
|
1344 } |
|
1345 else |
|
1346 { |
|
1347 __LOG(_L("MP3 codec, choosing fixed configuration...\n")); |
|
1348 // assume mp3 for now |
|
1349 // testing with blueant, just choose stereo, 44.1khz |
|
1350 TBuf8<4> mp3Cfg; |
|
1351 mp3Cfg.SetLength(4); |
|
1352 mp3Cfg[0]=0x32; |
|
1353 mp3Cfg[1]=0x02; |
|
1354 mp3Cfg[2]=0x00; |
|
1355 mp3Cfg[3]=0x02; |
|
1356 |
|
1357 TNonSBCCodecCapabilities mp3codecCaps(EAvdtpMediaTypeAudio,EAudioCodecMPEG12Audio); |
|
1358 mp3codecCaps.SetCodecData(mp3Cfg); |
|
1359 res = iGavdp.AddSEPCapability(mp3codecCaps); |
|
1360 } |
|
1361 } |
|
1362 } |
|
1363 }// for |
|
1364 |
|
1365 __LOG(_L("\nCommiting configuration...\n")); |
|
1366 iGavdp.CommitSEPConfiguration(); |
|
1367 } |
|
1368 |
|
1369 |
|
1370 TInt CAVTestApp::StartSrc() |
|
1371 { |
|
1372 TBool failed = EFalse; |
|
1373 |
|
1374 // register source/sink records in sdp |
|
1375 __LOG(_L("Registering A2DP Sink SDP Record")); |
|
1376 TRAPD(err, TTavsrcUtils::RegisterSinkSDPRecordL(iSdpDB, iSnkHandle, ETrue, ETrue, ETrue, ETrue)); |
|
1377 if (err != KErrNone) |
|
1378 { |
|
1379 __LOG(_L("Failed to Register A2DP Sink SDP Record: %d"), err); |
|
1380 __DEBUGGER(); |
|
1381 failed = ETrue; |
|
1382 } |
|
1383 |
|
1384 __LOG(_L("Registering A2DP Source SDP Record")); |
|
1385 TRAP(err, TTavsrcUtils::RegisterSourceSDPRecordL(iSdpDB, iSrcHandle, ETrue, ETrue, ETrue, ETrue)); |
|
1386 if (err != KErrNone) |
|
1387 { |
|
1388 __LOG(_L("Failed to Register A2DP Source SDP Record: %d"), err); |
|
1389 __DEBUGGER(); |
|
1390 failed = ETrue; |
|
1391 } |
|
1392 |
|
1393 __LOG(_L("Opening GAVDP Session")); |
|
1394 err = iGavdp.Open(*this, iSockServ); |
|
1395 if (err == KErrNone) |
|
1396 { |
|
1397 RHostResolver hostResolver; |
|
1398 err = hostResolver.Open( iSockServ, KBTAddrFamily, KBTLinkManager); |
|
1399 if (err == KErrNone) |
|
1400 { |
|
1401 err = hostResolver.SetHostName(_L("Boom Box!")); |
|
1402 hostResolver.Close(); |
|
1403 } |
|
1404 iActiveConsole->Console().Printf(_L("Set Host Name (ret:%d)\r\n"),err); |
|
1405 |
|
1406 iGavdpState = EIdle; |
|
1407 } |
|
1408 else |
|
1409 { |
|
1410 __LOG(_L("Failed to Open GAVDP Session: %d"), err); |
|
1411 __DEBUGGER(); |
|
1412 failed = ETrue; |
|
1413 } |
|
1414 err = RegisterSEP(); |
|
1415 if (err != KErrNone) |
|
1416 { |
|
1417 __LOG(_L("Failed to Register SEP: %d"), err); |
|
1418 __DEBUGGER(); |
|
1419 failed = ETrue; |
|
1420 } |
|
1421 |
|
1422 TRAP(err, CreateRemConInterfacesL()); |
|
1423 if (err != KErrNone) |
|
1424 { |
|
1425 __LOG(_L("Failed to Register RemCon interfaces: %d"), err); |
|
1426 __DEBUGGER(); |
|
1427 failed = ETrue; |
|
1428 } |
|
1429 |
|
1430 if(failed) |
|
1431 { |
|
1432 return KErrGeneral; |
|
1433 } |
|
1434 return KErrNone; |
|
1435 } |
|
1436 |
|
1437 void CAVTestApp::StopSrc() |
|
1438 { |
|
1439 // Close RBTPhysicalLinkAdapter |
|
1440 iPhy.Close(); |
|
1441 __LOG(_L("Closed iPhy\n")); |
|
1442 |
|
1443 iSdpDB.DeleteRecord(iSrcHandle); |
|
1444 iSdpDB.DeleteRecord(iSnkHandle); |
|
1445 delete iStreamer; |
|
1446 iStreamer = NULL; |
|
1447 iGavdp.Close(); |
|
1448 iAutoStream = EFalse; |
|
1449 |
|
1450 iGavdpState = ENoClientOpen; |
|
1451 |
|
1452 } |
|
1453 |
|
1454 void CAVTestApp::DisconnectSrc() |
|
1455 { |
|
1456 // Close RBTPhysicalLinkAdapter |
|
1457 iPhy.Close(); |
|
1458 __LOG(_L("Closed iPhy\n")); |
|
1459 |
|
1460 delete iStreamer; |
|
1461 iStreamer = NULL; |
|
1462 iGavdp.Shutdown(); |
|
1463 iAutoStream = EFalse; |
|
1464 |
|
1465 iGavdpState = EIdle; |
|
1466 Listen(); |
|
1467 } |
|
1468 |
|
1469 void CAVTestApp::Connect() |
|
1470 { |
|
1471 __LOG(_L("Connecting...\n")); |
|
1472 iGavdp.Connect(iDevAddr); |
|
1473 } |
|
1474 |
|
1475 void CAVTestApp::CreateBearers() |
|
1476 { |
|
1477 TInt ret = KErrNone; |
|
1478 TSEID seid; |
|
1479 |
|
1480 if (iAutoStream) |
|
1481 { |
|
1482 seid = iCurrentSEID; |
|
1483 } |
|
1484 else |
|
1485 { |
|
1486 __PRINT(_L("\n-> Create bearers for remote SEID")); |
|
1487 seid = TSEID(TTavsrcUtils::GetIntFromUser(iActiveConsole->Console()), EFalse); |
|
1488 } |
|
1489 |
|
1490 ret = iGavdp.CreateBearerSockets(seid); |
|
1491 __LOG(_L("Asking for Bearers..(sync_result) %d.\n"), ret); |
|
1492 } |
|
1493 |
|
1494 void CAVTestApp::CloseBearers() |
|
1495 { |
|
1496 __LOG(_L("Closing Bearer 0 (via Streamer dtor)...\n\r")); |
|
1497 |
|
1498 delete iStreamer; |
|
1499 iStreamer = NULL; |
|
1500 |
|
1501 __LOG(_L("Bearer closed (via Streamer dtor)...\n\r")); |
|
1502 |
|
1503 AllowLowPowerModes(); |
|
1504 } |
|
1505 |
|
1506 void CAVTestApp::DiscoverSEPs() |
|
1507 { |
|
1508 __LOG(_L("Sending SEP Discovery...\n\r")); |
|
1509 |
|
1510 iGavdp.DiscoverRemoteSEPs(); |
|
1511 } |
|
1512 |
|
1513 CAVTestApp::CAVTestApp() |
|
1514 { |
|
1515 } |
|
1516 |
|
1517 CAVTestApp::~CAVTestApp() |
|
1518 { |
|
1519 StopSrc(); |
|
1520 delete iActiveConsole; |
|
1521 delete iLogConsole; |
|
1522 delete iMtUpdater; |
|
1523 delete iTavsrcAbsoluteVolume; |
|
1524 delete iStreamer; |
|
1525 delete iRemConInterfaceSelector; |
|
1526 delete iController; |
|
1527 delete iPacketDropIoctl; |
|
1528 delete iOperations; |
|
1529 |
|
1530 #ifdef CHANNEL_BINDING_DEBUG_CHECK |
|
1531 delete iRepReader; |
|
1532 delete iRepWriter; |
|
1533 delete iRecvReader; |
|
1534 delete iRecvWriter; |
|
1535 #endif |
|
1536 |
|
1537 iFilename.Close(); |
|
1538 iLocallyRegisteredSEPs.Close(); |
|
1539 iSockServ.Close(); |
|
1540 iSdpDB.Close(); |
|
1541 iSdp.Close(); |
|
1542 iSEPCapabilities.ResetAndDestroy(); |
|
1543 iShortlistedSEIDs.Close(); |
|
1544 } |
|
1545 |
|
1546 CAVTestApp* CAVTestApp::NewL() |
|
1547 { |
|
1548 CAVTestApp* thisapp = new (ELeave) CAVTestApp; |
|
1549 CleanupStack::PushL(thisapp); |
|
1550 thisapp->ConstructL(); |
|
1551 CleanupStack::Pop(); |
|
1552 return thisapp; |
|
1553 } |
|
1554 |
|
1555 void CAVTestApp::ConstructL() |
|
1556 { |
|
1557 iLogConsole = CActiveConsole::NewL(*this,_L("Event Log"),KLogConsole); |
|
1558 iActiveConsole = CActiveConsole::NewL(*this,_L(" Boom Box "),KMainConsole); |
|
1559 |
|
1560 User::LeaveIfError(iSockServ.Connect()); |
|
1561 } |
|
1562 |
|
1563 void CAVTestApp::CreateRemConInterfacesL() |
|
1564 { |
|
1565 iRemConInterfaceSelector = CRemConInterfaceSelector::NewL(); |
|
1566 |
|
1567 RArray<TRemConCoreApiOperationId> coreFeatures; |
|
1568 for(TInt i = 0; i<0x76; i++) |
|
1569 { |
|
1570 coreFeatures.Append(static_cast<TRemConCoreApiOperationId>(i)); |
|
1571 } |
|
1572 |
|
1573 if(iRemConInterfaces & ECoreApiTarget) |
|
1574 { |
|
1575 iRemConTarget = CRemConCoreApiTarget::NewL(*iRemConInterfaceSelector, *this, coreFeatures); |
|
1576 } |
|
1577 coreFeatures.Close(); |
|
1578 |
|
1579 if(iRemConInterfaces & EGroupNavigation) |
|
1580 { |
|
1581 iGroupNavigation = CRemConGroupNavigationApiTarget::NewL(*iRemConInterfaceSelector, *this, ETrue, ETrue); |
|
1582 } |
|
1583 |
|
1584 if(iRemConInterfaces & EMediaInformation) |
|
1585 { |
|
1586 iMediaInformation = CRemConMediaInformationTarget::NewL(*iRemConInterfaceSelector, *this); |
|
1587 } |
|
1588 |
|
1589 if(iRemConInterfaces & EBatteryStatus) |
|
1590 { |
|
1591 iBatteryStatus = CRemConBatteryApiTarget::NewL(*iRemConInterfaceSelector, *this); |
|
1592 } |
|
1593 |
|
1594 if(iRemConInterfaces & (EAbsoluteVolumeTarget | EAbsoluteVolumeController)) |
|
1595 { |
|
1596 iTavsrcAbsoluteVolume = CTavsrcAbsoluteVolume::NewL(*iRemConInterfaceSelector); |
|
1597 } |
|
1598 |
|
1599 if(iRemConInterfaces & EVendorTrackInfoTarget) |
|
1600 { |
|
1601 iTrackInfo = CRemConTrackInfoTarget::NewL(*iRemConInterfaceSelector, *this); |
|
1602 } |
|
1603 |
|
1604 if(iRemConInterfaces & (EPlayerInformation | ENowPlaying | EMediaBrowse )) |
|
1605 { |
|
1606 iMtUpdater = CTavsrcMtUpdater::NewL(*iRemConInterfaceSelector, iRemConInterfaces); |
|
1607 } |
|
1608 |
|
1609 if(iRemConInterfaces & EVendorAbsoluteVolumeTarget) |
|
1610 { |
|
1611 iAbsoluteVolume = CRemConAbsVolTarget::NewL(*iRemConInterfaceSelector, *this); |
|
1612 } |
|
1613 |
|
1614 iController = CTavsrcController::NewL(*iRemConInterfaceSelector, *iLogConsole); |
|
1615 |
|
1616 _LIT8(KTavsrcName, "Tavsrc"); |
|
1617 iRemConInterfaceSelector->OpenTargetL(ERemConAudioPlayer, ERemConNoSubType, KTavsrcName); |
|
1618 |
|
1619 iRemConInterfaceSelector->OpenControllerL(); |
|
1620 iOperations = CTavsrcOperations::NewL(); |
|
1621 } |
|
1622 |
|
1623 void CAVTestApp::DisplayHelp() |
|
1624 { |
|
1625 __LOG(_L("\nUsage: tavsrc [-A <Remote BT Addr>] [-D <Display Mode>] [-P] [-H]\n")); |
|
1626 __LOG(_L("\n-A <Remote BT Addr>: Optional argument to specify remote\n")); |
|
1627 __LOG(_L("Bluetooth address. If not specified then you will be prompted\n")); |
|
1628 __LOG(_L("using notifiers.\n")); |
|
1629 __LOG(_L("\n-D <Display Mode>: Optional argument to specify the display mode\n")); |
|
1630 __LOG(_L("to use. The possible values are a logical AND of the following:\n")); |
|
1631 __LOG(_L(" 0x00: Status and Command windows only\n")); |
|
1632 __LOG(_L(" 0x01: Streamer Info window\n")); |
|
1633 __LOG(_L(" 0x02: Progress Bar window\n")); |
|
1634 __LOG(_L(" 0x04: Playlist window\n")); |
|
1635 __LOG(_L(" 0x08: Chunky Icon window\n")); |
|
1636 __LOG(_L("For example, for all the windows except the Progress Bar: -D d\n")); |
|
1637 __LOG(_L("Default value is 1 - Status, Command and Streamer Info windows\n")); |
|
1638 __LOG(_L("\n-P: Preload SBC file before streaming.\n")); |
|
1639 __LOG(_L("\n-H: Display this help information.\n")); |
|
1640 __LOG(_L("\n-R <RemCon interfaces>: Optional argument to specify what interfaces to use:\n")); |
|
1641 __LOG(_L(" ECoreApiTarget = 1 << 0\n")); |
|
1642 __LOG(_L(" ECoreApiController = 1 << 1\n")); |
|
1643 __LOG(_L(" EGroupNavigation = 1 << 2\n")); |
|
1644 __LOG(_L(" EMediaInformation = 1 << 3\n")); |
|
1645 __LOG(_L(" EBatteryStatus = 1 << 4\n")); |
|
1646 __LOG(_L(" EAbsoluteVolumeTarget = 1 << 5\n")); |
|
1647 __LOG(_L(" EAbsoluteVolumeController = 1 << 6\n")); |
|
1648 __LOG(_L(" EPlayerInformation = 1 << 7\n")); |
|
1649 __LOG(_L(" ENowPlaying = 1 << 8\n")); |
|
1650 __LOG(_L(" EMediaBrowse = 1 << 9\n")); |
|
1651 __LOG(_L(" EDatabaseAware = 1 << 10\n")); |
|
1652 __LOG(_L(" ESeparateThreadForBrowse = 1 << 11\n")); |
|
1653 __LOG(_L(" EVendorTrackInfoTarget = 1 << 12\n")); |
|
1654 __LOG(_L(" EVendorAbsoluteVolumeTarget = 1 << 13\n")); |
|
1655 } |
|
1656 |
|
1657 void CAVTestApp::ParseCommandLineL() |
|
1658 { |
|
1659 CCommandLineArguments *cmdLine = CCommandLineArguments::NewL(); |
|
1660 CleanupStack::PushL(cmdLine); |
|
1661 |
|
1662 // set defaults |
|
1663 iDisplayMode = 0x01; |
|
1664 iPreloadFile = EFalse; |
|
1665 |
|
1666 TBool btAddrFound = EFalse; |
|
1667 TBool remConInterfacesFound = EFalse; |
|
1668 TBuf<20> arg; |
|
1669 for (TInt argIndex = 1; argIndex < cmdLine->Count(); argIndex++) |
|
1670 { |
|
1671 arg = cmdLine->Arg(argIndex); |
|
1672 arg.UpperCase(); |
|
1673 |
|
1674 // look for help |
|
1675 if (arg.FindF(_L("-H")) != KErrNotFound) |
|
1676 { |
|
1677 DisplayHelp(); |
|
1678 User::Leave(KErrArgument); |
|
1679 } |
|
1680 |
|
1681 // look for preload file |
|
1682 if (arg.FindF(_L("-P")) != KErrNotFound) |
|
1683 { |
|
1684 iPreloadFile = ETrue; |
|
1685 continue; |
|
1686 } |
|
1687 |
|
1688 // look for remote device address |
|
1689 if (arg.FindF(_L("-A")) != KErrNotFound) |
|
1690 { |
|
1691 if (argIndex != cmdLine->Count() - 1) |
|
1692 { |
|
1693 btAddrFound = ETrue; |
|
1694 iDevAddr.SetReadable(cmdLine->Arg(++argIndex)); |
|
1695 continue; |
|
1696 } |
|
1697 else |
|
1698 { |
|
1699 __LOG(_L("No address found for -A option\n")); |
|
1700 DisplayHelp(); |
|
1701 User::Leave(KErrArgument); |
|
1702 } |
|
1703 } |
|
1704 |
|
1705 // look for display mode |
|
1706 if (arg.FindF(_L("-D")) != KErrNotFound) |
|
1707 { |
|
1708 if(argIndex != cmdLine->Count() - 1) |
|
1709 { |
|
1710 TLex lex(cmdLine->Arg(++argIndex)); |
|
1711 lex.Val(iDisplayMode, EHex); |
|
1712 continue; |
|
1713 } |
|
1714 else |
|
1715 { |
|
1716 __LOG(_L("No display mode found for -D option\n")); |
|
1717 DisplayHelp(); |
|
1718 User::Leave(KErrArgument); |
|
1719 } |
|
1720 } |
|
1721 |
|
1722 // look for remcon interfaces |
|
1723 if (arg.FindF(_L("-R")) != KErrNotFound) |
|
1724 { |
|
1725 if(argIndex != cmdLine->Count() - 1) |
|
1726 { |
|
1727 TLex lex(cmdLine->Arg(++argIndex)); |
|
1728 TInt err = lex.Val(iRemConInterfaces, EHex); |
|
1729 if(!err) |
|
1730 { |
|
1731 remConInterfacesFound = ETrue; |
|
1732 } |
|
1733 else |
|
1734 { |
|
1735 __LOG(_L("Badly formatted interface bitmask\n")); |
|
1736 } |
|
1737 continue; |
|
1738 } |
|
1739 else |
|
1740 { |
|
1741 __LOG(_L("No remconinterfaces found for -R option\n")); |
|
1742 DisplayHelp(); |
|
1743 User::Leave(KErrArgument); |
|
1744 } |
|
1745 } |
|
1746 |
|
1747 // if we got here it means that we have an unhandled argument |
|
1748 __LOG(_L("Unrecognised argument\n")); |
|
1749 DisplayHelp(); |
|
1750 User::Leave(KErrArgument); |
|
1751 } |
|
1752 CleanupStack::PopAndDestroy(); // cmdLine |
|
1753 |
|
1754 if (!btAddrFound) |
|
1755 { |
|
1756 __LOG(_L("No address found on command line - please enter an address\n")); |
|
1757 TTavsrcUtils::GetDeviceAddressL(iDevAddr); |
|
1758 } |
|
1759 |
|
1760 if(!remConInterfacesFound) |
|
1761 { |
|
1762 __LOG(_L("No interfaces found on command line, defaulting to all interfaces\n")); |
|
1763 iRemConInterfaces = 0xFFFFFFFF; |
|
1764 } |
|
1765 } |
|
1766 |
|
1767 void CAVTestApp::StartL() |
|
1768 { |
|
1769 // connect to sdp |
|
1770 __LOG(_L("Connecting to ESOCK\n")); |
|
1771 User::LeaveIfError(iSockServ.Connect()); |
|
1772 __LOG(_L("Connecting to SDP Server\n")); |
|
1773 |
|
1774 __LOG(_L("Connecting to SDP Server\n")); |
|
1775 User::LeaveIfError(iSdp.Connect()); |
|
1776 __LOG(_L("Opening subsession on SDP Server\n")); |
|
1777 |
|
1778 __LOG(_L("Opening subsession on SDP Server\n")); |
|
1779 User::LeaveIfError(iSdpDB.Open(iSdp)); |
|
1780 TBuf<512> cmdline; |
|
1781 |
|
1782 // ensure that we have something to stream |
|
1783 RFs fs; |
|
1784 CDir* files; |
|
1785 User::LeaveIfError(fs.Connect()); |
|
1786 |
|
1787 TInt err = fs.GetDir(KSBCFiles, KEntryAttNormal, ESortByName, files); |
|
1788 |
|
1789 fs.Close(); |
|
1790 |
|
1791 if (err != KErrNone) |
|
1792 { |
|
1793 __LOG(_L("Error getting files %S: %d \n"), &KSBCFiles, err); |
|
1794 User::Leave(err); |
|
1795 } |
|
1796 |
|
1797 if (files->Count() > 0) |
|
1798 { |
|
1799 // store the filename for registering the SEP later |
|
1800 iFilename.Create(KMaxFileName); |
|
1801 iFilename.Append(KSBCFileRoot); |
|
1802 iFilename.Append(files->operator[](0).iName); |
|
1803 delete files; |
|
1804 } |
|
1805 else |
|
1806 { |
|
1807 __LOG(_L("\nNo files matching %S found, at least one is required,\n"), &KSBCFiles); |
|
1808 __LOG(_L("please add files and restart the application\n")); |
|
1809 delete files; |
|
1810 User::Leave(KErrNotFound); |
|
1811 } |
|
1812 |
|
1813 TRAP(err, ParseCommandLineL()); |
|
1814 if (err != KErrNone) |
|
1815 { |
|
1816 iActiveConsole->Console().ClearScreen(); |
|
1817 iActiveConsole->Console().Printf(_L("\nProblem with Command Line arguments, see status window for")); |
|
1818 iActiveConsole->Console().Printf(_L("\nmore information or press ESC to exit.\n")); |
|
1819 iActiveConsole->RequestKey(); |
|
1820 } |
|
1821 else |
|
1822 { |
|
1823 err = StartSrc(); |
|
1824 if(err == KErrNone) |
|
1825 { |
|
1826 TestMenu(); |
|
1827 } |
|
1828 else |
|
1829 { |
|
1830 iActiveConsole->Console().ClearScreen(); |
|
1831 iActiveConsole->Console().Printf(_L("\nProblem starting source, see status window for")); |
|
1832 iActiveConsole->Console().Printf(_L("\nmore information or press ESC to exit.\n")); |
|
1833 iActiveConsole->RequestKey(); |
|
1834 } |
|
1835 } |
|
1836 CActiveScheduler::Start(); |
|
1837 } |
|
1838 |
|
1839 void CAVTestApp::Stop() |
|
1840 { |
|
1841 CActiveScheduler::Stop(); |
|
1842 } |
|
1843 |
|
1844 //remcon |
|
1845 void CAVTestApp::MrccatoCommand(TRemConCoreApiOperationId aOperationId, |
|
1846 TRemConCoreApiButtonAction aButtonAct) |
|
1847 { |
|
1848 __LOG(_L("RemCon::Command received 0x%02x\t Button Act %d\n"), aOperationId, aButtonAct); |
|
1849 if((aOperationId == ERemConCoreApiStop) && |
|
1850 (aButtonAct == ERemConCoreApiButtonClick || aButtonAct == ERemConCoreApiButtonPress) ) |
|
1851 { |
|
1852 __LOG(_L("RemCon::Stop received\n")); |
|
1853 iAutoStream = EFalse; |
|
1854 if (iStreamer) |
|
1855 { |
|
1856 iStreamer->Stop(); |
|
1857 } |
|
1858 iStreamState = EStopped; |
|
1859 iOperations->EndOperation(KTavsrcOpStopStream, KErrNone); |
|
1860 } |
|
1861 else if (((aOperationId == ERemConCoreApiBackward) || (aOperationId == ERemConCoreApiRewind)) && iStreamer) |
|
1862 { |
|
1863 if (aButtonAct == ERemConCoreApiButtonClick) |
|
1864 { |
|
1865 iStreamer->PrevTrack(); |
|
1866 } |
|
1867 else if ((aButtonAct == ERemConCoreApiButtonPress) && (iStreamState == EStreaming)) |
|
1868 { |
|
1869 iStreamer->Backward(); |
|
1870 iStreamer->Faster(); |
|
1871 } |
|
1872 else if ((aButtonAct == ERemConCoreApiButtonRelease) && (iStreamState == EStreaming)) |
|
1873 { |
|
1874 iStreamer->Forward(); |
|
1875 iStreamer->Slower(); |
|
1876 } |
|
1877 } |
|
1878 else if (((aOperationId == ERemConCoreApiForward) || (aOperationId == ERemConCoreApiFastForward)) && iStreamer) |
|
1879 { |
|
1880 if (aButtonAct == ERemConCoreApiButtonClick) |
|
1881 { |
|
1882 iStreamer->NextTrack(); |
|
1883 } |
|
1884 else if ((aButtonAct == ERemConCoreApiButtonPress) && (iStreamState == EStreaming)) |
|
1885 { |
|
1886 iStreamer->Faster(); |
|
1887 } |
|
1888 else if ((aButtonAct == ERemConCoreApiButtonRelease) && (iStreamState == EStreaming)) |
|
1889 { |
|
1890 iStreamer->Slower(); |
|
1891 } |
|
1892 } |
|
1893 else if ((aOperationId == ERemConCoreApiPause) && (aButtonAct != ERemConCoreApiButtonRelease)) |
|
1894 { |
|
1895 TInt operation = KTavsrcOpStream; |
|
1896 |
|
1897 if (iStreamState == EStreaming) |
|
1898 { |
|
1899 // this demo app doesn't suspend GAVDP, just the streamer |
|
1900 if (iStreamer) |
|
1901 { |
|
1902 iStreamer->Suspend(); |
|
1903 } |
|
1904 iStreamState = EPaused; |
|
1905 operation = KTavsrcOpStopStream; |
|
1906 } |
|
1907 iOperations->EndOperation(operation, KErrNone); |
|
1908 } |
|
1909 |
|
1910 if (iStreamState == EStreaming) |
|
1911 { |
|
1912 PreventLowPowerModes(); |
|
1913 } |
|
1914 |
|
1915 TestMenu(); |
|
1916 } |
|
1917 |
|
1918 void CAVTestApp::MrccatoPlay(TRemConCoreApiPlaybackSpeed /*aSpeed*/, |
|
1919 TRemConCoreApiButtonAction aButtonAct) |
|
1920 { |
|
1921 __LOG(_L("RemCon::Play received\t Button Act %d\n"), aButtonAct); |
|
1922 if((aButtonAct == ERemConCoreApiButtonClick || aButtonAct == ERemConCoreApiButtonPress)) |
|
1923 { |
|
1924 TInt operation = KTavsrcOpStream; |
|
1925 |
|
1926 // kick everything off |
|
1927 if (iGavdpState == ESigConnected) |
|
1928 { |
|
1929 // auto |
|
1930 iAutoStream = ETrue; |
|
1931 // kick off |
|
1932 DiscoverSEPs(); |
|
1933 } |
|
1934 else if (iGavdpState == ESuspended) |
|
1935 { |
|
1936 if (iStreamer) |
|
1937 iStreamer->ReStream(); |
|
1938 iStreamState = EStreaming; |
|
1939 } |
|
1940 else if (iGavdpState == EOpen) |
|
1941 { |
|
1942 if (iStreamState == EPaused) |
|
1943 { |
|
1944 // this demo app doesn't unsuspend GAVDP, just the streamer |
|
1945 if (iStreamer) |
|
1946 iStreamer->ReStream(); |
|
1947 iStreamState = EStreaming; |
|
1948 } |
|
1949 else if (iStreamState == EStopped) |
|
1950 { |
|
1951 // this demo app doesn't unsuspend GAVDP, just the streamer |
|
1952 if (iStreamer) |
|
1953 iStreamer->Stream(CurrentSEIDIsSink()); //could be source or sink |
|
1954 iStreamState = EStreaming; |
|
1955 } |
|
1956 else if (iStreamState == EClosed) |
|
1957 { |
|
1958 if (iStreamer) |
|
1959 iStreamer->Stream(CurrentSEIDIsSink()); |
|
1960 iStreamState = EStreaming; |
|
1961 } |
|
1962 } |
|
1963 iOperations->EndOperation(operation, KErrNone); |
|
1964 |
|
1965 if (iStreamState == EStreaming) |
|
1966 { |
|
1967 PreventLowPowerModes(); |
|
1968 } |
|
1969 |
|
1970 TestMenu(); |
|
1971 } |
|
1972 } |
|
1973 |
|
1974 void CAVTestApp::MediaCodecConfigurationRequired(TSBCCodecCapabilities& aConfig) |
|
1975 { |
|
1976 if (!iLocalReconfigure) |
|
1977 { |
|
1978 // set the reconfigure information |
|
1979 iReconfigInfo = aConfig; |
|
1980 iLocalReconfigure = ETrue; |
|
1981 |
|
1982 // start streaming automatically after the reconfigure |
|
1983 iAutoStream = ETrue; |
|
1984 |
|
1985 SuspendStreams(); |
|
1986 } |
|
1987 } |
|
1988 |
|
1989 void CAVTestApp::PrintCommandOption(TChar aOperation, TPtrC aDesc) |
|
1990 { |
|
1991 if (iOperations->IsOperationAllowed(aOperation)) |
|
1992 { |
|
1993 iActiveConsole->Console().Printf(_L("%c%s"), aOperation.IsUpper() ? aOperation.GetUpperCase() : aOperation.GetLowerCase(), aDesc.Ptr()); |
|
1994 } |
|
1995 else |
|
1996 { |
|
1997 iActiveConsole->Console().Printf(_L(" %s"), aDesc.Ptr()); |
|
1998 } |
|
1999 } |
|
2000 |
|
2001 // from MRemConMediaInformationTargetObserver |
|
2002 void CAVTestApp::MrcmitoGetCurrentlyPlayingMetadata( TMediaAttributeIter& aAttributeIter ) |
|
2003 { |
|
2004 iActiveConsole->Console().Printf(_L("Got MrcpitoGetElementAttributes \n") ); |
|
2005 |
|
2006 // Make sure total of these defines is greater than KAVCMaxFrame (512 bytes) |
|
2007 // to ensure that fragmentation is performed on this response |
|
2008 _LIT8(KMediaTitle, "Frederic Chopin (1810-1849): Ballade for Piano #1 in A flat major, Opus 23, CT 2 - Largo allegretto, Moderato con brio vivace, Presto con fuoco"); |
|
2009 _LIT8(KArtistName, "Maurizio Pollini and the London Philharmonic Orchestra, conducted by Sir Colin Davis, recorded live at the Royal Albert Hall at the 1987 Proms season"); |
|
2010 _LIT8(KAlbumName, "Frederic Chopin (1810-1849): Four Ballades, Two Preludes, the Valse in D-flat major - Op. 64 No. 1 and the Andante Spianato & Grand Polonaise Brillante Op. 22"); |
|
2011 _LIT8(KTrackNumber, "10345"); |
|
2012 _LIT8(KNumberOfTracks, "6876436456"); |
|
2013 _LIT8(KGenre, "Alternative super cool Classical Music with a lemon twist and a hint of progressive rock"); |
|
2014 _LIT8(KPlayingTime, "150000"); |
|
2015 |
|
2016 TBuf8<255> buffer; |
|
2017 |
|
2018 // for each element requested |
|
2019 TMediaAttributeId id; |
|
2020 while (aAttributeIter.Next(id)) |
|
2021 { |
|
2022 switch(id) |
|
2023 { |
|
2024 case ETitleOfMedia: |
|
2025 buffer.Copy(KMediaTitle); |
|
2026 break; |
|
2027 case ENameOfArtist: |
|
2028 buffer.Copy(KArtistName); |
|
2029 break; |
|
2030 case ENameOfAlbum: |
|
2031 buffer.Copy(KAlbumName); |
|
2032 break; |
|
2033 case ETrackNumber: |
|
2034 buffer.Copy(KTrackNumber); |
|
2035 break; |
|
2036 case ENumberOfTracks: |
|
2037 buffer.Copy(KNumberOfTracks); |
|
2038 break; |
|
2039 case EGenre: |
|
2040 buffer.Copy(KGenre); |
|
2041 break; |
|
2042 case EPlayingTime: |
|
2043 buffer.Copy(KPlayingTime); |
|
2044 break; |
|
2045 default: |
|
2046 __DEBUGGER(); |
|
2047 break; |
|
2048 } |
|
2049 |
|
2050 // return the element value |
|
2051 iMediaInformation->AttributeValue( id, buffer ); |
|
2052 |
|
2053 // convert the element value to unicode for display |
|
2054 TBuf16<255> buf16; |
|
2055 buf16.Copy(buffer); |
|
2056 buf16.ZeroTerminate(); |
|
2057 iActiveConsole->Console().Printf(_L("Element:%d value:%s \n"), id, buf16.Ptr() ); |
|
2058 } |
|
2059 |
|
2060 // send response complete |
|
2061 iMediaInformation->Completed(); |
|
2062 |
|
2063 } |
|
2064 |
|
2065 |
|
2066 TInt CAVTestApp::MrcmtcGetElementAttributes(TUint64 /* aElement */, TUint32 aAttribute, HBufC8*& aOutValueOwnershipTransferred) |
|
2067 { |
|
2068 // |
|
2069 // __DEBUGGER(); //try this out |
|
2070 iActiveConsole->Console().Printf(_L("Got GEA, attrib %d!\n"), aAttribute); |
|
2071 |
|
2072 aOutValueOwnershipTransferred = HBufC8::New(20); |
|
2073 if (aOutValueOwnershipTransferred) |
|
2074 { |
|
2075 aOutValueOwnershipTransferred->Des() = _L8("Hello"); |
|
2076 } |
|
2077 |
|
2078 return KErrNone; |
|
2079 } |
|
2080 |
|
2081 void CAVTestApp::MrcncRegisterPlaybackStatusChangedNotification() |
|
2082 { |
|
2083 iActiveConsole->Console().Printf(_L("Queued notify: PlayStatusChanged!\n")); |
|
2084 } |
|
2085 |
|
2086 void CAVTestApp::MrcncRegisterTrackChangedNotification() |
|
2087 { |
|
2088 iActiveConsole->Console().Printf(_L("Queued notify: TrackChanged!\n")); |
|
2089 } |
|
2090 |
|
2091 void CAVTestApp::MrcncRegisterTrackReachedEndNotification() |
|
2092 { |
|
2093 iActiveConsole->Console().Printf(_L("Queued notify: TrackReachedEnd!\n")); |
|
2094 } |
|
2095 |
|
2096 void CAVTestApp::MrcncRegisterTrackReachedStartNotification() |
|
2097 { |
|
2098 iActiveConsole->Console().Printf(_L("Queued notify: TrackReachedStart!\n")); |
|
2099 } |
|
2100 |
|
2101 void CAVTestApp::MrcncRegisterPositionChangedNotification(TUint32 aInterval) |
|
2102 { |
|
2103 iActiveConsole->Console().Printf(_L("Queued notify: PositionChanged (0x%08x)!\n"), aInterval); |
|
2104 } |
|
2105 |
|
2106 void CAVTestApp::MrcncRegisterBatteryStatusChangedNotification() |
|
2107 { |
|
2108 iActiveConsole->Console().Printf(_L("Queued notify: BatteryStatusChanged!\n")); |
|
2109 } |
|
2110 |
|
2111 void CAVTestApp::MrcncRegisterSystemStatusChangedNotification() |
|
2112 { |
|
2113 iActiveConsole->Console().Printf(_L("Queued notify: SystemStatusChanged!\n")); |
|
2114 } |
|
2115 |
|
2116 void CAVTestApp::MrcncRegisterPlayerApplicationStatusChangedNotification() |
|
2117 { |
|
2118 iActiveConsole->Console().Printf(_L("Queued notify: PlayerAppStatusChanged!\n")); |
|
2119 } |
|
2120 |
|
2121 void CAVTestApp::MrcbstoBatteryStatus(TControllerBatteryStatus& aBatteryStatus ) |
|
2122 { |
|
2123 switch(aBatteryStatus) |
|
2124 { |
|
2125 case ENormal: |
|
2126 iActiveConsole->Console().Printf(_L("Battery status: Normal \n")); |
|
2127 break; |
|
2128 case EWarning: |
|
2129 iActiveConsole->Console().Printf(_L("Battery status: Warning \n")); |
|
2130 break; |
|
2131 case ECritical: |
|
2132 iActiveConsole->Console().Printf(_L("Battery status: Critical \n")); |
|
2133 break; |
|
2134 case EExternal: |
|
2135 iActiveConsole->Console().Printf(_L("Battery status: External \n")); |
|
2136 break; |
|
2137 case EFullCharge: |
|
2138 iActiveConsole->Console().Printf(_L("Battery status: FullCharge \n")); |
|
2139 break; |
|
2140 default: |
|
2141 iActiveConsole->Console().Printf(_L("Battery status: %d \n"), aBatteryStatus); |
|
2142 break; |
|
2143 } |
|
2144 } |
|
2145 |
|
2146 void CAVTestApp::MrcgntoNextGroup(TRemConCoreApiButtonAction aButtonAct ) |
|
2147 { |
|
2148 switch(aButtonAct) |
|
2149 { |
|
2150 case ERemConCoreApiButtonPress: |
|
2151 iActiveConsole->Console().Printf(_L("Got NextGroup! Button Press \n")); |
|
2152 break; |
|
2153 case ERemConCoreApiButtonRelease: |
|
2154 iActiveConsole->Console().Printf(_L("Got NextGroup! Button Release \n")); |
|
2155 break; |
|
2156 case ERemConCoreApiButtonClick: |
|
2157 iActiveConsole->Console().Printf(_L("Got NextGroup! Button Click \n")); |
|
2158 break; |
|
2159 default: |
|
2160 iActiveConsole->Console().Printf(_L("Got NextGroup! Button ??? \n")); |
|
2161 break; |
|
2162 } |
|
2163 |
|
2164 // for testing return an error |
|
2165 TRequestStatus status; |
|
2166 TRequestStatus* ptrStatus = &status; |
|
2167 iGroupNavigation->NextGroupResponse( ptrStatus, KErrNone); |
|
2168 User::WaitForRequest(status); |
|
2169 |
|
2170 } |
|
2171 |
|
2172 void CAVTestApp::MrcgntoPreviousGroup(TRemConCoreApiButtonAction aButtonAct ) |
|
2173 { |
|
2174 switch(aButtonAct) |
|
2175 { |
|
2176 case ERemConCoreApiButtonPress: |
|
2177 iActiveConsole->Console().Printf(_L("Got PreviousGroup! Button Press \n")); |
|
2178 break; |
|
2179 case ERemConCoreApiButtonRelease: |
|
2180 iActiveConsole->Console().Printf(_L("Got PreviousGroup! Button Release \n")); |
|
2181 break; |
|
2182 case ERemConCoreApiButtonClick: |
|
2183 iActiveConsole->Console().Printf(_L("Got PreviousGroup! Button Click \n")); |
|
2184 break; |
|
2185 default: |
|
2186 iActiveConsole->Console().Printf(_L("Got PreviousGroup! Button ??? \n")); |
|
2187 break; |
|
2188 } |
|
2189 |
|
2190 // return success |
|
2191 TRequestStatus status; |
|
2192 TRequestStatus* ptrStatus = &status; |
|
2193 iGroupNavigation->PreviousGroupResponse( ptrStatus, KErrNone ); |
|
2194 User::WaitForRequest(status); |
|
2195 } |
|
2196 |
|
2197 void CAVTestApp::MrcavtoGetAbsoluteVolume() |
|
2198 { |
|
2199 TRequestStatus status; |
|
2200 iAbsoluteVolume->GetAbsoluteVolumeResponse(status, 1, 2, KErrNone); |
|
2201 User::WaitForRequest(status); |
|
2202 } |
|
2203 |
|
2204 void CAVTestApp::MrcavtoSetAbsoluteVolume(TUint /*aAbsVol*/, TUint /*aMaxVol*/) |
|
2205 { |
|
2206 TRequestStatus status; |
|
2207 iAbsoluteVolume->SetAbsoluteVolumeResponse(status, KErrNone); |
|
2208 User::WaitForRequest(status); |
|
2209 } |
|
2210 |
|
2211 void CAVTestApp::MrctitoGetTrackName() |
|
2212 { |
|
2213 TRequestStatus status; |
|
2214 _LIT(KTrackName, "trackname"); |
|
2215 iTrackInfo->GetTrackNameResponse(status, KTrackName, KErrNone); |
|
2216 User::WaitForRequest(status); |
|
2217 } |
|
2218 |
|
2219 void CAVTestApp::MrctitoGetArtist() |
|
2220 { |
|
2221 TRequestStatus status; |
|
2222 _LIT(KArtist, "artist"); |
|
2223 iTrackInfo->GetArtistResponse(status, KArtist, KErrNone); |
|
2224 User::WaitForRequest(status); |
|
2225 } |
|
2226 |
|
2227 void CAVTestApp::MrctitoGetTrackDuration() |
|
2228 { |
|
2229 TRequestStatus status; |
|
2230 _LIT(KTrackDuration, "0.2.56"); |
|
2231 TTime trackDuration(KTrackDuration); |
|
2232 iTrackInfo->GetTrackDurationResponse(status, trackDuration, KErrNone); |
|
2233 User::WaitForRequest(status); |
|
2234 } |
|
2235 |
|
2236 _LIT(KOn, "On"); |
|
2237 _LIT(KOff, "Off"); |
|
2238 |
|
2239 void CAVTestApp::TestMenu() |
|
2240 { |
|
2241 iActiveConsole->Console().ClearScreen(); |
|
2242 |
|
2243 iActiveConsole->Console().Printf(_L("Safe Mode: %S\n"), iOperations->SafeMode() ? &KOn() : &KOff()); |
|
2244 |
|
2245 if (iGavdpState!=EIdle) |
|
2246 { |
|
2247 iActiveConsole->Console().Printf(_L("Connected \n\r")); |
|
2248 } |
|
2249 else |
|
2250 { |
|
2251 iActiveConsole->Console().Printf(_L(" \n\r")); |
|
2252 } |
|
2253 |
|
2254 RProperty property; |
|
2255 TBuf8<6> addr; |
|
2256 |
|
2257 TInt err = property.Get(KPropertyUidBluetoothCategory, |
|
2258 KPropertyKeyBluetoothGetLocalDeviceAddress, addr); |
|
2259 |
|
2260 if ((err) || (addr.Length()!=6)) |
|
2261 { |
|
2262 iActiveConsole->Console().Printf(_L("P&S: ERROR retrieving local address\n")); |
|
2263 } |
|
2264 else |
|
2265 { |
|
2266 TBTDevAddr localAddress(addr); |
|
2267 TBuf<20> dispBuf; |
|
2268 localAddress.GetReadable(dispBuf); |
|
2269 TBuf<20> rBuf; |
|
2270 iDevAddr.GetReadable(rBuf); |
|
2271 iActiveConsole->Console().Printf(_L("Local address = 0x%S; Using Remote Addr = 0x%S\n"),&dispBuf,&rBuf); |
|
2272 } |
|
2273 |
|
2274 iActiveConsole->Console().Printf(_L("\n")); |
|
2275 |
|
2276 switch (iGavdpState) |
|
2277 { |
|
2278 case ENoClientOpen: |
|
2279 PrintCommandOption(KTavsrcOpStartSrc, _L(". Open GAVDP for Src\n")); |
|
2280 break; |
|
2281 case EIdle: |
|
2282 PrintCommandOption(KTavsrcOpConnect, _L(". Connect\n")); |
|
2283 PrintCommandOption(KTavsrcOpCancel, _L(". Cancel\n")); |
|
2284 PrintCommandOption(KTavsrcOpRegisterSEP, _L(". Register SEP\n")); |
|
2285 break; |
|
2286 case ESigConnected: |
|
2287 case EOpen: |
|
2288 case ESuspended: |
|
2289 case ERemoteReconfiguring: |
|
2290 PrintCommandOption(KTavsrcOpAutoStream, _L(". Auto Stream\n")); |
|
2291 PrintCommandOption(KTavsrcOpDiscoverSEPs, _L(". Discover remote SEPs ")); |
|
2292 PrintCommandOption(KTavsrcOpCreateBearers, _L(". Create Bearers\n")); |
|
2293 |
|
2294 PrintCommandOption(KTavsrcOpGetCapabilities, _L(". Get Remote SEP Capabilites ")); |
|
2295 PrintCommandOption(KTavsrcOpCloseBearers, _L(". Close Bearers\n")); |
|
2296 |
|
2297 PrintCommandOption(KTavsrcOpStartStreams, _L(". Start Stream ")); |
|
2298 PrintCommandOption(KTavsrcOpSuspendStreams, _L(". Suspend Stream\n")); |
|
2299 |
|
2300 PrintCommandOption(KTavsrcOpContentProtection, _L(". Content Protection ")); |
|
2301 PrintCommandOption(KTavsrcOpAbort, _L(". Abort Stream\n")); |
|
2302 |
|
2303 PrintCommandOption(KTavsrcOpConfigureSEP, _L(". Select Remote SEP (configure the doofer)\n")); |
|
2304 |
|
2305 PrintCommandOption(KTavsrcOpStream, _L(". Start Streamer ")); |
|
2306 PrintCommandOption(KTavsrcOpStopStream, _L(". Stop Streamer\n\n")); |
|
2307 |
|
2308 PrintCommandOption(KTavsrcOpPacketDropIoctl, _L(". Send \"Notify Media Packet Dropped\" IOCTL\n\n")); |
|
2309 |
|
2310 PrintCommandOption(KTavsrcOpDisconnectSrc, _L(". Disconnect GAVDP - don't close\n")); |
|
2311 PrintCommandOption(KTavsrcOpStopSrc, _L(". Close GAVDP\n")); |
|
2312 break; |
|
2313 } |
|
2314 |
|
2315 iActiveConsole->Console().Printf(_L("\n")); |
|
2316 |
|
2317 PrintCommandOption(KTavsrcOpPlay, _L(". AVRCP Play ")); |
|
2318 PrintCommandOption(KTavsrcOpStop, _L(". AVRCP Stop\n")); |
|
2319 |
|
2320 iActiveConsole->Console().Printf(_L("Up. AVRCP Volume Up ")); |
|
2321 iActiveConsole->Console().Printf(_L("Down. AVRCP Volume Down\n")); |
|
2322 |
|
2323 iActiveConsole->Console().Printf(_L("Left. AVRCP Backwards ")); |
|
2324 iActiveConsole->Console().Printf(_L("Right. AVRCP Forwards\n")); |
|
2325 |
|
2326 iActiveConsole->Console().Printf(_L("\n")); |
|
2327 |
|
2328 PrintCommandOption(KTavsrcOpToggleSafeMode, _L(".\tToggle Safe Mode\n")); |
|
2329 iActiveConsole->Console().Printf(_L("Esc.\tStop\n")); |
|
2330 |
|
2331 if (!iActiveConsole->IsActive()) |
|
2332 { |
|
2333 iActiveConsole->RequestKey(); |
|
2334 } |
|
2335 } |
|
2336 |
|
2337 void CAVTestApp::KeyPressed(TChar aKey) |
|
2338 { |
|
2339 TInt beginOperation = iOperations->BeginOperation(aKey); |
|
2340 |
|
2341 if (beginOperation == KErrNone) |
|
2342 { |
|
2343 switch (aKey) |
|
2344 { |
|
2345 case KTavsrcOpConnect: |
|
2346 { |
|
2347 Connect(); |
|
2348 break; |
|
2349 } |
|
2350 case KTavsrcOpCancel: |
|
2351 { |
|
2352 iOperations->EndOperation(KTavsrcOpCancel, KErrCancel); |
|
2353 |
|
2354 iGavdp.Cancel(); |
|
2355 __LOG(_L("Current Request Cancelled \n")); |
|
2356 break; |
|
2357 } |
|
2358 case KTavsrcOpDiscoverSEPs: |
|
2359 { |
|
2360 DiscoverSEPs(); |
|
2361 break; |
|
2362 } |
|
2363 case KTavsrcOpCreateBearers: |
|
2364 { |
|
2365 CreateBearers(); |
|
2366 break; |
|
2367 } |
|
2368 case KTavsrcOpCloseBearers: |
|
2369 { |
|
2370 iOperations->EndOperation(KTavsrcOpCloseBearers, KErrNone); |
|
2371 |
|
2372 CloseBearers(); |
|
2373 break; |
|
2374 } |
|
2375 case KTavsrcOpContentProtection: |
|
2376 { |
|
2377 SendSecurityControl(); |
|
2378 break; |
|
2379 } |
|
2380 case KTavsrcOpGetCapabilities: |
|
2381 { |
|
2382 GetCapabilities(); |
|
2383 break; |
|
2384 } |
|
2385 case KTavsrcOpStartStreams: |
|
2386 { |
|
2387 StartStreams(); |
|
2388 break; |
|
2389 } |
|
2390 case KTavsrcOpSuspendStreams: |
|
2391 { |
|
2392 SuspendStreams(); |
|
2393 break; |
|
2394 } |
|
2395 case KTavsrcOpEchoStorm: |
|
2396 { |
|
2397 iOperations->EndOperation(KTavsrcOpEchoStorm, KErrNone); |
|
2398 |
|
2399 EchoStorm(); |
|
2400 break; |
|
2401 } |
|
2402 case KTavsrcOpAbort: |
|
2403 { |
|
2404 Abort(); |
|
2405 break; |
|
2406 } |
|
2407 case KTavsrcOpStream: |
|
2408 { |
|
2409 iOperations->EndOperation(KTavsrcOpStream, KErrNone); |
|
2410 |
|
2411 iStreamer->Stream(CurrentSEIDIsSink()); |
|
2412 iStreamState = EStreaming; |
|
2413 } |
|
2414 break; |
|
2415 case KTavsrcOpStreamFaster: |
|
2416 { |
|
2417 iOperations->EndOperation(KTavsrcOpStreamFaster, KErrNone); |
|
2418 |
|
2419 iStreamer->Faster(); |
|
2420 break; |
|
2421 } |
|
2422 |
|
2423 case KTavsrcOpStreamSlower: |
|
2424 { |
|
2425 iOperations->EndOperation(KTavsrcOpStreamSlower, KErrNone); |
|
2426 |
|
2427 iStreamer->Slower(); |
|
2428 break; |
|
2429 } |
|
2430 |
|
2431 case KTavsrcOpAutoStream: |
|
2432 { |
|
2433 // auto |
|
2434 iAutoStream = ETrue; |
|
2435 // kick off |
|
2436 DiscoverSEPs(); |
|
2437 } |
|
2438 break; |
|
2439 |
|
2440 case KTavsrcOpStopStream: |
|
2441 { |
|
2442 iOperations->EndOperation(KTavsrcOpStopStream, KErrNone); |
|
2443 |
|
2444 __LOG(_L("Stopping streaming... \n")); |
|
2445 iStreamState = EPaused; |
|
2446 iStreamer->Suspend(); |
|
2447 } |
|
2448 break; |
|
2449 case KTavsrcOpRegisterSEP: |
|
2450 { |
|
2451 iOperations->EndOperation(KTavsrcOpRegisterSEP, KErrNone); |
|
2452 |
|
2453 RegisterSEP(); |
|
2454 break; |
|
2455 } |
|
2456 case KTavsrcOpRegisterMultipleSEPs: |
|
2457 { |
|
2458 iOperations->EndOperation(KTavsrcOpRegisterMultipleSEPs, KErrNone); |
|
2459 |
|
2460 for (TInt i=0; i<=40; i++) |
|
2461 { |
|
2462 TAvdtpSEPInfo info; iGavdp.RegisterSEP(info); |
|
2463 } |
|
2464 break; |
|
2465 } |
|
2466 case KTavsrcOpStartSrc: |
|
2467 { |
|
2468 iOperations->EndOperation(KTavsrcOpStartSrc, KErrNone); |
|
2469 |
|
2470 //reopen GAVDP |
|
2471 StartSrc(); |
|
2472 break; |
|
2473 } |
|
2474 |
|
2475 case KTavsrcOpStopSrc: |
|
2476 { |
|
2477 iOperations->EndOperation(KTavsrcOpStopSrc, KErrNone); |
|
2478 |
|
2479 StopSrc(); |
|
2480 break; |
|
2481 } |
|
2482 case KTavsrcOpDisconnectSrc: |
|
2483 { |
|
2484 iOperations->EndOperation(KTavsrcOpDisconnectSrc, KErrNone); |
|
2485 |
|
2486 DisconnectSrc(); |
|
2487 break; |
|
2488 } |
|
2489 case KTavsrcOpConfigureSEP: |
|
2490 { |
|
2491 TRAPD(err, ConfigureSEPL()); |
|
2492 if (err != KErrNone) |
|
2493 { |
|
2494 iOperations->EndOperation(KTavsrcOpConfigureSEP, err); |
|
2495 } |
|
2496 break; |
|
2497 } |
|
2498 |
|
2499 case KTavsrcOpPacketDropIoctl: |
|
2500 { |
|
2501 iOperations->EndOperation(KTavsrcOpPacketDropIoctl, KErrNone); |
|
2502 |
|
2503 __LOG(_L("Sending packet drop IOCTL\n")); |
|
2504 iPacketDropIoctl = CActivePacketDropIoctl::NewL(iLogConsole, iPendingSockets);//Qualified |
|
2505 iPacketDropIoctl->Start(); |
|
2506 break; |
|
2507 } |
|
2508 |
|
2509 case KTavsrcOpVolumeUp: |
|
2510 { |
|
2511 iOperations->EndOperation(KTavsrcOpVolumeUp, KErrNone); |
|
2512 |
|
2513 iController->Command(ERemConCoreApiVolumeUp); |
|
2514 break; |
|
2515 } |
|
2516 |
|
2517 case KTavsrcOpVolumeDown: |
|
2518 { |
|
2519 iOperations->EndOperation(KTavsrcOpVolumeDown, KErrNone); |
|
2520 |
|
2521 iController->Command(ERemConCoreApiVolumeDown); |
|
2522 break; |
|
2523 } |
|
2524 |
|
2525 case KTavsrcOpBackwards: |
|
2526 { |
|
2527 iOperations->EndOperation(KTavsrcOpBackwards, KErrNone); |
|
2528 |
|
2529 iController->Command(ERemConCoreApiBackward); |
|
2530 break; |
|
2531 } |
|
2532 |
|
2533 case KTavsrcOpForwards: |
|
2534 { |
|
2535 iOperations->EndOperation(KTavsrcOpForwards, KErrNone); |
|
2536 |
|
2537 iController->Command(ERemConCoreApiForward); |
|
2538 break; |
|
2539 } |
|
2540 |
|
2541 case KTavsrcOpPlay: |
|
2542 { |
|
2543 iOperations->EndOperation(KTavsrcOpPlay, KErrNone); |
|
2544 |
|
2545 iController->Command(ERemConCoreApiPlay); |
|
2546 break; |
|
2547 } |
|
2548 |
|
2549 case KTavsrcOpStop: |
|
2550 { |
|
2551 iOperations->EndOperation(KTavsrcOpStop, KErrNone); |
|
2552 |
|
2553 iController->Command(ERemConCoreApiStop); |
|
2554 break; |
|
2555 } |
|
2556 |
|
2557 case KTavsrcOpExit: |
|
2558 { |
|
2559 iOperations->EndOperation(KTavsrcOpExit, KErrNone); |
|
2560 |
|
2561 Stop(); |
|
2562 return; |
|
2563 } |
|
2564 |
|
2565 case KTavsrcOpToggleSafeMode: |
|
2566 { |
|
2567 iOperations->EndOperation(KTavsrcOpToggleSafeMode, KErrNone); |
|
2568 |
|
2569 iOperations->SetSafeMode(!iOperations->SafeMode()); |
|
2570 break; |
|
2571 } |
|
2572 |
|
2573 default: |
|
2574 iActiveConsole->Console().Printf(_L("Unknown command\r\n")); |
|
2575 } |
|
2576 } |
|
2577 else |
|
2578 { |
|
2579 __LOG(_L("Operation not allowed: %d\r\n"), beginOperation); |
|
2580 } |
|
2581 |
|
2582 TestMenu(); |
|
2583 |
|
2584 } |
|
2585 |
|
2586 TInt CAVTestApp::RegisterSEP() |
|
2587 { |
|
2588 TInt err; |
|
2589 |
|
2590 TAvdtpSEPInfo info; |
|
2591 info.SetIsSink(TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(), _L("Sink "))); |
|
2592 info.SetMediaType(TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(), _L("Audio ")) ? |
|
2593 EAvdtpMediaTypeAudio : |
|
2594 EAvdtpMediaTypeVideo); |
|
2595 err = iGavdp.RegisterSEP(info); |
|
2596 |
|
2597 if (err==KErrNone) |
|
2598 { |
|
2599 iLocallyRegisteredSEPs.Append(info); |
|
2600 } |
|
2601 __LOG(_L("Registering SEP [SEID %d] - completed with error %d\n"), info.SEID().SEID(), err); |
|
2602 |
|
2603 if (err==KErrNone) |
|
2604 { |
|
2605 iCurrentLocalSEID = info.SEID(); |
|
2606 |
|
2607 // add some caps, not to all though for testing! |
|
2608 err = iGavdp.BeginConfiguringLocalSEP(info.SEID()); |
|
2609 |
|
2610 __LOG(_L("Begin config Local SEP [SEID %d] - completed with error %d\n"), info.SEID().SEID(), err); |
|
2611 |
|
2612 TAvdtpMediaTransportCapabilities media; |
|
2613 err = iGavdp.AddSEPCapability(media); |
|
2614 __LOG(_L("Add configuration [Category %d] - completed with error %d\n"), media.Category(), err); |
|
2615 /* |
|
2616 TAvdtpReportingCapabilities rep; |
|
2617 err = iGavdp.AddSEPCapability(rep); |
|
2618 __LOG(_L("Add configuration [Category %d] - completed with error %d\n"), rep.Category(), err); |
|
2619 |
|
2620 TAvdtpRecoveryCapabilities rec; |
|
2621 rec.SetRecoveryType(ERFC2733Recovery); |
|
2622 rec.SetMaxWindowSize(5); |
|
2623 rec.SetMinWindowSize(1); |
|
2624 err = iGavdp.AddSEPCapability(rec); |
|
2625 __LOG(_L("Add configuration [Category %d] - completed with error %d\n"), rec.Category(), err); |
|
2626 |
|
2627 TAvdtpContentProtectionCapabilities cp; |
|
2628 cp.SetContentProtectionType(0x1234); |
|
2629 cp.SetContentProtectionData(_L8("A test content protection method")); |
|
2630 err = iGavdp.AddSEPCapability(cp); |
|
2631 */ |
|
2632 if(TTavsrcUtils::GetYNFromUser(iActiveConsole->Console(), _L("SBC "))) |
|
2633 { |
|
2634 TSBCCodecCapabilities sbc; |
|
2635 sbc.SetSamplingFrequencies(E48kHz|E44100Hz|E32kHz|E16kHz); |
|
2636 sbc.SetBlockLengths(EBlockLenFour | EBlockLenEight | EBlockLenTwelve | EBlockLenSixteen); |
|
2637 sbc.SetMinBitpoolValue(2); |
|
2638 sbc.SetMaxBitpoolValue(250); |
|
2639 sbc.SetChannelModes(EJointStereo | EStereo | EMono | EDualChannel); |
|
2640 sbc.SetSubbands(EFourSubbands|EEightSubbands); |
|
2641 sbc.SetAllocationMethods(ELoudness | ESNR); |
|
2642 |
|
2643 // crazy stuff testing |
|
2644 /* |
|
2645 sbc.SetSamplingFrequencies(E16kHz); |
|
2646 sbc.SetBlockLengths(EBlockLenTwelve); |
|
2647 sbc.SetChannelModes(EJointStereo); |
|
2648 sbc.SetSubbands(EFourSubbands); |
|
2649 */ |
|
2650 err = iGavdp.AddSEPCapability(sbc); |
|
2651 |
|
2652 __LOG(_L("Add configuration [Category %d] - completed with error %d\n"), sbc.Category(), err); |
|
2653 } |
|
2654 else |
|
2655 { |
|
2656 TNonSBCCodecCapabilities codec(SymbianBluetoothAV::EAvdtpMediaTypeAudio, SymbianBluetoothAV::EAudioCodecMPEG24AAC); |
|
2657 TBuf8<18> mpeg2aacData; |
|
2658 mpeg2aacData.Append(0x80); // MPEG2 AAC LC |
|
2659 mpeg2aacData.Append(0x01); // 44.1 kHz |
|
2660 mpeg2aacData.Append(0x80); // 48.0 kHz, Channels 1 & 2 |
|
2661 mpeg2aacData.Append(0x80); // VBR, unknown bitrate |
|
2662 mpeg2aacData.Append(0x00); // unknown bitrate |
|
2663 mpeg2aacData.Append(0x00); // unknown bitrate |
|
2664 |
|
2665 codec.SetCodecData(mpeg2aacData); |
|
2666 |
|
2667 err = iGavdp.AddSEPCapability(codec); |
|
2668 |
|
2669 __LOG(_L("Add configuration [Category %d] - completed with error %d\n"), codec.Category(), err); |
|
2670 } |
|
2671 |
|
2672 iRegisteringLocalSEP = ETrue; |
|
2673 iGavdp.CommitSEPConfiguration(); |
|
2674 |
|
2675 __LOG(_L("Commit configuration [SEID %d]\n"), info.SEID().SEID()); |
|
2676 } |
|
2677 return err; |
|
2678 } |
|