|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "MCEConstants.h" |
|
21 #include "TCmdSetSource.h" |
|
22 #include "CTcMCEContext.h" |
|
23 #include <MceMediaStream.h> |
|
24 #include <MCEAudioStream.h> |
|
25 #include <MceRtpSource.h> |
|
26 #include <MCEMicSource.h> |
|
27 |
|
28 void TCmdSetSource::ExecuteL() |
|
29 { |
|
30 // ---------- Setup -------------------------------------------------------- |
|
31 |
|
32 // Get stream |
|
33 CMceMediaStream* mediaStream = reinterpret_cast<CMceMediaStream*> |
|
34 (GetObjectForIdL(KStreamId, ETrue)); |
|
35 |
|
36 if ( mediaStream->Type() != KMceAudio ) |
|
37 { |
|
38 User::Leave( KErrNotSupported ); |
|
39 } |
|
40 |
|
41 CMceAudioStream* audioStream = static_cast<CMceAudioStream*>(mediaStream); |
|
42 |
|
43 // Get type |
|
44 TPtrC8 source = ExtractTextL( KParamSource, ETrue ); |
|
45 |
|
46 //get the inactivity timer value for rtp source |
|
47 TInt rtpInactivityTimer = ExtractIntegerL(KParamRTPInactivityTimer, 0, EFalse); |
|
48 |
|
49 // ---------- Execution ---------------------------------------------------- |
|
50 |
|
51 if (source == KValueSourceRTP ) |
|
52 { |
|
53 CMceRtpSource* rtpSource = NULL; |
|
54 |
|
55 if(rtpInactivityTimer != 0) |
|
56 rtpSource = CMceRtpSource::NewLC(KMceJitterBufferLength, KMceJitterBufferTreshold, rtpInactivityTimer * 1000); |
|
57 else |
|
58 rtpSource = CMceRtpSource::NewLC(); |
|
59 |
|
60 audioStream->SetSourceL(rtpSource); |
|
61 CleanupStack::Pop(rtpSource); |
|
62 AddIdResponseL( KSourceId, *rtpSource ); |
|
63 } |
|
64 else if (source == KValueSourceMic ) |
|
65 { |
|
66 CMceMicSource* mic = CMceMicSource::NewLC(); |
|
67 audioStream->SetSourceL(mic); |
|
68 CleanupStack::Pop(mic); |
|
69 AddIdResponseL( KSourceId, *mic ); |
|
70 } |
|
71 else |
|
72 { |
|
73 User::Leave( KErrNotSupported ); |
|
74 } |
|
75 |
|
76 // ---------- Response creation -------------------------------------------- |
|
77 |
|
78 AddIdResponseL( KStreamId, *audioStream ); |
|
79 // Source added to response during execution |
|
80 |
|
81 } |
|
82 |
|
83 TBool TCmdSetSource::Match( const TTcIdentifier& aId ) |
|
84 { |
|
85 return TTcMceCommandBase::Match( aId, _L8("SetSource") ); |
|
86 } |
|
87 |
|
88 TTcCommandBase* TCmdSetSource::CreateL( MTcTestContext& aContext ) |
|
89 { |
|
90 return new( ELeave ) TCmdSetSource( aContext ); |
|
91 } |