|
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 "mceh263codec.h" |
|
22 #include "mcecomh263codec.h" |
|
23 #include "mcevideostream.h" |
|
24 |
|
25 |
|
26 #define _FLAT_DATA static_cast<CMceComVideoCodec*>( iFlatData ) |
|
27 #define FLAT_DATA( data ) _FLAT_DATA->data |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CMceH263Codec::~CMceH263Codec |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 EXPORT_C CMceH263Codec::~CMceH263Codec() |
|
36 { |
|
37 } |
|
38 |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CMceH263Codec::NewL |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 EXPORT_C CMceH263Codec* CMceH263Codec::NewL( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
45 { |
|
46 CMceH263Codec* self = NewLC( aSdpName ); |
|
47 CleanupStack::Pop( self ); |
|
48 return self; |
|
49 } |
|
50 |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CMceH263Codec::NewL |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 EXPORT_C CMceH263Codec* CMceH263Codec::NewLC( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
57 { |
|
58 CMceH263Codec* self = new (ELeave) CMceH263Codec(); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL( aSdpName ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CMceH263Codec::SetBitrate |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 EXPORT_C TInt CMceH263Codec::SetBitrate( TUint aBitrate ) |
|
70 { |
|
71 if ( aBitrate != Bitrate() ) |
|
72 { |
|
73 TInt ret = _FLAT_DATA->SetBitrate( aBitrate ); |
|
74 if ( ret == KErrNone ) |
|
75 { |
|
76 CMceVideoStream* stream = static_cast< CMceVideoStream* >( iStream ); |
|
77 if ( stream && stream->BoundStream() ) |
|
78 { |
|
79 // Find the same codec in bound stream, and set bitrate also to that. |
|
80 CMceCodec* codec = stream->Bound()->FindCodec( *this ); |
|
81 if ( codec ) |
|
82 { |
|
83 ret = codec->SetBitrate( aBitrate ); |
|
84 } |
|
85 } |
|
86 } |
|
87 return ret; |
|
88 } |
|
89 else |
|
90 { |
|
91 // Avoid looping, go here if already set |
|
92 return KErrNone; |
|
93 } |
|
94 } |
|
95 |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CMceH263Codec::SetAllowedBitrates |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C TInt CMceH263Codec::SetAllowedBitrates(TUint aBitrates) |
|
102 { |
|
103 if ( aBitrates != AllowedBitrates() ) |
|
104 { |
|
105 TInt ret = _FLAT_DATA->SetAllowedBitrates( aBitrates ); |
|
106 if ( ret == KErrNone ) |
|
107 { |
|
108 CMceVideoStream* stream = static_cast< CMceVideoStream* >( iStream ); |
|
109 if ( stream && stream->BoundStream() ) |
|
110 { |
|
111 // Find the same codec in bound stream, and set bitrates also to that. |
|
112 CMceCodec* codec = stream->Bound()->FindCodec( *this ); |
|
113 if ( codec ) |
|
114 { |
|
115 ret = codec->SetAllowedBitrates( aBitrates ); |
|
116 } |
|
117 } |
|
118 } |
|
119 return ret; |
|
120 } |
|
121 else |
|
122 { |
|
123 // Avoid looping, go here if already set |
|
124 return KErrNone; |
|
125 } |
|
126 } |
|
127 |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CMceH263Codec::SetCodecMode |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 EXPORT_C TInt CMceH263Codec::SetCodecMode(TUint aCodecMode) |
|
134 { |
|
135 if ( aCodecMode != CodecMode() ) |
|
136 { |
|
137 FLAT_DATA( iCodecMode ) = aCodecMode; |
|
138 TInt ret = KErrNone; |
|
139 CMceVideoStream* stream = static_cast< CMceVideoStream* >( iStream ); |
|
140 if ( stream && stream->BoundStream() ) |
|
141 { |
|
142 // Find the same codec in bound stream, and set mode also to that. |
|
143 CMceCodec* codec = stream->Bound()->FindCodec( *this ); |
|
144 if ( codec ) |
|
145 { |
|
146 ret = codec->SetCodecMode( aCodecMode ); |
|
147 } |
|
148 } |
|
149 return ret; |
|
150 } |
|
151 else |
|
152 { |
|
153 // Avoid looping, go here if already set |
|
154 return KErrNone; |
|
155 }} |
|
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CMceH263Codec::SetPayloadType |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 EXPORT_C TInt CMceH263Codec::SetPayloadType(TUint8 aPayloadType) |
|
163 { |
|
164 return _FLAT_DATA->SetPayloadType( aPayloadType ); |
|
165 } |
|
166 |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CMceH263Codec::CloneL |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 EXPORT_C CMceVideoCodec* CMceH263Codec::CloneL() const |
|
173 { |
|
174 CMceH263Codec* clone = CMceH263Codec::NewLC( FLAT_DATA( iSdpName ) ); |
|
175 |
|
176 CMceComVideoCodec* cloneFlatData = |
|
177 static_cast<CMceComVideoCodec*>(clone->iFlatData); |
|
178 |
|
179 cloneFlatData->iID = FLAT_DATA( iID ); |
|
180 cloneFlatData->SetFmtpAttributeL( *(FLAT_DATA( iFmtpAttr )) ); |
|
181 cloneFlatData->iPayloadType = FLAT_DATA( iPayloadType ); |
|
182 |
|
183 cloneFlatData->iBitrate = FLAT_DATA( iBitrate ); |
|
184 cloneFlatData->iAllowedBitrates = FLAT_DATA( iAllowedBitrates ); |
|
185 cloneFlatData->iCodecMode = FLAT_DATA( iCodecMode ); |
|
186 cloneFlatData->iFourCC = FLAT_DATA( iFourCC ); |
|
187 cloneFlatData->iFrameSize = FLAT_DATA( iFrameSize ); |
|
188 |
|
189 cloneFlatData->iFrameRate = FLAT_DATA( iFrameRate ); |
|
190 cloneFlatData->iMaxBitRate = FLAT_DATA( iMaxBitRate ); |
|
191 cloneFlatData->iAllowedResolutions = FLAT_DATA( iAllowedResolutions ); |
|
192 cloneFlatData->iResolutionWidth = FLAT_DATA( iResolutionWidth ); |
|
193 cloneFlatData->iResolutionHeight = FLAT_DATA( iResolutionHeight ); |
|
194 cloneFlatData->iAllowedFrameRates = FLAT_DATA( iAllowedFrameRates ); |
|
195 cloneFlatData->iClockRate = FLAT_DATA( iClockRate ); |
|
196 |
|
197 CleanupStack::Pop( clone ); |
|
198 return clone; |
|
199 } |
|
200 |
|
201 |
|
202 // ----------------------------------------------------------------------------- |
|
203 // CMceH263Codec:: |
|
204 // ----------------------------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C void CMceH263Codec::SetMaxBitrateL( TUint aMaxBitrate ) |
|
207 { |
|
208 User::LeaveIfError( _FLAT_DATA->SetMaxBitrate( aMaxBitrate ) ); |
|
209 } |
|
210 |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CMceH263Codec:: |
|
214 // ----------------------------------------------------------------------------- |
|
215 // |
|
216 EXPORT_C void CMceH263Codec::SetAllowedResolutionsL( TUint aResolutions ) |
|
217 { |
|
218 FLAT_DATA( iAllowedResolutions ) = aResolutions; |
|
219 } |
|
220 |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // CMceH263Codec:: |
|
224 // ----------------------------------------------------------------------------- |
|
225 // |
|
226 EXPORT_C void CMceH263Codec::SetResolutionL( TSize aResolution ) |
|
227 { |
|
228 FLAT_DATA( iResolutionWidth ) = aResolution.iWidth; |
|
229 FLAT_DATA( iResolutionHeight ) = aResolution.iHeight; |
|
230 } |
|
231 |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CMceH263Codec:: |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 EXPORT_C void CMceH263Codec::SetAllowedFrameRatesL( TUint aFrameRates ) |
|
238 { |
|
239 FLAT_DATA( iAllowedFrameRates ) = aFrameRates; |
|
240 } |
|
241 |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CMceH263Codec:: |
|
245 // ----------------------------------------------------------------------------- |
|
246 // |
|
247 EXPORT_C void CMceH263Codec::SetFrameRateL( TReal aFrameRate ) |
|
248 { |
|
249 FLAT_DATA( iFrameRate ) = aFrameRate; |
|
250 } |
|
251 |
|
252 // ----------------------------------------------------------------------------- |
|
253 // CMceH263Codec::SetPreferredEncodingDecodingDeviceL |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 EXPORT_C void CMceH263Codec::SetPreferredEncodingDecodingDeviceL( |
|
257 TUid /*aEncodingDecodingDevice*/ ) |
|
258 { |
|
259 User::Leave( KErrNotSupported ); |
|
260 } |
|
261 |
|
262 // ----------------------------------------------------------------------------- |
|
263 // CMceH263Codec::SetConfigKeyL |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 EXPORT_C void CMceH263Codec::SetConfigKeyL( const TDesC8& /*aConfigKey*/ ) |
|
267 { |
|
268 User::Leave( KErrNotSupported ); |
|
269 } |
|
270 |
|
271 // ----------------------------------------------------------------------------- |
|
272 // CMceH263Codec::SetSdpNameL |
|
273 // ----------------------------------------------------------------------------- |
|
274 // |
|
275 void CMceH263Codec::SetSdpNameL( const TDesC8& aSdpName ) |
|
276 { |
|
277 __ASSERT_ALWAYS( aSdpName.Length() <= KMceMaxSdpNameLength, |
|
278 User::Leave( KErrArgument ) ); |
|
279 FLAT_DATA( iSdpName ).Copy( aSdpName ); |
|
280 } |
|
281 |
|
282 |
|
283 // ----------------------------------------------------------------------------- |
|
284 // CMceH263Codec::CMceH263Codec |
|
285 // ----------------------------------------------------------------------------- |
|
286 // |
|
287 CMceH263Codec::CMceH263Codec() |
|
288 :CMceVideoCodec() |
|
289 { |
|
290 } |
|
291 |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CMceH263Codec::ConstructL |
|
295 // ----------------------------------------------------------------------------- |
|
296 // |
|
297 void CMceH263Codec::ConstructL( TBuf8<KMceMaxSdpNameLength> aSdpName ) |
|
298 { |
|
299 CMceComVideoCodec* codec = CMceComH263Codec::NewLC( aSdpName ); |
|
300 CMceVideoCodec::ConstructL( codec ); |
|
301 |
|
302 CleanupStack::Pop( codec ); |
|
303 } |
|
304 |
|
305 |
|
306 |
|
307 |