|
1 /* |
|
2 * Copyright (c) 2008 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: This class plays local video file |
|
15 * |
|
16 */ |
|
17 |
|
18 // Version : %version: 15 % |
|
19 |
|
20 |
|
21 // |
|
22 // INCLUDE FILES |
|
23 // |
|
24 #include <apgcli.h> |
|
25 #include <e32cmn.h> |
|
26 #include <mpxcenrepwatcher.h> |
|
27 #include <mpxcenrepobserver.h> |
|
28 #include <mpxmediageneraldefs.h> |
|
29 #include <mpxcommandgeneraldefs.h> |
|
30 #include <mpxmessagegeneraldefs.h> |
|
31 #include <mpxplaybackcommanddefs.h> |
|
32 #include <mmf/server/mmffile.h> |
|
33 |
|
34 #include "mpxvideohelixplayback.h" |
|
35 #include "mpxvideoprivatecrkeys.h" |
|
36 #include <mpxvideoplaybackdefs.h> |
|
37 |
|
38 // |
|
39 // CONSTANTS |
|
40 // |
|
41 const TUid KLocalPlaybackUid = { 0x10282551 }; |
|
42 |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 // ---------------------------------------------------------------------------- |
|
47 // Two-phased constructor. |
|
48 // ---------------------------------------------------------------------------- |
|
49 // |
|
50 CMPXVideoHelixPlayback* CMPXVideoHelixPlayback::NewL( TAny* /*aInitParams*/ ) |
|
51 { |
|
52 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::NewL()")); |
|
53 |
|
54 CMPXVideoHelixPlayback* p = new (ELeave) CMPXVideoHelixPlayback(); |
|
55 CleanupStack::PushL(p); |
|
56 p->ConstructL(); |
|
57 CleanupStack::Pop(p); |
|
58 return p; |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // Symbian 2nd phase constructor can leave. |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 void CMPXVideoHelixPlayback::ConstructL() |
|
66 { |
|
67 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::ConstructL()")); |
|
68 |
|
69 iVideoPlaybackCtlr = CMPXVideoPlaybackController::NewL( *iObs ); |
|
70 |
|
71 User::LeaveIfError( iFs.Connect() ); |
|
72 iFs.ShareProtected(); |
|
73 } |
|
74 |
|
75 // ---------------------------------------------------------------------------- |
|
76 // C++ constructor |
|
77 // ---------------------------------------------------------------------------- |
|
78 // |
|
79 CMPXVideoHelixPlayback::CMPXVideoHelixPlayback() |
|
80 { |
|
81 MPX_DEBUG(_L("CMPXVideoHelixPlayback::CMPXVideoHelixPlayback()")); |
|
82 } |
|
83 |
|
84 // ---------------------------------------------------------------------------- |
|
85 // Destructor |
|
86 // ---------------------------------------------------------------------------- |
|
87 // |
|
88 CMPXVideoHelixPlayback::~CMPXVideoHelixPlayback() |
|
89 { |
|
90 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::~CMPXVideoHelixPlayback")); |
|
91 |
|
92 iFs.Close(); |
|
93 |
|
94 if ( iVideoPlaybackCtlr ) |
|
95 { |
|
96 delete iVideoPlaybackCtlr; |
|
97 iVideoPlaybackCtlr = NULL; |
|
98 } |
|
99 } |
|
100 |
|
101 // ------------------------------------------------------------------------------------------------ |
|
102 // Sets the file name and file handle |
|
103 // ------------------------------------------------------------------------------------------------ |
|
104 // |
|
105 void CMPXVideoHelixPlayback::OpenFileHandleL( const TDesC& aUri, RFile& aFile ) |
|
106 { |
|
107 MPX_ENTER_EXIT( |
|
108 _L("CMPXVideoHelixPlayback::OpenFileHandleL( RFile )"), |
|
109 _L("aSong %S"), &aUri ); |
|
110 |
|
111 if ( aFile.SubSessionHandle() ) |
|
112 { |
|
113 aFile.Close(); |
|
114 } |
|
115 |
|
116 TInt err = aFile.Open( iFs, aUri, EFileRead | EFileShareReadersOrWriters ); |
|
117 |
|
118 // |
|
119 // Check if RFile64 is needed |
|
120 // |
|
121 if ( err == KErrTooBig ) |
|
122 { |
|
123 User::Leave( KErrTooBig ); |
|
124 } |
|
125 else if ( err != KErrNone ) |
|
126 { |
|
127 CheckForStreamingUrlL( aUri ); |
|
128 } |
|
129 } |
|
130 |
|
131 // ---------------------------------------------------------------------------- |
|
132 // Initializes a clip for playback from a file name |
|
133 // ---------------------------------------------------------------------------- |
|
134 // |
|
135 void CMPXVideoHelixPlayback::InitialiseL( const TDesC& aSong ) |
|
136 { |
|
137 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseL()"), |
|
138 _L("aSong %S"), &aSong ); |
|
139 |
|
140 InitialiseWithPositionL( aSong ); |
|
141 } |
|
142 |
|
143 |
|
144 // ---------------------------------------------------------------------------- |
|
145 // Initializes a clip for playback from a file name with position |
|
146 // ---------------------------------------------------------------------------- |
|
147 // |
|
148 void CMPXVideoHelixPlayback::InitialiseWithPositionL( const TDesC& aSong, TInt aPosition ) |
|
149 { |
|
150 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseL()"), |
|
151 _L("aSong %S, aPosition %d"), &aSong, aPosition ); |
|
152 |
|
153 RFile fileHandle; |
|
154 |
|
155 CleanupClosePushL( fileHandle ); |
|
156 |
|
157 MPX_TRAPD( err, OpenFileHandleL( aSong, fileHandle )); |
|
158 |
|
159 if ( err == KErrNone ) |
|
160 { |
|
161 iVideoPlaybackCtlr->OpenFileL( aSong, fileHandle, aPosition ); |
|
162 } |
|
163 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
164 else if ( err == KErrTooBig ) |
|
165 { |
|
166 // |
|
167 // use RFile64 handle |
|
168 // |
|
169 RFile64 fileHandle64; |
|
170 CleanupClosePushL( fileHandle64 ); |
|
171 |
|
172 MPX_TRAPD( err, OpenFileHandle64L( aSong, fileHandle64 )); |
|
173 |
|
174 if ( err != KErrNone ) |
|
175 { |
|
176 // Handle error |
|
177 iVideoPlaybackCtlr->HandleError( err ); |
|
178 } |
|
179 else |
|
180 { |
|
181 iVideoPlaybackCtlr->OpenFile64L( aSong, fileHandle64, aPosition ); |
|
182 } |
|
183 |
|
184 CleanupStack::PopAndDestroy(); // fileHandle64 |
|
185 } |
|
186 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
187 else |
|
188 { |
|
189 // Handle error |
|
190 iVideoPlaybackCtlr->HandleError( err ); |
|
191 } |
|
192 |
|
193 CleanupStack::PopAndDestroy(); // fileHandle |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 // Initializes a clip for playback from a file handle |
|
198 // ---------------------------------------------------------------------------- |
|
199 // |
|
200 void CMPXVideoHelixPlayback::InitialiseL( RFile& aSong ) |
|
201 { |
|
202 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseL( RFile )")); |
|
203 |
|
204 InitialiseWithPositionL( aSong ); |
|
205 } |
|
206 |
|
207 // ---------------------------------------------------------------------------- |
|
208 // Initializes a clip for playback from a file handle with position |
|
209 // ---------------------------------------------------------------------------- |
|
210 // |
|
211 void CMPXVideoHelixPlayback::InitialiseWithPositionL( RFile& aSong, TInt aPosition ) |
|
212 { |
|
213 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseWithPositionL( RFile )"), |
|
214 _L("aPosition %d"), aPosition ); |
|
215 |
|
216 TFileName filename; |
|
217 aSong.FullName( filename ); |
|
218 |
|
219 iVideoPlaybackCtlr->OpenFileL( filename, aSong, aPosition ); |
|
220 } |
|
221 |
|
222 |
|
223 // ---------------------------------------------------------------------------- |
|
224 // Initializes a clip for playback from a file name |
|
225 // ---------------------------------------------------------------------------- |
|
226 // |
|
227 void CMPXVideoHelixPlayback::InitStreamingL( const TDesC& aUri, |
|
228 const TDesC8& /*aType*/, |
|
229 TInt aAccessPoint, |
|
230 TInt aPosition ) |
|
231 { |
|
232 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreamingL()"), |
|
233 _L("aUri %S, aAccessPoint %d, aPosition %d"), &aUri, aAccessPoint, aPosition ); |
|
234 |
|
235 RFile fileHandle; |
|
236 |
|
237 CleanupClosePushL( fileHandle ); |
|
238 |
|
239 MPX_TRAPD( err, OpenFileHandleL( aUri, fileHandle )); |
|
240 |
|
241 if ( err != KErrNone ) |
|
242 { |
|
243 // Handle error |
|
244 iVideoPlaybackCtlr->HandleError( err ); |
|
245 } |
|
246 else |
|
247 { |
|
248 iVideoPlaybackCtlr->OpenFileL( aUri, fileHandle, aPosition, aAccessPoint ); |
|
249 } |
|
250 |
|
251 CleanupStack::PopAndDestroy(); |
|
252 } |
|
253 |
|
254 // ---------------------------------------------------------------------------- |
|
255 // Initializes a clip for playback from a file handle |
|
256 // ---------------------------------------------------------------------------- |
|
257 // |
|
258 void CMPXVideoHelixPlayback::InitStreamingL( RFile& aFile, TInt aAccessPoint, TInt aPosition ) |
|
259 { |
|
260 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreamingL( RFile )"), |
|
261 _L("aAccessPoint = %d, aPosition = %d"), aAccessPoint, aPosition ); |
|
262 |
|
263 TFileName filename; |
|
264 aFile.FullName( filename ); |
|
265 |
|
266 iVideoPlaybackCtlr->OpenFileL( filename, aFile, aPosition, aAccessPoint ); |
|
267 } |
|
268 |
|
269 // ---------------------------------------------------------------------------- |
|
270 // Executes a command on the selected song |
|
271 // ---------------------------------------------------------------------------- |
|
272 // |
|
273 void CMPXVideoHelixPlayback::CommandL( CMPXCommand& aCmd ) |
|
274 { |
|
275 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::CommandL() - CMPXCommand")); |
|
276 |
|
277 iVideoPlaybackCtlr->HandleCommandL( aCmd ); |
|
278 } |
|
279 |
|
280 |
|
281 // ---------------------------------------------------------------------------- |
|
282 // Executes a command on the selected song |
|
283 // ---------------------------------------------------------------------------- |
|
284 // |
|
285 void CMPXVideoHelixPlayback::CommandL(TMPXPlaybackCommand aCmd, TInt aData) |
|
286 { |
|
287 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::CommandL() - TMPXPlaybackCommand")); |
|
288 |
|
289 iVideoPlaybackCtlr->HandleCommandL(aCmd, aData); |
|
290 } |
|
291 |
|
292 |
|
293 // ---------------------------------------------------------------------------- |
|
294 // Sets a property of the plugin |
|
295 // ---------------------------------------------------------------------------- |
|
296 // |
|
297 void CMPXVideoHelixPlayback::SetL( TMPXPlaybackProperty aProperty, TInt aValue ) |
|
298 { |
|
299 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::SetL()")); |
|
300 |
|
301 // Route the SetL() to VideoPlaybackController |
|
302 iVideoPlaybackCtlr->SetPropertyL(aProperty, aValue); |
|
303 } |
|
304 |
|
305 // ---------------------------------------------------------------------------- |
|
306 // Gets a property of the plugin (async) |
|
307 // ---------------------------------------------------------------------------- |
|
308 // |
|
309 void CMPXVideoHelixPlayback::PropertyL( TMPXPlaybackProperty aProperty ) const |
|
310 { |
|
311 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::PropertyL()")); |
|
312 |
|
313 // Route the PropertyL() to VideoPlaybackController |
|
314 iVideoPlaybackCtlr->GetPropertyL( aProperty ); |
|
315 } |
|
316 |
|
317 // ---------------------------------------------------------------------------- |
|
318 // Gets a list of sub players, UPnP only |
|
319 // ---------------------------------------------------------------------------- |
|
320 // |
|
321 void CMPXVideoHelixPlayback::SubPlayerNamesL() |
|
322 { |
|
323 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::SubPlayerNamesL()")); |
|
324 iObs->HandleSubPlayerNames( KLocalPlaybackUid, NULL, ETrue, KErrNone ); |
|
325 } |
|
326 |
|
327 // ---------------------------------------------------------------------------- |
|
328 // Select a sub player |
|
329 // ---------------------------------------------------------------------------- |
|
330 // |
|
331 void CMPXVideoHelixPlayback::SelectSubPlayerL( TInt /*aIndex*/ ) |
|
332 { |
|
333 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::SelectSubPlayerL()")); |
|
334 User::Leave( KErrNotSupported ); |
|
335 } |
|
336 |
|
337 // ---------------------------------------------------------------------------- |
|
338 // Gets media properties |
|
339 // ---------------------------------------------------------------------------- |
|
340 // |
|
341 void CMPXVideoHelixPlayback::MediaL( const TArray<TMPXAttribute>& aAttrs ) |
|
342 { |
|
343 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::MediaL()")); |
|
344 iVideoPlaybackCtlr->SendMediaL( aAttrs ); |
|
345 } |
|
346 |
|
347 // ---------------------------------------------------------------------------- |
|
348 // Cancel request |
|
349 // ---------------------------------------------------------------------------- |
|
350 // |
|
351 void CMPXVideoHelixPlayback::CancelRequest() |
|
352 { |
|
353 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::CancelRequest()")); |
|
354 } |
|
355 |
|
356 // ------------------------------------------------------------------------------------------------ |
|
357 // CMPXVideoHelixPlayback::CheckForStreamingUrlL() |
|
358 // ------------------------------------------------------------------------------------------------ |
|
359 // |
|
360 void CMPXVideoHelixPlayback::CheckForStreamingUrlL( const TDesC& aUri ) |
|
361 { |
|
362 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::CMPXVideoHelixPlayback::CheckForStreamingUrlL()")); |
|
363 |
|
364 CMediaRecognizer* recognizer = CMediaRecognizer::NewL(); |
|
365 CleanupStack::PushL( recognizer ); |
|
366 |
|
367 if ( ! recognizer->IsValidStreamingPrefix( aUri ) ) |
|
368 { |
|
369 User::LeaveIfError( KErrNotFound ); |
|
370 } |
|
371 |
|
372 CleanupStack::PopAndDestroy( recognizer ); |
|
373 } |
|
374 |
|
375 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
376 |
|
377 // ------------------------------------------------------------------------------------------------ |
|
378 // Sets the file name and 64-bit file handle |
|
379 // ------------------------------------------------------------------------------------------------ |
|
380 // |
|
381 void CMPXVideoHelixPlayback::OpenFileHandle64L( const TDesC& aUri, RFile64& aFile ) |
|
382 { |
|
383 MPX_ENTER_EXIT( |
|
384 _L("CMPXVideoHelixPlayback::OpenFileHandle64L( RFile64 )"), |
|
385 _L("aSong %S"), &aUri ); |
|
386 |
|
387 if ( aFile.SubSessionHandle() ) |
|
388 { |
|
389 aFile.Close(); |
|
390 } |
|
391 |
|
392 TInt err = aFile.Open( iFs, aUri, EFileRead | EFileShareReadersOrWriters ); |
|
393 |
|
394 if ( err != KErrNone ) |
|
395 { |
|
396 CheckForStreamingUrlL( aUri ); |
|
397 } |
|
398 } |
|
399 |
|
400 // ---------------------------------------------------------------------------- |
|
401 // Initializes a clip for playback from a 64-bit file handle |
|
402 // ---------------------------------------------------------------------------- |
|
403 // |
|
404 void CMPXVideoHelixPlayback::Initialise64L( RFile64& aSong, TInt aPosition ) |
|
405 { |
|
406 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::Initialise64L( RFile64 )"), |
|
407 _L("aPosition %d"), aPosition ); |
|
408 TFileName filename; |
|
409 aSong.FullName( filename ); |
|
410 |
|
411 iVideoPlaybackCtlr->OpenFile64L( filename, aSong, aPosition ); |
|
412 } |
|
413 |
|
414 // ---------------------------------------------------------------------------- |
|
415 // Initializes a clip for playback from a 64-bit file handle |
|
416 // ---------------------------------------------------------------------------- |
|
417 // |
|
418 void CMPXVideoHelixPlayback::InitStreaming64L( RFile64& aFile, TInt aAccessPoint, TInt aPosition ) |
|
419 { |
|
420 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreaming64L( RFile64 )"), |
|
421 _L("aAccessPoint = %d, aPosition %d"), aAccessPoint, aPosition ); |
|
422 |
|
423 TFileName filename; |
|
424 aFile.FullName( filename ); |
|
425 |
|
426 iVideoPlaybackCtlr->OpenFile64L( filename, aFile, aPosition, aAccessPoint ); |
|
427 } |
|
428 |
|
429 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
430 |
|
431 // End of file |