|
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 FILES |
|
22 #include <mmf/devvideo/devvideobase.h> |
|
23 #include <mmcccodecinformationfactory.h> |
|
24 #include <mmcccodecinformation.h> |
|
25 #include "mccvideosourceimpl.h" |
|
26 #include "mccinternalcodecs.h" |
|
27 #include "mmcccodecinformation.h" |
|
28 #include "mmcccodech263.h" |
|
29 #include "mmcccodecavc.h" |
|
30 #include "mccvideosourcewrapper.h" |
|
31 #include "mccvideosourcesinklogs.h" |
|
32 #include "mccinternalevents.h" |
|
33 #include "mmccinterfacedef.h" |
|
34 #include "mccrateadaptationdef.h" |
|
35 #include "mccdef.h" |
|
36 #include "mccinternaldef.h" |
|
37 #include "mccvideosourcekeyretriever.h" |
|
38 #include "mccresources.h" |
|
39 |
|
40 _LIT8(KVideoCodecFourCC, "video/%S; %S"); |
|
41 |
|
42 const TInt KMccMaxVideoQueueSize = 10; |
|
43 const TUint KMccBitrateTooLowLimit = 20000; |
|
44 |
|
45 // ============================ MEMBER FUNCTIONS =============================== |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CMccVideoSourceImpl::NewL |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 CMccVideoSourceImpl* CMccVideoSourceImpl::NewL( |
|
52 TUint32 aEndpointId, MMccResources* aMccResources, TBool aConfigKeyRetrieval ) |
|
53 { |
|
54 CMccVideoSourceImpl* self = new ( ELeave ) CMccVideoSourceImpl( |
|
55 aEndpointId, aMccResources, aConfigKeyRetrieval ); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CMccVideoSourceImpl::ConstructL |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 void CMccVideoSourceImpl::ConstructL() |
|
67 { |
|
68 iMediaRecorder = CMccVideoSourceWrapper::NewL(*this, *this); |
|
69 iVideoCodec.iFourCC = TFourCC(); |
|
70 iAudioFourCC = TFourCC(); |
|
71 iFrameRate = KMccDefaultVideoFrameRate; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CMccVideoSourceImpl::CMccVideoSourceImpl |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CMccVideoSourceImpl::CMccVideoSourceImpl( |
|
79 TUint32 aEndpointId, MMccResources* aMccResources, TBool aConfigKeyRetrieval ) : |
|
80 iAudioEnabled( EFalse ), |
|
81 iEndpointId( aEndpointId ), |
|
82 iMccResources( aMccResources ), |
|
83 iConfigKeyRetrieval( aConfigKeyRetrieval ) |
|
84 { |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CMccVideoSourceImpl::~CMccVideoSourceImpl |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CMccVideoSourceImpl::~CMccVideoSourceImpl() |
|
92 { |
|
93 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::~CMccVideoSourceImpl" ) |
|
94 |
|
95 StopCameraMonitoring(); |
|
96 |
|
97 if ( iMediaRecorder ) |
|
98 { |
|
99 TRAP_IGNORE( iMediaRecorder->StopL() ) |
|
100 } |
|
101 |
|
102 delete iVideoCodecFourCC; |
|
103 delete iMediaRecorder; |
|
104 iAsyncEventHandler = NULL; |
|
105 |
|
106 iVideoQueue.ResetAndDestroy(); |
|
107 |
|
108 delete iConfigKey; |
|
109 delete iConfigKeyData; |
|
110 |
|
111 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::~CMccVideoSourceImpl, exit" ) |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CMccVideoSourceImpl::SetResources |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CMccVideoSourceImpl::SetResources( MMccResources* aResources ) |
|
119 { |
|
120 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SetResources" ) |
|
121 |
|
122 iMccResources = aResources; |
|
123 } |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CMccVideoSourceImpl::SetCameraHandler |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 void CMccVideoSourceImpl::SetCameraHandler( MMccCameraHandler& aCameraHandler ) |
|
130 { |
|
131 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SetCameraHandler" ) |
|
132 |
|
133 iCameraHandler = &aCameraHandler; |
|
134 } |
|
135 |
|
136 // ----------------------------------------------------------------------------- |
|
137 // CMccVideoSourceImpl::SourcePrimeL |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 void CMccVideoSourceImpl::SourcePrimeL( TBool aMultipleCodecs ) |
|
141 { |
|
142 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePrimeL" ) |
|
143 __ASSERT_ALWAYS( iMediaRecorder, User::Leave( KErrNotReady ) ); |
|
144 __ASSERT_ALWAYS( iCameraHandler, User::Leave( KErrNotReady ) ); |
|
145 |
|
146 iMultipleCodecs = aMultipleCodecs; |
|
147 |
|
148 if ( !iCameraHandler->IsCameraReady() ) |
|
149 { |
|
150 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePrimeL, camera not ready" ) |
|
151 |
|
152 HandleCameraReservationL(); |
|
153 } |
|
154 else if ( iMediaRecorder->State() == CCMRMediaRecorder::EStateNone ) |
|
155 { |
|
156 if ( !FullPrepareAllowed() ) |
|
157 { |
|
158 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePrimeL, prepare partially" ) |
|
159 |
|
160 // Cannot prepare recorder yet fully, fake preparing and do it |
|
161 // later automatically once recording is started |
|
162 SendStreamEventToClient( KMccStreamPrepared, KErrNone, KMccAutomaticEvent ); |
|
163 } |
|
164 else |
|
165 { |
|
166 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePrimeL, prepare fully" ) |
|
167 |
|
168 TUid encoderUid( KNullUid ); |
|
169 DoCodecSpecificConfigurationL( encoderUid ); |
|
170 |
|
171 __ASSERT_ALWAYS( iVideoCodecFourCC, User::Leave( KErrNotReady ) ); |
|
172 |
|
173 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePrimeL, opening source" ) |
|
174 iMediaRecorder->OpenL( iAudioSource, iCameraHandler->Handle(), |
|
175 *iVideoCodecFourCC, iAudioFourCC, encoderUid ) ; |
|
176 } |
|
177 } |
|
178 else |
|
179 { |
|
180 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePrimeL, not priming" ) |
|
181 } |
|
182 |
|
183 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePrimeL, exit" ) |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CMccVideoSourceImpl::SourcePlayL() |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 void CMccVideoSourceImpl::SourcePlayL() |
|
191 { |
|
192 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePlayL" ) |
|
193 |
|
194 TMccEventType event = KMccEventNone; |
|
195 TUint32 eventNumData = 0; |
|
196 iMultipleCodecs = EFalse; |
|
197 |
|
198 if ( iMediaRecorder->State() == CCMRMediaRecorder::EStateNone ) |
|
199 { |
|
200 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePlayL, \ |
|
201 not prepared, prepare in autoplay mode" ) |
|
202 SetAutoPlayMode( ETrue ); |
|
203 SourcePrimeL(); |
|
204 } |
|
205 else if ( iMediaRecorder->State() == CCMRMediaRecorder::EStateReadyToRecord ) |
|
206 { |
|
207 iMediaRecorder->PlayL(); |
|
208 if ( AutoPlayMode() ) |
|
209 { |
|
210 event = KMccStreamResumed; |
|
211 eventNumData = KMccAutomaticEvent; |
|
212 SetAutoPlayMode( EFalse ); |
|
213 } |
|
214 else |
|
215 { |
|
216 event = KMccStreamStarted; |
|
217 } |
|
218 } |
|
219 else |
|
220 { |
|
221 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePlayL, \ |
|
222 already playing or stopping" ) |
|
223 } |
|
224 |
|
225 if ( event != KMccEventNone && !AutoPlayMode() ) |
|
226 { |
|
227 SendStreamEventToClient( event, KErrNone, eventNumData ); |
|
228 } |
|
229 |
|
230 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePlayL, exit" ) |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CMccVideoSourceImpl::SourcePauseL() |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 void CMccVideoSourceImpl::SourcePauseL() |
|
238 { |
|
239 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePauseL") |
|
240 |
|
241 iVideoConsumer = NULL; |
|
242 iVideoConsumerBuffer = NULL; |
|
243 SetAutoPlayMode( EFalse ); |
|
244 |
|
245 StopCameraMonitoring(); |
|
246 |
|
247 // Always stop the recorder, this will free camera resources |
|
248 iMediaRecorder->StopL(); |
|
249 |
|
250 iVideoQueue.ResetAndDestroy(); |
|
251 |
|
252 SendStreamEventToClient( KMccStreamPaused ); |
|
253 |
|
254 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourcePauseL, exit") |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // CMccVideoSourceImpl::SourceStopL() |
|
259 // ----------------------------------------------------------------------------- |
|
260 // |
|
261 void CMccVideoSourceImpl::SourceStopL() |
|
262 { |
|
263 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourceStopL" ) |
|
264 __V_SOURCESINK_MEDIA_INT1("CMccVideoSourceImpl::SourceStopL, thread", \ |
|
265 RThread().Id().operator TUint()); |
|
266 iVideoConsumer = NULL; |
|
267 iVideoConsumerBuffer = NULL; |
|
268 iMultipleCodecs = EFalse; |
|
269 iMediaRecorder->StopL(); |
|
270 |
|
271 iVideoQueue.ResetAndDestroy(); |
|
272 |
|
273 SendStreamEventToClient( KMccStreamStopped ); |
|
274 |
|
275 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourceStopL, exit" ) |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CMccVideoSourceImpl::SourceDataTypeCode() |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 TFourCC CMccVideoSourceImpl::SourceDataTypeCode( TMediaId aMediaId ) |
|
283 { |
|
284 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourceDataTypeCode" ) |
|
285 |
|
286 if ( KUidMediaTypeVideo == aMediaId.iMediaType ) |
|
287 { |
|
288 return iVideoCodec.iFourCC; |
|
289 } |
|
290 else if ( KUidMediaTypeAudio == aMediaId.iMediaType ) |
|
291 { |
|
292 return iAudioFourCC; |
|
293 } |
|
294 else |
|
295 { |
|
296 return TFourCC( KMMFFourCCCodeNULL ); |
|
297 } |
|
298 } |
|
299 |
|
300 // ----------------------------------------------------------------------------- |
|
301 // CMccVideoSourceImpl::SetSourceDataTypeCode() |
|
302 // ----------------------------------------------------------------------------- |
|
303 // |
|
304 TInt CMccVideoSourceImpl::SetSourceDataTypeCode( |
|
305 TFourCC aCodec, |
|
306 TMediaId aMediaId ) |
|
307 { |
|
308 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SetSourceDataTypeCode" ) |
|
309 |
|
310 if ( KUidMediaTypeVideo == aMediaId.iMediaType && |
|
311 aCodec == iVideoCodec.iFourCC ) |
|
312 { |
|
313 return KErrNone; |
|
314 } |
|
315 else if ( KUidMediaTypeAudio == aMediaId.iMediaType && |
|
316 aCodec == iAudioFourCC ) |
|
317 { |
|
318 return KErrNone; |
|
319 } |
|
320 else |
|
321 { |
|
322 return KErrNotSupported; |
|
323 } |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CMccVideoSourceImpl::BufferEmptiedL() |
|
328 // ----------------------------------------------------------------------------- |
|
329 // |
|
330 void CMccVideoSourceImpl::BufferEmptiedL( CMMFBuffer* /*aBuffer*/ ) |
|
331 { |
|
332 __V_SOURCESINK_MEDIA( "CMccVideoSourceImpl::BufferEmptiedL" ) |
|
333 __ASSERT_ALWAYS( EFalse, User::Leave( KErrNotSupported ) ); |
|
334 } |
|
335 |
|
336 // ----------------------------------------------------------------------------- |
|
337 // CMccVideoSourceImpl::CanCreateSourceBuffer() |
|
338 // ----------------------------------------------------------------------------- |
|
339 // |
|
340 TBool CMccVideoSourceImpl::CanCreateSourceBuffer() |
|
341 { |
|
342 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::CanCreateSourceBuffer, ETrue" ) |
|
343 return EFalse; |
|
344 } |
|
345 |
|
346 // ----------------------------------------------------------------------------- |
|
347 // CMccVideoSourceImpl::CreateSourceBufferL() |
|
348 // ----------------------------------------------------------------------------- |
|
349 // |
|
350 CMMFBuffer* CMccVideoSourceImpl::CreateSourceBufferL( |
|
351 TMediaId /*aMediaId*/, |
|
352 TBool& /*aReference*/ ) |
|
353 { |
|
354 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::CreateSourceBufferL" ) |
|
355 CMMFBuffer* buffer = NULL; |
|
356 __ASSERT_ALWAYS( EFalse, User::Leave( KErrNotSupported ) ); |
|
357 |
|
358 return buffer; |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // CMccVideoSourceImpl::SourceThreadLogon() |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 TInt CMccVideoSourceImpl::SourceThreadLogon( MAsyncEventHandler& aEventHandler ) |
|
366 { |
|
367 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourceThreadLogon" ) |
|
368 iAsyncEventHandler = static_cast<MAsyncEventHandler*>( &aEventHandler ); |
|
369 return KErrNone; |
|
370 } |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // CMccVideoSourceImpl::SourceThreadLogoff() |
|
374 // ----------------------------------------------------------------------------- |
|
375 // |
|
376 void CMccVideoSourceImpl::SourceThreadLogoff() |
|
377 { |
|
378 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SourceThreadLogoff" ) |
|
379 iAsyncEventHandler = NULL; |
|
380 |
|
381 iVideoQueue.ResetAndDestroy(); |
|
382 } |
|
383 |
|
384 // ----------------------------------------------------------------------------- |
|
385 // CMccVideoSourceImpl::FillBufferL() |
|
386 // ----------------------------------------------------------------------------- |
|
387 // |
|
388 void CMccVideoSourceImpl::FillBufferL( |
|
389 CMMFBuffer* aBuffer, |
|
390 MDataSink* aConsumer, |
|
391 TMediaId aMediaId ) |
|
392 { |
|
393 __V_SOURCESINK_MEDIA( "CMccVideoSourceImpl::FillBufferL" ) |
|
394 |
|
395 // Sink might want to indicate pause/stop by passing NULL buffer |
|
396 if ( aBuffer ) |
|
397 { |
|
398 __ASSERT_ALWAYS ( aConsumer, User::Leave( KErrArgument ) ); |
|
399 } |
|
400 |
|
401 if ( aMediaId.iMediaType == KUidMediaTypeVideo ) |
|
402 { |
|
403 __V_SOURCESINK_MEDIA( "CMccVideoSourceImpl::FillBufferL, video" ) |
|
404 iVideoConsumer = aConsumer; |
|
405 iVideoConsumerBuffer = aBuffer; |
|
406 |
|
407 WriteFirstBufferL(); |
|
408 } |
|
409 else |
|
410 { |
|
411 __V_SOURCESINK_MEDIA_INT1( "CMccVideoSourceImpl::FillBufferL, \ |
|
412 unknown media, type=", aMediaId.iMediaType.iUid ) |
|
413 User::Leave( KErrNotSupported ); |
|
414 } |
|
415 } |
|
416 |
|
417 // ----------------------------------------------------------------------------- |
|
418 // CMccVideoSourceImpl::NegotiateSourceL() |
|
419 // ----------------------------------------------------------------------------- |
|
420 // |
|
421 void CMccVideoSourceImpl::NegotiateSourceL( MDataSink& /*aDataSink*/ ) |
|
422 { |
|
423 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::NegotiateSourceL" ) |
|
424 } |
|
425 |
|
426 // ----------------------------------------------------------------------------- |
|
427 // CMccVideoSourceImpl::WriteBufferL() |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 void CMccVideoSourceImpl::WriteBufferL( CCMRMediaBuffer* aBuffer ) |
|
431 { |
|
432 __V_SOURCESINK_MEDIA( "CMccVideoSourceImpl::WriteBufferL" ) |
|
433 |
|
434 __ASSERT_ALWAYS( aBuffer, User::Leave( KErrArgument ) ); |
|
435 |
|
436 if ( QueueBufferL( *aBuffer ) ) |
|
437 { |
|
438 WriteFirstBufferL(); |
|
439 } |
|
440 |
|
441 __V_SOURCESINK_MEDIA( "CMccVideoSourceImpl::WriteBufferL, exit" ) |
|
442 } |
|
443 |
|
444 // ----------------------------------------------------------------------------- |
|
445 // CMccVideoSourceImpl::SetVideoFrameSize() |
|
446 // ----------------------------------------------------------------------------- |
|
447 // |
|
448 TInt CMccVideoSourceImpl::SetVideoFrameSize( TSize aSize ) |
|
449 { |
|
450 __V_SOURCESINK_CONTROLL_INT2( |
|
451 "CMccVideoSourceImpl::SetVideoFrameSize (from mediarecorder), width", |
|
452 aSize.iWidth, |
|
453 " heigth", |
|
454 aSize.iHeight ) |
|
455 |
|
456 iVideoCodec.iVideoHeight = aSize.iHeight; |
|
457 iVideoCodec.iVideoWidth = aSize.iWidth; |
|
458 |
|
459 return KErrNone; |
|
460 } |
|
461 |
|
462 // ----------------------------------------------------------------------------- |
|
463 // CMccVideoSourceImpl::SetAverageVideoBitRate() |
|
464 // ----------------------------------------------------------------------------- |
|
465 // |
|
466 TInt CMccVideoSourceImpl::SetAverageVideoBitRate( TInt aBitRate ) |
|
467 { |
|
468 __V_SOURCESINK_CONTROLL_INT1( |
|
469 "CMccVideoSourceImpl::SetAverageVideoBitRate (from mediarecorder)", |
|
470 aBitRate ) |
|
471 iVideoCodec.iAverageBitrate = (TUint)aBitRate; |
|
472 return KErrNone; |
|
473 } |
|
474 |
|
475 // ----------------------------------------------------------------------------- |
|
476 // CMccVideoSourceImpl::SetMaxVideoBitRate() |
|
477 // ----------------------------------------------------------------------------- |
|
478 // |
|
479 TInt CMccVideoSourceImpl::SetMaxVideoBitRate( TInt aBitRate ) |
|
480 { |
|
481 __V_SOURCESINK_CONTROLL_INT1( |
|
482 "CMccVideoSourceImpl::SetMaxVideoBitRate (from mediarecorder)", |
|
483 aBitRate ) |
|
484 |
|
485 // Do not reset max bitrate as mediarecorder will call back with the same |
|
486 // value which was given in SetVideoBitrate phase (i.e. value is meaningless) |
|
487 aBitRate = aBitRate; |
|
488 return KErrNone; |
|
489 } |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // CMccVideoSourceImpl::SetAverageAudioBitRate() |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 TInt CMccVideoSourceImpl::SetAverageAudioBitRate( TInt aBitRate ) |
|
496 { |
|
497 __V_SOURCESINK_CONTROLL_INT1( |
|
498 "CMccVideoSourceImpl::SetAverageAudioBitRate (from mediarecorder)", |
|
499 aBitRate ) |
|
500 iAverageAudioBitRate = aBitRate; |
|
501 return KErrNone; |
|
502 } |
|
503 |
|
504 // ----------------------------------------------------------------------------- |
|
505 // CMccVideoSourceImpl::MmroPrepareComplete() |
|
506 // ----------------------------------------------------------------------------- |
|
507 // |
|
508 void CMccVideoSourceImpl::MmroPrepareComplete( TInt aError ) |
|
509 { |
|
510 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroPrepareComplete=", aError ) |
|
511 |
|
512 if ( !aError ) |
|
513 { |
|
514 aError = SetVideoBitrate( iVideoCodec.iBitrate ); |
|
515 if ( !aError ) |
|
516 { |
|
517 TRAP( aError, iMediaRecorder->SetVideoFrameRateL( iVideoCodec.iFramerate ) ); |
|
518 |
|
519 if ( !aError ) |
|
520 { |
|
521 TRateControlOptions options; |
|
522 TRAP( aError, iMediaRecorder->GetVideoRateControlOptionsL( options ) ); |
|
523 if ( !aError ) |
|
524 { |
|
525 __V_SOURCESINK_CONTROLL_INT1( |
|
526 "Ratecontrol options:: control:", options.iControl ) |
|
527 __V_SOURCESINK_CONTROLL_INT1( |
|
528 "Ratecontrol options:: bitrate:", options.iBitrate ) |
|
529 __V_SOURCESINK_CONTROLL_INT1( |
|
530 "Ratecontrol options:: quality:", options.iPictureQuality ) |
|
531 __V_SOURCESINK_CONTROLL_REAL( |
|
532 "Ratecontrol options:: rate:", options.iPictureRate ) |
|
533 __V_SOURCESINK_CONTROLL_REAL( |
|
534 "Ratecontrol options:: qtt:", options.iQualityTemporalTradeoff ) |
|
535 __V_SOURCESINK_CONTROLL_REAL( |
|
536 "Ratecontrol options:: lqt:", options.iLatencyQualityTradeoff ) |
|
537 |
|
538 // Enable constant bitrate (CBR i.e. more strict bitrate control) |
|
539 options.iLatencyQualityTradeoff = KMccLatencyQyalityTradeoff; |
|
540 |
|
541 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::MmroPrepareComplete, set CBR" ) |
|
542 TRAP( aError, iMediaRecorder->SetVideoRateControlOptionsL( options ) ); |
|
543 } |
|
544 } |
|
545 } |
|
546 } |
|
547 |
|
548 |
|
549 if ( AutoPlayMode() && !aError ) |
|
550 { |
|
551 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::MmroPrepareComplete, autoplay" ) |
|
552 |
|
553 TRAPD( err, SourcePlayL() ); |
|
554 if ( err ) |
|
555 { |
|
556 SendStreamEventToClient( KMccStreamPrepared, err, KMccAutomaticEvent ); |
|
557 } |
|
558 } |
|
559 else |
|
560 { |
|
561 SendStreamEventToClient( KMccStreamPrepared, aError, KMccAutomaticEvent ); |
|
562 } |
|
563 } |
|
564 |
|
565 // ----------------------------------------------------------------------------- |
|
566 // CMccVideoSourceImpl::MmroStateChange() |
|
567 // ----------------------------------------------------------------------------- |
|
568 // |
|
569 void CMccVideoSourceImpl::MmroStateChange( TInt aState, TInt aError ) |
|
570 { |
|
571 __V_SOURCESINK_CONTROLL_INT2( "CMccVideoSourceImpl::MmroStateChange, \ |
|
572 aState=", aState, "aError=", aError ) |
|
573 |
|
574 if ( aError ) |
|
575 { |
|
576 SendStreamEventToClient( KMccStreamError, aError ); |
|
577 } |
|
578 else |
|
579 { |
|
580 switch ( aState ) |
|
581 { |
|
582 case CCMRMediaRecorder::EStateNone: |
|
583 { |
|
584 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroStateChange, \ |
|
585 aState=EStateNone, aError=", aError ) |
|
586 } |
|
587 break; |
|
588 case CCMRMediaRecorder::EStateOpen: |
|
589 { |
|
590 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroStateChange, \ |
|
591 aState=EStateOpen, aError=", aError ) |
|
592 } |
|
593 break; |
|
594 case CCMRMediaRecorder::EStatePreparing: |
|
595 { |
|
596 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroStateChange, \ |
|
597 aState=EStatePreparing, aError=", aError ) |
|
598 } |
|
599 break; |
|
600 case CCMRMediaRecorder::EStateRecording: |
|
601 { |
|
602 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroStateChange, \ |
|
603 aState=EStateRecording, aError=", aError ) |
|
604 } |
|
605 break; |
|
606 case CCMRMediaRecorder::EStatePausing: |
|
607 { |
|
608 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroStateChange, \ |
|
609 aState=EStatePausing, aError=", aError ) |
|
610 } |
|
611 break; |
|
612 case CCMRMediaRecorder::EStateStopping: |
|
613 { |
|
614 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroStateChange, \ |
|
615 aState=EStateStopping, aError=", aError ) |
|
616 } |
|
617 break; |
|
618 case CCMRMediaRecorder::EStateReadyToRecord: |
|
619 { |
|
620 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroStateChange, \ |
|
621 aState=EStateReadyToRecord, aError=", aError ) |
|
622 } |
|
623 break; |
|
624 case CCMRMediaRecorder::EStatePaused: |
|
625 { |
|
626 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroStateChange, \ |
|
627 aState=EStatePaused, aError=", aError ) |
|
628 } |
|
629 break; |
|
630 default: |
|
631 break; |
|
632 } |
|
633 } |
|
634 } |
|
635 |
|
636 // ----------------------------------------------------------------------------- |
|
637 // CMccVideoSourceImpl::MmroTemporaryError() |
|
638 // ----------------------------------------------------------------------------- |
|
639 // |
|
640 void CMccVideoSourceImpl::MmroTemporaryError( TInt aError ) |
|
641 { |
|
642 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroTemporaryError=", |
|
643 aError ) |
|
644 |
|
645 SendStreamEventToClient( KMccStreamError, aError ); |
|
646 } |
|
647 |
|
648 // ----------------------------------------------------------------------------- |
|
649 // CMccVideoSourceImpl::MmroFatalError() |
|
650 // ----------------------------------------------------------------------------- |
|
651 // |
|
652 void CMccVideoSourceImpl::MmroFatalError( TInt aError ) |
|
653 { |
|
654 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::MmroFatalError=", aError ) |
|
655 |
|
656 SendStreamEventToClient( KMccStreamError, aError ); |
|
657 } |
|
658 |
|
659 // ----------------------------------------------------------------------------- |
|
660 // CMccVideoSourceImpl::CameraReady() |
|
661 // ----------------------------------------------------------------------------- |
|
662 // |
|
663 void CMccVideoSourceImpl::CameraReady( TInt aError ) |
|
664 { |
|
665 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::CameraReady", aError ) |
|
666 |
|
667 if ( !aError ) |
|
668 { |
|
669 TRAP( aError, SourcePrimeL( iMultipleCodecs ) ); |
|
670 } |
|
671 |
|
672 if ( aError ) |
|
673 { |
|
674 SendStreamEventToClient( KMccStreamError, aError ); |
|
675 } |
|
676 } |
|
677 |
|
678 // ----------------------------------------------------------------------------- |
|
679 // CMccVideoSourceImpl::SetVideoCodecL() |
|
680 // ----------------------------------------------------------------------------- |
|
681 // |
|
682 void CMccVideoSourceImpl::SetVideoCodecL( const TMccCodecInfo& aVideoCodec ) |
|
683 { |
|
684 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SetVideoCodecL " ) |
|
685 |
|
686 iVideoCodec = aVideoCodec; |
|
687 |
|
688 if ( iVideoCodec.iConfigKey.Length() > 0 && !iConfigKey ) |
|
689 { |
|
690 __V_SOURCESINK_CONTROLL( "Setting config key" ) |
|
691 iConfigKey = iVideoCodec.iConfigKey.AllocL(); |
|
692 } |
|
693 |
|
694 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::SetVideoCodecL, iVideoHeight ", |
|
695 iVideoCodec.iVideoHeight ) |
|
696 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::SetVideoCodecL, iVideoWidth ", |
|
697 iVideoCodec.iVideoWidth ) |
|
698 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::SetVideoCodecL, iVideoFourCC ", |
|
699 iVideoCodec.iFourCC.FourCC() ) |
|
700 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::SetVideoCodecL, iVideoBitRate ", |
|
701 iVideoCodec.iBitrate ) |
|
702 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::SetVideoCodecL, iAverageVideoBitRate ", |
|
703 iVideoCodec.iAverageBitrate ) |
|
704 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::SetVideoCodecL, iMaxVideoBitRate ", |
|
705 iVideoCodec.iMaxBitrate ) |
|
706 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::SetVideoCodecL, iVideoCodecMode ", |
|
707 iVideoCodec.iCodecMode ) |
|
708 __V_SOURCESINK_CONTROLL_REAL( "CMccVideoSourceImpl::SetVideoCodecL, iFrameRate ", |
|
709 iVideoCodec.iFramerate ) |
|
710 } |
|
711 |
|
712 // ----------------------------------------------------------------------------- |
|
713 // CMccVideoSourceImpl::GetVideoCodecL() |
|
714 // ----------------------------------------------------------------------------- |
|
715 // |
|
716 void CMccVideoSourceImpl::GetVideoCodecL( TMccCodecInfo& aVideoCodec ) |
|
717 { |
|
718 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::GetVideoCodecL " ) |
|
719 |
|
720 aVideoCodec = iVideoCodec; |
|
721 } |
|
722 |
|
723 // ----------------------------------------------------------------------------- |
|
724 // CMccVideoSourceImpl::GetSupportedVideoCodecsL() |
|
725 // ----------------------------------------------------------------------------- |
|
726 // |
|
727 void CMccVideoSourceImpl::GetSupportedVideoCodecsL( RArray<TFourCC>& /*aVideoTypes*/ ) |
|
728 { |
|
729 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::GetSupportedVideoCodecsL " ) |
|
730 } |
|
731 |
|
732 // ----------------------------------------------------------------------------- |
|
733 // CMccVideoSourceImpl::SetAudioCodecL() |
|
734 // ----------------------------------------------------------------------------- |
|
735 // |
|
736 void CMccVideoSourceImpl::SetAudioCodecL( const TMccCodecInfo& aAudioCodec ) |
|
737 { |
|
738 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SetAudioCodecL" ) |
|
739 iAudioFourCC = aAudioCodec.iFourCC; |
|
740 iAverageAudioBitRate = aAudioCodec.iAverageBitrate; |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // CMccVideoSourceImpl::GetAudioCodecL() |
|
745 // ----------------------------------------------------------------------------- |
|
746 // |
|
747 void CMccVideoSourceImpl::GetAudioCodecL( TMccCodecInfo& aAudioCodec ) |
|
748 { |
|
749 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::GetAudioCodecL" ) |
|
750 |
|
751 aAudioCodec.iFourCC = iAudioFourCC; |
|
752 aAudioCodec.iAverageBitrate = iAverageAudioBitRate; |
|
753 } |
|
754 |
|
755 // ----------------------------------------------------------------------------- |
|
756 // CMccVideoSourceImpl::GetSupportedAudioCodecsL() |
|
757 // ----------------------------------------------------------------------------- |
|
758 // |
|
759 void CMccVideoSourceImpl::GetSupportedAudioCodecsL( RArray<TFourCC>& /*aAudioTypes*/ ) |
|
760 { |
|
761 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::GetSupportedAudioCodecsL" ) |
|
762 } |
|
763 |
|
764 // ----------------------------------------------------------------------------- |
|
765 // CMccVideoSourceImpl::SetAudioEnabledL() |
|
766 // ----------------------------------------------------------------------------- |
|
767 // |
|
768 void CMccVideoSourceImpl::SetAudioEnabledL( TBool aEnabled ) |
|
769 { |
|
770 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SetAudioEnabledL" ) |
|
771 iAudioEnabled = aEnabled; |
|
772 } |
|
773 |
|
774 // ----------------------------------------------------------------------------- |
|
775 // CMccVideoSourceImpl::AudioEnabledL() |
|
776 // ----------------------------------------------------------------------------- |
|
777 // |
|
778 TBool CMccVideoSourceImpl::AudioEnabledL() const |
|
779 { |
|
780 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::AudioEnabledL" ) |
|
781 return iAudioEnabled; |
|
782 } |
|
783 |
|
784 // ----------------------------------------------------------------------------- |
|
785 // CMccVideoSourceImpl::SetGainL() |
|
786 // ----------------------------------------------------------------------------- |
|
787 // |
|
788 void CMccVideoSourceImpl::SetGainL( TInt aGain ) |
|
789 { |
|
790 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SetGainL" ) |
|
791 iAudioGain = aGain; |
|
792 } |
|
793 |
|
794 // ----------------------------------------------------------------------------- |
|
795 // CMccVideoSourceImpl::GainL() |
|
796 // ----------------------------------------------------------------------------- |
|
797 // |
|
798 TInt CMccVideoSourceImpl::GainL() const |
|
799 { |
|
800 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::GainL" ) |
|
801 |
|
802 return iAudioGain; |
|
803 } |
|
804 |
|
805 // ----------------------------------------------------------------------------- |
|
806 // CMccVideoSourceImpl::MaxGainL() |
|
807 // ----------------------------------------------------------------------------- |
|
808 // |
|
809 TInt CMccVideoSourceImpl::MaxGainL() const |
|
810 { |
|
811 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::MaxGainL" ) |
|
812 return iAudioGain; |
|
813 } |
|
814 |
|
815 // ----------------------------------------------------------------------------- |
|
816 // CMccVideoSourceImpl::RateAdaptationRequest |
|
817 // ----------------------------------------------------------------------------- |
|
818 // |
|
819 TInt CMccVideoSourceImpl::RateAdaptationRequest( |
|
820 const TMccEvent& aInputData, |
|
821 TMccEvent& aOutputData ) |
|
822 { |
|
823 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::RateAdaptationRequest, entry" ) |
|
824 |
|
825 TRAPD( err, RateAdaptationRequestL( aInputData, aOutputData ) ); |
|
826 |
|
827 __V_SOURCESINK_CONTROLL_INT1( |
|
828 "CMccVideoSourceImpl::RateAdaptationRequest, exit with err:", err ) |
|
829 |
|
830 return err; |
|
831 } |
|
832 |
|
833 // ----------------------------------------------------------------------------- |
|
834 // CMccVideoSourceImpl::IsStopped() |
|
835 // ----------------------------------------------------------------------------- |
|
836 // |
|
837 TBool CMccVideoSourceImpl::IsStopped() const |
|
838 { |
|
839 return ( iMediaRecorder->State() == CCMRMediaRecorder::EStateNone ); |
|
840 } |
|
841 |
|
842 // ----------------------------------------------------------------------------- |
|
843 // CMccVideoSourceImpl::GetConfigKeyL() |
|
844 // ----------------------------------------------------------------------------- |
|
845 // |
|
846 void CMccVideoSourceImpl::GetConfigKeyL( |
|
847 const TMccCodecInfo& aVideoCodec, |
|
848 TDes8& aConfigKey, |
|
849 TBool aAllowAsyncRetrieval ) |
|
850 { |
|
851 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::GetConfigKeyL" ) |
|
852 |
|
853 if ( iConfigKey ) |
|
854 { |
|
855 __ASSERT_ALWAYS( iConfigKey->Length() <= aConfigKey.MaxLength(), |
|
856 User::Leave( KErrArgument ) ); |
|
857 aConfigKey.Copy( *iConfigKey ); |
|
858 } |
|
859 else |
|
860 { |
|
861 __ASSERT_ALWAYS( iCameraHandler != NULL, User::Leave( KErrNotReady ) ); |
|
862 __ASSERT_ALWAYS( aAllowAsyncRetrieval, User::Leave( KErrNotReady ) ); |
|
863 |
|
864 CMccVideoSourceConfigKeyRetriever* retriever = |
|
865 CMccVideoSourceConfigKeyRetriever::NewLC( *iCameraHandler ); |
|
866 retriever->RetrieveL( aVideoCodec, aConfigKey ); |
|
867 CleanupStack::PopAndDestroy( retriever ); |
|
868 |
|
869 iConfigKey = aConfigKey.AllocL(); |
|
870 } |
|
871 |
|
872 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::GetConfigKeyL, entry" ) |
|
873 } |
|
874 |
|
875 // ----------------------------------------------------------------------------- |
|
876 // CMccVideoSourceImpl::HasConfigKey() |
|
877 // ----------------------------------------------------------------------------- |
|
878 // |
|
879 TBool CMccVideoSourceImpl::HasConfigKey() const |
|
880 { |
|
881 return ( iConfigKey != NULL ); |
|
882 } |
|
883 |
|
884 // ----------------------------------------------------------------------------- |
|
885 // CMccVideoSourceImpl::SendStreamEventToClient() |
|
886 // ----------------------------------------------------------------------------- |
|
887 // |
|
888 void CMccVideoSourceImpl::SendStreamEventToClient( |
|
889 TMccEventType aEventType, |
|
890 TInt aError, |
|
891 TUint32 aEventNumData ) |
|
892 { |
|
893 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SendStreamEventToClient" ) |
|
894 |
|
895 if ( iAsyncEventHandler ) |
|
896 { |
|
897 aEventType = aError ? KMccStreamError : aEventType; |
|
898 |
|
899 TMccEvent event( 0, |
|
900 0, |
|
901 0, |
|
902 iEndpointId, |
|
903 KMccEventCategoryStream, |
|
904 aEventType, |
|
905 aError, |
|
906 KNullDesC8 ); |
|
907 |
|
908 event.iEventNumData = aEventNumData; |
|
909 |
|
910 TMccInternalEvent internalEvent( KMccVideoSourceUid, |
|
911 EMccInternalEventNone, |
|
912 event ); |
|
913 |
|
914 iAsyncEventHandler->SendEventToClient( internalEvent ); |
|
915 } |
|
916 else |
|
917 { |
|
918 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SendStreamEventToClient, \ |
|
919 iAsyncEventHandler=NULL" ) |
|
920 } |
|
921 } |
|
922 |
|
923 // ----------------------------------------------------------------------------- |
|
924 // CMccVideoSourceImpl::SetAutoPlayMode() |
|
925 // ----------------------------------------------------------------------------- |
|
926 // |
|
927 void CMccVideoSourceImpl::SetAutoPlayMode( TBool aIsInAutoPlayMode ) |
|
928 { |
|
929 iAutoPlayMode = aIsInAutoPlayMode; |
|
930 } |
|
931 |
|
932 // ----------------------------------------------------------------------------- |
|
933 // CMccVideoSourceImpl::AutoPlayMode() |
|
934 // ----------------------------------------------------------------------------- |
|
935 // |
|
936 TBool CMccVideoSourceImpl::AutoPlayMode() const |
|
937 { |
|
938 return iAutoPlayMode; |
|
939 } |
|
940 |
|
941 |
|
942 // ----------------------------------------------------------------------------- |
|
943 // CMccVideoSourceImpl::CopyBufferData() |
|
944 // ----------------------------------------------------------------------------- |
|
945 // |
|
946 TBool CMccVideoSourceImpl::CopyBufferData( |
|
947 CMMFBuffer& aDstBuffer, |
|
948 CCMRMediaBuffer& aSrcBuffer ) |
|
949 { |
|
950 CMMFDataBuffer& dstBuf = |
|
951 static_cast<CMMFDataBuffer&>( aDstBuffer ); |
|
952 |
|
953 __V_SOURCESINK_MEDIA_INT2( "CMccVideoSourceImpl::CopyBufferData, \ |
|
954 src buf length =", aSrcBuffer.Data().Length(), " type =", aSrcBuffer.Type() ) |
|
955 |
|
956 __V_SOURCESINK_MEDIA_INT1( "CMccVideoSourceImpl::CopyBufferData, \ |
|
957 dst buf size =", dstBuf.BufferSize() ) |
|
958 |
|
959 if ( aSrcBuffer.Type() == CCMRMediaBuffer::EVideoH264NALDecSpecInfo || |
|
960 aSrcBuffer.Type() == CCMRMediaBuffer::EVideoH264BytestreamDecSpecInfo ) |
|
961 { |
|
962 __V_SOURCESINK_CONTROLL_STR8( "Decoder spec info:", aSrcBuffer.Data() ) |
|
963 TRAP_IGNORE( SetConfigKeyL( aSrcBuffer.Data() ) ) |
|
964 } |
|
965 |
|
966 TBool copied( EFalse ); |
|
967 if ( dstBuf.Data().MaxLength() >= aSrcBuffer.Data().Length() ) |
|
968 { |
|
969 dstBuf.Data().Copy( aSrcBuffer.Data() ); |
|
970 dstBuf.SetTimeToPlay( aSrcBuffer.TimeStamp().Int64() ); |
|
971 dstBuf.SetLastBuffer( EFalse ); |
|
972 copied = ETrue; |
|
973 } |
|
974 |
|
975 return copied; |
|
976 } |
|
977 |
|
978 // ----------------------------------------------------------------------------- |
|
979 // CMccVideoSourceImpl::CopyBufferData() |
|
980 // ----------------------------------------------------------------------------- |
|
981 // |
|
982 TBool CMccVideoSourceImpl::CopyBufferData( |
|
983 CMMFBuffer& aDstBuffer, |
|
984 CMMFDataBuffer& aSrcBuffer ) |
|
985 { |
|
986 CMMFDataBuffer& dstBuf = |
|
987 static_cast<CMMFDataBuffer&>( aDstBuffer ); |
|
988 |
|
989 __V_SOURCESINK_MEDIA_INT1( "CMccVideoSourceImpl::CopyBufferData, \ |
|
990 src buf size =", aSrcBuffer.BufferSize() ) |
|
991 |
|
992 __V_SOURCESINK_MEDIA_INT1( "CMccVideoSourceImpl::CopyBufferData, \ |
|
993 dst buf size =", dstBuf.BufferSize() ) |
|
994 |
|
995 TBool copied( EFalse ); |
|
996 if ( dstBuf.Data().MaxLength() >= aSrcBuffer.Data().Length() ) |
|
997 { |
|
998 dstBuf.Data().Copy( aSrcBuffer.Data() ); |
|
999 dstBuf.SetTimeToPlay( aSrcBuffer.TimeToPlay() ); |
|
1000 dstBuf.SetLastBuffer( EFalse ); |
|
1001 copied = ETrue; |
|
1002 } |
|
1003 return copied; |
|
1004 } |
|
1005 |
|
1006 // ----------------------------------------------------------------------------- |
|
1007 // CMccVideoSourceImpl::QueueBufferL() |
|
1008 // ----------------------------------------------------------------------------- |
|
1009 // |
|
1010 TBool CMccVideoSourceImpl::QueueBufferL( CCMRMediaBuffer& aBuffer ) |
|
1011 { |
|
1012 TBool queued( EFalse ); |
|
1013 |
|
1014 if ( iVideoQueue.Count() < KMccMaxVideoQueueSize ) |
|
1015 { |
|
1016 CMMFDataBuffer* dataBuf = CMMFDataBuffer::NewL( aBuffer.Data().Length() ); |
|
1017 CleanupStack::PushL( dataBuf ); |
|
1018 if ( CopyBufferData( *dataBuf, aBuffer ) ) |
|
1019 { |
|
1020 // Random access point buffers (IFrames) have special handling |
|
1021 if ( aBuffer.RandomAccessPoint() ) |
|
1022 { |
|
1023 AddIFrameToQueueL( dataBuf ); |
|
1024 CleanupStack::Pop( dataBuf ); |
|
1025 } |
|
1026 else |
|
1027 { |
|
1028 iVideoQueue.AppendL( dataBuf ); |
|
1029 CleanupStack::Pop( dataBuf ); |
|
1030 } |
|
1031 queued = ETrue; |
|
1032 } |
|
1033 else |
|
1034 { |
|
1035 CleanupStack::PopAndDestroy( dataBuf ); |
|
1036 } |
|
1037 } |
|
1038 return queued; |
|
1039 } |
|
1040 |
|
1041 // ----------------------------------------------------------------------------- |
|
1042 // CMccVideoSourceImpl::FetchQueuedBuffer() |
|
1043 // ----------------------------------------------------------------------------- |
|
1044 // |
|
1045 CMMFDataBuffer* CMccVideoSourceImpl::FetchQueuedBuffer() |
|
1046 { |
|
1047 CMMFDataBuffer* queuedBuf = NULL; |
|
1048 if ( iVideoQueue.Count() > 0 ) |
|
1049 { |
|
1050 queuedBuf = iVideoQueue[ 0 ]; |
|
1051 iVideoQueue.Remove( 0 ); |
|
1052 } |
|
1053 return queuedBuf; |
|
1054 } |
|
1055 |
|
1056 // ----------------------------------------------------------------------------- |
|
1057 // CMccVideoSourceImpl::DoBufferFilledL() |
|
1058 // ----------------------------------------------------------------------------- |
|
1059 // |
|
1060 void CMccVideoSourceImpl::DoBufferFilledL() |
|
1061 { |
|
1062 CMMFBuffer* tempBuf = iVideoConsumerBuffer; |
|
1063 MDataSink* tempSink = iVideoConsumer; |
|
1064 iVideoConsumer = NULL; |
|
1065 iVideoConsumerBuffer = NULL; |
|
1066 |
|
1067 if ( tempSink ) |
|
1068 { |
|
1069 tempSink->BufferFilledL( tempBuf ); |
|
1070 } |
|
1071 } |
|
1072 |
|
1073 // ----------------------------------------------------------------------------- |
|
1074 // CMccVideoSourceImpl::SetVideoBitrate() |
|
1075 // ----------------------------------------------------------------------------- |
|
1076 // |
|
1077 TInt CMccVideoSourceImpl::SetVideoBitrate( TUint& aVideoBitrate ) |
|
1078 { |
|
1079 // Respect maximum negotiation bitrate and do not allow too low values |
|
1080 // |
|
1081 |
|
1082 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SetVideoBitrate" ) |
|
1083 |
|
1084 TUint videoBitrate( aVideoBitrate ); |
|
1085 |
|
1086 if ( videoBitrate > iMaxNegBitRate ) |
|
1087 { |
|
1088 __V_SOURCESINK_CONTROLL( |
|
1089 "CMccVideoSourceImpl:: bitrate higher than negotiated" ) |
|
1090 videoBitrate = iMaxNegBitRate; |
|
1091 } |
|
1092 |
|
1093 if ( videoBitrate > iVideoCodec.iMaxBitrate ) |
|
1094 { |
|
1095 __V_SOURCESINK_CONTROLL( |
|
1096 "CMccVideoSourceImpl:: bitrate higher than maximum set" ) |
|
1097 videoBitrate = iVideoCodec.iMaxBitrate; |
|
1098 } |
|
1099 |
|
1100 if ( videoBitrate < KMccBitrateTooLowLimit ) |
|
1101 { |
|
1102 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl:: bitrate too low" ) |
|
1103 videoBitrate = KMccBitrateTooLowLimit; |
|
1104 } |
|
1105 |
|
1106 TRAPD( err, iMediaRecorder->SetVideoBitrateL( videoBitrate ) ); |
|
1107 if ( err == KErrNone ) |
|
1108 { |
|
1109 aVideoBitrate = videoBitrate; |
|
1110 } |
|
1111 |
|
1112 __V_SOURCESINK_CONTROLL_INT1( |
|
1113 "CMccVideoSourceImpl::SetVideoBitrate, exit with err", err ) |
|
1114 |
|
1115 return err; |
|
1116 } |
|
1117 |
|
1118 // ----------------------------------------------------------------------------- |
|
1119 // CMccVideoSourceImpl::RateAdaptationRequestL |
|
1120 // ----------------------------------------------------------------------------- |
|
1121 // |
|
1122 void CMccVideoSourceImpl::RateAdaptationRequestL( |
|
1123 const TMccEvent& aInputData, |
|
1124 TMccEvent& aOutputData ) |
|
1125 { |
|
1126 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::RateAdaptationRequestL" ) |
|
1127 |
|
1128 TMccRateAdaptationEventDataPackage inputdatapkg; |
|
1129 inputdatapkg.Copy(aInputData.iEventData); |
|
1130 TMccRateAdaptationEventData inputdata = inputdatapkg(); |
|
1131 TMccRateAdaptationEventData outputdata = TMccRateAdaptationEventData(); |
|
1132 |
|
1133 #ifdef RATECONTROL |
|
1134 |
|
1135 if ( iMediaRecorder && |
|
1136 ( iMediaRecorder->State() == CCMRMediaRecorder::EStateRecording || |
|
1137 iMediaRecorder->State() == CCMRMediaRecorder::EStatePaused ) ) |
|
1138 { |
|
1139 __V_SOURCESINK_CONTROLL( |
|
1140 "CMccVideoSourceImpl::RateAdaptationRequest EStateRecording or EStatePaused" ) |
|
1141 |
|
1142 TUint bitrate = 0; |
|
1143 |
|
1144 bitrate = iMediaRecorder->GetVideoBitrateL(); |
|
1145 |
|
1146 __V_SOURCESINK_CONTROLL( |
|
1147 "CMccVideoSourceImpl::RateAdaptationRequest GetVideoBitRateL done" ) |
|
1148 |
|
1149 outputdata.iBitrateOriginal = bitrate; |
|
1150 |
|
1151 __V_SOURCESINK_CONTROLL_INT1( |
|
1152 "CMccVideoSourceImpl::RateAdaptationRequest originalBitrate=", bitrate) |
|
1153 TUint mbitrate = TUint( inputdata.iRateAdaptationAdvice * TReal( bitrate ) ); |
|
1154 __V_SOURCESINK_CONTROLL_INT1( |
|
1155 "CMccVideoSourceImpl::RateAdaptationRequest modifiedBitrate=", mbitrate) |
|
1156 |
|
1157 TInt bitrateErr = SetVideoBitrate( mbitrate ); |
|
1158 if ( bitrateErr == KErrNone ) |
|
1159 { |
|
1160 __V_SOURCESINK_CONTROLL( |
|
1161 "CMccVideoSourceImpl::RateAdaptationRequest SetVideoBitRate ok" ) |
|
1162 iVideoCodec.iBitrate = mbitrate; // This will be used after pause/resume |
|
1163 outputdata.iBitrateModified = mbitrate; |
|
1164 } |
|
1165 else |
|
1166 { |
|
1167 __V_SOURCESINK_CONTROLL( |
|
1168 "CMccVideoSourceImpl::RateAdaptationRequest SetVideoBitRate nok" ) |
|
1169 outputdata.iBitrateModified = bitrate; |
|
1170 } |
|
1171 |
|
1172 #ifdef FRAMERATECONTROL |
|
1173 |
|
1174 TReal frameRate = KMccDefaultVideoFrameRate; |
|
1175 |
|
1176 if ( mbitrate > KIPULFrameRate10Limit ) |
|
1177 { |
|
1178 __V_SOURCESINK_CONTROLL_INT1( |
|
1179 "CMccVideoSourceImpl::RateAdaptationRequest frameRate=", (TInt) frameRate) |
|
1180 |
|
1181 frameRate = iFrameRate; |
|
1182 } |
|
1183 else if (mbitrate < KIPULFrameRate5Limit ) |
|
1184 { |
|
1185 __V_SOURCESINK_CONTROLL_INT1( |
|
1186 "CMccVideoSourceImpl::RateAdaptationRequest frameRate=", (TInt) frameRate) |
|
1187 |
|
1188 frameRate = Min( 5.0, (TUint) iFrameRate ); |
|
1189 } |
|
1190 else |
|
1191 { |
|
1192 __V_SOURCESINK_CONTROLL_INT1( |
|
1193 "CMccVideoSourceImpl::RateAdaptationRequest frameRate=", (TInt) frameRate) |
|
1194 |
|
1195 frameRate = Min( 10.0, (TUint) iFrameRate ); |
|
1196 } |
|
1197 |
|
1198 iMediaRecorder->SetVideoFrameRateL( frameRate ); |
|
1199 |
|
1200 __V_SOURCESINK_CONTROLL( |
|
1201 "CMccVideoSourceImpl::RateAdaptationRequest SetVideoFrameRateL done" ) |
|
1202 |
|
1203 #endif //FRAMERATECONTROL |
|
1204 |
|
1205 TMccRateAdaptationEventDataPackage temp( outputdata ); |
|
1206 aOutputData.iEventData.Copy( temp ); |
|
1207 |
|
1208 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::RateAdaptationRequest end" ) |
|
1209 return; |
|
1210 } |
|
1211 |
|
1212 #endif //RATECONTROL |
|
1213 |
|
1214 User::Leave( KErrNotSupported ); |
|
1215 } |
|
1216 |
|
1217 // --------------------------------------------------------------------------- |
|
1218 // CMccVideoSourceImpl::DoCodecSpecificConfigurationL |
|
1219 // --------------------------------------------------------------------------- |
|
1220 // |
|
1221 void CMccVideoSourceImpl::DoCodecSpecificConfigurationL( TUid& aEncoderUid ) |
|
1222 { |
|
1223 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::DoCodecSpecificConfigurationL" ) |
|
1224 |
|
1225 TBuf8<KMaxSdpNameLength> sdpName = iVideoCodec.iSdpName; |
|
1226 |
|
1227 if ( iVideoCodec.iSdpName.FindF( KH263SdpName ) != KErrNotFound ) |
|
1228 { |
|
1229 __V_SOURCESINK_CONTROLL( "H263" ) |
|
1230 const TUint maxBitRateOne = 64000; |
|
1231 const TUint maxBitRateTwo = 128000; |
|
1232 |
|
1233 if ( iVideoCodec.iMaxBitrate <= maxBitRateOne ) |
|
1234 { |
|
1235 __V_SOURCESINK_CONTROLL( "level set 10" ) |
|
1236 iMaxNegBitRate = maxBitRateOne; |
|
1237 } |
|
1238 else if ( iVideoCodec.iMaxBitrate > maxBitRateOne && |
|
1239 iVideoCodec.iMaxBitrate <= maxBitRateTwo ) |
|
1240 { |
|
1241 __V_SOURCESINK_CONTROLL( "level set 45" ) |
|
1242 iMaxNegBitRate = maxBitRateTwo; |
|
1243 } |
|
1244 else |
|
1245 { |
|
1246 __V_SOURCESINK_CONTROLL( "max bitrate too high, set level 45" ) |
|
1247 iMaxNegBitRate = maxBitRateTwo; |
|
1248 iVideoCodec.iMaxBitrate = maxBitRateTwo; |
|
1249 } |
|
1250 |
|
1251 if ( iVideoCodec.iCodecMode == KH263FormatModeOld ) |
|
1252 { |
|
1253 __V_SOURCESINK_CONTROLL( "mode set 1998" ) |
|
1254 } |
|
1255 |
|
1256 // Always use H263-2000 mime type as mediarecorder doesn't support 1998 mode |
|
1257 sdpName = KH2632000SdpName; |
|
1258 } |
|
1259 else if ( iVideoCodec.iSdpName.CompareF( KAVCSdpName ) == 0 ) |
|
1260 { |
|
1261 __V_SOURCESINK_CONTROLL( "AVC" ) |
|
1262 |
|
1263 iMaxNegBitRate = iVideoCodec.iMaxBitrate; |
|
1264 __V_SOURCESINK_CONTROLL_INT1( "CMccVideoSourceImpl::DoCodecSpecificConfigurationL, EncodingDecodingDeviceUid:", |
|
1265 iVideoCodec.iEncodingDecodingDevice.iUid ) |
|
1266 aEncoderUid = iVideoCodec.iEncodingDecodingDevice; |
|
1267 } |
|
1268 else |
|
1269 { |
|
1270 // NOP |
|
1271 } |
|
1272 |
|
1273 HBufC8* fmtp = GetFmtpLC( iVideoCodec ); |
|
1274 |
|
1275 delete iVideoCodecFourCC; |
|
1276 iVideoCodecFourCC = NULL; |
|
1277 iVideoCodecFourCC = |
|
1278 HBufC8::NewL( KVideoCodecFourCC().Length() + KMaxSdpNameLength + fmtp->Length() ); |
|
1279 |
|
1280 iVideoCodecFourCC->Des().Format( KVideoCodecFourCC, &sdpName, &*fmtp ); |
|
1281 |
|
1282 CleanupStack::PopAndDestroy( fmtp ); |
|
1283 |
|
1284 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::DoCodecSpecificConfigurationL, exit" ); |
|
1285 } |
|
1286 |
|
1287 // --------------------------------------------------------------------------- |
|
1288 // CMccVideoSourceImpl::GetFmtpLC |
|
1289 // --------------------------------------------------------------------------- |
|
1290 // |
|
1291 HBufC8* CMccVideoSourceImpl::GetFmtpLC( const TMccCodecInfo& aCodecInfo ) |
|
1292 { |
|
1293 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::GetFmtpLC" ) |
|
1294 |
|
1295 CMccCodecInformationFactory* factory = CMccCodecInformationFactory::NewL(); |
|
1296 CleanupStack::PushL( factory ); |
|
1297 CMccCodecInformation* codec = |
|
1298 factory->CreateCodecInformationL( aCodecInfo.iSdpName ); |
|
1299 CleanupStack::PushL( codec ); |
|
1300 codec->SetValues( aCodecInfo ); |
|
1301 HBufC8* fmtp = codec->GetFmtpL().AllocL(); |
|
1302 CleanupStack::PopAndDestroy( codec ); |
|
1303 CleanupStack::PopAndDestroy( factory ); |
|
1304 CleanupStack::PushL( fmtp ); |
|
1305 |
|
1306 __V_SOURCESINK_CONTROLL_STR8( "fmtp:", *fmtp ) |
|
1307 |
|
1308 if ( aCodecInfo.iSdpName.CompareF( KAVCSdpName ) == 0 ) |
|
1309 { |
|
1310 __V_SOURCESINK_CONTROLL( "avc handling" ) |
|
1311 |
|
1312 TPtr8 ptrFmtp( fmtp->Des() ); |
|
1313 // Strip useless information off from SDP |
|
1314 // (mediarecorder does not accept packetization mode etc.) |
|
1315 TInt index = ptrFmtp.Find( KTxtProfileLevelId ); |
|
1316 if ( index >= 0 ) |
|
1317 { |
|
1318 _LIT8( KSemicolon, ";" ); |
|
1319 TInt semicolonIndex = ptrFmtp.Mid( index ).Find( KSemicolon ); |
|
1320 |
|
1321 if ( semicolonIndex > 0 ) |
|
1322 { |
|
1323 HBufC8* strippedFmtp = ptrFmtp.Mid( index, semicolonIndex ).AllocL(); |
|
1324 CleanupStack::PopAndDestroy( fmtp ); |
|
1325 fmtp = strippedFmtp; |
|
1326 CleanupStack::PushL( fmtp ); |
|
1327 __V_SOURCESINK_CONTROLL_STR8( "stripped fmtp:", *fmtp ) |
|
1328 } |
|
1329 } |
|
1330 } |
|
1331 |
|
1332 return fmtp; |
|
1333 } |
|
1334 |
|
1335 // --------------------------------------------------------------------------- |
|
1336 // CMccVideoSourceImpl::SetConfigKeyL |
|
1337 // Base 64 encoded version of key is more for session negotiation and does |
|
1338 // not need to be updated if it already existis. Raw data config key is |
|
1339 // used inside stream and it will represent current configuration information |
|
1340 // as it will be received from mediarecorded. Therefore keep updating it. |
|
1341 // --------------------------------------------------------------------------- |
|
1342 // |
|
1343 void CMccVideoSourceImpl::SetConfigKeyL( const TDesC8& aData ) |
|
1344 { |
|
1345 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SetConfigKeyL" ) |
|
1346 |
|
1347 if ( iConfigKey == NULL ) |
|
1348 { |
|
1349 TInt bufferProgressIndex( 0 ); |
|
1350 TInt part1StartIndex = |
|
1351 TMccCodecInfo::FindAvcNaluStart( bufferProgressIndex, aData ); |
|
1352 __ASSERT_ALWAYS( part1StartIndex != KErrNotFound, User::Leave( KErrNotFound ) ); |
|
1353 |
|
1354 TInt part1EndIndex = TMccCodecInfo::FindAvcNaluEnd( bufferProgressIndex, aData ); |
|
1355 __ASSERT_ALWAYS( part1EndIndex != KErrNotFound, User::Leave( KErrNotFound ) ); |
|
1356 |
|
1357 TInt part2StartIndex = TMccCodecInfo::FindAvcNaluStart( bufferProgressIndex, aData ); |
|
1358 __ASSERT_ALWAYS( part2StartIndex != KErrNotFound, User::Leave( KErrNotFound ) ); |
|
1359 |
|
1360 TInt part2EndIndex = TMccCodecInfo::FindAvcNaluEnd( bufferProgressIndex, aData ); |
|
1361 __ASSERT_ALWAYS( part2EndIndex != KErrNotFound, User::Leave( KErrNotFound ) ); |
|
1362 |
|
1363 TInt part1Len = part1EndIndex - part1StartIndex; |
|
1364 HBufC8* confKeyPart1 = |
|
1365 MccConversionUtility::Base64EncodeLC( aData.Mid( part1StartIndex, part1Len ) ); |
|
1366 |
|
1367 TInt part2Len = part2EndIndex - part2StartIndex; |
|
1368 HBufC8* confKeyPart2 = |
|
1369 MccConversionUtility::Base64EncodeLC( aData.Mid( part2StartIndex, part2Len ) ); |
|
1370 |
|
1371 _LIT8( KMccVideoSourceNaluSeparator, "," ); |
|
1372 |
|
1373 iConfigKey = HBufC8::NewL( |
|
1374 confKeyPart1->Length() + |
|
1375 confKeyPart2->Length() + |
|
1376 KMccVideoSourceNaluSeparator().Length() ); |
|
1377 TPtr8 ptrConfigKey( iConfigKey->Des() ); |
|
1378 ptrConfigKey.Append( *confKeyPart1 ); |
|
1379 ptrConfigKey.Append( KMccVideoSourceNaluSeparator() ); |
|
1380 ptrConfigKey.Append( *confKeyPart2 ); |
|
1381 |
|
1382 CleanupStack::PopAndDestroy( confKeyPart2 ); |
|
1383 CleanupStack::PopAndDestroy( confKeyPart1 ); |
|
1384 |
|
1385 __V_SOURCESINK_CONTROLL_STR8( "base64 encoded:", *iConfigKey ) |
|
1386 } |
|
1387 |
|
1388 delete iConfigKeyData; |
|
1389 iConfigKeyData = NULL; |
|
1390 iConfigKeyData = aData.AllocL(); |
|
1391 |
|
1392 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::SetConfigKeyL, exit" ) |
|
1393 } |
|
1394 |
|
1395 // --------------------------------------------------------------------------- |
|
1396 // CMccVideoSourceImpl::FullPrepareAllowed |
|
1397 // --------------------------------------------------------------------------- |
|
1398 // |
|
1399 TBool CMccVideoSourceImpl::FullPrepareAllowed() |
|
1400 { |
|
1401 TBool allowed( !iMultipleCodecs ); |
|
1402 if ( iVideoCodec.iSdpName.CompareF( KAVCSdpName ) == 0 ) |
|
1403 { |
|
1404 // Config key needs to exists before full prepare is allowed for AVC |
|
1405 allowed &= ( iConfigKey != NULL || iConfigKeyRetrieval ); |
|
1406 } |
|
1407 |
|
1408 return allowed; |
|
1409 } |
|
1410 |
|
1411 // --------------------------------------------------------------------------- |
|
1412 // CMccVideoSourceImpl::WriteFirstBufferL |
|
1413 // --------------------------------------------------------------------------- |
|
1414 // |
|
1415 void CMccVideoSourceImpl::WriteFirstBufferL() |
|
1416 { |
|
1417 if ( iVideoConsumerBuffer ) |
|
1418 { |
|
1419 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::WriteFirstBufferL" ) |
|
1420 |
|
1421 CMMFDataBuffer* queuedBuf = FetchQueuedBuffer(); |
|
1422 CleanupStack::PushL( queuedBuf ); |
|
1423 if ( queuedBuf && CopyBufferData( *iVideoConsumerBuffer, *queuedBuf ) ) |
|
1424 { |
|
1425 DoBufferFilledL(); |
|
1426 } |
|
1427 CleanupStack::PopAndDestroy( queuedBuf ); |
|
1428 |
|
1429 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::WriteFirstBufferL, exit" ) |
|
1430 } |
|
1431 } |
|
1432 |
|
1433 // --------------------------------------------------------------------------- |
|
1434 // CMccVideoSourceImpl::AddIFrameToQueueL |
|
1435 // In case of AVC is used, config data is sent before each iframe. |
|
1436 // Config data is not sent before first iframe or if queue doesn't have |
|
1437 // room for config data. |
|
1438 // --------------------------------------------------------------------------- |
|
1439 // |
|
1440 void CMccVideoSourceImpl::AddIFrameToQueueL( CMMFDataBuffer* aBuffer ) |
|
1441 { |
|
1442 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::AddIFrameToQueueL" ) |
|
1443 |
|
1444 __ASSERT_ALWAYS( aBuffer, User::Leave( KErrArgument ) ); |
|
1445 |
|
1446 if ( iConfigKeyData && |
|
1447 ( iVideoCodec.iSdpName.CompareF( KAVCSdpName ) == 0 ) && |
|
1448 ( iVideoQueue.Count() < ( KMccMaxVideoQueueSize - 1 ) ) && |
|
1449 iFirstIFrameQueued ) |
|
1450 { |
|
1451 __V_SOURCESINK_CONTROLL( |
|
1452 "CMccVideoSourceImpl::AddIFrameToQueueL, adding config data" ) |
|
1453 |
|
1454 CMMFDataBuffer* configDataBuf = |
|
1455 CMMFDataBuffer::NewL( iConfigKeyData->Length() ); |
|
1456 CleanupStack::PushL( configDataBuf ); |
|
1457 configDataBuf->Data().Copy( *iConfigKeyData ); |
|
1458 configDataBuf->SetTimeToPlay( aBuffer->TimeToPlay() ); |
|
1459 configDataBuf->SetLastBuffer( EFalse ); |
|
1460 iVideoQueue.AppendL( configDataBuf ); |
|
1461 CleanupStack::Pop( configDataBuf ); |
|
1462 } |
|
1463 |
|
1464 if ( iMccResources ) |
|
1465 { |
|
1466 __V_SOURCESINK_CONTROLL( |
|
1467 "CMccVideoSourceImpl::AddIFrameToQueueL, store iframe info" ) |
|
1468 iMccResources->StoreKeyFrameInfoL( iEndpointId, *aBuffer ); |
|
1469 |
|
1470 __V_SOURCESINK_CONTROLL( |
|
1471 "CMccVideoSourceImpl::AddIFrameToQueueL, info stored" ) |
|
1472 } |
|
1473 |
|
1474 iVideoQueue.AppendL( aBuffer ); |
|
1475 |
|
1476 iFirstIFrameQueued = ETrue; |
|
1477 |
|
1478 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::AddIFrameToQueueL, exit" ) |
|
1479 } |
|
1480 |
|
1481 // --------------------------------------------------------------------------- |
|
1482 // CMccVideoSourceImpl::HandleCameraReservationL |
|
1483 // Camera is needed only for real once autoplay is enabled or config key |
|
1484 // is retrieved. If retrieving config key, we need to force camera creation. |
|
1485 // --------------------------------------------------------------------------- |
|
1486 // |
|
1487 void CMccVideoSourceImpl::HandleCameraReservationL() |
|
1488 { |
|
1489 if ( AutoPlayMode() || iConfigKeyRetrieval ) |
|
1490 { |
|
1491 TBool forceImmediateCameraCreation( iConfigKeyRetrieval ); |
|
1492 |
|
1493 __V_SOURCESINK_CONTROLL_INT1( |
|
1494 "CMccVideoSourceImpl::HandleCameraReservationL, force", |
|
1495 forceImmediateCameraCreation ) |
|
1496 |
|
1497 User::LeaveIfError( iCameraHandler->MonitorCameraReservation( |
|
1498 *this, forceImmediateCameraCreation ) ); |
|
1499 } |
|
1500 else |
|
1501 { |
|
1502 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::HandleCameraReservationL, nop" ) |
|
1503 |
|
1504 SendStreamEventToClient( KMccStreamPrepared, KErrNone, KMccAutomaticEvent ); |
|
1505 } |
|
1506 __V_SOURCESINK_CONTROLL( "CMccVideoSourceImpl::HandleCameraReservationL, exit" ) |
|
1507 } |
|
1508 |
|
1509 // --------------------------------------------------------------------------- |
|
1510 // CMccVideoSourceImpl::StopCameraMonitoring |
|
1511 // --------------------------------------------------------------------------- |
|
1512 // |
|
1513 void CMccVideoSourceImpl::StopCameraMonitoring() |
|
1514 { |
|
1515 if ( iCameraHandler ) |
|
1516 { |
|
1517 // Unregister, ignore error as we might not be even monitoring |
|
1518 // Can release resource as if it was created just for temporary purpose |
|
1519 TBool forceImmediateCameraRelease( iConfigKeyRetrieval ); |
|
1520 iCameraHandler->StopCameraMonitoring( |
|
1521 *this, forceImmediateCameraRelease ); |
|
1522 } |
|
1523 } |
|
1524 |
|
1525 #ifndef EKA2 |
|
1526 // DLL interface code |
|
1527 EXPORT_C TInt E32Dll( TDllReason ) |
|
1528 { |
|
1529 return KErrNone; |
|
1530 } |
|
1531 #endif |