|
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 "mcedisplaysink.h" |
|
22 #include "mcecomdisplaysink.h" |
|
23 #include "mceevents.h" |
|
24 #include "mcecomcodec.h" |
|
25 #include "mcecommediastream.h" |
|
26 #include "mcecomsession.h" |
|
27 #include "mcecomavsink.h" |
|
28 |
|
29 #ifdef MCE_COMMON_SERVER_SIDE |
|
30 |
|
31 #include <mmccinterface.h> |
|
32 #include "mcesdpsession.h" |
|
33 #include "mcemediamanager.h" |
|
34 #include "mcevideostream.h" |
|
35 #include "mcecomvideocodec.h" |
|
36 |
|
37 #endif//MCE_COMMON_SERVER_SIDE |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 |
|
41 |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CMceComDisplaySink::NewL |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CMceComDisplaySink* CMceComDisplaySink::NewL() |
|
48 { |
|
49 CMceComDisplaySink* self = NewLC(); |
|
50 CleanupStack::Pop( self ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CMceComDisplaySink::NewLC |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CMceComDisplaySink* CMceComDisplaySink::NewLC() |
|
59 { |
|
60 CMceComDisplaySink* self = new (ELeave) CMceComDisplaySink(); |
|
61 CleanupStack::PushL( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CMceComDisplaySink::~CMceComDisplaySink |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 CMceComDisplaySink::~CMceComDisplaySink() |
|
70 { |
|
71 |
|
72 delete iSettings; |
|
73 if ( iEndpointProxy ) |
|
74 { |
|
75 CMceComAvSink* endpointProxy = static_cast<CMceComAvSink*>( iEndpointProxy ); |
|
76 endpointProxy->RemoveProxyClient( *this ); |
|
77 if ( endpointProxy->ReferenceCount() == 0 ) |
|
78 { |
|
79 delete endpointProxy; |
|
80 } |
|
81 iEndpointProxy = NULL; |
|
82 } |
|
83 |
|
84 } |
|
85 |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CMceComDisplaySink::CMceComDisplaySink |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CMceComDisplaySink::CMceComDisplaySink() |
|
92 : CMceComMediaSink( KMceDisplaySink ) |
|
93 { |
|
94 // Temporarily some default values |
|
95 // TRect (0,83,352,378); |
|
96 iDisplayIndex = 0; |
|
97 iDisplayRectTlX = 0; |
|
98 iDisplayRectTlY = 83; |
|
99 iDisplayRectBrX = 352; |
|
100 iDisplayRectBrY = 378; |
|
101 iPriority = 0; |
|
102 iIsViewFinder = EFalse; |
|
103 iRotation = CMceDisplaySink::ENone; |
|
104 iDisplaysAvailable = 0; |
|
105 iInitialInfoRetrieved = EFalse; |
|
106 |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CMceComDisplaySink::CloneL |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 CMceComMediaSink* CMceComDisplaySink::CloneL() |
|
114 { |
|
115 CMceComDisplaySink* copy = new (ELeave) CMceComDisplaySink(); |
|
116 Mem::Copy( copy, this, sizeof(CMceComDisplaySink) ); |
|
117 copy->Zero(); |
|
118 copy->iSettings = 0; |
|
119 return copy; |
|
120 |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CMceComDisplaySink::UsesEndpointProxy() |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TBool CMceComDisplaySink::UsesEndpointProxy() const |
|
128 { |
|
129 return ETrue; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CMceComDisplaySink::CreateEndpointProxyL() |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 MMceComEndPointProxy* CMceComDisplaySink::CreateEndpointProxyL() const |
|
137 { |
|
138 return CMceComAvSink::NewL(); |
|
139 } |
|
140 |
|
141 |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CMceComDisplaySink::InternalizeFlatL |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void CMceComDisplaySink::InternalizeFlatL( RReadStream& aReadStream ) |
|
148 { |
|
149 CMceComMediaSink::InternalizeFlatL( aReadStream ); |
|
150 |
|
151 iDisplayIndex = aReadStream.ReadInt32L(); |
|
152 iDisplayRectTlX = aReadStream.ReadInt32L(); |
|
153 iDisplayRectTlY = aReadStream.ReadInt32L(); |
|
154 iDisplayRectBrX = aReadStream.ReadInt32L(); |
|
155 iDisplayRectBrY = aReadStream.ReadInt32L(); |
|
156 iPriority = aReadStream.ReadUint32L(); |
|
157 iIsViewFinder = aReadStream.ReadInt32L(); |
|
158 iRotation = static_cast<CMceDisplaySink::TRotation> ( aReadStream.ReadInt32L() ); |
|
159 |
|
160 iDisplaysAvailable = aReadStream.ReadInt32L(); |
|
161 iInitialInfoRetrieved = static_cast<TBool>( aReadStream.ReadUint8L() ); |
|
162 |
|
163 } |
|
164 |
|
165 |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CMceComDisplaySink::ExternalizeFlatL |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CMceComDisplaySink::ExternalizeFlatL( RWriteStream& aWriteStream ) |
|
172 { |
|
173 CMceComMediaSink::ExternalizeFlatL( aWriteStream ); |
|
174 |
|
175 aWriteStream.WriteInt32L( iDisplayIndex ); |
|
176 aWriteStream.WriteInt32L( iDisplayRectTlX ); |
|
177 aWriteStream.WriteInt32L( iDisplayRectTlY ); |
|
178 aWriteStream.WriteInt32L( iDisplayRectBrX ); |
|
179 aWriteStream.WriteInt32L( iDisplayRectBrY ); |
|
180 aWriteStream.WriteUint32L( iPriority ); |
|
181 aWriteStream.WriteInt32L( iIsViewFinder ); |
|
182 aWriteStream.WriteInt32L( iRotation ); |
|
183 aWriteStream.WriteInt32L( iDisplaysAvailable ); |
|
184 aWriteStream.WriteUint8L( iInitialInfoRetrieved ); |
|
185 |
|
186 } |
|
187 |
|
188 |
|
189 |
|
190 // ----------------------------------------------------------------------------- |
|
191 // CMceComDisplaySink::EventReceivedL |
|
192 // ----------------------------------------------------------------------------- |
|
193 // |
|
194 TInt CMceComDisplaySink::EventReceivedL( TMceComEvent& aEvent ) |
|
195 { |
|
196 TInt status = CMceComMediaSink::EventReceivedL( aEvent ); |
|
197 if ( status != KMceEventNotConsumed ) |
|
198 { |
|
199 return status; |
|
200 } |
|
201 |
|
202 if ( aEvent.Id().IsSinkId() ) |
|
203 { |
|
204 status = aEvent.Handler().HandleL( *this, aEvent ); |
|
205 } |
|
206 else |
|
207 { |
|
208 status = KMceEventNotConsumed; |
|
209 } |
|
210 |
|
211 return status; |
|
212 |
|
213 } |
|
214 |
|
215 |
|
216 // ----------------------------------------------------------------------------- |
|
217 // CMceComDisplaySink::UpdateL |
|
218 // ----------------------------------------------------------------------------- |
|
219 // |
|
220 void CMceComDisplaySink::UpdateL( CMceComMediaSink& aUpdate ) |
|
221 { |
|
222 CMceComMediaSink::UpdateL( aUpdate ); |
|
223 CMceComDisplaySink& update = static_cast<CMceComDisplaySink&>( aUpdate ); |
|
224 |
|
225 iDisplayIndex = update.iDisplayIndex; |
|
226 iDisplayRectTlX = update.iDisplayRectTlX; |
|
227 iDisplayRectTlY = update.iDisplayRectTlY; |
|
228 iDisplayRectBrX = update.iDisplayRectBrX; |
|
229 iDisplayRectBrY = update.iDisplayRectBrY; |
|
230 iPriority = update.iPriority; |
|
231 iIsViewFinder = update.iIsViewFinder; |
|
232 iDisplaysAvailable = update.iDisplaysAvailable; |
|
233 iInitialInfoRetrieved = update.iDisplaysAvailable; |
|
234 |
|
235 } |
|
236 |
|
237 |
|
238 #ifdef MCE_COMMON_SERVER_SIDE |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // CMceComDisplaySink::MccType |
|
242 // ----------------------------------------------------------------------------- |
|
243 // |
|
244 const TUid CMceComDisplaySink::MccType() |
|
245 { |
|
246 TUid id = KUidMccVideoSink; |
|
247 |
|
248 if ( EndpointProxy() ) |
|
249 { |
|
250 CMceComAvSink* endpointProxy = static_cast<CMceComAvSink*>( EndpointProxy() ); |
|
251 id = endpointProxy->MccType(); |
|
252 } |
|
253 return id; |
|
254 |
|
255 } |
|
256 |
|
257 |
|
258 // ----------------------------------------------------------------------------- |
|
259 // CMceComDisplaySink::EnableL |
|
260 // ----------------------------------------------------------------------------- |
|
261 // |
|
262 void CMceComDisplaySink::EnableL( const CMceComCodec& aCodec ) |
|
263 { |
|
264 __ASSERT_ALWAYS( iIsViewFinder, User::Leave( KErrArgument ) ); |
|
265 CMceMediaManager& manager = MediaStream()->Session()->SdpSession().Manager(); |
|
266 |
|
267 // Update iSettings |
|
268 DoInitParamL( aCodec ); |
|
269 |
|
270 manager.EnableViewFinderL( *this, *iSettings ); |
|
271 |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CMceComMediaSource::DisableL |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void CMceComDisplaySink::DisableL() |
|
279 { |
|
280 __ASSERT_ALWAYS( iIsViewFinder, User::Leave( KErrArgument ) ); |
|
281 CMceMediaManager& manager = MediaStream()->Session()->SdpSession().Manager(); |
|
282 |
|
283 manager.DisableViewFinderL( *this ); |
|
284 |
|
285 } |
|
286 |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // CMceComDisplaySink::InitParamL |
|
290 // ----------------------------------------------------------------------------- |
|
291 // |
|
292 const TDesC8& CMceComDisplaySink::InitParamL( const CMceComCodec& aCodec ) |
|
293 { |
|
294 delete iSettings; |
|
295 iSettings = NULL; |
|
296 |
|
297 if ( EndpointProxy() ) |
|
298 { |
|
299 CMceComAvSink* endpointProxy = static_cast<CMceComAvSink*>( EndpointProxy() ); |
|
300 return endpointProxy->InitParamL( aCodec ); |
|
301 } |
|
302 else |
|
303 { |
|
304 DoInitParamL( aCodec ); |
|
305 } |
|
306 |
|
307 return *iSettings; |
|
308 |
|
309 } |
|
310 |
|
311 // ----------------------------------------------------------------------------- |
|
312 // CMceComDisplaySink::PrepareL |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 void CMceComDisplaySink::PrepareL() |
|
316 { |
|
317 if ( EndpointProxy() ) |
|
318 { |
|
319 CMceComAvSink* endpointProxy = static_cast<CMceComAvSink*>( EndpointProxy() ); |
|
320 endpointProxy->PrepareL(); |
|
321 } |
|
322 } |
|
323 |
|
324 // ----------------------------------------------------------------------------- |
|
325 // CMceComDisplaySink::DoInitParamL |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 const TDesC8& CMceComDisplaySink::DoInitParamL( const CMceComCodec& aCodec ) |
|
329 { |
|
330 delete iSettings; |
|
331 iSettings = NULL; |
|
332 |
|
333 TMccVideoSinkSetting displaySetting; |
|
334 TRect displayRect = DisplayRect(); |
|
335 |
|
336 CMceComDisplaySink::ToPointAndSize( displayRect, |
|
337 displaySetting.iLocation, |
|
338 displaySetting.iSize ); |
|
339 displaySetting.iDeviceIndex = 0; |
|
340 TMMFPrioritySettings priority; |
|
341 priority.iPriority = aCodec.iPriority; |
|
342 priority.iPref = TMdaPriorityPreference(aCodec.iPriorityPreference); |
|
343 displaySetting.iPriority = priority; |
|
344 |
|
345 displaySetting.iVideoPayloadType = aCodec.iPayloadType; |
|
346 displaySetting.iIAPId = MediaStream()->Session()->iIapId; |
|
347 displaySetting.iWindowOrdinalPosition = 1; |
|
348 displaySetting.iWindowOrdinalPriority = iPriority; |
|
349 displaySetting.iRotation = EMccNone; |
|
350 |
|
351 if ( aCodec.Stream() && aCodec.Stream()->iType == KMceVideo ) |
|
352 { |
|
353 displaySetting.iVideoFrameRate = |
|
354 reinterpret_cast<const CMceComVideoCodec&>( aCodec ).iReceiveFrameRate; |
|
355 } |
|
356 else |
|
357 { |
|
358 displaySetting.iVideoFrameRate = 0; |
|
359 } |
|
360 |
|
361 TMccVideoSinkSettingBuf settings( displaySetting ); |
|
362 |
|
363 iSettings = settings.AllocL(); |
|
364 |
|
365 return *iSettings; |
|
366 |
|
367 } |
|
368 |
|
369 // ----------------------------------------------------------------------------- |
|
370 // CMceComDisplaySink::DisplayRect |
|
371 // ----------------------------------------------------------------------------- |
|
372 // |
|
373 TRect CMceComDisplaySink::DisplayRect() |
|
374 { |
|
375 return TRect( iDisplayRectTlX, |
|
376 iDisplayRectTlY, |
|
377 iDisplayRectBrX, |
|
378 iDisplayRectBrY ); |
|
379 } |
|
380 |
|
381 // ----------------------------------------------------------------------------- |
|
382 // CMceComDisplaySink::SetDisplayRect |
|
383 // ----------------------------------------------------------------------------- |
|
384 // |
|
385 void CMceComDisplaySink::SetDisplayRect( const TRect& aRect ) |
|
386 { |
|
387 iDisplayRectTlX = aRect.iTl.iX; |
|
388 iDisplayRectTlY = aRect.iTl.iY; |
|
389 iDisplayRectBrX = aRect.iBr.iX; |
|
390 iDisplayRectBrY = aRect.iBr.iY; |
|
391 } |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CMceComDisplaySink::ToRect |
|
395 // ----------------------------------------------------------------------------- |
|
396 // |
|
397 void CMceComDisplaySink::ToRect( const TPoint& aPoint, const TSize& aSize, TRect& aRect ) |
|
398 { |
|
399 aRect = TRect( aPoint, aSize ); |
|
400 } |
|
401 |
|
402 |
|
403 // ----------------------------------------------------------------------------- |
|
404 // CMceComDisplaySink::ToPointAndSize |
|
405 // ----------------------------------------------------------------------------- |
|
406 // |
|
407 void CMceComDisplaySink::ToPointAndSize( const TRect& aRect, TPoint& aPoint, TSize& aSize ) |
|
408 { |
|
409 aPoint = TPoint( aRect.iTl.iX, aRect.iTl.iY ); |
|
410 aSize = TSize( aRect.iBr.iX - aRect.iTl.iX, |
|
411 aRect.iBr.iY - aRect.iTl.iY ); |
|
412 |
|
413 } |
|
414 |
|
415 |
|
416 // ----------------------------------------------------------------------------- |
|
417 // CMceComDisplaySink::SetViewFinder |
|
418 // ----------------------------------------------------------------------------- |
|
419 // |
|
420 void CMceComDisplaySink::SetViewFinder( TBool aIsViewFinder ) |
|
421 { |
|
422 iIsViewFinder = aIsViewFinder; |
|
423 } |
|
424 |
|
425 // ----------------------------------------------------------------------------- |
|
426 // CMceComDisplaySink::MccParameterName |
|
427 // ----------------------------------------------------------------------------- |
|
428 // |
|
429 TUint32 CMceComDisplaySink::MccParameterName() const |
|
430 { |
|
431 return iIsViewFinder ? KMccCamLocalVideo : KMccDisplayLocalVideo; |
|
432 } |
|
433 |
|
434 #endif//MCE_COMMON_SERVER_SIDE |
|
435 |