1 /* This file is part of the KDE project. |
|
2 |
|
3 Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 |
|
5 This library is free software: you can redistribute it and/or modify |
|
6 it under the terms of the GNU Lesser General Public License as published by |
|
7 the Free Software Foundation, either version 2.1 or 3 of the License. |
|
8 |
|
9 This library is distributed in the hope that it will be useful, |
|
10 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 GNU Lesser General Public License for more details. |
|
13 |
|
14 You should have received a copy of the GNU Lesser General Public License |
|
15 along with this library. If not, see <http://www.gnu.org/licenses/>. |
|
16 |
|
17 */ |
|
18 |
|
19 #include <QApplication> // for QApplication::activeWindow |
|
20 #include <QUrl> |
|
21 #include <QTimer> |
|
22 #include <QWidget> |
|
23 |
|
24 #include <coemain.h> // for CCoeEnv |
|
25 #include <coecntrl.h> |
|
26 |
|
27 #include "mmf_videoplayer.h" |
|
28 #include "utils.h" |
|
29 |
|
30 #ifndef QT_NO_DEBUG |
|
31 #include "objectdump.h" |
|
32 #endif |
|
33 |
|
34 QT_BEGIN_NAMESPACE |
|
35 |
|
36 using namespace Phonon; |
|
37 using namespace Phonon::MMF; |
|
38 |
|
39 /*! \class MMF::VideoPlayer |
|
40 \internal |
|
41 */ |
|
42 |
|
43 //----------------------------------------------------------------------------- |
|
44 // Constructor / destructor |
|
45 //----------------------------------------------------------------------------- |
|
46 |
|
47 MMF::VideoPlayer::VideoPlayer(MediaObject *parent, const AbstractPlayer *player) |
|
48 : AbstractMediaPlayer(parent, player) |
|
49 , m_wsSession(CCoeEnv::Static()->WsSession()) |
|
50 , m_screenDevice(*CCoeEnv::Static()->ScreenDevice()) |
|
51 , m_window(0) |
|
52 , m_totalTime(0) |
|
53 , m_pendingChanges(false) |
|
54 , m_dsaActive(false) |
|
55 { |
|
56 construct(); |
|
57 } |
|
58 |
|
59 void MMF::VideoPlayer::construct() |
|
60 { |
|
61 TRACE_CONTEXT(VideoPlayer::VideoPlayer, EVideoApi); |
|
62 TRACE_ENTRY_0(); |
|
63 |
|
64 getVideoWindow(); |
|
65 |
|
66 const TInt priority = 0; |
|
67 const TMdaPriorityPreference preference = EMdaPriorityPreferenceNone; |
|
68 |
|
69 CVideoPlayerUtility *player = 0; |
|
70 QT_TRAP_THROWING(player = CVideoPlayerUtility::NewL |
|
71 ( |
|
72 *this, |
|
73 priority, preference, |
|
74 m_wsSession, m_screenDevice, |
|
75 *m_window, |
|
76 m_videoRect, m_videoRect |
|
77 ) |
|
78 ); |
|
79 m_player.reset(player); |
|
80 |
|
81 // CVideoPlayerUtility::NewL starts DSA |
|
82 m_dsaActive = true; |
|
83 |
|
84 m_player->RegisterForVideoLoadingNotification(*this); |
|
85 |
|
86 TRACE_EXIT_0(); |
|
87 } |
|
88 |
|
89 MMF::VideoPlayer::~VideoPlayer() |
|
90 { |
|
91 TRACE_CONTEXT(VideoPlayer::~VideoPlayer, EVideoApi); |
|
92 TRACE_ENTRY_0(); |
|
93 |
|
94 // QObject destructor removes all signal-slot connections involving this |
|
95 // object, so we do not need to disconnect from m_videoOutput here. |
|
96 |
|
97 TRACE_EXIT_0(); |
|
98 } |
|
99 |
|
100 CVideoPlayerUtility* MMF::VideoPlayer::nativePlayer() const |
|
101 { |
|
102 return m_player.data(); |
|
103 } |
|
104 |
|
105 //----------------------------------------------------------------------------- |
|
106 // Public API |
|
107 //----------------------------------------------------------------------------- |
|
108 |
|
109 void MMF::VideoPlayer::doPlay() |
|
110 { |
|
111 TRACE_CONTEXT(VideoPlayer::doPlay, EVideoApi); |
|
112 |
|
113 applyPendingChanges(); |
|
114 |
|
115 m_player->Play(); |
|
116 } |
|
117 |
|
118 void MMF::VideoPlayer::doPause() |
|
119 { |
|
120 TRACE_CONTEXT(VideoPlayer::doPause, EVideoApi); |
|
121 |
|
122 TRAPD(err, m_player->PauseL()); |
|
123 if (KErrNone != err && state() != ErrorState) { |
|
124 TRACE("PauseL error %d", err); |
|
125 setError(tr("Pause failed"), err); |
|
126 } |
|
127 } |
|
128 |
|
129 void MMF::VideoPlayer::doStop() |
|
130 { |
|
131 m_player->Stop(); |
|
132 } |
|
133 |
|
134 void MMF::VideoPlayer::doSeek(qint64 ms) |
|
135 { |
|
136 TRACE_CONTEXT(VideoPlayer::doSeek, EVideoApi); |
|
137 |
|
138 TRAPD(err, m_player->SetPositionL(TTimeIntervalMicroSeconds(ms * 1000))); |
|
139 |
|
140 if(KErrNone != err) |
|
141 setError(tr("Seek failed"), err); |
|
142 } |
|
143 |
|
144 int MMF::VideoPlayer::setDeviceVolume(int mmfVolume) |
|
145 { |
|
146 TRAPD(err, m_player->SetVolumeL(mmfVolume)); |
|
147 return err; |
|
148 } |
|
149 |
|
150 int MMF::VideoPlayer::openFile(RFile& file) |
|
151 { |
|
152 TRAPD(err, m_player->OpenFileL(file)); |
|
153 return err; |
|
154 } |
|
155 |
|
156 int MMF::VideoPlayer::openUrl(const QString& url) |
|
157 { |
|
158 TRAPD(err, m_player->OpenUrlL(qt_QString2TPtrC(url))); |
|
159 return err; |
|
160 } |
|
161 |
|
162 int MMF::VideoPlayer::bufferStatus() const |
|
163 { |
|
164 int result = 0; |
|
165 TRAP_IGNORE(m_player->GetVideoLoadingProgressL(result)); |
|
166 return result; |
|
167 } |
|
168 |
|
169 void MMF::VideoPlayer::close() |
|
170 { |
|
171 m_player->Close(); |
|
172 } |
|
173 |
|
174 bool MMF::VideoPlayer::hasVideo() const |
|
175 { |
|
176 return true; |
|
177 } |
|
178 |
|
179 qint64 MMF::VideoPlayer::currentTime() const |
|
180 { |
|
181 TRACE_CONTEXT(VideoPlayer::currentTime, EVideoApi); |
|
182 |
|
183 TTimeIntervalMicroSeconds us; |
|
184 TRAPD(err, us = m_player->PositionL()) |
|
185 |
|
186 qint64 result = 0; |
|
187 |
|
188 if (KErrNone == err) { |
|
189 result = toMilliSeconds(us); |
|
190 } else { |
|
191 TRACE("PositionL error %d", err); |
|
192 |
|
193 // If we don't cast away constness here, we simply have to ignore |
|
194 // the error. |
|
195 const_cast<VideoPlayer*>(this)->setError(tr("Getting position failed"), err); |
|
196 } |
|
197 |
|
198 return result; |
|
199 } |
|
200 |
|
201 qint64 MMF::VideoPlayer::totalTime() const |
|
202 { |
|
203 return m_totalTime; |
|
204 } |
|
205 |
|
206 |
|
207 //----------------------------------------------------------------------------- |
|
208 // MVideoPlayerUtilityObserver callbacks |
|
209 //----------------------------------------------------------------------------- |
|
210 |
|
211 void MMF::VideoPlayer::MvpuoOpenComplete(TInt aError) |
|
212 { |
|
213 TRACE_CONTEXT(VideoPlayer::MvpuoOpenComplete, EVideoApi); |
|
214 TRACE_ENTRY("state %d error %d", state(), aError); |
|
215 |
|
216 __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); |
|
217 |
|
218 if (KErrNone == aError) |
|
219 m_player->Prepare(); |
|
220 else |
|
221 setError(tr("Opening clip failed"), aError); |
|
222 |
|
223 TRACE_EXIT_0(); |
|
224 } |
|
225 |
|
226 void MMF::VideoPlayer::MvpuoPrepareComplete(TInt aError) |
|
227 { |
|
228 TRACE_CONTEXT(VideoPlayer::MvpuoPrepareComplete, EVideoApi); |
|
229 TRACE_ENTRY("state %d error %d", state(), aError); |
|
230 |
|
231 __ASSERT_ALWAYS(LoadingState == state(), Utils::panic(InvalidStatePanic)); |
|
232 |
|
233 TRAPD(err, doPrepareCompleteL(aError)); |
|
234 |
|
235 if (KErrNone == err) { |
|
236 maxVolumeChanged(m_player->MaxVolume()); |
|
237 |
|
238 if (m_videoOutput) |
|
239 m_videoOutput->setVideoSize(m_videoFrameSize); |
|
240 |
|
241 updateVideoRect(); |
|
242 applyPendingChanges(); |
|
243 |
|
244 emit totalTimeChanged(totalTime()); |
|
245 changeState(StoppedState); |
|
246 } else { |
|
247 setError(tr("Buffering clip failed"), err); |
|
248 } |
|
249 |
|
250 TRACE_EXIT_0(); |
|
251 } |
|
252 |
|
253 void MMF::VideoPlayer::doPrepareCompleteL(TInt aError) |
|
254 { |
|
255 User::LeaveIfError(aError); |
|
256 |
|
257 // Get frame size |
|
258 TSize size; |
|
259 m_player->VideoFrameSizeL(size); |
|
260 m_videoFrameSize = QSize(size.iWidth, size.iHeight); |
|
261 |
|
262 // Get duration |
|
263 m_totalTime = toMilliSeconds(m_player->DurationL()); |
|
264 } |
|
265 |
|
266 |
|
267 void MMF::VideoPlayer::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) |
|
268 { |
|
269 TRACE_CONTEXT(VideoPlayer::MvpuoFrameReady, EVideoApi); |
|
270 TRACE_ENTRY("state %d error %d", state(), aError); |
|
271 |
|
272 Q_UNUSED(aFrame); |
|
273 Q_UNUSED(aError); // suppress warnings in release builds |
|
274 |
|
275 TRACE_EXIT_0(); |
|
276 } |
|
277 |
|
278 void MMF::VideoPlayer::MvpuoPlayComplete(TInt aError) |
|
279 { |
|
280 TRACE_CONTEXT(VideoPlayer::MvpuoPlayComplete, EVideoApi) |
|
281 TRACE_ENTRY("state %d error %d", state(), aError); |
|
282 |
|
283 // Call base class function which handles end of playback for both |
|
284 // audio and video clips. |
|
285 playbackComplete(aError); |
|
286 |
|
287 TRACE_EXIT_0(); |
|
288 } |
|
289 |
|
290 void MMF::VideoPlayer::MvpuoEvent(const TMMFEvent &aEvent) |
|
291 { |
|
292 TRACE_CONTEXT(VideoPlayer::MvpuoEvent, EVideoApi); |
|
293 TRACE_ENTRY("state %d", state()); |
|
294 |
|
295 Q_UNUSED(aEvent); |
|
296 |
|
297 TRACE_EXIT_0(); |
|
298 } |
|
299 |
|
300 |
|
301 //----------------------------------------------------------------------------- |
|
302 // MVideoLoadingObserver callbacks |
|
303 //----------------------------------------------------------------------------- |
|
304 |
|
305 void MMF::VideoPlayer::MvloLoadingStarted() |
|
306 { |
|
307 bufferingStarted(); |
|
308 } |
|
309 |
|
310 void MMF::VideoPlayer::MvloLoadingComplete() |
|
311 { |
|
312 bufferingComplete(); |
|
313 } |
|
314 |
|
315 |
|
316 //----------------------------------------------------------------------------- |
|
317 // Video window updates |
|
318 //----------------------------------------------------------------------------- |
|
319 |
|
320 void MMF::VideoPlayer::getVideoWindow() |
|
321 { |
|
322 TRACE_CONTEXT(VideoPlayer::getVideoWindow, EVideoInternal); |
|
323 TRACE_ENTRY_0(); |
|
324 |
|
325 if(m_videoOutput) { |
|
326 // Dump information to log, only in debug builds |
|
327 m_videoOutput->dump(); |
|
328 |
|
329 initVideoOutput(); |
|
330 videoWindowChanged(); |
|
331 } else |
|
332 // Top-level window |
|
333 m_window = QApplication::activeWindow()->effectiveWinId()->DrawableWindow(); |
|
334 |
|
335 TRACE_EXIT_0(); |
|
336 } |
|
337 |
|
338 void MMF::VideoPlayer::videoOutputChanged() |
|
339 { |
|
340 TRACE_CONTEXT(VideoPlayer::videoOutputChanged, EVideoInternal); |
|
341 TRACE_ENTRY_0(); |
|
342 |
|
343 if (m_videoOutput) { |
|
344 initVideoOutput(); |
|
345 videoWindowChanged(); |
|
346 } |
|
347 |
|
348 TRACE_EXIT_0(); |
|
349 } |
|
350 |
|
351 void MMF::VideoPlayer::initVideoOutput() |
|
352 { |
|
353 m_videoOutput->winId(); |
|
354 m_videoOutput->setVideoSize(m_videoFrameSize); |
|
355 |
|
356 bool connected = connect( |
|
357 m_videoOutput, SIGNAL(videoWindowChanged()), |
|
358 this, SLOT(videoWindowChanged()) |
|
359 ); |
|
360 Q_ASSERT(connected); |
|
361 |
|
362 connected = connect( |
|
363 m_videoOutput, SIGNAL(beginVideoWindowNativePaint()), |
|
364 this, SLOT(suspendDirectScreenAccess()) |
|
365 ); |
|
366 Q_ASSERT(connected); |
|
367 |
|
368 connected = connect( |
|
369 m_videoOutput, SIGNAL(endVideoWindowNativePaint()), |
|
370 this, SLOT(resumeDirectScreenAccess()) |
|
371 ); |
|
372 Q_ASSERT(connected); |
|
373 |
|
374 connected = connect( |
|
375 m_videoOutput, SIGNAL(aspectRatioChanged()), |
|
376 this, SLOT(aspectRatioChanged()) |
|
377 ); |
|
378 Q_ASSERT(connected); |
|
379 |
|
380 connected = connect( |
|
381 m_videoOutput, SIGNAL(scaleModeChanged()), |
|
382 this, SLOT(scaleModeChanged()) |
|
383 ); |
|
384 Q_ASSERT(connected); |
|
385 |
|
386 // Suppress warnings in release builds |
|
387 Q_UNUSED(connected); |
|
388 } |
|
389 |
|
390 void MMF::VideoPlayer::videoWindowChanged() |
|
391 { |
|
392 TRACE_CONTEXT(VideoPlayer::videoOutputRegionChanged, EVideoInternal); |
|
393 TRACE_ENTRY("state %d", state()); |
|
394 |
|
395 m_window = m_videoOutput->videoWindow(); |
|
396 updateVideoRect(); |
|
397 |
|
398 TRACE_EXIT_0(); |
|
399 } |
|
400 |
|
401 void MMF::VideoPlayer::suspendDirectScreenAccess() |
|
402 { |
|
403 m_dsaWasActive = stopDirectScreenAccess(); |
|
404 } |
|
405 |
|
406 void MMF::VideoPlayer::resumeDirectScreenAccess() |
|
407 { |
|
408 if(m_dsaWasActive) { |
|
409 startDirectScreenAccess(); |
|
410 m_dsaWasActive = false; |
|
411 } |
|
412 } |
|
413 |
|
414 void MMF::VideoPlayer::startDirectScreenAccess() |
|
415 { |
|
416 if(!m_dsaActive) { |
|
417 TRAPD(err, m_player->StartDirectScreenAccessL()); |
|
418 if(KErrNone == err) |
|
419 m_dsaActive = true; |
|
420 else |
|
421 setError(tr("Video display error"), err); |
|
422 } |
|
423 } |
|
424 |
|
425 bool MMF::VideoPlayer::stopDirectScreenAccess() |
|
426 { |
|
427 const bool dsaWasActive = m_dsaActive; |
|
428 if(m_dsaActive) { |
|
429 TRAPD(err, m_player->StopDirectScreenAccessL()); |
|
430 if(KErrNone == err) |
|
431 m_dsaActive = false; |
|
432 else |
|
433 setError(tr("Video display error"), err); |
|
434 } |
|
435 return dsaWasActive; |
|
436 } |
|
437 |
|
438 // Helper function for aspect ratio / scale mode handling |
|
439 QSize scaleToAspect(const QSize& srcRect, int aspectWidth, int aspectHeight) |
|
440 { |
|
441 const qreal aspectRatio = qreal(aspectWidth) / aspectHeight; |
|
442 |
|
443 int width = srcRect.width(); |
|
444 int height = srcRect.width() / aspectRatio; |
|
445 if (height > srcRect.height()){ |
|
446 height = srcRect.height(); |
|
447 width = srcRect.height() * aspectRatio; |
|
448 } |
|
449 return QSize(width, height); |
|
450 } |
|
451 |
|
452 void MMF::VideoPlayer::updateVideoRect() |
|
453 { |
|
454 QRect videoRect; |
|
455 QRect windowRect = m_videoOutput->videoWindowRect(); |
|
456 |
|
457 // Clip to physical window size |
|
458 // This is due to a defect in the layout when running on S60 3.2, which |
|
459 // results in the rectangle of the video widget extending outside the |
|
460 // screen in certain circumstances. These include the initial startup |
|
461 // of the mediaplayer demo in portrait mode. When this rectangle is |
|
462 // passed to the CVideoPlayerUtility, no video is rendered. |
|
463 const TSize screenSize = m_screenDevice.SizeInPixels(); |
|
464 const QRect screenRect(0, 0, screenSize.iWidth, screenSize.iHeight); |
|
465 windowRect = windowRect.intersected(screenRect); |
|
466 |
|
467 const QSize windowSize = windowRect.size(); |
|
468 |
|
469 // Calculate size of smallest rect which contains video frame size |
|
470 // and conforms to aspect ratio |
|
471 switch (m_videoOutput->aspectRatio()) { |
|
472 case Phonon::VideoWidget::AspectRatioAuto: |
|
473 videoRect.setSize(m_videoFrameSize); |
|
474 break; |
|
475 |
|
476 case Phonon::VideoWidget::AspectRatioWidget: |
|
477 videoRect.setSize(windowSize); |
|
478 break; |
|
479 |
|
480 case Phonon::VideoWidget::AspectRatio4_3: |
|
481 videoRect.setSize(scaleToAspect(m_videoFrameSize, 4, 3)); |
|
482 break; |
|
483 |
|
484 case Phonon::VideoWidget::AspectRatio16_9: |
|
485 videoRect.setSize(scaleToAspect(m_videoFrameSize, 16, 9)); |
|
486 break; |
|
487 } |
|
488 |
|
489 // Scale to fill the window width |
|
490 const int windowWidth = windowSize.width(); |
|
491 const int windowHeight = windowSize.height(); |
|
492 const qreal windowScaleFactor = qreal(windowWidth) / videoRect.width(); |
|
493 int videoWidth = windowWidth; |
|
494 int videoHeight = videoRect.height() * windowScaleFactor; |
|
495 |
|
496 const qreal windowToVideoHeightRatio = qreal(windowHeight) / videoHeight; |
|
497 |
|
498 switch(m_videoOutput->scaleMode()) { |
|
499 case Phonon::VideoWidget::ScaleAndCrop: |
|
500 if(videoHeight < windowHeight) { |
|
501 videoWidth *= windowToVideoHeightRatio; |
|
502 videoHeight = windowHeight; |
|
503 } |
|
504 break; |
|
505 case Phonon::VideoWidget::FitInView: |
|
506 default: |
|
507 if(videoHeight > windowHeight) { |
|
508 videoWidth *= windowToVideoHeightRatio; |
|
509 videoHeight = windowHeight; |
|
510 } |
|
511 break; |
|
512 } |
|
513 |
|
514 // Calculate scale factors |
|
515 m_scaleWidth = 100.0f * videoWidth / m_videoFrameSize.width(); |
|
516 m_scaleHeight = 100.0f * videoHeight / m_videoFrameSize.height(); |
|
517 |
|
518 m_videoRect = qt_QRect2TRect(windowRect); |
|
519 |
|
520 if (state() == LoadingState) |
|
521 m_pendingChanges = true; |
|
522 else { |
|
523 applyVideoWindowChange(); |
|
524 m_pendingChanges = false; |
|
525 } |
|
526 } |
|
527 |
|
528 void MMF::VideoPlayer::aspectRatioChanged() |
|
529 { |
|
530 TRACE_CONTEXT(VideoPlayer::aspectRatioChanged, EVideoInternal); |
|
531 TRACE_ENTRY("state %d aspectRatio %d", state()); |
|
532 |
|
533 updateVideoRect(); |
|
534 |
|
535 TRACE_EXIT_0(); |
|
536 } |
|
537 |
|
538 void MMF::VideoPlayer::scaleModeChanged() |
|
539 { |
|
540 TRACE_CONTEXT(VideoPlayer::scaleModeChanged, EVideoInternal); |
|
541 TRACE_ENTRY("state %d", state()); |
|
542 |
|
543 updateVideoRect(); |
|
544 |
|
545 TRACE_EXIT_0(); |
|
546 } |
|
547 |
|
548 #ifndef QT_NO_DEBUG |
|
549 |
|
550 // The following code is for debugging problems related to video visibility. It allows |
|
551 // the VideoPlayer instance to query the window server in order to determine the |
|
552 // DSA drawing region for the video window. |
|
553 |
|
554 class CDummyAO : public CActive |
|
555 { |
|
556 public: |
|
557 CDummyAO() : CActive(CActive::EPriorityStandard) { CActiveScheduler::Add(this); } |
|
558 void RunL() { } |
|
559 void DoCancel() { } |
|
560 TRequestStatus& Status() { return iStatus; } |
|
561 void SetActive() { CActive::SetActive(); } |
|
562 }; |
|
563 |
|
564 void getDsaRegion(RWsSession &session, const RWindowBase &window) |
|
565 { |
|
566 RDirectScreenAccess dsa(session); |
|
567 TInt err = dsa.Construct(); |
|
568 CDummyAO ao; |
|
569 RRegion* region; |
|
570 err = dsa.Request(region, ao.Status(), window); |
|
571 ao.SetActive(); |
|
572 dsa.Close(); |
|
573 ao.Cancel(); |
|
574 if (region) { |
|
575 qDebug() << "Phonon::MMF::getDsaRegion count" << region->Count(); |
|
576 for (int i=0; i<region->Count(); ++i) { |
|
577 const TRect& rect = region->RectangleList()[i]; |
|
578 qDebug() << "Phonon::MMF::getDsaRegion rect" |
|
579 << rect.iTl.iX << rect.iTl.iY << rect.iBr.iX << rect.iBr.iY; |
|
580 } |
|
581 region->Close(); |
|
582 } |
|
583 } |
|
584 |
|
585 #endif // _DEBUG |
|
586 |
|
587 void MMF::VideoPlayer::applyPendingChanges() |
|
588 { |
|
589 if(m_pendingChanges) |
|
590 applyVideoWindowChange(); |
|
591 |
|
592 m_pendingChanges = false; |
|
593 } |
|
594 |
|
595 void MMF::VideoPlayer::applyVideoWindowChange() |
|
596 { |
|
597 TRACE_CONTEXT(VideoPlayer::applyVideoWindowChange, EVideoInternal); |
|
598 TRACE_ENTRY_0(); |
|
599 |
|
600 #ifndef QT_NO_DEBUG |
|
601 getDsaRegion(m_wsSession, *m_window); |
|
602 #endif |
|
603 |
|
604 static const TBool antialias = ETrue; |
|
605 |
|
606 TRAPD(err, m_player->SetScaleFactorL(m_scaleWidth, m_scaleHeight, antialias)); |
|
607 if(KErrNone != err) { |
|
608 TRACE("SetScaleFactorL (1) err %d", err); |
|
609 setError(tr("Video display error"), err); |
|
610 } |
|
611 |
|
612 if(KErrNone == err) { |
|
613 TRAP(err, |
|
614 m_player->SetDisplayWindowL |
|
615 ( |
|
616 m_wsSession, m_screenDevice, |
|
617 *m_window, |
|
618 m_videoRect, m_videoRect |
|
619 ) |
|
620 ); |
|
621 |
|
622 if (KErrNone != err) { |
|
623 TRACE("SetDisplayWindowL err %d", err); |
|
624 setError(tr("Video display error"), err); |
|
625 } else { |
|
626 m_dsaActive = true; |
|
627 TRAP(err, m_player->SetScaleFactorL(m_scaleWidth, m_scaleHeight, antialias)); |
|
628 if(KErrNone != err) { |
|
629 TRACE("SetScaleFactorL (2) err %d", err); |
|
630 setError(tr("Video display error"), err); |
|
631 } |
|
632 } |
|
633 } |
|
634 |
|
635 TRACE_EXIT_0(); |
|
636 } |
|
637 |
|
638 |
|
639 //----------------------------------------------------------------------------- |
|
640 // Metadata |
|
641 //----------------------------------------------------------------------------- |
|
642 |
|
643 int MMF::VideoPlayer::numberOfMetaDataEntries() const |
|
644 { |
|
645 int numberOfEntries = 0; |
|
646 TRAP_IGNORE(numberOfEntries = m_player->NumberOfMetaDataEntriesL()); |
|
647 return numberOfEntries; |
|
648 } |
|
649 |
|
650 QPair<QString, QString> MMF::VideoPlayer::metaDataEntry(int index) const |
|
651 { |
|
652 CMMFMetaDataEntry *entry = 0; |
|
653 QT_TRAP_THROWING(entry = m_player->MetaDataEntryL(index)); |
|
654 return QPair<QString, QString>(qt_TDesC2QString(entry->Name()), qt_TDesC2QString(entry->Value())); |
|
655 } |
|
656 |
|
657 QT_END_NAMESPACE |
|
658 |
|