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 VideoServices
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
37
|
18 |
// Version : %version: 6 %
|
36
|
19 |
|
|
20 |
#include "videoplayerengine.h"
|
|
21 |
#include "videoservices.h"
|
|
22 |
#include "videoserviceurifetch.h"
|
|
23 |
#include "videoserviceplay.h"
|
|
24 |
#include "videoserviceview.h"
|
|
25 |
#include "videoservicebrowse.h"
|
|
26 |
#include "mpxvideo_debug.h"
|
30
|
27 |
|
|
28 |
VideoServices *VideoServices::mInstance = 0;
|
|
29 |
|
|
30 |
// -----------------------------------------------------------------------------
|
|
31 |
// VideoServices::instance()
|
|
32 |
// -----------------------------------------------------------------------------
|
|
33 |
//
|
|
34 |
VideoServices* VideoServices::instance(QVideoPlayerEngine* engine)
|
|
35 |
{
|
36
|
36 |
MPX_ENTER_EXIT(_L("VideoServices::instance()"));
|
|
37 |
|
|
38 |
if ( ! mInstance )
|
30
|
39 |
{
|
|
40 |
mInstance = new VideoServices(engine);
|
|
41 |
}
|
36
|
42 |
else if ( engine && ! mInstance->engine() )
|
30
|
43 |
{
|
|
44 |
mInstance->setEngine(engine);
|
|
45 |
}
|
37
|
46 |
|
30
|
47 |
mInstance->mReferenceCount++;
|
|
48 |
return mInstance;
|
|
49 |
}
|
|
50 |
|
|
51 |
// -----------------------------------------------------------------------------
|
|
52 |
// VideoServices::decreaseReferenceCount()
|
|
53 |
// -----------------------------------------------------------------------------
|
|
54 |
//
|
|
55 |
void VideoServices::decreaseReferenceCount()
|
|
56 |
{
|
36
|
57 |
MPX_ENTER_EXIT(_L("VideoServices::decreaseReferenceCount()"));
|
|
58 |
|
|
59 |
if ( mInstance )
|
30
|
60 |
{
|
36
|
61 |
if( --mInstance->mReferenceCount == 0 )
|
30
|
62 |
{
|
|
63 |
delete mInstance;
|
|
64 |
mInstance = NULL;
|
|
65 |
}
|
|
66 |
}
|
|
67 |
}
|
|
68 |
|
|
69 |
// ----------------------------------------------------------------------------
|
|
70 |
// setEngine()
|
|
71 |
// ----------------------------------------------------------------------------
|
|
72 |
//
|
|
73 |
void VideoServices::setEngine(QVideoPlayerEngine* engine)
|
|
74 |
{
|
36
|
75 |
MPX_ENTER_EXIT(_L("VideoServices::setEngine()"));
|
|
76 |
|
|
77 |
if ( mServicePlay )
|
30
|
78 |
{
|
|
79 |
mEngine = engine;
|
|
80 |
mServicePlay->setEngine(engine);
|
|
81 |
}
|
36
|
82 |
|
|
83 |
if ( mServiceView )
|
|
84 |
{
|
|
85 |
mEngine = engine;
|
|
86 |
mServiceView->setEngine(engine);
|
|
87 |
}
|
|
88 |
|
30
|
89 |
}
|
|
90 |
|
|
91 |
// ----------------------------------------------------------------------------
|
|
92 |
// engine()
|
|
93 |
// ----------------------------------------------------------------------------
|
|
94 |
//
|
|
95 |
QVideoPlayerEngine* VideoServices::engine()
|
|
96 |
{
|
36
|
97 |
MPX_DEBUG(_L("VideoServices::engine"));
|
|
98 |
|
37
|
99 |
return mEngine;
|
30
|
100 |
}
|
|
101 |
|
|
102 |
// ----------------------------------------------------------------------------
|
|
103 |
// VideoServices()
|
|
104 |
// ----------------------------------------------------------------------------
|
|
105 |
//
|
36
|
106 |
VideoServices::VideoServices( QVideoPlayerEngine* engine )
|
|
107 |
: mReferenceCount( 0 )
|
|
108 |
, mEngine( engine )
|
|
109 |
, mCurrentService( VideoServices::ENoService )
|
37
|
110 |
, mFetchSelected( false )
|
30
|
111 |
{
|
36
|
112 |
MPX_ENTER_EXIT(_L("VideoServices::VideoServices()"));
|
|
113 |
|
30
|
114 |
mServiceUriFetch = new VideoServiceUriFetch(this);
|
37
|
115 |
mServicePlay = new VideoServicePlay(this, engine);
|
|
116 |
mServiceView = new VideoServiceView(this, engine);
|
|
117 |
mServiceBrowse = new VideoServiceBrowse(this);
|
30
|
118 |
}
|
|
119 |
|
|
120 |
// ----------------------------------------------------------------------------
|
|
121 |
// ~VideoServices()
|
|
122 |
// ----------------------------------------------------------------------------
|
|
123 |
//
|
|
124 |
VideoServices::~VideoServices()
|
|
125 |
{
|
36
|
126 |
MPX_ENTER_EXIT(_L("VideoServices::~VideoServices()"));
|
|
127 |
|
37
|
128 |
delete mServiceUriFetch;
|
|
129 |
delete mServicePlay;
|
|
130 |
delete mServiceView;
|
|
131 |
delete mServiceBrowse;
|
30
|
132 |
}
|
|
133 |
|
|
134 |
// ----------------------------------------------------------------------------
|
|
135 |
// currentService()
|
|
136 |
// ----------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
VideoServices::TVideoService VideoServices::currentService()
|
|
139 |
{
|
36
|
140 |
MPX_DEBUG(_L("VideoServices::currentService() ret %d"), mCurrentService );
|
|
141 |
|
37
|
142 |
return mCurrentService;
|
30
|
143 |
}
|
|
144 |
|
|
145 |
// ----------------------------------------------------------------------------
|
36
|
146 |
// getBrowseCategory()
|
|
147 |
// ----------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
int VideoServices::getBrowseCategory() const
|
|
150 |
{
|
|
151 |
MPX_DEBUG(_L("VideoServices::getBrowseCategory()"));
|
|
152 |
|
|
153 |
int category = 0;
|
|
154 |
|
|
155 |
if ( mServiceBrowse )
|
|
156 |
{
|
|
157 |
category = mServiceBrowse->getBrowseCategory();
|
|
158 |
}
|
|
159 |
|
|
160 |
return category;
|
|
161 |
}
|
|
162 |
|
|
163 |
// ----------------------------------------------------------------------------
|
30
|
164 |
// setCurrentService()
|
|
165 |
// ----------------------------------------------------------------------------
|
|
166 |
//
|
|
167 |
void VideoServices::setCurrentService(VideoServices::TVideoService service)
|
|
168 |
{
|
36
|
169 |
MPX_DEBUG(_L("VideoServices::setCurrentService(%d)"), service );
|
|
170 |
|
37
|
171 |
mCurrentService = service;
|
30
|
172 |
}
|
36
|
173 |
|
30
|
174 |
// ----------------------------------------------------------------------------
|
|
175 |
// contextTitle()
|
|
176 |
// ----------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
QString VideoServices::contextTitle() const
|
|
179 |
{
|
36
|
180 |
MPX_DEBUG(_L("VideoServices::contextTitle()") );
|
|
181 |
|
|
182 |
QString title;
|
|
183 |
|
37
|
184 |
if (mCurrentService == VideoServices::EUriFetcher && mServiceUriFetch)
|
36
|
185 |
{
|
|
186 |
title = mServiceUriFetch->contextTitle();
|
|
187 |
}
|
37
|
188 |
else if (mCurrentService == VideoServices::EBrowse && mServiceBrowse)
|
36
|
189 |
{
|
|
190 |
title = mServiceBrowse->contextTitle();
|
|
191 |
}
|
|
192 |
|
|
193 |
return title;
|
30
|
194 |
}
|
|
195 |
|
|
196 |
// ----------------------------------------------------------------------------
|
37
|
197 |
// sortRole()
|
|
198 |
// ----------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
int VideoServices::sortRole() const
|
|
201 |
{
|
|
202 |
MPX_ENTER_EXIT(_L("VideoServices::sortType()"));
|
|
203 |
|
|
204 |
int sortRole = 0;
|
|
205 |
|
|
206 |
if (mCurrentService == EBrowse && mServiceBrowse)
|
|
207 |
{
|
|
208 |
sortRole = mServiceBrowse->sortRole();
|
|
209 |
}
|
|
210 |
|
|
211 |
return sortRole;
|
|
212 |
}
|
|
213 |
|
|
214 |
// ----------------------------------------------------------------------------
|
30
|
215 |
// itemSelected()
|
|
216 |
// ----------------------------------------------------------------------------
|
|
217 |
//
|
|
218 |
void VideoServices::itemSelected(const QString& item)
|
|
219 |
{
|
36
|
220 |
MPX_ENTER_EXIT(_L("VideoServices::itemSelected()"),
|
|
221 |
_L("item = %s"), item.data() );
|
|
222 |
|
30
|
223 |
QStringList list;
|
36
|
224 |
list.append( item );
|
|
225 |
mServiceUriFetch->complete( list );
|
37
|
226 |
mFetchSelected = true;
|
30
|
227 |
}
|
|
228 |
|
36
|
229 |
// ----------------------------------------------------------------------------
|
|
230 |
// browsingEnded()
|
|
231 |
// ----------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
void VideoServices::browsingEnded()
|
|
234 |
{
|
|
235 |
MPX_ENTER_EXIT(_L("VideoServices::browsingEnded()"));
|
|
236 |
|
|
237 |
if ( mServiceBrowse )
|
|
238 |
{
|
|
239 |
mServiceBrowse->complete();
|
|
240 |
}
|
|
241 |
}
|
|
242 |
|
|
243 |
// End of file
|