|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <videoplayer.h> |
|
17 #include <videoplayer2.h> |
|
18 #include "mmfvideocallback.h" |
|
19 #include "VideoPlayerBody.h" |
|
20 |
|
21 /** |
|
22 Creates a new instance of the video player utility. Unlike CVideoPlayerUtility::NewL(), |
|
23 the CVideoPlayerUtility2 factory does not require window handles and other video display |
|
24 information as its arguments. The client can set up rendering later with |
|
25 AddDisplayWindowL(), or optionally use the utility without a window, for example, for metadata |
|
26 query purposes. |
|
27 |
|
28 @param aObserver |
|
29 A client class to receive notifications from the video player. |
|
30 @param aPriority |
|
31 The Priority Value - this client's relative priority. This is a value between EMdaPriorityMin and |
|
32 EMdaPriorityMax and represents a relative priority. A higher value indicates a more important request. |
|
33 @param aPref |
|
34 The Priority Preference - an additional audio policy parameter. The suggested default is |
|
35 EMdaPriorityPreferenceNone. Further values are given by TMdaPriorityPreference, and additional |
|
36 values may be supported by given phones and/or platforms, but should not be depended upon by |
|
37 portable code. |
|
38 |
|
39 @return A pointer to the new video player utility object. |
|
40 |
|
41 @leave The method will leave if an error occurs. Typical error codes used: |
|
42 * KErrNoMemory if out of memory. |
|
43 |
|
44 Note: The Priority Value and Priority Preference are used primarily when deciding what to do when |
|
45 several audio clients attempt to play or record simultaneously. In addition to the Priority Value and Preference, |
|
46 the adaptation may consider other parameters such as the SecureId and Capabilities of the client process. |
|
47 Whatever, the decision as to what to do in such situations is up to the audio adaptation, and may |
|
48 vary between different phones. Portable applications are advised not to assume any specific behaviour. |
|
49 |
|
50 */ |
|
51 EXPORT_C CVideoPlayerUtility2* CVideoPlayerUtility2::NewL(MVideoPlayerUtilityObserver& aObserver, |
|
52 TInt aPriority, |
|
53 TInt aPref) |
|
54 { |
|
55 CVideoPlayerUtility2* s = new(ELeave) CVideoPlayerUtility2(); |
|
56 CleanupStack::PushL(s); |
|
57 s->iBody = CVideoPlayerUtility::CBody::NewL(s, aObserver, aPriority, aPref); |
|
58 CleanupStack::Pop(); |
|
59 return s; |
|
60 } |
|
61 |
|
62 /** |
|
63 Destructor. Closes any open video clips and frees any resources held by the Video Player. |
|
64 */ |
|
65 CVideoPlayerUtility2::~CVideoPlayerUtility2() |
|
66 { |
|
67 } |
|
68 |
|
69 /** |
|
70 Adds a new window for displaying the video picture. Client applications must use this method |
|
71 instead of SetDisplayWindowL() when using CVideoPlayerUtility2. |
|
72 |
|
73 This method can only be called after opening the source is complete and the client has |
|
74 received an MvpuoOpenComplete() callback. |
|
75 |
|
76 @param aWs |
|
77 The window server session for this window. |
|
78 @param aScreenDevice |
|
79 The screen device for the screen that the window is displayed on. |
|
80 @param aWindow |
|
81 The display window. |
|
82 @param aVideoExtent |
|
83 Video extent on the screen, relative to the window. Video picture position within |
|
84 the extent depends on the scaled picture and content alignment or offset. The video |
|
85 extent can be partially or completely outside the window. |
|
86 @param aWindowClipRect |
|
87 Window clipping rectangle, relative to the window. The clipping rectangle specifies |
|
88 the part of the window used for video display. The rectangle must be contained |
|
89 completely within the window. |
|
90 @leave The method will leave if an error occurs. Typical error codes used: |
|
91 * KErrNotReady if the source file, URL, or descriptor has not been opened. |
|
92 */ |
|
93 EXPORT_C void CVideoPlayerUtility2::AddDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, |
|
94 RWindow& aWindow, const TRect& aVideoExtent, |
|
95 const TRect& aWindowClipRect) |
|
96 { |
|
97 iBody->AddDisplayWindowL(aWs, aScreenDevice, aWindow, aVideoExtent, aWindowClipRect); |
|
98 } |
|
99 |
|
100 /** |
|
101 A simplified variant of AddDisplayWindowL(). When this variant is used, the video extent and |
|
102 window clipping rectangle default to the whole window. |
|
103 |
|
104 This method can only be called after opening the source is complete and the client has |
|
105 received an MvpuoOpenComplete() callback. |
|
106 |
|
107 @param aWs |
|
108 The window server session for this window. |
|
109 @param aScreenDevice |
|
110 The screen device for the screen that the window is displayed on. |
|
111 @param aWindow |
|
112 The display window. |
|
113 @leave The method will leave if an error occurs. Typical error codes used: |
|
114 * KErrNotReady if the source file, URL, or descriptor has not been opened. |
|
115 */ |
|
116 EXPORT_C void CVideoPlayerUtility2::AddDisplayWindowL(RWsSession& aWs, CWsScreenDevice& aScreenDevice, RWindow& aWindow) |
|
117 { |
|
118 iBody->AddDisplayWindowL(aWs, aScreenDevice, aWindow); |
|
119 } |
|
120 |
|
121 /** |
|
122 Removes a window that is currently being used to display the video picture. The window must |
|
123 have previously been added with AddDisplayWindowL(). |
|
124 |
|
125 This method cannot fail. If the window has not been added with AddDisplayWindowL(), the |
|
126 method call will be ignored. |
|
127 |
|
128 @param aWindow |
|
129 The display window. |
|
130 */ |
|
131 EXPORT_C void CVideoPlayerUtility2::RemoveDisplayWindow(RWindow& aWindow) |
|
132 { |
|
133 iBody->RemoveDisplayWindow(aWindow); |
|
134 } |
|
135 |
|
136 /** |
|
137 Sets the video extent on the screen, relative to the window. The extent specifies the area |
|
138 of screen in which the video picture is placed, and may be partially or completely outside of |
|
139 the video window. Video picture position within the extent depends on the picture size and |
|
140 content alignment or offset. |
|
141 |
|
142 This method can only be called after opening the source is complete and the client has |
|
143 received an MvpuoOpenComplete() callback. |
|
144 |
|
145 @param aWindow |
|
146 Window to set video extent for. |
|
147 @param aVideoExtent |
|
148 The new video extent, relative to the video window. |
|
149 @leave The method will leave if an error occurs. Typical error codes used: |
|
150 * KErrNotReady if the source file, URL, or descriptor has not been opened. |
|
151 */ |
|
152 EXPORT_C void CVideoPlayerUtility2::SetVideoExtentL(const RWindow& aWindow, const TRect& aVideoExtent) |
|
153 { |
|
154 iBody->SetVideoExtentL(aWindow, aVideoExtent); |
|
155 } |
|
156 |
|
157 /** |
|
158 Sets the window clipping rectangle, relative to the window. The clipping rectangle specifies |
|
159 the part of the window used to display the video picture and must be fully contained within |
|
160 the window. |
|
161 |
|
162 This method can only be called after opening the source is complete and the client has |
|
163 received an MvpuoOpenComplete() callback. |
|
164 |
|
165 @param aWindow |
|
166 Window to set clipping rectangle for. |
|
167 @param aWindowClipRect |
|
168 The clipping rectangle to use for this window. |
|
169 @leave The method will leave if an error occurs. Typical error codes used: |
|
170 * KErrArgument if the rectangle is not contained within the window. |
|
171 * KErrNotReady if the source file, URL, or descriptor has not been opened. |
|
172 */ |
|
173 EXPORT_C void CVideoPlayerUtility2::SetWindowClipRectL(const RWindow& aWindow, const TRect& aWindowClipRect) |
|
174 { |
|
175 iBody->SetWindowClipRectL(aWindow, aWindowClipRect); |
|
176 } |
|
177 |
|
178 /** |
|
179 Rotates the video image within the window. This is the preferred method to use with CVideoPlayerUtility2. |
|
180 |
|
181 The rotation will replace any rotation set with CVideoPlayerUtility::SetRotationL. |
|
182 Likewise with setting the rotation with CVideoPlayerUtility::SetRotationL after a call to CVideoPlayerUtility2::SetRotationL has been |
|
183 made, then the rotation specified will replace any rotation set with CVideoPlayerUtility2::SetRotationL. |
|
184 |
|
185 @param aWindow Window to set rotation for. |
|
186 @param aRotation The video rotation to use for aWindow. |
|
187 |
|
188 @leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2 |
|
189 @leave KErrNotReady if controller hasn't been opened. |
|
190 |
|
191 @see CVideoPlayerUtility::SetRotationL |
|
192 @see TVideoRotation |
|
193 */ |
|
194 |
|
195 EXPORT_C void CVideoPlayerUtility2::SetRotationL(const RWindow& aWindow, TVideoRotation aRotation) |
|
196 { |
|
197 iBody->SetRotationL(aWindow, aRotation); |
|
198 } |
|
199 |
|
200 /** |
|
201 Retrieves the video rotation set for a window. This is the preferred method to use with CVideoPlayerUtility2. |
|
202 |
|
203 @param aWindow Window to retrieve rotation for. |
|
204 @return The video rotation. |
|
205 |
|
206 @leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2 |
|
207 @leave KErrNotReady if controller hasn't been opened. |
|
208 |
|
209 @see TVideoRotation |
|
210 @see CVideoPlayerUtility2::AddDisplayWindowL |
|
211 */ |
|
212 |
|
213 EXPORT_C TVideoRotation CVideoPlayerUtility2::RotationL(const RWindow& aWindow) |
|
214 { |
|
215 return iBody->RotationL(aWindow); |
|
216 } |
|
217 |
|
218 /** |
|
219 Scales the video image to a specified percentage of its original size within the window. |
|
220 This is the preferred method to use with CVideoPlayerUtility2. |
|
221 Setting scale factor will set auto scale to EAutoScaleNone for the window. |
|
222 |
|
223 The scale factor will replace any scale factor set with CVideoPlayerUtility::SetScaleFactorL. |
|
224 Likewise with setting the scale factor with CVideoPlayerUtility::SetScaleFactorL after a call to CVideoPlayerUtility2::SetScaleFactorL has been |
|
225 made, then the scale factor specified will replace any scale factor set with CVideoPlayerUtility2::SetScaleFactorL. |
|
226 |
|
227 @param aWindow Window to set scale factor for. |
|
228 @param aWidthPercentage |
|
229 The percentage (100 = original size) to be used to scale the width of the video image |
|
230 @param aHeightPercentage |
|
231 The percentage (100 = original size) to be used to scale the height of the video image. |
|
232 If this is not equal to aWidthPercentage then the image may be distorted. |
|
233 |
|
234 @leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2 |
|
235 @leave KErrNotReady if controller hasn't been opened. |
|
236 |
|
237 @see CVideoPlayerUtility::SetScaleFactorL |
|
238 */ |
|
239 |
|
240 EXPORT_C void CVideoPlayerUtility2::SetScaleFactorL(const RWindow& aWindow, TReal32 aWidthPercentage, TReal32 aHeightPercentage) |
|
241 { |
|
242 iBody->SetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage); |
|
243 } |
|
244 |
|
245 /** |
|
246 Retrieves the scale factor currently set for a window. This is the preferred method to use with CVideoPlayerUtility2. |
|
247 |
|
248 @param aWindow Window to retrieve scale factor for. |
|
249 @param aWidthPercentage |
|
250 On function return, contains the current scaling percentage applied to the width of the |
|
251 video image (100 = original size). |
|
252 @param aHeightPercentage |
|
253 On function return, contains the current scaling percentage applied to the height |
|
254 of the video image (100 = original size). |
|
255 |
|
256 @leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2 |
|
257 @leave KErrNotReady if controller hasn't been opened. |
|
258 */ |
|
259 |
|
260 EXPORT_C void CVideoPlayerUtility2::GetScaleFactorL(const RWindow& aWindow, TReal32& aWidthPercentage, TReal32& aHeightPercentage) |
|
261 { |
|
262 iBody->GetScaleFactorL(aWindow, aWidthPercentage, aHeightPercentage); |
|
263 } |
|
264 |
|
265 /** |
|
266 Set video automatic scaling. When automatic scaling is active, the |
|
267 video picture is scaled automatically to match the video extent, |
|
268 based on the scaling type. This variant of SetAutoScaleL() will |
|
269 always center the picture in the extent. |
|
270 |
|
271 This is the preferred method to use with CVideoPlayerUtility2. |
|
272 |
|
273 Calling SetAutoScaleL() will override any scaling factors set with |
|
274 SetScaleFactorL(). Calling SetScaleFactorL() will disable automatic |
|
275 scaling. |
|
276 |
|
277 @see TAutoScaleType, THorizontalAlign, TVerticalAlign |
|
278 |
|
279 @param aWindow Window to set auto scaling options for. |
|
280 @param aScaleType Automatic scaling type |
|
281 |
|
282 @pre The video clip has been opened by the client |
|
283 |
|
284 @leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2 |
|
285 @leave KErrNotReady if controller hasn't been opened. |
|
286 */ |
|
287 |
|
288 EXPORT_C void CVideoPlayerUtility2::SetAutoScaleL(const RWindow& aWindow, TAutoScaleType aScaleType) |
|
289 { |
|
290 iBody->SetAutoScaleL(aWindow, aScaleType); |
|
291 } |
|
292 |
|
293 /** |
|
294 Set video automatic scaling. When automatic scaling is active, the |
|
295 video picture is scaled automatically to match the video extent, |
|
296 based on the scaling type, and positioned according to the |
|
297 parameters. |
|
298 |
|
299 This is the preferred method to use with CVideoPlayerUtility2. |
|
300 |
|
301 Calling SetAutoScaleL() will override any scaling factors set with |
|
302 SetScaleFactorL(). Calling SetScaleFactorL() will disable automatic |
|
303 scaling. |
|
304 |
|
305 @see TAutoScaleType, THorizontalAlign, TVerticalAlign |
|
306 |
|
307 @param aWindow Window to set auto scaling options for. |
|
308 @param aScaleType Automatic scaling type |
|
309 @param aHorizPos Video picture horizontal position, relative to the |
|
310 video window. The value can be either a pixel offset |
|
311 (positive or negative) from the top left corner of the |
|
312 window to the top left corner of the picture, or an |
|
313 alignment constant from enum THorizontalAlign. |
|
314 @param aVertPos Video picture vertical position, relative to the |
|
315 video window. The value can be either a pixel offset |
|
316 (positive or negative) from the top left corner of the |
|
317 window to the top left corner of the picture, or an |
|
318 alignment constant from enum TVerticalAlign. |
|
319 |
|
320 @pre The video clip has been opened by the client. |
|
321 |
|
322 @leave KErrNotFound if aWindow isn't currently added to CVideoPlayerUtility2 |
|
323 @leave KErrNotReady if controller hasn't been opened. |
|
324 */ |
|
325 |
|
326 EXPORT_C void CVideoPlayerUtility2::SetAutoScaleL(const RWindow& aWindow, TAutoScaleType aScaleType, TInt aHorizPos, TInt aVertPos) |
|
327 { |
|
328 iBody->SetAutoScaleL(aWindow, aScaleType, aHorizPos, aVertPos); |
|
329 } |
|
330 |
|
331 /** |
|
332 Adds the specified display to the list of surface rendering targets. |
|
333 This API can be used in conjunction with AddDisplayWindowL calls. |
|
334 The caller is responsible for handling surface events generated for the specific display. |
|
335 A single graphics surface is created and shared between all windows and displays. |
|
336 Surface registration and de-registration is managed by the MMF framework. |
|
337 |
|
338 @see AddDisplayWindowL |
|
339 |
|
340 @param aWs Window server session. |
|
341 @param aDisplay Display to create graphics surface on. |
|
342 @param aEventHandler Call-back interface for receiving surface specific events. |
|
343 |
|
344 @leave Any of the system wide error codes. |
|
345 @leave KErrNotReady if the source file, URL or descriptor has not been opened. |
|
346 @leave KErrInUse if the display has already been added by a previous AddDisplayL call. |
|
347 */ |
|
348 |
|
349 EXPORT_C void CVideoPlayerUtility2::AddDisplayL(RWsSession& /* aWs */, TInt aDisplay, MMMFSurfaceEventHandler& aEventHandler) |
|
350 { |
|
351 iBody->AddDisplayL(aDisplay, aEventHandler); |
|
352 } |
|
353 |
|
354 /** |
|
355 Removes the specified display from the list of surface rendering targets. |
|
356 |
|
357 @param aDisplay Display id of display to remove |
|
358 */ |
|
359 |
|
360 EXPORT_C void CVideoPlayerUtility2::RemoveDisplay(TInt aDisplay) |
|
361 { |
|
362 iBody->RemoveDisplay(aDisplay); |
|
363 } |
|
364 |
|
365 /** |
|
366 When enabled sets automatic switching of surface to/from external display when it is connected/disconnected from the device. |
|
367 |
|
368 Automatic switching is enabled by default, but only if the client thread that created this utility has an Active Scheduler |
|
369 installed and the device supports external display switching. |
|
370 |
|
371 To use this function the client thread must have an Active Scheduler installed otherwise it will leave with KErrNotReady. |
|
372 |
|
373 @param aControl |
|
374 ETrue to enable. EFalse to disable. |
|
375 @param aDisplay |
|
376 Display id of display to enable external switching for. |
|
377 @leave KErrNotSupported Device does not support external displays |
|
378 @leave KErrNotReady CActiveScheduler is not installed |
|
379 */ |
|
380 EXPORT_C void CVideoPlayerUtility2::SetExternalDisplaySwitchingL(TInt aDisplay, TBool aControl) |
|
381 { |
|
382 iBody->SetExternalDisplaySwitchingL(aDisplay, aControl); |
|
383 } |
|
384 |
|
385 #ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT |
|
386 /** |
|
387 Check to see if subtitles are available with the current video stream and controller. |
|
388 |
|
389 @return ETrue if subtitles can be enabled, |
|
390 EFalse if subtitles are not available with the current video stream or video clip has not been opened |
|
391 */ |
|
392 EXPORT_C TBool CVideoPlayerUtility2::SubtitlesAvailable() |
|
393 { |
|
394 return iBody->SubtitlesAvailable(); |
|
395 } |
|
396 |
|
397 /** |
|
398 Enable subtitles with the current video stream. |
|
399 |
|
400 @pre The video clip has been opened by the client and SubtitlesAvailable() return ETrue. |
|
401 |
|
402 @leave KErrNotReady if the video source file, URL, or descriptor has not been opened, |
|
403 or no window has been added to CVideoPlayerUtility2. |
|
404 @leave KErrNotSupported if underlying video player controller does not support subtitles. |
|
405 @leave KErrNotFound if the opened video source has no associated subtitle data. |
|
406 @leave KErrInUse if subtitle is already enabled. |
|
407 @leave Otherwise leaves with any of the system wide error codes. |
|
408 |
|
409 @panic MMFVideoPlayUtil 1 In debug mode, if the video source file, URL, or descriptor has not been opened. |
|
410 @panic MMFVideoPlayUtil 2 In debug mode, if subtitle is not supported or not available. |
|
411 @panic MMFVideoPlayUtil 3 In debug mode, if no display window has been added. |
|
412 */ |
|
413 EXPORT_C void CVideoPlayerUtility2::EnableSubtitlesL() |
|
414 { |
|
415 iBody->EnableSubtitlesL(); |
|
416 } |
|
417 |
|
418 /** |
|
419 Disable subtitles. |
|
420 */ |
|
421 EXPORT_C void CVideoPlayerUtility2::DisableSubtitles() |
|
422 { |
|
423 iBody->DisableSubtitles(); |
|
424 } |
|
425 |
|
426 /** |
|
427 Get the current subtitle language. |
|
428 |
|
429 @pre Subtitle has been enabled. |
|
430 @return The current subtitle language, or ELangNone if no language information is available |
|
431 |
|
432 @leave KErrNotReady if subtitle has not been enabled. |
|
433 @leave Otherwise leaves with any of the system wide error codes. |
|
434 |
|
435 @panic MMFVideoPlayUtil 4 In debug mode, if subtitle has not been enabled. |
|
436 */ |
|
437 EXPORT_C TLanguage CVideoPlayerUtility2::SubtitleLanguageL() |
|
438 { |
|
439 return iBody->SubtitleLanguageL(); |
|
440 } |
|
441 |
|
442 /** |
|
443 Return the subtitle languages available. |
|
444 |
|
445 @pre Subtitles have been enabled. |
|
446 @return A array of the currently available languages, or an empty array if |
|
447 subtitle source does not contain any language information. Array is valid |
|
448 until subtitles are disabled. |
|
449 |
|
450 @leave KErrNotReady if subtitles have not been enabled. |
|
451 @leave Otherwise leaves with any of the system wide error codes. |
|
452 |
|
453 @panic MMFVideoPlayUtil 4 In debug mode, if subtitles have not been enabled. |
|
454 */ |
|
455 EXPORT_C TArray<TLanguage> CVideoPlayerUtility2::SupportedSubtitleLanguagesL() |
|
456 { |
|
457 return iBody->SupportedSubtitleLanguagesL(); |
|
458 } |
|
459 |
|
460 /** |
|
461 Set the current subtitle language. |
|
462 |
|
463 @see CVideoPlayerUtility2::GetSupportedSubtitleLanguagesL() |
|
464 |
|
465 @pre Subtitles have been enabled. |
|
466 @pre GetSupportedSubtitleLanguagesL() return a non empty array |
|
467 |
|
468 @param aLanguage Language to be used for subtitle stream. |
|
469 |
|
470 @leave KErrNotReady if subtitles have not been enabled. |
|
471 @leave KErrNotSupported if subtitle language is not supported |
|
472 @leave Otherwise leaves with any of the system wide error codes. |
|
473 |
|
474 @panic MMFVideoPlayUtil 4 In debug mode, if subtitles have not been enabled. |
|
475 @panic MMFVideoPlayUtil 5 In debug mode, if subtitle language is not supported. |
|
476 */ |
|
477 EXPORT_C void CVideoPlayerUtility2::SetSubtitleLanguageL(TLanguage aLanguage) |
|
478 { |
|
479 iBody->SetSubtitleLanguageL(aLanguage); |
|
480 } |
|
481 |
|
482 /** |
|
483 To be called when the video window is asked to redraw. E.g. For cone control, when CCoeControl::Draw() is called. |
|
484 |
|
485 @param aWindow Handle to the video window to be redrawn. |
|
486 @param aRect The region of the control to be redrawn from aRect in CCodControl::Draw(). |
|
487 */ |
|
488 EXPORT_C void CVideoPlayerUtility2::RedrawSubtitle(RWindow& aWindow, const TRect &aRect) |
|
489 { |
|
490 iBody->RedrawSubtitle(aWindow, aRect); |
|
491 } |
|
492 |
|
493 #endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT |