|
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 |
|
22 #include "mcefilesource.h" |
|
23 #include "mcecomfilesource.h" |
|
24 #include "mceitcsender.h" |
|
25 #include "mcestreamobserver.h" |
|
26 #include "mcevideostream.h" |
|
27 #include "mceaudiostream.h" |
|
28 #include "mcemanager.h" |
|
29 #include "mce.h" |
|
30 #include "mcesession.h" |
|
31 #include "mceserial.h" |
|
32 #include "utf.h" |
|
33 #include "mceevents.h" |
|
34 #include "mceclilogs.h" |
|
35 |
|
36 #define _FLAT_DATA static_cast<CMceComFileSource*>( iFlatData ) |
|
37 #define FLAT_DATA( data ) _FLAT_DATA->data |
|
38 |
|
39 // ============================ MEMBER FUNCTIONS =============================== |
|
40 |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C CMceFileSource* CMceFileSource::NewL( |
|
47 CMceManager& aManager, |
|
48 const TFileName& aFileName ) |
|
49 { |
|
50 CMceFileSource* self = CMceFileSource::NewLC( aManager, aFileName ); |
|
51 CleanupStack::Pop( self ); |
|
52 return self; |
|
53 } |
|
54 |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 EXPORT_C CMceFileSource* CMceFileSource::NewLC( |
|
61 CMceManager& aManager, |
|
62 const TFileName& aFileName ) |
|
63 { |
|
64 CMceFileSource* self = new (ELeave) CMceFileSource(); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL( &aManager, aFileName ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C CMceFileSource::~CMceFileSource() |
|
76 { |
|
77 if ( iManager && iFlatData ) |
|
78 { |
|
79 TRAP_IGNORE( DoCancelTranscodeL() ); |
|
80 } |
|
81 } |
|
82 |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C void CMceFileSource::EnableL() |
|
89 { |
|
90 MCECLI_DEBUG("CMceFileSource::EnableL, Entry"); |
|
91 |
|
92 CMceMediaSource::DoEnableL(); |
|
93 |
|
94 MCECLI_DEBUG("CMceFileSource::EnableL, Exit"); |
|
95 } |
|
96 |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C void CMceFileSource::DisableL() |
|
103 { |
|
104 MCECLI_DEBUG("CMceFileSource::DisableL, Entry"); |
|
105 |
|
106 CMceMediaSource::DoDisableL(); |
|
107 |
|
108 MCECLI_DEBUG("CMceFileSource::DisableL, Exit"); |
|
109 } |
|
110 |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 EXPORT_C TInt CMceFileSource::MediaElementCountL( TMceMediaType aType ) const |
|
117 { |
|
118 if ( aType == KMceAudio ) |
|
119 { |
|
120 return FLAT_DATA( iFileInfo.iAudioElementCount ); |
|
121 } |
|
122 else if ( aType == KMceVideo ) |
|
123 { |
|
124 return FLAT_DATA( iFileInfo.iVideoElementCount ); |
|
125 } |
|
126 |
|
127 return 0; |
|
128 } |
|
129 |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C void CMceFileSource::SetCurrentMediaElementL( |
|
136 TMceMediaType aType, |
|
137 TInt aIndex ) |
|
138 { |
|
139 __ASSERT_ALWAYS( aIndex >= 0 && |
|
140 aIndex < MediaElementCountL( aType ), |
|
141 User::Leave( KErrArgument ) ); |
|
142 |
|
143 if ( aType == KMceAudio ) |
|
144 { |
|
145 FLAT_DATA( iCurrentAudioElement ) = aIndex; |
|
146 } |
|
147 else if ( aType == KMceVideo ) |
|
148 { |
|
149 FLAT_DATA( iCurrentVideoElement ) = aIndex; |
|
150 } |
|
151 } |
|
152 |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 EXPORT_C TInt CMceFileSource::CurrentMediaElement( TMceMediaType aType ) |
|
159 { |
|
160 if ( aType == KMceAudio ) |
|
161 { |
|
162 return FLAT_DATA( iCurrentAudioElement ); |
|
163 } |
|
164 else if ( aType == KMceVideo ) |
|
165 { |
|
166 return FLAT_DATA( iCurrentVideoElement ); |
|
167 } |
|
168 |
|
169 return 0; |
|
170 } |
|
171 |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 EXPORT_C void CMceFileSource::SetPositionL( |
|
178 const TTimeIntervalMicroSeconds& aPosition ) |
|
179 { |
|
180 MCECLI_DEBUG("CMceFileSource::SetPositionL, Entry"); |
|
181 |
|
182 __ASSERT_ALWAYS( aPosition <= DurationL() && |
|
183 aPosition >= TTimeIntervalMicroSeconds( 0 ), |
|
184 User::Leave( KErrArgument ) ); |
|
185 |
|
186 if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) |
|
187 { |
|
188 |
|
189 TMceIds ids; |
|
190 iStream->Session()->PrepareForITC( ids ); |
|
191 ids.iMediaID = iStream->Id(); |
|
192 ids.iSourceID = Id(); |
|
193 |
|
194 TMceItcArgTime position( aPosition ); |
|
195 |
|
196 iStream->Session()->ITCSender().WriteL( ids, EMceItcSetFilePosition, position ); |
|
197 |
|
198 FLAT_DATA( iPosition ) = position(); |
|
199 } |
|
200 else |
|
201 { |
|
202 FLAT_DATA( iPosition ) = aPosition; |
|
203 MCECLI_DEBUG("CMceDisplaySink::SetPositionL, done locally"); |
|
204 } |
|
205 MCECLI_DEBUG("CMceFileSource::SetPositionL, Exit"); |
|
206 } |
|
207 |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 EXPORT_C TTimeIntervalMicroSeconds CMceFileSource::PositionL() const |
|
214 { |
|
215 MCECLI_DEBUG("CMceFileSource::PositionL, Entry"); |
|
216 |
|
217 if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) |
|
218 { |
|
219 |
|
220 TPckgBuf<TTimeIntervalMicroSeconds> pckg( FLAT_DATA( iPosition ) ); |
|
221 |
|
222 TMceIds ids; |
|
223 iStream->Session()->PrepareForITC( ids ); |
|
224 ids.iMediaID = iStream->Id(); |
|
225 ids.iSourceID = Id(); |
|
226 |
|
227 TMceItcArgTime position; |
|
228 |
|
229 iStream->Session()->ITCSender().ReadL( ids, EMceItcFilePosition, position ); |
|
230 |
|
231 FLAT_DATA( iPosition ) = position(); |
|
232 } |
|
233 else |
|
234 { |
|
235 MCECLI_DEBUG("CMceDisplaySink::PositionL, done locally"); |
|
236 } |
|
237 |
|
238 MCECLI_DEBUG("CMceFileSource::PositionL, Exit"); |
|
239 return FLAT_DATA( iPosition ); |
|
240 |
|
241 } |
|
242 |
|
243 |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 EXPORT_C TTimeIntervalMicroSeconds CMceFileSource::DurationL() const |
|
249 { |
|
250 return FLAT_DATA( iFileInfo.iDuration ); |
|
251 } |
|
252 |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 EXPORT_C void CMceFileSource::SetFastForwardL( TBool aUseFFWD ) |
|
259 { |
|
260 MCECLI_DEBUG("CMceFileSource::SetFastForwardL, Entry"); |
|
261 |
|
262 __ASSERT_ALWAYS( this->MediaElementCountL( KMceVideo ) > 0, |
|
263 User::Leave( KErrNotSupported ) ); |
|
264 |
|
265 if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) |
|
266 { |
|
267 |
|
268 TMceIds ids; |
|
269 iStream->Session()->PrepareForITC( ids ); |
|
270 ids.iMediaID = iStream->Id(); |
|
271 ids.iSourceID = Id(); |
|
272 ids.iState = aUseFFWD; |
|
273 |
|
274 iStream->Session()->ITCSender().SendL( ids, EMceItcSetFastForward ); |
|
275 |
|
276 FLAT_DATA( iFastForward ) = static_cast<TBool>( ids.iState ); |
|
277 } |
|
278 else |
|
279 { |
|
280 MCECLI_DEBUG("CMceDisplaySink::SetFastForwardL, done locally"); |
|
281 FLAT_DATA( iFastForward ) = aUseFFWD; |
|
282 } |
|
283 |
|
284 if ( FLAT_DATA( iFastForward ) ) |
|
285 { |
|
286 FLAT_DATA( iFastRewind ) = EFalse ; |
|
287 } |
|
288 |
|
289 MCECLI_DEBUG("CMceFileSource::SetFastForwardL, Exit"); |
|
290 |
|
291 } |
|
292 |
|
293 |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 EXPORT_C void CMceFileSource::SetFastRewindL( TBool aUseFRWD ) |
|
299 { |
|
300 MCECLI_DEBUG("CMceFileSource::SetFastRewindL, Entry"); |
|
301 |
|
302 __ASSERT_ALWAYS( this->MediaElementCountL( KMceVideo ) > 0, |
|
303 User::Leave( KErrNotSupported ) ); |
|
304 |
|
305 if ( MCE_ENDPOINT_ITC_ALLOWED( *this ) ) |
|
306 { |
|
307 |
|
308 TMceIds ids; |
|
309 iStream->Session()->PrepareForITC( ids ); |
|
310 ids.iMediaID = iStream->Id(); |
|
311 ids.iSourceID = Id(); |
|
312 ids.iState = aUseFRWD; |
|
313 |
|
314 iStream->Session()->ITCSender().SendL( ids, EMceItcSetFastRewind ); |
|
315 |
|
316 FLAT_DATA( iFastRewind ) = static_cast<TBool>( ids.iState ); |
|
317 } |
|
318 else |
|
319 { |
|
320 MCECLI_DEBUG("CMceDisplaySink::SetFastRewindL, done locally"); |
|
321 FLAT_DATA( iFastRewind ) = aUseFRWD; |
|
322 } |
|
323 |
|
324 if ( FLAT_DATA( iFastRewind ) ) |
|
325 { |
|
326 FLAT_DATA( iFastForward ) = EFalse ; |
|
327 } |
|
328 MCECLI_DEBUG("CMceFileSource::SetFastRewindL, Exit"); |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 EXPORT_C void CMceFileSource::UpdateL ( const TFileName& aFileName ) |
|
336 { |
|
337 MCECLI_DEBUG("CMceFileSource::UpdateL, Entry"); |
|
338 MCECLI_DEBUG_SVALUE("file", aFileName ); |
|
339 |
|
340 FLAT_DATA( iFileInfo.iFileName ) = aFileName; |
|
341 |
|
342 __ASSERT_ALWAYS( iManager, User::Leave( KErrNotReady ) ); |
|
343 |
|
344 MCECLI_DEBUG("CMceFileSource::UpdateL, querying file info"); |
|
345 GetFileInfoL( EFalse ); |
|
346 |
|
347 SynchronizeWithStreamL(); |
|
348 |
|
349 // If any of the streams need transcoding, filesource needs to be paused |
|
350 TBool transcodingRequired = EFalse; |
|
351 TInt index = 0; |
|
352 while( index < iParents.Count() && !transcodingRequired ) |
|
353 { |
|
354 transcodingRequired = |
|
355 ( iParents[ index++ ]->State() == CMceMediaStream::ETranscodingRequired ); |
|
356 } |
|
357 |
|
358 if ( transcodingRequired ) |
|
359 { |
|
360 MCECLI_DEBUG("CMceFileSource::UpdateL, transcoding required"); |
|
361 if ( IsEnabled() ) |
|
362 { |
|
363 // If enabled, filesource has to be disabled |
|
364 MCECLI_DEBUG("CMceFileSource::UpdateL, disabling file source"); |
|
365 DisableL(); |
|
366 } |
|
367 else |
|
368 { |
|
369 // If already disabled, stream state change can be notified immediately |
|
370 Updated(); |
|
371 } |
|
372 } |
|
373 else |
|
374 { |
|
375 SetFileInfoL(); |
|
376 } |
|
377 |
|
378 MCECLI_DEBUG("CMceFileSource::UpdateL, Exit"); |
|
379 |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // |
|
384 // ----------------------------------------------------------------------------- |
|
385 // |
|
386 EXPORT_C void CMceFileSource::TranscodeL( const TFileName& aFileName ) |
|
387 { |
|
388 MCECLI_DEBUG("CMceDisplaySink::TranscodeL, Entry"); |
|
389 MCECLI_DEBUG_SVALUE("file", aFileName ); |
|
390 |
|
391 __ASSERT_ALWAYS( iManager, User::Leave( KErrNotReady ) ); |
|
392 |
|
393 FLAT_DATA( iTranscodeInfo.iFileName ) = aFileName; |
|
394 FLAT_DATA( iTranscodeInfo.iQuality ) = 1; |
|
395 FLAT_DATA( iTranscodeInfo.iError ) = KErrNone; |
|
396 FLAT_DATA( iTranscodeInfo.iProgress ) = 0; |
|
397 |
|
398 if ( FLAT_DATA( iID ) == KMceMediaIdNotAssigned ) |
|
399 { |
|
400 FLAT_DATA( iID ) = iManager->NextMediaId(); |
|
401 } |
|
402 |
|
403 TUint sessionid = iManager->TranscodeL( *this ); |
|
404 |
|
405 FLAT_DATA( iTranscodeInfo.iTranscodeSessionId ) = sessionid; |
|
406 |
|
407 UpdateState( CMceMediaStream::ETranscoding ); |
|
408 |
|
409 MCECLI_DEBUG("CMceDisplaySink::TranscodeL, Exit"); |
|
410 } |
|
411 |
|
412 // ----------------------------------------------------------------------------- |
|
413 // |
|
414 // ----------------------------------------------------------------------------- |
|
415 // |
|
416 EXPORT_C void CMceFileSource::CancelTranscodeL() |
|
417 { |
|
418 MCECLI_DEBUG("CMceDisplaySink::CancelTranscodeL, Entry"); |
|
419 |
|
420 DoCancelTranscodeL(); |
|
421 |
|
422 SynchronizeWithStreamL(); |
|
423 |
|
424 MCECLI_DEBUG("CMceDisplaySink::CancelTranscodeL, Exit"); |
|
425 } |
|
426 |
|
427 |
|
428 // ----------------------------------------------------------------------------- |
|
429 // |
|
430 // ----------------------------------------------------------------------------- |
|
431 // |
|
432 void CMceFileSource::UpdateState( CMceMediaStream::TState aState ) |
|
433 { |
|
434 TInt index = 0; |
|
435 while( index < iParents.Count() ) |
|
436 { |
|
437 iParents[ index++ ]->SetState( aState ); |
|
438 } |
|
439 } |
|
440 |
|
441 |
|
442 // ----------------------------------------------------------------------------- |
|
443 // |
|
444 // ----------------------------------------------------------------------------- |
|
445 // |
|
446 void CMceFileSource::SynchronizeWithStreamL() |
|
447 { |
|
448 TInt index = 0; |
|
449 while( index < iParents.Count() ) |
|
450 { |
|
451 iParents[ index++ ]->SynchronizeWithFileL( *this ); |
|
452 } |
|
453 } |
|
454 |
|
455 |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // |
|
459 // ----------------------------------------------------------------------------- |
|
460 // |
|
461 EXPORT_C TInt CMceFileSource::TranscodingProgressL() const |
|
462 { |
|
463 __ASSERT_ALWAYS( iManager, User::Leave( KErrArgument ) ); |
|
464 __ASSERT_ALWAYS( iParents.Count() > 0, User::Leave( KErrNotReady ) ); |
|
465 |
|
466 return FLAT_DATA( iTranscodeInfo.iProgress ); |
|
467 |
|
468 } |
|
469 |
|
470 // ----------------------------------------------------------------------------- |
|
471 // |
|
472 // ----------------------------------------------------------------------------- |
|
473 // |
|
474 void CMceFileSource::InitializeL( CMceManager* aManager ) |
|
475 { |
|
476 __ASSERT_ALWAYS( aManager, User::Leave( KErrArgument ) ); |
|
477 iManager = aManager; |
|
478 |
|
479 if ( !FLAT_DATA( iInitialInfoRetrieved ) ) |
|
480 { |
|
481 MCECLI_DEBUG("CMceFileSource::InitializeL, querying file info"); |
|
482 GetFileInfoL(); |
|
483 |
|
484 FLAT_DATA( iInitialInfoRetrieved ) = ETrue; |
|
485 |
|
486 } |
|
487 |
|
488 |
|
489 } |
|
490 |
|
491 // ----------------------------------------------------------------------------- |
|
492 // |
|
493 // ----------------------------------------------------------------------------- |
|
494 // |
|
495 const TDesC8& CMceFileSource::SupportedVideo() |
|
496 { |
|
497 return FLAT_DATA( iFileInfo.iVideoCodec ); |
|
498 |
|
499 } |
|
500 |
|
501 // ----------------------------------------------------------------------------- |
|
502 // |
|
503 // ----------------------------------------------------------------------------- |
|
504 // |
|
505 const TDesC8& CMceFileSource::SupportedAudio() |
|
506 { |
|
507 return FLAT_DATA( iFileInfo.iAudioCodec ); |
|
508 } |
|
509 |
|
510 // ----------------------------------------------------------------------------- |
|
511 // |
|
512 // ----------------------------------------------------------------------------- |
|
513 // |
|
514 const TMceFileInfo& CMceFileSource::FileInfo() |
|
515 { |
|
516 return FLAT_DATA( iFileInfo ); |
|
517 } |
|
518 |
|
519 // ----------------------------------------------------------------------------- |
|
520 // |
|
521 // ----------------------------------------------------------------------------- |
|
522 // |
|
523 void CMceFileSource::StreamAddedL( CMceMediaStream& aParent ) |
|
524 { |
|
525 CMceMediaSource::StreamAddedL( aParent ); |
|
526 |
|
527 if ( iManager ) //not intialized |
|
528 { |
|
529 SynchronizeWithStreamL(); |
|
530 } |
|
531 |
|
532 } |
|
533 |
|
534 |
|
535 |
|
536 // ----------------------------------------------------------------------------- |
|
537 // Factory method for inner usage |
|
538 // ----------------------------------------------------------------------------- |
|
539 // |
|
540 CMceFileSource* CMceFileSource::NewL() |
|
541 { |
|
542 CMceFileSource* self = CMceFileSource::NewLC(); |
|
543 CleanupStack::Pop( self ); |
|
544 return self; |
|
545 } |
|
546 |
|
547 |
|
548 // ----------------------------------------------------------------------------- |
|
549 // Factory method for inner usage |
|
550 // ----------------------------------------------------------------------------- |
|
551 // |
|
552 CMceFileSource* CMceFileSource::NewLC() |
|
553 { |
|
554 CMceFileSource* self = new (ELeave) CMceFileSource(); |
|
555 CleanupStack::PushL( self ); |
|
556 self->ConstructL( NULL, KNullDesC() ); |
|
557 return self; |
|
558 } |
|
559 |
|
560 |
|
561 // ----------------------------------------------------------------------------- |
|
562 // |
|
563 // ----------------------------------------------------------------------------- |
|
564 // |
|
565 CMceFileSource::CMceFileSource() |
|
566 { |
|
567 } |
|
568 |
|
569 |
|
570 // ----------------------------------------------------------------------------- |
|
571 // CMceFileSource::Updated |
|
572 // ----------------------------------------------------------------------------- |
|
573 // |
|
574 void CMceFileSource::Updated() |
|
575 { |
|
576 MMceStreamObserver* observer = iManager->MediaObserver(); |
|
577 |
|
578 if ( observer && iParents.Count() > 0 ) |
|
579 { |
|
580 observer->StreamStateChanged( *iParents[ 0 ], *this ); |
|
581 } |
|
582 } |
|
583 |
|
584 |
|
585 // ----------------------------------------------------------------------------- |
|
586 // CMceFileSource::EventReceivedL |
|
587 // ----------------------------------------------------------------------------- |
|
588 // |
|
589 TInt CMceFileSource::EventReceivedL( TMceEvent& aEvent ) |
|
590 { |
|
591 TInt status = CMceMediaSource::EventReceivedL( aEvent ); |
|
592 if ( status != KMceEventNotConsumed ) |
|
593 { |
|
594 return status; |
|
595 } |
|
596 |
|
597 if ( aEvent.Id().IsSourceId() ) |
|
598 { |
|
599 if ( aEvent.Action() == EMceItcTranscodingCompleted ) |
|
600 { |
|
601 // If we leave here, client cannot interpret the failure |
|
602 TRAPD( err, TranscodingCompletedL( aEvent ) ) |
|
603 if ( err ) |
|
604 { |
|
605 // Client will see that transcoding failed as file info is not |
|
606 // updated and stream will stay in transcoding needed state. |
|
607 MCECLI_DEBUG("CMceFileSource::EventReceivedL, transcoding failed"); |
|
608 const TInt KMceTranscodingCompletedPercentage = 100; |
|
609 FLAT_DATA( iTranscodeInfo.iProgress ) = KMceTranscodingCompletedPercentage; |
|
610 } |
|
611 |
|
612 SynchronizeWithStreamL(); |
|
613 |
|
614 } |
|
615 status = HandleEvent( aEvent ); |
|
616 |
|
617 } |
|
618 else |
|
619 { |
|
620 status = KMceEventNotConsumed; |
|
621 } |
|
622 |
|
623 return status; |
|
624 |
|
625 } |
|
626 |
|
627 // ----------------------------------------------------------------------------- |
|
628 // CMceFileSource::GetFileInfoL |
|
629 // ----------------------------------------------------------------------------- |
|
630 // |
|
631 void CMceFileSource::GetFileInfoL( TBool aUseSession ) |
|
632 { |
|
633 TMceIds ids; |
|
634 TMceItcArgTFileInfo fileInfoBuf( FLAT_DATA( iFileInfo ) ); |
|
635 |
|
636 if ( iStream && iStream->Id().IsAssigned() && |
|
637 Id().IsAssigned() && aUseSession ) |
|
638 { |
|
639 |
|
640 iStream->Session()->PrepareForITC( ids ); |
|
641 ids.iMediaID = iStream->Id(); |
|
642 ids.iSourceID = Id(); |
|
643 iStream->Session()->ITCSender().ReadL( ids, EMceItcFileInfo, fileInfoBuf ); |
|
644 } |
|
645 else |
|
646 { |
|
647 ids.iAppUID = iManager->AppUid().iUid; |
|
648 _FLAT_DATA->SenderL( |
|
649 iManager->ServerSession() ).ReadL( ids, EMceItcFileInfo, fileInfoBuf ); |
|
650 } |
|
651 |
|
652 FLAT_DATA( iFileInfo ) = fileInfoBuf(); |
|
653 |
|
654 User::LeaveIfError( FLAT_DATA( iFileInfo.iAccessRights ) == TMceFileInfo::EZero ? |
|
655 KErrAccessDenied : KErrNone ); |
|
656 |
|
657 } |
|
658 |
|
659 // ----------------------------------------------------------------------------- |
|
660 // CMceFileSource::SetFileInfoL |
|
661 // ----------------------------------------------------------------------------- |
|
662 // |
|
663 void CMceFileSource::SetFileInfoL() |
|
664 { |
|
665 |
|
666 if ( iStream && iStream->Id().IsAssigned() && |
|
667 Id().IsAssigned() ) |
|
668 { |
|
669 TMceIds ids; |
|
670 iStream->Session()->PrepareForITC( ids ); |
|
671 ids.iMediaID = iStream->Id(); |
|
672 ids.iSourceID = Id(); |
|
673 |
|
674 TMceItcArgTFileInfo fileInfo( FLAT_DATA( iFileInfo ) ); |
|
675 |
|
676 iStream->Session()->ITCSender().WriteL( ids, EMceItcSetFileInfo, fileInfo ); |
|
677 } |
|
678 } |
|
679 |
|
680 // ----------------------------------------------------------------------------- |
|
681 // CMceFileSource::HandleEvent |
|
682 // ----------------------------------------------------------------------------- |
|
683 // |
|
684 TInt CMceFileSource::HandleEvent( TMceEvent& aEvent ) |
|
685 { |
|
686 MCECLI_DEBUG("CMceFileSource::HandleEvent, Entry"); |
|
687 TInt status = KMceEventNotConsumed; |
|
688 |
|
689 if ( aEvent.Action() == EMceItcTranscodingCompleted ) |
|
690 { |
|
691 MCECLI_DEBUG("CMceFileSource::HandleEvent, transcoding completed"); |
|
692 iManager->TranscodeCompleted( *this ); |
|
693 status = KMceEventConsumed; |
|
694 Updated(); |
|
695 } |
|
696 else if ( aEvent.Action() == EMceItcTranscodingInProgress ) |
|
697 { |
|
698 MCECLI_DEBUG("CMceFileSource::HandleEvent, transcoding in progress"); |
|
699 FLAT_DATA( iTranscodeInfo.iProgress ) = aEvent.ActionData(); |
|
700 status = KMceEventConsumed; |
|
701 Updated(); |
|
702 } |
|
703 else |
|
704 { |
|
705 //NOP |
|
706 MCECLI_DEBUG("CMceFileSource::HandleEvent, not consumed"); |
|
707 } |
|
708 |
|
709 MCECLI_DEBUG_DVALUE("CMceFileSource::HandleEvent, Exit. status", status ); |
|
710 return status; |
|
711 } |
|
712 |
|
713 |
|
714 // ----------------------------------------------------------------------------- |
|
715 // CMceFileSource::ConstructL |
|
716 // ----------------------------------------------------------------------------- |
|
717 // |
|
718 void CMceFileSource::ConstructL( CMceManager* aManager, |
|
719 const TFileName& aFileName ) |
|
720 { |
|
721 CMceComFileSource* source = CMceComFileSource::NewLC(); |
|
722 CMceMediaSource::ConstructL( source ); |
|
723 CleanupStack::Pop( source ); |
|
724 |
|
725 FLAT_DATA( iFileInfo.iFileName ) = aFileName; |
|
726 FLAT_DATA( iFileInfo.iDirection ) = TMceFileInfo::ERead; |
|
727 |
|
728 if ( aManager ) |
|
729 { |
|
730 InitializeL( aManager ); |
|
731 } |
|
732 |
|
733 } |
|
734 |
|
735 // ----------------------------------------------------------------------------- |
|
736 // CMceFileSource::Manager |
|
737 // ----------------------------------------------------------------------------- |
|
738 // |
|
739 CMceManager* CMceFileSource::Manager() |
|
740 { |
|
741 return iManager; |
|
742 } |
|
743 |
|
744 // ----------------------------------------------------------------------------- |
|
745 // CMceFileSource::TranscodingCompletedL |
|
746 // ----------------------------------------------------------------------------- |
|
747 // |
|
748 void CMceFileSource::TranscodingCompletedL( TMceEvent& aEvent ) |
|
749 { |
|
750 // Update file to be the transcoded file only if transcoding |
|
751 // completed succesfully |
|
752 User::LeaveIfError( aEvent.Id().iStatus ); |
|
753 |
|
754 FLAT_DATA( iFileInfo.iFileName ) = FLAT_DATA( iTranscodeInfo.iFileName ); |
|
755 |
|
756 MCECLI_DEBUG("CMceFileSource::TranscodingCompletedL, querying file info"); |
|
757 // Get new info outside session |
|
758 GetFileInfoL( EFalse ); |
|
759 |
|
760 MCECLI_DEBUG("CMceFileSource::TranscodingCompletedL, setting file info"); |
|
761 // Set it to the session |
|
762 SetFileInfoL(); |
|
763 } |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // CMceFileSource::DoCancelTranscodeL |
|
767 // ----------------------------------------------------------------------------- |
|
768 // |
|
769 void CMceFileSource::DoCancelTranscodeL() |
|
770 { |
|
771 MCECLI_DEBUG("CMceDisplaySink::DoCancelTranscodeL, Entry"); |
|
772 |
|
773 __ASSERT_ALWAYS( iManager, User::Leave( KErrNotReady ) ); |
|
774 |
|
775 iManager->CancelTranscodeL( *this, |
|
776 FLAT_DATA( iTranscodeInfo.iTranscodeSessionId ) ); |
|
777 |
|
778 MCECLI_DEBUG("CMceDisplaySink::DoCancelTranscodeL, Exit"); |
|
779 } |
|
780 |
|
781 // End of File |
|
782 |