|
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: 11 % |
|
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 HandleOpenFileHandleL( err ); |
|
118 } |
|
119 |
|
120 // ---------------------------------------------------------------------------- |
|
121 // Initializes a clip for playback from a file name |
|
122 // ---------------------------------------------------------------------------- |
|
123 // |
|
124 void CMPXVideoHelixPlayback::InitialiseL( const TDesC& aSong ) |
|
125 { |
|
126 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseL()"), |
|
127 _L("aSong %S"), &aSong ); |
|
128 |
|
129 RFile fileHandle; |
|
130 |
|
131 CleanupClosePushL( fileHandle ); |
|
132 |
|
133 MPX_TRAPD( err, OpenFileHandleL( aSong, fileHandle )); |
|
134 |
|
135 if ( err == KErrNone ) |
|
136 { |
|
137 iVideoPlaybackCtlr->OpenFileL( aSong, fileHandle ); |
|
138 } |
|
139 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
140 else if ( err == KErrTooBig ) |
|
141 { |
|
142 // |
|
143 // use RFile64 handle |
|
144 // |
|
145 RFile64 fileHandle64; |
|
146 CleanupClosePushL( fileHandle64 ); |
|
147 |
|
148 MPX_TRAPD( err, OpenFileHandle64L( aSong, fileHandle64 )); |
|
149 |
|
150 if ( err != KErrNone ) |
|
151 { |
|
152 // Handle error |
|
153 iVideoPlaybackCtlr->HandleError( err ); |
|
154 } |
|
155 else |
|
156 { |
|
157 iVideoPlaybackCtlr->OpenFile64L( aSong, fileHandle64 ); |
|
158 } |
|
159 |
|
160 CleanupStack::PopAndDestroy(); // fileHandle64 |
|
161 } |
|
162 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
163 else |
|
164 { |
|
165 // Handle error |
|
166 iVideoPlaybackCtlr->HandleError( err ); |
|
167 } |
|
168 |
|
169 CleanupStack::PopAndDestroy(); // fileHandle |
|
170 } |
|
171 |
|
172 // ---------------------------------------------------------------------------- |
|
173 // Initializes a clip for playback from a file handle |
|
174 // ---------------------------------------------------------------------------- |
|
175 // |
|
176 void CMPXVideoHelixPlayback::InitialiseL( RFile& aSong ) |
|
177 { |
|
178 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitialiseL( RFile )")); |
|
179 |
|
180 TFileName filename; |
|
181 aSong.FullName( filename ); |
|
182 |
|
183 iVideoPlaybackCtlr->OpenFileL( filename, aSong ); |
|
184 } |
|
185 |
|
186 |
|
187 // ---------------------------------------------------------------------------- |
|
188 // Initializes a clip for playback from a file name |
|
189 // ---------------------------------------------------------------------------- |
|
190 // |
|
191 void CMPXVideoHelixPlayback::InitStreamingL( const TDesC& aUri, |
|
192 const TDesC8& /*aType*/, |
|
193 TInt aAccessPoint ) |
|
194 { |
|
195 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreamingL()"), |
|
196 _L("aUri %S, aType %d"), &aUri, aAccessPoint ); |
|
197 |
|
198 RFile fileHandle; |
|
199 |
|
200 CleanupClosePushL( fileHandle ); |
|
201 |
|
202 MPX_TRAPD( err, OpenFileHandleL( aUri, fileHandle )); |
|
203 |
|
204 if ( err != KErrNone ) |
|
205 { |
|
206 // Handle error |
|
207 iVideoPlaybackCtlr->HandleError( err ); |
|
208 } |
|
209 else |
|
210 { |
|
211 iVideoPlaybackCtlr->OpenFileL( aUri, fileHandle, aAccessPoint ); |
|
212 } |
|
213 |
|
214 CleanupStack::PopAndDestroy(); |
|
215 } |
|
216 |
|
217 // ---------------------------------------------------------------------------- |
|
218 // Initializes a clip for playback from a file handle |
|
219 // ---------------------------------------------------------------------------- |
|
220 // |
|
221 void CMPXVideoHelixPlayback::InitStreamingL( RFile& aFile, TInt aAccessPoint ) |
|
222 { |
|
223 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreamingL( RFile )")); |
|
224 |
|
225 TFileName filename; |
|
226 aFile.FullName( filename ); |
|
227 |
|
228 iVideoPlaybackCtlr->OpenFileL( filename, aFile, aAccessPoint ); |
|
229 } |
|
230 |
|
231 // ---------------------------------------------------------------------------- |
|
232 // Executes a command on the selected song |
|
233 // ---------------------------------------------------------------------------- |
|
234 // |
|
235 void CMPXVideoHelixPlayback::CommandL( CMPXCommand& aCmd ) |
|
236 { |
|
237 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::CommandL() - CMPXCommand")); |
|
238 |
|
239 iVideoPlaybackCtlr->HandleCommandL( aCmd ); |
|
240 } |
|
241 |
|
242 |
|
243 // ---------------------------------------------------------------------------- |
|
244 // Executes a command on the selected song |
|
245 // ---------------------------------------------------------------------------- |
|
246 // |
|
247 void CMPXVideoHelixPlayback::CommandL(TMPXPlaybackCommand aCmd, TInt aData) |
|
248 { |
|
249 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::CommandL() - TMPXPlaybackCommand")); |
|
250 |
|
251 iVideoPlaybackCtlr->HandleCommandL(aCmd, aData); |
|
252 } |
|
253 |
|
254 |
|
255 // ---------------------------------------------------------------------------- |
|
256 // Sets a property of the plugin |
|
257 // ---------------------------------------------------------------------------- |
|
258 // |
|
259 void CMPXVideoHelixPlayback::SetL( TMPXPlaybackProperty aProperty, TInt aValue ) |
|
260 { |
|
261 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::SetL()")); |
|
262 |
|
263 // Route the SetL() to VideoPlaybackController |
|
264 iVideoPlaybackCtlr->SetPropertyL(aProperty, aValue); |
|
265 } |
|
266 |
|
267 // ---------------------------------------------------------------------------- |
|
268 // Gets a property of the plugin (async) |
|
269 // ---------------------------------------------------------------------------- |
|
270 // |
|
271 void CMPXVideoHelixPlayback::PropertyL( TMPXPlaybackProperty aProperty ) const |
|
272 { |
|
273 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::PropertyL()")); |
|
274 |
|
275 // Route the PropertyL() to VideoPlaybackController |
|
276 iVideoPlaybackCtlr->GetPropertyL( aProperty ); |
|
277 } |
|
278 |
|
279 // ---------------------------------------------------------------------------- |
|
280 // Gets a list of sub players, UPnP only |
|
281 // ---------------------------------------------------------------------------- |
|
282 // |
|
283 void CMPXVideoHelixPlayback::SubPlayerNamesL() |
|
284 { |
|
285 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::SubPlayerNamesL()")); |
|
286 iObs->HandleSubPlayerNames( KLocalPlaybackUid, NULL, ETrue, KErrNone ); |
|
287 } |
|
288 |
|
289 // ---------------------------------------------------------------------------- |
|
290 // Select a sub player |
|
291 // ---------------------------------------------------------------------------- |
|
292 // |
|
293 void CMPXVideoHelixPlayback::SelectSubPlayerL( TInt /*aIndex*/ ) |
|
294 { |
|
295 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::SelectSubPlayerL()")); |
|
296 User::Leave( KErrNotSupported ); |
|
297 } |
|
298 |
|
299 // ---------------------------------------------------------------------------- |
|
300 // Gets media properties |
|
301 // ---------------------------------------------------------------------------- |
|
302 // |
|
303 void CMPXVideoHelixPlayback::MediaL( const TArray<TMPXAttribute>& aAttrs ) |
|
304 { |
|
305 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::MediaL()")); |
|
306 iVideoPlaybackCtlr->SendMediaL( aAttrs ); |
|
307 } |
|
308 |
|
309 // ---------------------------------------------------------------------------- |
|
310 // Cancel request |
|
311 // ---------------------------------------------------------------------------- |
|
312 // |
|
313 void CMPXVideoHelixPlayback::CancelRequest() |
|
314 { |
|
315 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::CancelRequest()")); |
|
316 } |
|
317 |
|
318 // ---------------------------------------------------------------------------- |
|
319 // Handle Open File Handle |
|
320 // ---------------------------------------------------------------------------- |
|
321 // |
|
322 void CMPXVideoHelixPlayback::HandleOpenFileHandleL( TInt aError ) |
|
323 { |
|
324 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::HandleOpenFileHandleL()")); |
|
325 |
|
326 // |
|
327 // Remap KErrNotReady to KErrNotFound, because it is referencing a drive |
|
328 // that is not existent |
|
329 // |
|
330 if ( aError == KErrNotReady ) |
|
331 { |
|
332 aError = KErrNotFound; |
|
333 } |
|
334 |
|
335 MPX_DEBUG(_L("CMPXVideoHelixPlayback::HandleOpenFileHandleL() Open error = %d"), aError); |
|
336 |
|
337 // |
|
338 // if aSong is an streaming link and contains one of the streaming schemas |
|
339 // eg. rtsp:// , http:// etc. then a file handle can not be opened |
|
340 // ignore KErrBadName |
|
341 // |
|
342 if ( aError != KErrBadName ) |
|
343 { |
|
344 User::LeaveIfError( aError ); |
|
345 } |
|
346 } |
|
347 |
|
348 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
349 |
|
350 // ------------------------------------------------------------------------------------------------ |
|
351 // Sets the file name and 64-bit file handle |
|
352 // ------------------------------------------------------------------------------------------------ |
|
353 // |
|
354 void CMPXVideoHelixPlayback::OpenFileHandle64L( const TDesC& aUri, RFile64& aFile ) |
|
355 { |
|
356 MPX_ENTER_EXIT( |
|
357 _L("CMPXVideoHelixPlayback::OpenFileHandle64L( RFile64 )"), |
|
358 _L("aSong %S"), &aUri ); |
|
359 |
|
360 if ( aFile.SubSessionHandle() ) |
|
361 { |
|
362 aFile.Close(); |
|
363 } |
|
364 |
|
365 TInt err = aFile.Open( iFs, aUri, EFileRead | EFileShareReadersOrWriters ); |
|
366 HandleOpenFileHandleL( err ); |
|
367 } |
|
368 |
|
369 // ---------------------------------------------------------------------------- |
|
370 // Initializes a clip for playback from a 64-bit file handle |
|
371 // ---------------------------------------------------------------------------- |
|
372 // |
|
373 void CMPXVideoHelixPlayback::Initialise64L( RFile64& aSong ) |
|
374 { |
|
375 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::Initialise64L( RFile64 )")); |
|
376 |
|
377 TFileName filename; |
|
378 aSong.FullName( filename ); |
|
379 |
|
380 iVideoPlaybackCtlr->OpenFile64L( filename, aSong ); |
|
381 } |
|
382 |
|
383 // ---------------------------------------------------------------------------- |
|
384 // Initializes a clip for playback from a 64-bit file handle |
|
385 // ---------------------------------------------------------------------------- |
|
386 // |
|
387 void CMPXVideoHelixPlayback::InitStreaming64L( RFile64& aFile, TInt aAccessPoint ) |
|
388 { |
|
389 MPX_ENTER_EXIT(_L("CMPXVideoHelixPlayback::InitStreaming64L( RFile64 )")); |
|
390 |
|
391 TFileName filename; |
|
392 aFile.FullName( filename ); |
|
393 |
|
394 iVideoPlaybackCtlr->OpenFile64L( filename, aFile, aAccessPoint ); |
|
395 } |
|
396 |
|
397 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
398 |
|
399 // End of file |