30
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Implementation of VideoPlayerEngine
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
37
|
18 |
// Version : %version: 27 %
|
30
|
19 |
|
|
20 |
|
34
|
21 |
#include <QApplication>
|
30
|
22 |
|
|
23 |
#include <hbinstance.h>
|
|
24 |
#include <xqpluginloader.h>
|
|
25 |
#include <xqplugininfo.h>
|
|
26 |
#include <xqserviceutil.h>
|
35
|
27 |
#include <hbview.h>
|
30
|
28 |
|
|
29 |
#include "videoplayerengine.h"
|
|
30 |
#include "mpxvideoplaybackwrapper.h"
|
|
31 |
#include "videoservices.h"
|
35
|
32 |
#include "mpxvideo_debug.h"
|
30
|
33 |
|
|
34 |
// -------------------------------------------------------------------------------------------------
|
|
35 |
// QVideoPlayerEngine()
|
|
36 |
// -------------------------------------------------------------------------------------------------
|
|
37 |
//
|
36
|
38 |
QVideoPlayerEngine::QVideoPlayerEngine( bool isService )
|
30
|
39 |
: mIsService( isService )
|
36
|
40 |
, mEmbedded( false )
|
|
41 |
, mDelayedLoadDone( false )
|
30
|
42 |
, mCurrentViewPlugin( 0 )
|
|
43 |
, mPlaybackViewPlugin( 0 )
|
|
44 |
, mCollectionViewPlugin( 0 )
|
|
45 |
, mFileDetailsViewPlugin( 0 )
|
|
46 |
, mPlaybackWrapper( 0 )
|
36
|
47 |
, mVideoServices( 0 )
|
30
|
48 |
{
|
36
|
49 |
MPX_DEBUG(_L("QVideoPlayerEngine::QVideoPlayerEngine()"));
|
30
|
50 |
}
|
|
51 |
|
|
52 |
// -------------------------------------------------------------------------------------------------
|
|
53 |
// ~QVideoPlayerEngine()
|
|
54 |
// -------------------------------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
QVideoPlayerEngine::~QVideoPlayerEngine()
|
|
57 |
{
|
35
|
58 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::~QVideoPlayerEngine()"));
|
|
59 |
|
30
|
60 |
if ( mVideoServices )
|
|
61 |
{
|
|
62 |
mVideoServices->decreaseReferenceCount();
|
|
63 |
mVideoServices = 0;
|
|
64 |
}
|
|
65 |
|
|
66 |
if ( mCollectionViewPlugin )
|
|
67 |
{
|
|
68 |
mCollectionViewPlugin->destroyView();
|
|
69 |
}
|
|
70 |
|
|
71 |
if ( mPlaybackViewPlugin )
|
|
72 |
{
|
|
73 |
mPlaybackViewPlugin->destroyView();
|
|
74 |
}
|
|
75 |
|
|
76 |
if ( mFileDetailsViewPlugin )
|
|
77 |
{
|
|
78 |
mFileDetailsViewPlugin->destroyView();
|
|
79 |
}
|
|
80 |
|
|
81 |
delete mPlaybackWrapper;
|
|
82 |
|
|
83 |
// disconnect all signals
|
|
84 |
disconnect();
|
|
85 |
}
|
|
86 |
|
|
87 |
// -------------------------------------------------------------------------------------------------
|
|
88 |
// initialize()
|
|
89 |
// -------------------------------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
void QVideoPlayerEngine::initialize()
|
|
92 |
{
|
35
|
93 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::initialize()"));
|
36
|
94 |
|
30
|
95 |
//
|
|
96 |
// Clean up QVideoPlayerEngine when qApp try to quit
|
|
97 |
//
|
|
98 |
connect( qApp, SIGNAL( aboutToQuit() ), this, SLOT( handleQuit() ) );
|
|
99 |
|
|
100 |
//
|
|
101 |
// Create playback wrapper
|
|
102 |
//
|
|
103 |
if ( !mPlaybackWrapper )
|
|
104 |
{
|
|
105 |
mPlaybackWrapper = new QMpxVideoPlaybackWrapper();
|
|
106 |
connect( mPlaybackWrapper,
|
|
107 |
SIGNAL( handlePlaybackView( int ) ),
|
|
108 |
this,
|
|
109 |
SLOT( handleCommand( int ) ) );
|
|
110 |
}
|
|
111 |
|
|
112 |
//
|
|
113 |
// Get VideoServices instance
|
|
114 |
//
|
37
|
115 |
if ( mIsService && ! mVideoServices )
|
30
|
116 |
{
|
37
|
117 |
mVideoServices = VideoServices::instance(this);
|
|
118 |
connect( mVideoServices, SIGNAL(activated(int)), this, SLOT(handleCommand(int)));
|
30
|
119 |
}
|
|
120 |
|
|
121 |
QList<XQPluginInfo> impls;
|
|
122 |
XQPluginLoader::listImplementations("org.nokia.mmdt.MpxViewPlugin/1.0", impls);
|
|
123 |
|
|
124 |
//
|
36
|
125 |
// Pre-load collection plugin and create collection view
|
30
|
126 |
//
|
36
|
127 |
loadPluginAndCreateView( MpxHbVideoCommon::CollectionView );
|
30
|
128 |
|
|
129 |
//
|
36
|
130 |
// if app is opened via serviceFW create remaining views
|
|
131 |
// otherwise activate default view i.e. the collection view.
|
30
|
132 |
//
|
37
|
133 |
if ( mIsService )
|
30
|
134 |
{
|
36
|
135 |
createPlayAndDetailsViews();
|
|
136 |
}
|
|
137 |
else
|
|
138 |
{
|
30
|
139 |
activateView( MpxHbVideoCommon::CollectionView );
|
36
|
140 |
}
|
|
141 |
|
30
|
142 |
}
|
|
143 |
|
|
144 |
// -------------------------------------------------------------------------------------------------
|
|
145 |
// handleCommand()
|
|
146 |
// -------------------------------------------------------------------------------------------------
|
|
147 |
//
|
|
148 |
void QVideoPlayerEngine::handleCommand( int commandCode )
|
|
149 |
{
|
36
|
150 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleCommand()"),
|
|
151 |
_L("commandCode = %d"), commandCode );
|
|
152 |
|
30
|
153 |
switch ( commandCode )
|
|
154 |
{
|
|
155 |
case MpxHbVideoCommon::ActivateCollectionView:
|
|
156 |
{
|
|
157 |
if ( mCurrentViewPlugin != mCollectionViewPlugin )
|
|
158 |
{
|
|
159 |
activateView( MpxHbVideoCommon::CollectionView );
|
|
160 |
}
|
|
161 |
break;
|
|
162 |
}
|
|
163 |
case MpxHbVideoCommon::ActivatePlaybackView:
|
|
164 |
{
|
|
165 |
if ( mCurrentViewPlugin != mPlaybackViewPlugin )
|
|
166 |
{
|
|
167 |
activateView( MpxHbVideoCommon::PlaybackView );
|
|
168 |
}
|
|
169 |
break;
|
|
170 |
}
|
|
171 |
case MpxHbVideoCommon::ActivateVideoDetailsView:
|
|
172 |
{
|
|
173 |
if ( mCurrentViewPlugin != mFileDetailsViewPlugin )
|
37
|
174 |
{
|
|
175 |
activateView( MpxHbVideoCommon::VideoDetailsView );
|
30
|
176 |
}
|
|
177 |
break;
|
|
178 |
}
|
35
|
179 |
case MpxHbVideoCommon::DoDelayedLoad:
|
30
|
180 |
{
|
37
|
181 |
if ( ! mDelayedLoadDone )
|
|
182 |
{
|
|
183 |
doDelayedLoad();
|
|
184 |
}
|
35
|
185 |
break;
|
|
186 |
}
|
30
|
187 |
|
|
188 |
default:
|
|
189 |
{
|
|
190 |
break;
|
|
191 |
}
|
|
192 |
}
|
|
193 |
}
|
|
194 |
|
|
195 |
// -------------------------------------------------------------------------------------------------
|
35
|
196 |
// doDelayedLoad()
|
|
197 |
// -------------------------------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
void QVideoPlayerEngine::doDelayedLoad()
|
|
200 |
{
|
36
|
201 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::doDelayedLoad()"));
|
|
202 |
|
|
203 |
createPlayAndDetailsViews();
|
35
|
204 |
|
37
|
205 |
mDelayedLoadDone = true;
|
35
|
206 |
}
|
|
207 |
|
|
208 |
// -------------------------------------------------------------------------------------------------
|
36
|
209 |
// createPlayAndDetailsViews()
|
|
210 |
// -------------------------------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
void QVideoPlayerEngine::createPlayAndDetailsViews()
|
|
213 |
{
|
|
214 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::createPlayAndDetailsViews()"));
|
|
215 |
|
37
|
216 |
//
|
|
217 |
// delayed initialization of some uiengine member variables
|
|
218 |
// to help application startup time & improve playback start time
|
|
219 |
//
|
|
220 |
mPlaybackWrapper->lateInit();
|
|
221 |
|
36
|
222 |
if ( ! mPlaybackViewPlugin )
|
|
223 |
{
|
|
224 |
loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
|
|
225 |
}
|
|
226 |
|
|
227 |
if ( ! mFileDetailsViewPlugin )
|
|
228 |
{
|
|
229 |
loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView );
|
37
|
230 |
}
|
36
|
231 |
}
|
|
232 |
|
|
233 |
|
|
234 |
// -------------------------------------------------------------------------------------------------
|
30
|
235 |
// activateView()
|
|
236 |
// activate view based on view type.
|
|
237 |
// -------------------------------------------------------------------------------------------------
|
|
238 |
//
|
|
239 |
void QVideoPlayerEngine::activateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
|
|
240 |
{
|
36
|
241 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::activateView() "),
|
|
242 |
_L("viewType = %d"), viewType );
|
|
243 |
|
30
|
244 |
disconnectView();
|
|
245 |
|
|
246 |
if ( mCurrentViewPlugin )
|
|
247 |
{
|
|
248 |
mCurrentViewPlugin->deactivateView();
|
|
249 |
mCurrentViewPlugin = NULL;
|
|
250 |
}
|
|
251 |
|
|
252 |
if ( viewType == MpxHbVideoCommon::CollectionView && mCollectionViewPlugin )
|
|
253 |
{
|
36
|
254 |
if ( mIsService &&
|
|
255 |
( mVideoServices->currentService() == VideoServices::EPlayback ||
|
37
|
256 |
mVideoServices->currentService() == VideoServices::EView ||
|
|
257 |
mVideoServices->currentService() == VideoServices::EUriFetcher ) )
|
36
|
258 |
{
|
37
|
259 |
if ( mVideoServices->currentService() == VideoServices::EUriFetcher )
|
|
260 |
{
|
|
261 |
if ( ! mVideoServices->mFetchSelected )
|
|
262 |
{
|
|
263 |
//
|
|
264 |
// view is in 'fetch' service but 'attach' operation has not been selected,
|
|
265 |
// therefore, go back to collection view
|
|
266 |
//
|
|
267 |
mCurrentViewPlugin = mCollectionViewPlugin;
|
|
268 |
setCurrentView();
|
|
269 |
}
|
|
270 |
}
|
|
271 |
else
|
|
272 |
{
|
|
273 |
qApp->quit();
|
|
274 |
XQServiceUtil::toBackground( false );
|
|
275 |
}
|
36
|
276 |
}
|
|
277 |
else
|
|
278 |
{
|
|
279 |
mCurrentViewPlugin = mCollectionViewPlugin;
|
|
280 |
setCurrentView();
|
|
281 |
}
|
30
|
282 |
}
|
35
|
283 |
else if ( viewType == MpxHbVideoCommon::PlaybackView )
|
30
|
284 |
{
|
37
|
285 |
if ( ! mPlaybackViewPlugin )
|
35
|
286 |
{
|
37
|
287 |
loadPluginAndCreateView( MpxHbVideoCommon::PlaybackView );
|
36
|
288 |
}
|
|
289 |
|
30
|
290 |
mCurrentViewPlugin = mPlaybackViewPlugin;
|
36
|
291 |
setCurrentView();
|
30
|
292 |
}
|
35
|
293 |
else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
|
30
|
294 |
{
|
37
|
295 |
if ( ! mFileDetailsViewPlugin )
|
35
|
296 |
{
|
37
|
297 |
loadPluginAndCreateView( MpxHbVideoCommon::VideoDetailsView );
|
35
|
298 |
}
|
36
|
299 |
|
30
|
300 |
mCurrentViewPlugin = mFileDetailsViewPlugin;
|
36
|
301 |
setCurrentView();
|
30
|
302 |
}
|
|
303 |
}
|
|
304 |
|
|
305 |
// -------------------------------------------------------------------------------------------------
|
36
|
306 |
// loadPluginAndCreateView()
|
30
|
307 |
// -------------------------------------------------------------------------------------------------
|
|
308 |
//
|
36
|
309 |
void QVideoPlayerEngine::loadPluginAndCreateView( MpxHbVideoCommon::MpxHbVideoViewType viewType )
|
30
|
310 |
{
|
36
|
311 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::loadPluginAndCreateView() "),
|
|
312 |
_L("viewType = %d"), viewType );
|
35
|
313 |
|
30
|
314 |
int viewTypeUid( 0 );
|
|
315 |
|
|
316 |
if ( viewType == MpxHbVideoCommon::CollectionView )
|
|
317 |
{
|
|
318 |
viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllCollectionUid;
|
|
319 |
}
|
|
320 |
else if ( viewType == MpxHbVideoCommon::PlaybackView )
|
|
321 |
{
|
|
322 |
viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllPlaybackUid;
|
|
323 |
}
|
37
|
324 |
else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
|
30
|
325 |
{
|
|
326 |
viewTypeUid = MpxHbVideoCommon::KMpxVideoPluginDllFileDetailsUid;
|
|
327 |
}
|
|
328 |
|
|
329 |
if ( viewTypeUid )
|
|
330 |
{
|
36
|
331 |
//
|
37
|
332 |
// load corresponding plug-in
|
|
333 |
//
|
30
|
334 |
XQPluginLoader pluginLoader( viewTypeUid );
|
|
335 |
QObject* instance = pluginLoader.instance();
|
|
336 |
|
|
337 |
if ( instance )
|
|
338 |
{
|
36
|
339 |
MpxViewPlugin *currentViewPlugin = NULL;
|
|
340 |
|
30
|
341 |
if ( viewType == MpxHbVideoCommon::CollectionView )
|
|
342 |
{
|
|
343 |
mCollectionViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
|
36
|
344 |
currentViewPlugin = mCollectionViewPlugin;
|
30
|
345 |
}
|
|
346 |
else if ( viewType == MpxHbVideoCommon::PlaybackView )
|
|
347 |
{
|
|
348 |
mPlaybackViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
|
36
|
349 |
currentViewPlugin = mPlaybackViewPlugin;
|
30
|
350 |
}
|
|
351 |
else if ( viewType == MpxHbVideoCommon::VideoDetailsView )
|
|
352 |
{
|
|
353 |
mFileDetailsViewPlugin = qobject_cast<MpxViewPlugin*>( instance )->viewPlugin();
|
36
|
354 |
currentViewPlugin = mFileDetailsViewPlugin;
|
30
|
355 |
}
|
36
|
356 |
else
|
|
357 |
{
|
|
358 |
MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : plugin not FOUND ! "));
|
|
359 |
}
|
|
360 |
|
37
|
361 |
//
|
|
362 |
// create corresponding view
|
|
363 |
//
|
36
|
364 |
if ( currentViewPlugin )
|
|
365 |
{
|
|
366 |
QGraphicsWidget *view = currentViewPlugin->getView();
|
|
367 |
|
|
368 |
if ( ! view )
|
|
369 |
{
|
|
370 |
MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : create view "));
|
|
371 |
|
|
372 |
currentViewPlugin->createView();
|
|
373 |
hbInstance->allMainWindows().value(0)->addView( currentViewPlugin->getView() );
|
|
374 |
}
|
|
375 |
else
|
|
376 |
{
|
|
377 |
MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : view has already been created! "));
|
|
378 |
}
|
|
379 |
}
|
|
380 |
else
|
|
381 |
{
|
|
382 |
MPX_DEBUG(_L("QVideoPlayerEngine::loadPluginAndCreateView() : currentViewPlugin is NULL ! "));
|
|
383 |
}
|
30
|
384 |
}
|
|
385 |
}
|
|
386 |
}
|
|
387 |
|
|
388 |
// -------------------------------------------------------------------------------------------------
|
|
389 |
// connectView()
|
|
390 |
// connect application to view by setting up the signals and slots.
|
|
391 |
// -------------------------------------------------------------------------------------------------
|
|
392 |
//
|
|
393 |
void QVideoPlayerEngine::connectView()
|
|
394 |
{
|
36
|
395 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::connectView()"));
|
35
|
396 |
|
30
|
397 |
connect( mCurrentViewPlugin,
|
|
398 |
SIGNAL( command( int ) ),
|
|
399 |
this,
|
|
400 |
SLOT( handleCommand( int ) ) );
|
|
401 |
}
|
|
402 |
|
|
403 |
// -------------------------------------------------------------------------------------------------
|
|
404 |
// disconnectView()
|
|
405 |
// connect application to view by setting up the signals and slots.
|
|
406 |
// -------------------------------------------------------------------------------------------------
|
|
407 |
//
|
|
408 |
void QVideoPlayerEngine::disconnectView()
|
|
409 |
{
|
36
|
410 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::disconnectView()"));
|
35
|
411 |
|
30
|
412 |
if ( mCurrentViewPlugin )
|
|
413 |
{
|
|
414 |
disconnect( mCurrentViewPlugin,
|
|
415 |
SIGNAL( command( int ) ),
|
|
416 |
this,
|
|
417 |
SLOT( handleCommand( int ) ) );
|
|
418 |
}
|
|
419 |
}
|
|
420 |
|
|
421 |
// -------------------------------------------------------------------------------------------------
|
|
422 |
// handleQuit()
|
|
423 |
// -------------------------------------------------------------------------------------------------
|
|
424 |
//
|
|
425 |
void QVideoPlayerEngine::handleQuit()
|
|
426 |
{
|
36
|
427 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::handleQuit()"));
|
35
|
428 |
|
30
|
429 |
delete this;
|
|
430 |
}
|
|
431 |
|
|
432 |
|
|
433 |
// -------------------------------------------------------------------------------------------------
|
|
434 |
// playMedia()
|
|
435 |
// -------------------------------------------------------------------------------------------------
|
|
436 |
//
|
|
437 |
void QVideoPlayerEngine::playMedia( QString filePath )
|
|
438 |
{
|
36
|
439 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia()"),
|
|
440 |
_L("filePath = %s"), filePath.data() );
|
35
|
441 |
|
30
|
442 |
mPlaybackWrapper->playMedia( filePath );
|
|
443 |
}
|
|
444 |
|
|
445 |
// -------------------------------------------------------------------------------------------------
|
36
|
446 |
// playMedia()
|
|
447 |
// -------------------------------------------------------------------------------------------------
|
|
448 |
//
|
|
449 |
void QVideoPlayerEngine::playMedia( RFile file )
|
|
450 |
{
|
|
451 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::playMedia( RFile )"));
|
|
452 |
|
|
453 |
mPlaybackWrapper->playMedia( file );
|
|
454 |
}
|
|
455 |
|
|
456 |
// -------------------------------------------------------------------------------------------------
|
30
|
457 |
// setEmbedded()
|
|
458 |
// -------------------------------------------------------------------------------------------------
|
|
459 |
//
|
|
460 |
void QVideoPlayerEngine::setEmbedded()
|
|
461 |
{
|
36
|
462 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setEmbedded()"));
|
35
|
463 |
|
30
|
464 |
mEmbedded = true;
|
|
465 |
}
|
|
466 |
|
36
|
467 |
// -------------------------------------------------------------------------------------------------
|
|
468 |
// setCurrentView()
|
|
469 |
// -------------------------------------------------------------------------------------------------
|
|
470 |
//
|
|
471 |
void QVideoPlayerEngine::setCurrentView()
|
|
472 |
{
|
|
473 |
MPX_ENTER_EXIT(_L("QVideoPlayerEngine::setCurrentView()"));
|
|
474 |
|
|
475 |
if ( mCurrentViewPlugin )
|
|
476 |
{
|
|
477 |
//
|
|
478 |
// set current view
|
|
479 |
//
|
|
480 |
hbInstance->allMainWindows().value(0)->setCurrentView(
|
|
481 |
qobject_cast<HbView*>( mCurrentViewPlugin->getView() ), false );
|
|
482 |
|
|
483 |
//
|
|
484 |
// connect view
|
|
485 |
//
|
|
486 |
connectView();
|
|
487 |
|
|
488 |
//
|
|
489 |
// activate view
|
|
490 |
//
|
|
491 |
mCurrentViewPlugin->activateView();
|
|
492 |
}
|
|
493 |
}
|
|
494 |
|
|
495 |
|
30
|
496 |
// End of file
|