|
1 /* |
|
2 * Copyright (c) 2007 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: Video player implementaion. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_BUBBLEVIDEOPLAYER_H |
|
20 #define C_BUBBLEVIDEOPLAYER_H |
|
21 |
|
22 #include <videoplayer.h> |
|
23 |
|
24 // FORWARD DECLARATIONS |
|
25 class MBubbleVideoPlayerObserver; |
|
26 |
|
27 /** |
|
28 * Video ringing tone player |
|
29 * |
|
30 * Uses CVideoPlayerUtility to play video clips. |
|
31 * |
|
32 * @lib BubbleManager.lib |
|
33 * @since S60 v3.2 |
|
34 */ |
|
35 class CBubbleVideoPlayer : public CBase, |
|
36 public MVideoPlayerUtilityObserver |
|
37 { |
|
38 public: |
|
39 enum TVideoPlayerState // from MMF-VideoPlayer IF spec. |
|
40 { |
|
41 EVideoError = -1, |
|
42 EVideoClosed, |
|
43 EVideoOpening, |
|
44 EVideoOpen, |
|
45 EVideoPreparing, |
|
46 EVideoReady, // player's stopped state |
|
47 EVideoPlaying, |
|
48 EVideoPaused |
|
49 }; |
|
50 |
|
51 enum TRingingType |
|
52 { |
|
53 ETypeRinging, |
|
54 ETypeRingingOnce, |
|
55 ETypeAscending |
|
56 }; |
|
57 |
|
58 enum TVideoResolution |
|
59 { |
|
60 EVideoOther = -1, |
|
61 EVideoQCIF, |
|
62 EVideoSubQCIF |
|
63 }; |
|
64 |
|
65 public: // Constructor and destructor |
|
66 |
|
67 /** |
|
68 * Two-phased constructor. |
|
69 * @param aRingingTone The ringing tone |
|
70 * @param aPriority The priority for the playing |
|
71 * @param aPreference The preference value |
|
72 * @param aObserver Video player observer |
|
73 * @param aVideo Window for video |
|
74 * @return The instance of the video player. |
|
75 */ |
|
76 static CBubbleVideoPlayer* NewL( |
|
77 const TDesC& aRingingTone, |
|
78 TInt aPriority, |
|
79 TUint aPreference, |
|
80 MBubbleVideoPlayerObserver& aObserver, |
|
81 RWindow& aVideoTarget ); |
|
82 |
|
83 /** |
|
84 * Two-phased constructor (non leaving). |
|
85 * @param aFileName The ringing tone |
|
86 * @param aPriority The priority for the playing |
|
87 * @param aPreference The preference value |
|
88 * @param aObserver Video player observer |
|
89 * @param aVideo Window for video |
|
90 * @return The instance of the video player. NULL is |
|
91 * returned if creation failed. |
|
92 */ |
|
93 static CBubbleVideoPlayer* New( |
|
94 const TDesC& aRingingTone, |
|
95 TInt aPriority, |
|
96 TUint aPreference, |
|
97 MBubbleVideoPlayerObserver& aObserver, |
|
98 RWindow& aVideoTarget ); |
|
99 |
|
100 /** |
|
101 * Destructor. |
|
102 */ |
|
103 virtual ~CBubbleVideoPlayer(); |
|
104 |
|
105 public: |
|
106 /** |
|
107 * Plays the loaded video. |
|
108 * @since Series 60 v3.2 |
|
109 * @param aRingingType Ringing type. |
|
110 * @param aVolume take value from 1 to 10 |
|
111 */ |
|
112 void Play( TRingingType aRingType, TInt aVolume ); |
|
113 |
|
114 /** |
|
115 * Stops video playback. |
|
116 * @since Series 60 v3.2 |
|
117 */ |
|
118 void StopPlaying(); |
|
119 |
|
120 /** |
|
121 * Pauses video playback. |
|
122 * @since Series 60 v3.2 |
|
123 * @return KErrNone is successful. |
|
124 */ |
|
125 TInt PausePlaying(); |
|
126 |
|
127 /** |
|
128 * Resumes video playback. |
|
129 * @since Series 60 v3.2 |
|
130 */ |
|
131 void ResumePlaying(); |
|
132 |
|
133 /** |
|
134 * Make video to play silent. |
|
135 * @since Series 60 v3.2 |
|
136 */ |
|
137 void MuteAudio(); |
|
138 |
|
139 /** |
|
140 * Get the state of the phone video player. |
|
141 * @since Series 60 v3.2 |
|
142 * @return The status of video player |
|
143 */ |
|
144 TVideoPlayerState State() const; |
|
145 |
|
146 /** |
|
147 * Get the resolution of the loaded video. |
|
148 * @since Series 60 v3.2 |
|
149 * @return The resolution. |
|
150 */ |
|
151 TVideoResolution VideoResolution() const; |
|
152 |
|
153 /** |
|
154 * Scales and crops video to cover target window. |
|
155 * @since Series 60 v3.2 |
|
156 * @param aDisplayWindow Window for video. |
|
157 * @param aUncropPane Rectangle for cropping control. |
|
158 * @param aArbitaryScalingSupported Scaling capability of the device. |
|
159 */ |
|
160 void AdjustToWindow( RWindow& aDisplayWindow, |
|
161 const TRect& aUncropPane, |
|
162 TBool aArbitaryScalingSupported = EFalse ); |
|
163 |
|
164 /** |
|
165 * Scales and crops video to cover target window. This method |
|
166 * doens't use uncrop pane and crops video only when needed. |
|
167 * Allowed cropping can be set via KPhoneMaxVideoCrop. |
|
168 * Cropped video is centered to video pane. |
|
169 * This metdod should be used only when video player supports |
|
170 * arbitrary scaling of video image. |
|
171 * @since Series 60 v3.2 |
|
172 * @param aDisplayWindow Window for video playback. |
|
173 */ |
|
174 void AdjustToWindow2( RWindow& aDisplayWindow ); |
|
175 |
|
176 private: // Functions from MVideoPlayerUtilityObserver |
|
177 /** |
|
178 * MvpuoOpenComplete |
|
179 */ |
|
180 void MvpuoOpenComplete( TInt aError ); |
|
181 |
|
182 /** |
|
183 * MvpuoPrepareComplete |
|
184 */ |
|
185 void MvpuoPrepareComplete( TInt aError ); |
|
186 |
|
187 /** |
|
188 * MvpuoFrameReady |
|
189 */ |
|
190 void MvpuoFrameReady( CFbsBitmap& aFrame ,TInt aError ); |
|
191 |
|
192 /** |
|
193 * MvpuoPlayComplete |
|
194 */ |
|
195 void MvpuoPlayComplete( TInt aError ); |
|
196 |
|
197 /** |
|
198 * MvpuoEvent |
|
199 */ |
|
200 void MvpuoEvent( const TMMFEvent& aEvent ); |
|
201 |
|
202 private: // Constructors |
|
203 |
|
204 /** |
|
205 * C++ default constructor. |
|
206 */ |
|
207 CBubbleVideoPlayer(); |
|
208 |
|
209 /** |
|
210 * C++ constructor. |
|
211 */ |
|
212 CBubbleVideoPlayer( MBubbleVideoPlayerObserver& aObserver ); |
|
213 |
|
214 /** |
|
215 * By default Symbian 2nd phase constructor is private. |
|
216 */ |
|
217 void ConstructL( const TDesC& aFileName, |
|
218 TInt aPriority, |
|
219 TUint aPreference, |
|
220 RWindow& aVideoTarget ); |
|
221 |
|
222 private: |
|
223 /** |
|
224 * SetRingingType |
|
225 */ |
|
226 void SetRingingType( TRingingType aRingingType ); |
|
227 |
|
228 /** |
|
229 * SetVolume |
|
230 */ |
|
231 void SetVolume( TInt aVolume ); |
|
232 |
|
233 /** |
|
234 * VolumeRampTimerCallback |
|
235 */ |
|
236 static TInt VolumeRampTimerCallback( TAny* aObj ); |
|
237 |
|
238 /** |
|
239 * DoVolumeRamp |
|
240 */ |
|
241 TInt DoVolumeRamp(); |
|
242 |
|
243 /** |
|
244 * RepeatsTrailPauseTimerCallback |
|
245 */ |
|
246 static TInt RepeatsTrailPauseTimerCallback( TAny* aObj ); |
|
247 |
|
248 /** |
|
249 * DoRingingRepeat |
|
250 */ |
|
251 TInt DoRingingRepeat(); |
|
252 |
|
253 /** |
|
254 * Frame size |
|
255 */ |
|
256 TSize VideoFrameSize() const; |
|
257 |
|
258 /** |
|
259 * Calculates size for video player screen rectangle based on |
|
260 * canvas and video dimensions. |
|
261 */ |
|
262 static TSize CalculateScreenRectSize( |
|
263 const TSize& aCanvasSize, |
|
264 const TSize& aVideoFrameSize, |
|
265 TBool aArbitraryScalingSupported ); |
|
266 |
|
267 /** |
|
268 * Calculates aClipSize and aScreenSize based on aWindowSize |
|
269 * and aVideoFrameSize. aScreenSize is set to maximum without |
|
270 * exceeding the crop limit (KPhoneMaxVideoCrop). aClipSize |
|
271 * is set match to scaled video image to prevent black stripes |
|
272 * around video. |
|
273 */ |
|
274 static void CalculateClipAndScreenRectSize( |
|
275 const TSize& aWindowSize, |
|
276 const TSize& aVideoFrameSize, |
|
277 TSize& aClipSize, |
|
278 TSize& aScreenSize ); |
|
279 |
|
280 private: //Data |
|
281 |
|
282 MBubbleVideoPlayerObserver& iObserver; |
|
283 CVideoPlayerUtility* iVideoPlayer; // Owned |
|
284 TVideoPlayerState iPlayerState; |
|
285 TBool iToBePlayed; |
|
286 |
|
287 // Ringing properties |
|
288 TInt iVolume; |
|
289 TRingingType iRingingType; |
|
290 |
|
291 // Ascending volume |
|
292 TInt iRampedVolume; |
|
293 CPeriodic* iVolumeRampTimer; // Owned |
|
294 |
|
295 // Pause between repeats |
|
296 CPeriodic* iRepeatsTrailPauseTimer; // Owned |
|
297 |
|
298 // Ringing tone |
|
299 RFile iFileHandle; |
|
300 |
|
301 }; |
|
302 |
|
303 #endif // C_BUBBLEVIDEOPLAYER_H |