|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the Qt Mobility Components. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 #include "s60videoplayersession.h" |
|
43 #include "s60videowidget.h" |
|
44 #include "s60mediaplayerservice.h" |
|
45 #include "s60videooverlay.h" |
|
46 |
|
47 #include <QtGui/qwidget.h> |
|
48 #include <QtCore/qtimer.h> |
|
49 #include <QApplication> |
|
50 |
|
51 #include <coecntrl.h> |
|
52 #include <coemain.h> // For CCoeEnv |
|
53 #include <w32std.h> |
|
54 #include <mmf/common/mmfcontrollerframeworkbase.h> |
|
55 |
|
56 S60VideoPlayerSession::S60VideoPlayerSession(QMediaService *service) |
|
57 : S60MediaPlayerSession(service) |
|
58 , m_player(0) |
|
59 , m_rect(0, 0, 0, 0) |
|
60 , m_videoOutput(0) |
|
61 , m_windowId(0) |
|
62 , m_dsaActive(false) |
|
63 , m_dsaStopped(false) |
|
64 , m_wsSession(CCoeEnv::Static()->WsSession()) |
|
65 , m_screenDevice(*CCoeEnv::Static()->ScreenDevice()) |
|
66 , m_window(0) |
|
67 , m_displayWindow(0) |
|
68 , m_service(*service) |
|
69 , m_aspectRatioMode(Qt::KeepAspectRatio) |
|
70 , m_originalSize(1, 1) |
|
71 , m_audioEndpoint("Default") |
|
72 { |
|
73 #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER |
|
74 m_audioOutput = 0; |
|
75 #endif |
|
76 |
|
77 #ifdef MMF_VIDEO_SURFACES_SUPPORTED |
|
78 QT_TRAP_THROWING(m_player = CVideoPlayerUtility2::NewL( |
|
79 *this, |
|
80 0, |
|
81 EMdaPriorityPreferenceNone |
|
82 )); |
|
83 #else |
|
84 resetNativeHandles(); |
|
85 QT_TRAP_THROWING(m_player = CVideoPlayerUtility::NewL( |
|
86 *this, |
|
87 0, |
|
88 EMdaPriorityPreferenceNone, |
|
89 m_wsSession, |
|
90 m_screenDevice, |
|
91 *m_window, |
|
92 m_rect, |
|
93 m_rect)); |
|
94 m_dsaActive = true; |
|
95 m_player->RegisterForVideoLoadingNotification(*this); |
|
96 #endif // MMF_VIDEO_SURFACES_SUPPORTED |
|
97 } |
|
98 |
|
99 S60VideoPlayerSession::~S60VideoPlayerSession() |
|
100 { |
|
101 #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER |
|
102 if (m_audioOutput) |
|
103 m_audioOutput->UnregisterObserver(*this); |
|
104 delete m_audioOutput; |
|
105 #endif |
|
106 if (m_player) { |
|
107 m_player->Close(); |
|
108 delete m_player; |
|
109 m_player = NULL; |
|
110 } |
|
111 } |
|
112 |
|
113 void S60VideoPlayerSession::doLoadL(const TDesC &path) |
|
114 { |
|
115 #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER |
|
116 // m_audioOutput needs to be reinitialized after MapcInitComplete |
|
117 if (m_audioOutput) |
|
118 m_audioOutput->UnregisterObserver(*this); |
|
119 delete m_audioOutput; |
|
120 m_audioOutput = NULL; |
|
121 #endif |
|
122 m_player->OpenFileL(path); |
|
123 } |
|
124 |
|
125 void S60VideoPlayerSession::doLoadUrlL(const TDesC &path) |
|
126 { |
|
127 #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER |
|
128 // m_audioOutput needs to be reinitialized after MapcInitComplete |
|
129 if (m_audioOutput) |
|
130 m_audioOutput->UnregisterObserver(*this); |
|
131 delete m_audioOutput; |
|
132 m_audioOutput = NULL; |
|
133 #endif |
|
134 m_player->OpenUrlL(path); |
|
135 } |
|
136 |
|
137 int S60VideoPlayerSession::doGetBufferStatusL() const |
|
138 { |
|
139 int progress = 0; |
|
140 m_player->GetVideoLoadingProgressL(progress); |
|
141 return progress; |
|
142 } |
|
143 |
|
144 qint64 S60VideoPlayerSession::doGetDurationL() const |
|
145 { |
|
146 return m_player->DurationL().Int64() / qint64(1000); |
|
147 } |
|
148 |
|
149 #ifdef MMF_VIDEO_SURFACES_SUPPORTED |
|
150 void S60VideoPlayerSession::setVideoRenderer(QObject *videoOutput) |
|
151 { |
|
152 if (videoOutput == m_videoOutput) |
|
153 return; |
|
154 |
|
155 S60VideoWidgetControl *newWidgetControl = qobject_cast<S60VideoWidgetControl *>(videoOutput); |
|
156 S60VideoWidgetControl *oldWidgetControl = qobject_cast<S60VideoWidgetControl *>(m_videoOutput); |
|
157 |
|
158 if (oldWidgetControl) { |
|
159 disconnect(oldWidgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay())); |
|
160 disconnect(oldWidgetControl, SIGNAL(widgetResized()), this, SLOT(resizeVideoWindow())); |
|
161 disconnect(this, SIGNAL(stateChanged(QMediaPlayer::State)), oldWidgetControl, SLOT(videoStateChanged(QMediaPlayer::State))); |
|
162 } |
|
163 if (newWidgetControl) { |
|
164 connect(newWidgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay())); |
|
165 connect(newWidgetControl, SIGNAL(widgetResized()), this, SLOT(resizeVideoWindow())); |
|
166 connect(this, SIGNAL(stateChanged(QMediaPlayer::State)), newWidgetControl, SLOT(videoStateChanged(QMediaPlayer::State))); |
|
167 } |
|
168 |
|
169 m_videoOutput = videoOutput; |
|
170 resetVideoDisplay(); |
|
171 } |
|
172 #else // MMF_VIDEO_SURFACES_SUPPORTED |
|
173 void S60VideoPlayerSession::setVideoRenderer(QObject *videoOutput) |
|
174 { |
|
175 if (videoOutput == m_videoOutput) |
|
176 return; |
|
177 |
|
178 S60VideoWidgetControl *newWidgetControl = qobject_cast<S60VideoWidgetControl *>(videoOutput); |
|
179 S60VideoWidgetControl *oldWidgetControl = qobject_cast<S60VideoWidgetControl *>(m_videoOutput); |
|
180 |
|
181 if (oldWidgetControl) { |
|
182 disconnect(oldWidgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay())); |
|
183 disconnect(oldWidgetControl, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess())); |
|
184 disconnect(oldWidgetControl, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess())); |
|
185 disconnect(this, SIGNAL(stateChanged(QMediaPlayer::State)), oldWidgetControl, SLOT(videoStateChanged(QMediaPlayer::State))); |
|
186 } |
|
187 if (newWidgetControl) { |
|
188 connect(newWidgetControl, SIGNAL(widgetUpdated()), this, SLOT(resetVideoDisplay())); |
|
189 connect(newWidgetControl, SIGNAL(beginVideoWindowNativePaint()), this, SLOT(suspendDirectScreenAccess())); |
|
190 connect(newWidgetControl, SIGNAL(endVideoWindowNativePaint()), this, SLOT(resumeDirectScreenAccess())); |
|
191 connect(this, SIGNAL(stateChanged(QMediaPlayer::State)), newWidgetControl, SLOT(videoStateChanged(QMediaPlayer::State))); |
|
192 } |
|
193 m_videoOutput = videoOutput; |
|
194 resetVideoDisplay(); |
|
195 } |
|
196 #endif // MMF_VIDEO_SURFACES_SUPPORTED |
|
197 |
|
198 bool S60VideoPlayerSession::resetNativeHandles() |
|
199 { |
|
200 WId newId = 0; |
|
201 TRect newRect = TRect(0,0,0,0); |
|
202 Qt::AspectRatioMode aspectRatioMode = Qt::KeepAspectRatio; |
|
203 |
|
204 S60VideoWidgetControl *widgetControl; |
|
205 |
|
206 if (!m_videoOutput) // this is for pre Symbian^3 devices as we need output for CVideoPlayerUtility |
|
207 widgetControl = qobject_cast<S60VideoWidgetControl *>(m_service.requestControl(QVideoWidgetControl_iid)); |
|
208 else |
|
209 widgetControl = qobject_cast<S60VideoWidgetControl *>(m_videoOutput); |
|
210 |
|
211 if (widgetControl) { |
|
212 QWidget *videoWidget = widgetControl->videoWidget(); |
|
213 newId = widgetControl->videoWidgetWId(); |
|
214 newRect = QRect2TRect(QRect(videoWidget->mapToGlobal(videoWidget->pos()), videoWidget->size())); |
|
215 aspectRatioMode = widgetControl->aspectRatioMode(); |
|
216 } else { |
|
217 if (QApplication::activeWindow()) |
|
218 newId = QApplication::activeWindow()->effectiveWinId(); |
|
219 if (!newId && QApplication::allWidgets().count()) |
|
220 newId = QApplication::allWidgets().at(0)->effectiveWinId(); |
|
221 Q_ASSERT(newId != 0); |
|
222 } |
|
223 if (newRect == m_rect && newId == m_windowId && aspectRatioMode == m_aspectRatioMode) |
|
224 return false; |
|
225 |
|
226 if (newId) { |
|
227 m_rect = newRect; |
|
228 m_windowId = newId; |
|
229 m_window = m_windowId->DrawableWindow(); |
|
230 m_aspectRatioMode = aspectRatioMode; |
|
231 return true; |
|
232 } |
|
233 return false; |
|
234 } |
|
235 |
|
236 bool S60VideoPlayerSession::isVideoAvailable() const |
|
237 { |
|
238 #ifdef PRE_S60_50_PLATFORM |
|
239 return true; // this is not support in pre 5th platforms |
|
240 #else |
|
241 if (m_player) |
|
242 return m_player->VideoEnabledL(); |
|
243 else |
|
244 return false; |
|
245 #endif |
|
246 } |
|
247 |
|
248 bool S60VideoPlayerSession::isAudioAvailable() const |
|
249 { |
|
250 if (m_player) |
|
251 return m_player->AudioEnabledL(); |
|
252 else |
|
253 return false; |
|
254 } |
|
255 |
|
256 void S60VideoPlayerSession::doPlay() |
|
257 { |
|
258 m_player->Play(); |
|
259 } |
|
260 |
|
261 void S60VideoPlayerSession::doPauseL() |
|
262 { |
|
263 m_player->PauseL(); |
|
264 } |
|
265 |
|
266 void S60VideoPlayerSession::doStop() |
|
267 { |
|
268 m_player->Stop(); |
|
269 } |
|
270 |
|
271 qint64 S60VideoPlayerSession::doGetPositionL() const |
|
272 { |
|
273 return m_player->PositionL().Int64() / qint64(1000); |
|
274 } |
|
275 |
|
276 void S60VideoPlayerSession::doSetPositionL(qint64 microSeconds) |
|
277 { |
|
278 m_player->SetPositionL(TTimeIntervalMicroSeconds(microSeconds)); |
|
279 } |
|
280 |
|
281 void S60VideoPlayerSession::doSetVolumeL(int volume) |
|
282 { |
|
283 m_player->SetVolumeL((volume / 100.0)* m_player->MaxVolume()); |
|
284 } |
|
285 |
|
286 QPair<qreal, qreal> S60VideoPlayerSession::scaleFactor() |
|
287 { |
|
288 QSize scaled = m_originalSize; |
|
289 if (m_aspectRatioMode == Qt::IgnoreAspectRatio) |
|
290 scaled.scale(TRect2QRect(m_rect).size(), Qt::IgnoreAspectRatio); |
|
291 else if(m_aspectRatioMode == Qt::KeepAspectRatio) |
|
292 scaled.scale(TRect2QRect(m_rect).size(), Qt::KeepAspectRatio); |
|
293 |
|
294 qreal width = qreal(scaled.width()) / qreal(m_originalSize.width()) * qreal(100); |
|
295 qreal height = qreal(scaled.height()) / qreal(m_originalSize.height()) * qreal(100); |
|
296 |
|
297 return QPair<qreal, qreal>(width, height); |
|
298 } |
|
299 |
|
300 void S60VideoPlayerSession::startDirectScreenAccess() |
|
301 { |
|
302 if(m_dsaActive) |
|
303 return; |
|
304 |
|
305 TRAPD(err, m_player->StartDirectScreenAccessL()); |
|
306 if(err == KErrNone) |
|
307 m_dsaActive = true; |
|
308 setError(err); |
|
309 } |
|
310 |
|
311 bool S60VideoPlayerSession::stopDirectScreenAccess() |
|
312 { |
|
313 if(!m_dsaActive) |
|
314 return false; |
|
315 |
|
316 TRAPD(err, m_player->StopDirectScreenAccessL()); |
|
317 if(err == KErrNone) |
|
318 m_dsaActive = false; |
|
319 |
|
320 setError(err); |
|
321 return true; |
|
322 } |
|
323 |
|
324 void S60VideoPlayerSession::MvpuoOpenComplete(TInt aError) |
|
325 { |
|
326 setError(aError); |
|
327 m_player->Prepare(); |
|
328 } |
|
329 |
|
330 #ifdef MMF_VIDEO_SURFACES_SUPPORTED |
|
331 void S60VideoPlayerSession::MvpuoPrepareComplete(TInt aError) |
|
332 { |
|
333 setError(aError); // if we have some playback errors, handle them |
|
334 |
|
335 if (m_displayWindow) { |
|
336 m_player->RemoveDisplayWindow(*m_displayWindow); |
|
337 m_displayWindow = NULL; |
|
338 } |
|
339 |
|
340 RWindow *window = static_cast<RWindow *>(m_window); |
|
341 if (window) { |
|
342 TRect rect; |
|
343 S60VideoWidgetControl* widgetControl = qobject_cast<S60VideoWidgetControl *>(m_videoOutput); |
|
344 const QSize size = widgetControl->videoWidgetSize(); |
|
345 rect.SetSize(TSize(size.width(), size.height())); |
|
346 m_rect = rect; |
|
347 |
|
348 window->SetBackgroundColor(TRgb(0, 0, 0, 255)); |
|
349 TRAPD(error, |
|
350 m_player->AddDisplayWindowL(m_wsSession, m_screenDevice, *window, m_rect, m_rect);) |
|
351 setError(error); // if we can't add window it an error at this point |
|
352 TSize originalSize; |
|
353 TRAP_IGNORE( |
|
354 m_player->VideoFrameSizeL(originalSize); |
|
355 m_originalSize = QSize(originalSize.iWidth, originalSize.iHeight); |
|
356 m_player->SetScaleFactorL(*window, scaleFactor().first, scaleFactor().second);) |
|
357 |
|
358 m_displayWindow = window; |
|
359 } |
|
360 |
|
361 #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER |
|
362 TRAPD(err, |
|
363 m_audioOutput = CAudioOutput::NewL(*m_player); |
|
364 m_audioOutput->RegisterObserverL(*this); |
|
365 ); |
|
366 setActiveEndpoint(m_audioEndpoint); |
|
367 setError(err); |
|
368 #endif |
|
369 loaded(); |
|
370 } |
|
371 #else |
|
372 void S60VideoPlayerSession::MvpuoPrepareComplete(TInt aError) |
|
373 { |
|
374 setError(aError); |
|
375 TRAPD(err, |
|
376 m_player->SetDisplayWindowL(m_wsSession, |
|
377 m_screenDevice, |
|
378 *m_window, |
|
379 m_rect, |
|
380 m_rect); |
|
381 TSize originalSize; |
|
382 m_player->VideoFrameSizeL(originalSize); |
|
383 m_originalSize = QSize(originalSize.iWidth, originalSize.iHeight); |
|
384 m_player->SetScaleFactorL(scaleFactor().first, scaleFactor().second, true)); |
|
385 |
|
386 if (err == KErrNone) |
|
387 m_dsaActive = true; |
|
388 setError(err); |
|
389 #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER |
|
390 TRAP(err, |
|
391 m_audioOutput = CAudioOutput::NewL(*m_player); |
|
392 m_audioOutput->RegisterObserverL(*this); |
|
393 ); |
|
394 setActiveEndpoint(m_audioEndpoint); |
|
395 setError(err); |
|
396 #endif |
|
397 loaded(); |
|
398 } |
|
399 #endif // MMF_VIDEO_SURFACES_SUPPORTED |
|
400 |
|
401 void S60VideoPlayerSession::MvpuoFrameReady(CFbsBitmap &aFrame, TInt aError) |
|
402 { |
|
403 Q_UNUSED(aFrame); |
|
404 Q_UNUSED(aError); |
|
405 } |
|
406 |
|
407 void S60VideoPlayerSession::MvpuoPlayComplete(TInt aError) |
|
408 { |
|
409 setError(aError); |
|
410 endOfMedia(); |
|
411 } |
|
412 |
|
413 void S60VideoPlayerSession::MvpuoEvent(const TMMFEvent &aEvent) |
|
414 { |
|
415 Q_UNUSED(aEvent); |
|
416 } |
|
417 |
|
418 void S60VideoPlayerSession::updateMetaDataEntriesL() |
|
419 { |
|
420 metaDataEntries().clear(); |
|
421 int numberOfMetaDataEntries = 0; |
|
422 |
|
423 numberOfMetaDataEntries = m_player->NumberOfMetaDataEntriesL(); |
|
424 |
|
425 for (int i = 0; i < numberOfMetaDataEntries; i++) { |
|
426 CMMFMetaDataEntry *entry = NULL; |
|
427 entry = m_player->MetaDataEntryL(i); |
|
428 metaDataEntries().insert(TDesC2QString(entry->Name()), TDesC2QString(entry->Value())); |
|
429 delete entry; |
|
430 } |
|
431 emit metaDataChanged(); |
|
432 } |
|
433 #ifdef MMF_VIDEO_SURFACES_SUPPORTED |
|
434 void S60VideoPlayerSession::resetVideoDisplay() |
|
435 { |
|
436 if (resetNativeHandles()) { |
|
437 |
|
438 S60VideoWidgetControl *widgetControl = qobject_cast<S60VideoWidgetControl *>(m_videoOutput); |
|
439 if (!widgetControl) |
|
440 return; |
|
441 |
|
442 TRect rect; |
|
443 const QSize size = widgetControl->videoWidgetSize(); |
|
444 rect.SetSize(TSize(size.width(), size.height())); |
|
445 m_rect = rect; |
|
446 |
|
447 if (m_displayWindow) { |
|
448 m_player->RemoveDisplayWindow(*m_displayWindow); |
|
449 m_displayWindow = NULL; |
|
450 } |
|
451 |
|
452 RWindow *window = static_cast<RWindow *>(m_window); |
|
453 if (window) { |
|
454 window->SetBackgroundColor(TRgb(0, 0, 0, 255)); |
|
455 TRAP_IGNORE( |
|
456 m_player->AddDisplayWindowL(m_wsSession, |
|
457 m_screenDevice, |
|
458 *window, |
|
459 m_rect, |
|
460 m_rect)); |
|
461 m_displayWindow = window; |
|
462 } |
|
463 |
|
464 if( mediaStatus() == QMediaPlayer::LoadedMedia |
|
465 || mediaStatus() == QMediaPlayer::StalledMedia |
|
466 || mediaStatus() == QMediaPlayer::BufferingMedia |
|
467 || mediaStatus() == QMediaPlayer::BufferedMedia |
|
468 || mediaStatus() == QMediaPlayer::EndOfMedia) { |
|
469 Q_ASSERT(m_displayWindow != 0); |
|
470 TRAPD(err, m_player->SetScaleFactorL(*m_displayWindow, scaleFactor().first, scaleFactor().second)); |
|
471 setError(err); |
|
472 } |
|
473 } |
|
474 } |
|
475 #else |
|
476 void S60VideoPlayerSession::resetVideoDisplay() |
|
477 { |
|
478 if (resetNativeHandles()) { |
|
479 TRAPD(err, |
|
480 m_player->SetDisplayWindowL(m_wsSession, |
|
481 m_screenDevice, |
|
482 *m_window, |
|
483 m_rect, |
|
484 m_rect)); |
|
485 if (err == KErrNone) |
|
486 m_dsaActive = true; |
|
487 setError(err); |
|
488 if( mediaStatus() == QMediaPlayer::LoadedMedia |
|
489 || mediaStatus() == QMediaPlayer::StalledMedia |
|
490 || mediaStatus() == QMediaPlayer::BufferingMedia |
|
491 || mediaStatus() == QMediaPlayer::BufferedMedia |
|
492 || mediaStatus() == QMediaPlayer::EndOfMedia) { |
|
493 TRAPD(err, m_player->SetScaleFactorL(scaleFactor().first, scaleFactor().second, true)); |
|
494 setError(err); |
|
495 } |
|
496 } |
|
497 } |
|
498 #endif //MMF_VIDEO_SURFACES_SUPPORTED |
|
499 |
|
500 void S60VideoPlayerSession::resizeVideoWindow() |
|
501 { |
|
502 #ifdef MMF_VIDEO_SURFACES_SUPPORTED |
|
503 S60VideoWidgetControl *widgetControl = qobject_cast<S60VideoWidgetControl *>(m_videoOutput); |
|
504 m_aspectRatioMode = widgetControl->aspectRatioMode(); |
|
505 |
|
506 TRect rect; |
|
507 const QSize size = widgetControl->videoWidgetSize(); |
|
508 rect.SetSize(TSize(size.width(), size.height())); |
|
509 m_rect = rect; |
|
510 |
|
511 TRAPD( err, m_player->SetVideoExtentL(*m_displayWindow, m_rect); |
|
512 m_player->SetWindowClipRectL(*m_displayWindow, m_rect);) |
|
513 |
|
514 // don't waste time on calling this when we have error |
|
515 if (KErrNone != err) { |
|
516 TSize originalSize; |
|
517 TRAP_IGNORE( |
|
518 m_player->VideoFrameSizeL(originalSize); |
|
519 m_originalSize = QSize(originalSize.iWidth, originalSize.iHeight); |
|
520 m_player->SetScaleFactorL(*m_displayWindow, scaleFactor().first, scaleFactor().second); ) |
|
521 } |
|
522 #endif //MMF_VIDEO_SURFACES_SUPPORTED |
|
523 } |
|
524 void S60VideoPlayerSession::suspendDirectScreenAccess() |
|
525 { |
|
526 m_dsaStopped = stopDirectScreenAccess(); |
|
527 } |
|
528 |
|
529 void S60VideoPlayerSession::resumeDirectScreenAccess() |
|
530 { |
|
531 if(!m_dsaStopped) |
|
532 return; |
|
533 |
|
534 startDirectScreenAccess(); |
|
535 m_dsaStopped = false; |
|
536 } |
|
537 |
|
538 void S60VideoPlayerSession::MvloLoadingStarted() |
|
539 { |
|
540 buffering(); |
|
541 } |
|
542 |
|
543 void S60VideoPlayerSession::MvloLoadingComplete() |
|
544 { |
|
545 buffered(); |
|
546 } |
|
547 |
|
548 void S60VideoPlayerSession::doSetAudioEndpoint(const QString& audioEndpoint) |
|
549 { |
|
550 m_audioEndpoint = audioEndpoint; |
|
551 } |
|
552 |
|
553 QString S60VideoPlayerSession::activeEndpoint() const |
|
554 { |
|
555 QString outputName = QString("Default"); |
|
556 #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER |
|
557 if (m_audioOutput) { |
|
558 CAudioOutput::TAudioOutputPreference output = m_audioOutput->AudioOutput(); |
|
559 outputName = qStringFromTAudioOutputPreference(output); |
|
560 } |
|
561 #endif |
|
562 return outputName; |
|
563 } |
|
564 |
|
565 QString S60VideoPlayerSession::defaultEndpoint() const |
|
566 { |
|
567 QString outputName = QString("Default"); |
|
568 #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER |
|
569 if (m_audioOutput) { |
|
570 CAudioOutput::TAudioOutputPreference output = m_audioOutput->DefaultAudioOutput(); |
|
571 outputName = qStringFromTAudioOutputPreference(output); |
|
572 } |
|
573 #endif |
|
574 return outputName; |
|
575 } |
|
576 |
|
577 void S60VideoPlayerSession::setActiveEndpoint(const QString& name) |
|
578 { |
|
579 #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER |
|
580 CAudioOutput::TAudioOutputPreference output = CAudioOutput::ENoPreference; |
|
581 |
|
582 if (name == QString("Default")) |
|
583 output = CAudioOutput::ENoPreference; |
|
584 else if (name == QString("All")) |
|
585 output = CAudioOutput::EAll; |
|
586 else if (name == QString("None")) |
|
587 output = CAudioOutput::ENoOutput; |
|
588 else if (name == QString("Earphone")) |
|
589 output = CAudioOutput::EPrivate; |
|
590 else if (name == QString("Speaker")) |
|
591 output = CAudioOutput::EPublic; |
|
592 |
|
593 if (m_audioOutput) { |
|
594 TRAPD(err, m_audioOutput->SetAudioOutputL(output)); |
|
595 setError(err); |
|
596 |
|
597 if (m_audioEndpoint != name) { |
|
598 m_audioEndpoint = name; |
|
599 emit activeEndpointChanged(name); |
|
600 } |
|
601 } |
|
602 #endif |
|
603 } |
|
604 #ifdef HAS_AUDIOROUTING_IN_VIDEOPLAYER |
|
605 void S60VideoPlayerSession::DefaultAudioOutputChanged( CAudioOutput& aAudioOutput, |
|
606 CAudioOutput::TAudioOutputPreference aNewDefault ) |
|
607 { |
|
608 // Emit already implemented in setActiveEndpoint function |
|
609 Q_UNUSED(aAudioOutput) |
|
610 Q_UNUSED(aNewDefault) |
|
611 } |
|
612 |
|
613 QString S60VideoPlayerSession::qStringFromTAudioOutputPreference(CAudioOutput::TAudioOutputPreference output) const |
|
614 { |
|
615 if (output == CAudioOutput::ENoPreference) |
|
616 return QString("Default"); |
|
617 else if (output == CAudioOutput::EAll) |
|
618 return QString("All"); |
|
619 else if (output == CAudioOutput::ENoOutput) |
|
620 return QString("None"); |
|
621 else if (output == CAudioOutput::EPrivate) |
|
622 return QString("Earphone"); |
|
623 else if (output == CAudioOutput::EPublic) |
|
624 return QString("Speaker"); |
|
625 return QString("Default"); |
|
626 } |
|
627 #endif //HAS_AUDIOROUTING_IN_VIDEOPLAYER) |