|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "mceredcodec.h" |
|
22 #include "mcecomredcodec.h" |
|
23 |
|
24 #ifdef MCE_COMMON_SERVER_SIDE |
|
25 |
|
26 #include <mmcccodecinformationfactory.h> |
|
27 #include <mmcccodecinformation.h> |
|
28 #include "mcecomaudiostream.h" |
|
29 |
|
30 #endif //MCE_COMMON_SERVER_SIDE |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CMceComRedCodec::NewL |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CMceComRedCodec* CMceComRedCodec::NewL( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
39 { |
|
40 CMceComRedCodec* self = NewLC( aSdpName ); |
|
41 CleanupStack::Pop( self ); |
|
42 return self; |
|
43 |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CMceComRedCodec::NewLC |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CMceComRedCodec* CMceComRedCodec::NewLC( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
51 { |
|
52 CMceComRedCodec* self = new (ELeave) CMceComRedCodec(); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL( aSdpName ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CMceComRedCodec::~CMceComRedCodec |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CMceComRedCodec::~CMceComRedCodec() |
|
64 { |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CMceComRedCodec::CMceComRedCodec |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CMceComRedCodec::CMceComRedCodec() |
|
73 : CMceComAudioCodec() |
|
74 { |
|
75 iState = CMceCodec::EDisabled; // NOTE: Red is in disabled state by default |
|
76 |
|
77 iFourCC = 0; |
|
78 iEnableVAD = EFalse; |
|
79 iSamplingFreq = KMceRedSamplingFreq; |
|
80 iPTime = KMceRedDefaultPtime; |
|
81 iMaxPTime = KMceRedDefaultMaxPtime; |
|
82 iPayloadType = KMceDefaultRedPayloadType; |
|
83 |
|
84 // valid default codec mode is needed for MCC codec interaction |
|
85 const TUint KRedCodecMode = 1; |
|
86 iCodecMode = KRedCodecMode; |
|
87 } |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CMceComRedCodec::SendSupported |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 TBool CMceComRedCodec::SendSupported() |
|
94 { |
|
95 return EFalse; |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CMceComRedCodec::ConstructL |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 CMceComAudioCodec* CMceComRedCodec::CloneL() |
|
103 { |
|
104 CMceComRedCodec* copy = new (ELeave) CMceComRedCodec(); |
|
105 CleanupStack::PushL( copy ); |
|
106 copy->ConstructL( *this ); |
|
107 CleanupStack::Pop( copy ); |
|
108 return copy; |
|
109 |
|
110 } |
|
111 |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CMceComRedCodec::ConstructL |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 void CMceComRedCodec::ConstructL( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
118 { |
|
119 CMceComAudioCodec::ConstructL( aSdpName ); |
|
120 } |
|
121 |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CMceComRedCodec::ConstructL |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 void CMceComRedCodec::ConstructL( CMceComRedCodec& aCodec ) |
|
128 { |
|
129 CMceComAudioCodec::ConstructL( aCodec ); |
|
130 } |
|
131 |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CMceComRedCodec::SetPayloadType |
|
135 // ----------------------------------------------------------------------------- |
|
136 // |
|
137 TInt CMceComRedCodec::SetPayloadType( TUint8 aPayloadType ) |
|
138 { |
|
139 if ( KMinDynPayloadType <= aPayloadType ) |
|
140 { |
|
141 return CMceComCodec::SetPayloadType( aPayloadType ); |
|
142 } |
|
143 else |
|
144 { |
|
145 return KErrNotSupported; |
|
146 } |
|
147 } |
|
148 |
|
149 |
|
150 #ifdef MCE_COMMON_SERVER_SIDE |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CMceComRedCodec::DoDecodeAudioL |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CMceComRedCodec::DoDecodeAudioL( |
|
157 TInt aCodecIndex, |
|
158 RPointerArray<CMceSrvStream>& /*aStreams*/, |
|
159 CMceComAudioStream& aAudio, |
|
160 CMceMediaManager& /*aManager*/ ) |
|
161 { |
|
162 // Special handling for red codecs, red settings affect to other codecs. |
|
163 // If red codec is preferred send codec, associated codec of highest |
|
164 // preference is selected as send stream. If there's no associated |
|
165 // codec(s) for the red for some reason, next codec with sending capability |
|
166 // is enabled. |
|
167 // |
|
168 CMccCodecInformationFactory* factory = CMccCodecInformationFactory::NewL(); |
|
169 CleanupStack::PushL( factory ); |
|
170 CMccCodecInformation* mccCodec = factory->CreateCodecInformationL( iSdpName ); |
|
171 CleanupStack::PushL( mccCodec ); |
|
172 |
|
173 // Use dummy mcc codec for parsing the fmtp |
|
174 mccCodec->SetFmtpAttrL( *iFmtpAttr, ETrue ); |
|
175 |
|
176 RArray<TUint> redPayloads; |
|
177 CleanupClosePushL( redPayloads ); |
|
178 mccCodec->RedPayloadsL( redPayloads ); |
|
179 |
|
180 const TInt codecCount = aAudio.CodecCount(); |
|
181 |
|
182 for ( TInt i = 0 ; i < codecCount ; i++ ) |
|
183 { |
|
184 // There needs to be two entries of certain payload type in red payloads |
|
185 // array if red level 1 should be used. |
|
186 // |
|
187 CMceComAudioCodec* codec = aAudio.CodecL( i ); |
|
188 |
|
189 const TInt KMceRedNotPresent( -1 ); |
|
190 TInt redCount( KMceRedNotPresent ); |
|
191 |
|
192 for ( TInt j = 0; j < redPayloads.Count(); j++ ) |
|
193 { |
|
194 if ( codec->iPayloadType == static_cast<TUint8>( redPayloads[ j ] ) ) |
|
195 { |
|
196 redCount++; |
|
197 } |
|
198 } |
|
199 |
|
200 if ( redCount > 0 ) |
|
201 { |
|
202 codec->iRedPayloadType = iPayloadType; |
|
203 codec->iRedCount = redCount; |
|
204 UpdateSendCodec( aCodecIndex, aAudio, *codec ); |
|
205 } |
|
206 else |
|
207 { |
|
208 codec->iRedPayloadType = KMcePayloadTypeUndefined; |
|
209 codec->iRedCount = 0; |
|
210 } |
|
211 |
|
212 if ( !redPayloads.Count() ) |
|
213 { |
|
214 UpdateSendCodec( aCodecIndex, aAudio, *codec ); |
|
215 } |
|
216 } |
|
217 |
|
218 CleanupStack::PopAndDestroy( &redPayloads ); |
|
219 CleanupStack::PopAndDestroy( mccCodec ); |
|
220 CleanupStack::PopAndDestroy( factory ); |
|
221 } |
|
222 |
|
223 #endif |
|
224 |
|
225 // End of File |
|
226 |