|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include "mcecomh263codec.h" |
|
22 |
|
23 |
|
24 const TReal KMceH263DefaultLoweredFrameRate = 12; |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // CMceComH263Codec::NewL |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CMceComH263Codec* CMceComH263Codec::NewL( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
34 { |
|
35 CMceComH263Codec* self = NewLC( aSdpName ); |
|
36 CleanupStack::Pop( self ); |
|
37 return self; |
|
38 |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CMceComH263Codec::NewLC |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CMceComH263Codec* CMceComH263Codec::NewLC( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
46 { |
|
47 CMceComH263Codec* self = new (ELeave) CMceComH263Codec(); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL( aSdpName ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CMceComH263Codec::~CMceComH263Codec |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CMceComH263Codec::~CMceComH263Codec() |
|
59 { |
|
60 } |
|
61 |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CMceComH263Codec::CMceComH263Codec |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CMceComH263Codec::CMceComH263Codec() |
|
68 :CMceComVideoCodec() |
|
69 { |
|
70 iClockRate = KMceH263ClockRate; |
|
71 iFrameRate = KMceH263DefaultLoweredFrameRate; |
|
72 iResolutionWidth = KMceH263FrameWidth; |
|
73 iResolutionHeight = KMceH263FrameHeight; |
|
74 iBitrate = KMceH263DefaultBitrate; |
|
75 iMaxBitRate = KMceH263DefaultMaxBitrate; |
|
76 iAllowedBitrates = KMceH263DefaultAllowedBitrate; |
|
77 iFrameSize = KMceH263DefaultFrameSize; |
|
78 // Defaults should be defined in MCE API |
|
79 const TUint8 KMceDefaultH263PayloadType = 97; |
|
80 iPayloadType = KMceDefaultH263PayloadType; |
|
81 |
|
82 iReceiveFrameRate = KMceH263FrameRate; |
|
83 } |
|
84 |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CMceComH263Codec::ConstructL |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CMceComVideoCodec* CMceComH263Codec::CloneL() |
|
91 { |
|
92 CMceComH263Codec* copy = new (ELeave) CMceComH263Codec(); |
|
93 CleanupStack::PushL( copy ); |
|
94 copy->ConstructL( *this ); |
|
95 CleanupStack::Pop( copy ); |
|
96 return copy; |
|
97 |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CMceComH263Codec::ConstructL |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CMceComH263Codec::ConstructL( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
106 { |
|
107 CMceComVideoCodec::ConstructL( aSdpName ); |
|
108 |
|
109 // NOTE: 1998 mode codec is disabled by default in order to prevent |
|
110 // default offer to contain both 2000 and 1998 mode versions |
|
111 if ( iSdpName.CompareF( KMceSDPNameH2631998 ) == 0 ) |
|
112 { |
|
113 iState = CMceCodec::EDisabled; |
|
114 } |
|
115 } |
|
116 |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CMceComH263Codec::ConstructL |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void CMceComH263Codec::ConstructL( CMceComH263Codec& aCodec ) |
|
123 { |
|
124 CMceComVideoCodec::ConstructL( aCodec ); |
|
125 } |
|
126 |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CMceComH263Codec::SetBitrate |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 TInt CMceComH263Codec::SetBitrate( TUint aBitrate ) |
|
133 { |
|
134 return CMceComCodec::SetBitrate( aBitrate ); |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CMceComH263Codec::SetAllowedBitrates |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 TInt CMceComH263Codec::SetAllowedBitrates( TUint aBitrates ) |
|
142 { |
|
143 TInt error = KErrNone; |
|
144 |
|
145 //Confirm that the bitrate mask is valid |
|
146 //I.e. after all the valid bitrates are set to zero the value should be zero |
|
147 if ( !aBitrates || |
|
148 ( aBitrates >> 8 ) > 0 ) |
|
149 { |
|
150 error = KErrArgument; |
|
151 } |
|
152 else |
|
153 { |
|
154 CMceComCodec::SetAllowedBitrates( KMceAllowedH263BitrateAll ); |
|
155 iAllowedBitrates &= aBitrates; |
|
156 CMceComVideoCodec::SetMaxBitrate( GetMaxBitRate() ); |
|
157 if ( iBitrate > iMaxBitRate ) |
|
158 { |
|
159 error = CMceComCodec::SetBitrate( iMaxBitRate ); |
|
160 } |
|
161 } |
|
162 |
|
163 return error; |
|
164 |
|
165 } |
|
166 |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CMceComH263Codec::GetMaxBitRate |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 TUint CMceComH263Codec::GetMaxBitRate() |
|
173 { |
|
174 if( iAllowedBitrates & KMceAllowedH263Bitrate45 ) |
|
175 { |
|
176 return KMceH263Level45Bitrate; |
|
177 } |
|
178 else if( iAllowedBitrates & KMceAllowedH263Bitrate10 ) |
|
179 { |
|
180 return KMceH263Level10Bitrate; |
|
181 } |
|
182 else |
|
183 { |
|
184 return 0; |
|
185 } |
|
186 |
|
187 } |
|
188 |
|
189 // ----------------------------------------------------------------------------- |
|
190 // CMceComH263Codec::SetMaxBitrate |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 TInt CMceComH263Codec::SetMaxBitrate( TUint aMaxBitrate ) |
|
194 { |
|
195 TInt status = KErrNone; |
|
196 switch( aMaxBitrate ) |
|
197 { |
|
198 case KMceH263Level10Bitrate: |
|
199 { |
|
200 status = SetAllowedBitrates( KMceAllowedH263Bitrate10 ); |
|
201 break; |
|
202 } |
|
203 case KMceH263Level45Bitrate: |
|
204 { |
|
205 status = SetAllowedBitrates( KMceAllowedH263Bitrate45 ); |
|
206 break; |
|
207 } |
|
208 default: |
|
209 { |
|
210 status = KErrNotSupported; |
|
211 break; |
|
212 } |
|
213 } |
|
214 |
|
215 return status; |
|
216 |
|
217 } |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // CMceComH263Codec::ResolveAllowedBitrates |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 TInt CMceComH263Codec::ResolveAllowedBitrates( |
|
224 TUint aBitrate, TUint& aAllowedBitrates ) |
|
225 { |
|
226 TInt retVal( KErrNone ); |
|
227 |
|
228 if ( aBitrate <= KMceH263Level10Bitrate ) |
|
229 { |
|
230 aAllowedBitrates = KMceAllowedH263Bitrate10; |
|
231 } |
|
232 else if ( aBitrate <= KMceH263Level45Bitrate ) |
|
233 { |
|
234 aAllowedBitrates = KMceAllowedH263BitrateAll; |
|
235 } |
|
236 else |
|
237 { |
|
238 retVal = KErrNotSupported; |
|
239 } |
|
240 |
|
241 return retVal; |
|
242 } |
|
243 |
|
244 // End of File |
|
245 |
|
246 |