|
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 "mcecamerasource.h" |
|
22 #include "mcecomcamerasource.h" |
|
23 #include "mceevents.h" |
|
24 #include "mceserial.h" |
|
25 |
|
26 #ifdef MCE_COMMON_SERVER_SIDE |
|
27 |
|
28 #include <mmccinterface.h> |
|
29 #include "mcesdpsession.h" |
|
30 #include "mcemediamanager.h" |
|
31 #include "mcevideostream.h" |
|
32 #include "mcecomvideocodec.h" |
|
33 |
|
34 #endif//MCE_COMMON_SERVER_SIDE |
|
35 |
|
36 const TInt KInitialCameraIndex = 0; |
|
37 const TInt KInitialZoomFactor = 1; |
|
38 const TInt KInitialDigitalZoomFactor = 1; |
|
39 const TInt KInitialContrast = 0; |
|
40 const TInt KInitialBrightness = 0; |
|
41 const TInt KInitialExposure = CCamera::EExposureAuto; |
|
42 const TInt KInitialWhiteBalance = CCamera::EWBAuto; |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMceComCameraSource::NewL |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CMceComCameraSource* CMceComCameraSource::NewL() |
|
52 { |
|
53 CMceComCameraSource* self = NewLC(); |
|
54 CleanupStack::Pop( self ); |
|
55 return self; |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // CMceComCameraSource::NewLC |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CMceComCameraSource* CMceComCameraSource::NewLC() |
|
63 { |
|
64 CMceComCameraSource* self = new (ELeave) CMceComCameraSource(); |
|
65 CleanupStack::PushL( self ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 |
|
70 // ----------------------------------------------------------------------------- |
|
71 // CMceComCameraSource::~CMceComCameraSource |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CMceComCameraSource::~CMceComCameraSource() |
|
75 { |
|
76 delete iSettings; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CMceComCameraSource::CMceComCameraSource |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CMceComCameraSource::CMceComCameraSource() |
|
84 :CMceComMediaSource( KMceCameraSource ), |
|
85 iCameraIndex( KInitialCameraIndex ), |
|
86 iZoomFactor( KInitialZoomFactor ), |
|
87 iDigitalZoomFactor( KInitialDigitalZoomFactor ), |
|
88 iContrast( KInitialContrast ), |
|
89 iBrightness( KInitialBrightness ), |
|
90 iExposure( KInitialExposure ), |
|
91 iWhiteBalance( KInitialWhiteBalance ), |
|
92 iCamerasAvailable( 0 ), |
|
93 iInitialInfoRetrieved( EFalse ) |
|
94 { |
|
95 } |
|
96 |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CMceComCameraSource::InternalizeFlatL |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CMceComCameraSource::InternalizeFlatL( RReadStream& aReadStream ) |
|
103 { |
|
104 CMceComMediaSource::InternalizeFlatL( aReadStream ); |
|
105 |
|
106 iCameraIndex = aReadStream.ReadInt32L(); |
|
107 iZoomFactor = aReadStream.ReadInt32L(); |
|
108 iDigitalZoomFactor = aReadStream.ReadInt32L(); |
|
109 iContrast = aReadStream.ReadInt32L(); |
|
110 iBrightness = aReadStream.ReadInt32L(); |
|
111 iExposure = aReadStream.ReadInt32L(); |
|
112 iWhiteBalance = aReadStream.ReadInt32L(); |
|
113 iCamerasAvailable = aReadStream.ReadInt32L(); |
|
114 |
|
115 TPckgBuf<TCameraInfo> cameraBuf; |
|
116 MceSerial::DecodeL( cameraBuf, aReadStream ); |
|
117 iCameraInfo = cameraBuf(); |
|
118 |
|
119 iInitialInfoRetrieved = static_cast<TBool>( aReadStream.ReadUint8L() ); |
|
120 |
|
121 } |
|
122 |
|
123 |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CMceComCameraSource::ExternalizeFlatL |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CMceComCameraSource::ExternalizeFlatL( RWriteStream& aWriteStream ) |
|
130 { |
|
131 CMceComMediaSource::ExternalizeFlatL( aWriteStream ); |
|
132 |
|
133 aWriteStream.WriteInt32L( iCameraIndex ); |
|
134 aWriteStream.WriteInt32L( iZoomFactor ); |
|
135 aWriteStream.WriteInt32L( iDigitalZoomFactor ); |
|
136 aWriteStream.WriteInt32L( iContrast ); |
|
137 aWriteStream.WriteInt32L( iBrightness ); |
|
138 aWriteStream.WriteInt32L( iExposure ); |
|
139 aWriteStream.WriteInt32L( iWhiteBalance ); |
|
140 aWriteStream.WriteInt32L( iCamerasAvailable ); |
|
141 |
|
142 TPckgBuf<TCameraInfo> cameraBuf( iCameraInfo ); |
|
143 MceSerial::EncodeL( cameraBuf, aWriteStream ); |
|
144 |
|
145 aWriteStream.WriteUint8L( iInitialInfoRetrieved ); |
|
146 |
|
147 } |
|
148 |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // CMceComCameraSource::CloneL |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 CMceComMediaSource* CMceComCameraSource::CloneL() |
|
155 { |
|
156 CMceComCameraSource* copy = new (ELeave) CMceComCameraSource(); |
|
157 Mem::Copy( copy, this, sizeof(CMceComCameraSource) ); |
|
158 copy->Zero(); |
|
159 copy->iSettings = 0; |
|
160 return copy; |
|
161 |
|
162 } |
|
163 |
|
164 |
|
165 // ----------------------------------------------------------------------------- |
|
166 // CMceComCameraSource::EventReceivedL |
|
167 // ----------------------------------------------------------------------------- |
|
168 // |
|
169 TInt CMceComCameraSource::EventReceivedL( TMceComEvent& aEvent ) |
|
170 { |
|
171 TInt status = CMceComMediaSource::EventReceivedL( aEvent ); |
|
172 if ( status != KMceEventNotConsumed ) |
|
173 { |
|
174 return status; |
|
175 } |
|
176 |
|
177 if ( aEvent.Id().IsSourceId() ) |
|
178 { |
|
179 status = aEvent.Handler().HandleL( *this, aEvent ); |
|
180 } |
|
181 else |
|
182 { |
|
183 status = KMceEventNotConsumed; |
|
184 } |
|
185 |
|
186 return status; |
|
187 |
|
188 } |
|
189 |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // CMceComCameraSource::UpdateL |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 void CMceComCameraSource::UpdateL( CMceComMediaSource& aUpdate ) |
|
196 { |
|
197 CMceComMediaSource::UpdateL( aUpdate ); |
|
198 CMceComCameraSource& update = static_cast<CMceComCameraSource&>( aUpdate ); |
|
199 |
|
200 iCameraIndex = update.iCameraIndex; |
|
201 iZoomFactor = update.iZoomFactor; |
|
202 iDigitalZoomFactor = update.iDigitalZoomFactor; |
|
203 iContrast = update.iContrast; |
|
204 iBrightness = update.iBrightness; |
|
205 iExposure = update.iExposure; |
|
206 iWhiteBalance = update.iWhiteBalance; |
|
207 iCamerasAvailable = update.iCamerasAvailable; |
|
208 iCameraInfo = update.iCameraInfo; |
|
209 iInitialInfoRetrieved = update.iInitialInfoRetrieved; |
|
210 |
|
211 } |
|
212 |
|
213 #ifdef MCE_COMMON_SERVER_SIDE |
|
214 |
|
215 // ----------------------------------------------------------------------------- |
|
216 // CMceComCameraSource::MccType |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 const TUid CMceComCameraSource::MccType() |
|
220 { |
|
221 return KUidMccVideoSource; |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // CMceComCameraSource::InitParamL |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 const TDesC8& CMceComCameraSource::InitParamL( const CMceComCodec& aCodec ) |
|
229 { |
|
230 delete iSettings; |
|
231 iSettings = NULL; |
|
232 |
|
233 // Camera index is the only effective value |
|
234 TMccVideoSourceSetting cameraSetting; |
|
235 cameraSetting.iSize = TSize( 0, 0 ); |
|
236 cameraSetting.iVideoPayloadType = 0; |
|
237 cameraSetting.iAudioPayloadType = 0; |
|
238 cameraSetting.iDeviceIndex = iCameraIndex; |
|
239 cameraSetting.iPriority.iPriority = 0; |
|
240 cameraSetting.iPriority.iPref = EMdaPriorityPreferenceNone; |
|
241 |
|
242 if ( aCodec.Stream() && aCodec.Stream()->iType == KMceVideo ) |
|
243 { |
|
244 const CMceComVideoCodec& videoCodec = |
|
245 reinterpret_cast<const CMceComVideoCodec&>( aCodec ); |
|
246 if ( videoCodec.IsConfigKeyValid() ) |
|
247 { |
|
248 cameraSetting.iConfigKey = *videoCodec.iConfigKey; |
|
249 } |
|
250 else |
|
251 { |
|
252 cameraSetting.iConfigKey = KNullDesC8; |
|
253 } |
|
254 } |
|
255 |
|
256 TMccVideoSourceSettingBuf settings( cameraSetting ); |
|
257 |
|
258 iSettings = settings.AllocL(); |
|
259 |
|
260 return *iSettings; |
|
261 } |
|
262 |
|
263 // ----------------------------------------------------------------------------- |
|
264 // CMceComCameraSource::DoPrepared |
|
265 // ----------------------------------------------------------------------------- |
|
266 // |
|
267 TInt CMceComCameraSource::DoPrepared() |
|
268 { |
|
269 TInt err( KErrNone ); |
|
270 if ( MediaStream() && MediaStream()->Session() && |
|
271 &MediaStream()->Session()->SdpSession() ) |
|
272 { |
|
273 TRAP( err, |
|
274 MediaStream()->Session()->SdpSession().Manager().UpdateConfigKeyL( *this ) ); |
|
275 } |
|
276 return err; |
|
277 } |
|
278 |
|
279 #endif//MCE_COMMON_SERVER_SIDE |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |