|
1 /* |
|
2 * Copyright (c) 2008 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 |
|
21 #include <e32const.h> |
|
22 #include "MCEConstants.h" |
|
23 #include "TCmdModifyVideoCodec.h" |
|
24 #include "CTcMCEContext.h" |
|
25 |
|
26 #include <MCEVideoCodec.h> |
|
27 |
|
28 void TCmdModifyVideoCodec::ExecuteL() |
|
29 { |
|
30 // ---------- Setup -------------------------------------------------------- |
|
31 |
|
32 // Get codec |
|
33 CMceVideoCodec* codec = |
|
34 reinterpret_cast<CMceVideoCodec*>(GetObjectForIdL(KCodecId, ETrue)); |
|
35 |
|
36 // ---------- Execution ---------------------------------------------------- |
|
37 TInt err; |
|
38 |
|
39 // Setting MaxBitrate |
|
40 TInt maxBitrate( 0 ); |
|
41 maxBitrate = ExtractIntegerL( KParamMaxBitRate, 0, EFalse ); |
|
42 if ( maxBitrate != 0 ) |
|
43 { |
|
44 TRAP_IGNORE( codec->SetMaxBitrateL(maxBitrate) ) |
|
45 } |
|
46 |
|
47 //Bitrate |
|
48 TInt bitrate( 0 ); |
|
49 bitrate = ExtractIntegerL( KParamBitrates, 0, EFalse ); |
|
50 if ( bitrate != 0 ) |
|
51 { |
|
52 if( codec->SetBitrate(bitrate) == KErrNotSupported ) |
|
53 AddIntegerResponseL( KResponseBitrates, KErrNotSupported ); |
|
54 } |
|
55 |
|
56 //AllowedBitrates |
|
57 TInt allowedBitrates( 0 ); |
|
58 allowedBitrates = ExtractIntegerL( KParamAllowedBitRate, 0, EFalse ); |
|
59 if ( allowedBitrates != 0 ) |
|
60 { |
|
61 if( codec->SetAllowedBitrates(allowedBitrates) == KErrNotSupported ) |
|
62 AddIntegerResponseL( KResponseAllowedBitRate, KErrNotSupported ); |
|
63 } |
|
64 |
|
65 |
|
66 // Setting allowed Resolutions |
|
67 TInt allowedResolutions( 0 ); |
|
68 allowedResolutions = ExtractIntegerL( KParamResolution, 0, EFalse ); |
|
69 if ( allowedResolutions != 0 ) |
|
70 { |
|
71 TRAP_IGNORE( codec->SetAllowedResolutionsL( allowedResolutions ) ) |
|
72 } |
|
73 |
|
74 //TODO |
|
75 /* |
|
76 // Resolution |
|
77 CDesC8Array* res = ExtractArrayL(KParamResolution, EFalse); |
|
78 if ( res ) |
|
79 { |
|
80 TInt w( 0 ); |
|
81 TInt h( 0 ); //= static_cast< TInt >(*res)[1]; |
|
82 |
|
83 TLex8 lexer( (*res)[0]->Des() ); |
|
84 lexer.Val( w ); |
|
85 TSize resolution( w, h ); |
|
86 TRAPD(err,codec->SetResolutionL( resolution )); |
|
87 } |
|
88 */ |
|
89 |
|
90 // CodecMode |
|
91 TInt codecMode( 0 ); |
|
92 codecMode = ExtractIntegerL( KParamCodecMode, 0, EFalse ); |
|
93 if ( codecMode != 0 ) |
|
94 { |
|
95 if( codec->SetCodecMode( codecMode ) == KErrNotSupported ) |
|
96 AddIntegerResponseL( KResponseCodecMode, KErrNotSupported ); |
|
97 } |
|
98 |
|
99 // Allowed FrameRates |
|
100 TInt allowedFrameRates( 0 ); |
|
101 allowedFrameRates = ExtractIntegerL( KParamAllowedFrameRates, 0, EFalse ); |
|
102 if ( allowedFrameRates != 0 ) |
|
103 { |
|
104 TRAP_IGNORE( codec->SetAllowedFrameRatesL( allowedFrameRates ) ) |
|
105 } |
|
106 |
|
107 // FrameRate |
|
108 TInt frameRate( 0 ); |
|
109 frameRate = ExtractIntegerL( KParamFrameRate, 0, EFalse ); |
|
110 if ( frameRate != 0 ) |
|
111 { |
|
112 TRAP_IGNORE( codec->SetFrameRateL( frameRate ) ) |
|
113 } |
|
114 |
|
115 //preferred EncodingDecodingDevice |
|
116 TUint id( 0 ); |
|
117 TPtrC8 idTxt = ExtractTextL(KParamPreferredEncodingDecodingDeviceUid, EFalse); |
|
118 TLex8 lexer = TLex8(idTxt); |
|
119 err = lexer.Val(id, EHex); |
|
120 |
|
121 if(err == KErrNone) |
|
122 { |
|
123 const TUid preferredEncodingDecodingDevice = TUid::Uid( id ); |
|
124 if(id != 0) |
|
125 { |
|
126 TRAP_IGNORE( codec->SetPreferredEncodingDecodingDeviceL(preferredEncodingDecodingDevice) ) |
|
127 } |
|
128 } |
|
129 |
|
130 //Config Keys |
|
131 TPtrC8 configKeys = ExtractTextL( KParamConfigKeys, EFalse ); |
|
132 if( configKeys.Compare( KNullDesC8 ) != 0 ) |
|
133 { |
|
134 TRAP_IGNORE( codec->SetConfigKeyL(configKeys) ) |
|
135 } |
|
136 |
|
137 // Payload Type |
|
138 TInt pType( 0 ); |
|
139 pType = ExtractIntegerL( KParamPayloadType, 0, ETrue ); |
|
140 if ( pType != 0 ) |
|
141 { |
|
142 if( codec->SetPayloadType( pType ) == KErrNotSupported) |
|
143 AddIntegerResponseL( KResponsePayloadType, KErrNotSupported ); |
|
144 } |
|
145 |
|
146 // ---------- Response creation -------------------------------------------- |
|
147 |
|
148 AddIdResponseL( KCodecId, *codec ); |
|
149 |
|
150 AddTextResponseL( KResponseCodecName, codec->SdpName() ); |
|
151 |
|
152 AddIntegerResponseL( KResponseBitrates, codec->Bitrate() ); |
|
153 |
|
154 AddIntegerResponseL( KParamMaxBitRate, codec->MaxBitRate() ); |
|
155 |
|
156 AddIntegerResponseL( KParamAllowedResolutions, codec->AllowedResolutions() ); |
|
157 |
|
158 AddIntegerResponseL( KResponseCodecMode, codec->CodecMode() ); |
|
159 |
|
160 AddIntegerResponseL( KParamAllowedFrameRates, codec->AllowedFrameRates() ); |
|
161 |
|
162 AddIntegerResponseL( KParamFrameRate, codec->FrameRate() ); |
|
163 |
|
164 AddIntegerResponseL( KResponsePayloadType, codec->PayloadType() ); |
|
165 |
|
166 } |
|
167 |
|
168 TBool TCmdModifyVideoCodec::Match( const TTcIdentifier& aId ) |
|
169 { |
|
170 return TTcMceCommandBase::Match( aId, _L8("ModifyVideoCodec") ); |
|
171 } |
|
172 |
|
173 TTcCommandBase* TCmdModifyVideoCodec::CreateL( MTcTestContext& aContext ) |
|
174 { |
|
175 return new( ELeave ) TCmdModifyVideoCodec( aContext ); |
|
176 } |