|
1 /* |
|
2 * Copyright (c) 2002-2006 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: |
|
15 * Base class for SMIL Player media renderers |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #ifndef CSMILMEDIARENDERERBASE_H |
|
23 #define CSMILMEDIARENDERERBASE_H |
|
24 |
|
25 #include <coecntrl.h> |
|
26 #include <smilmediarendererinterface.h> |
|
27 #include <caf/caftypes.h> |
|
28 #include <DRMCommon.h> |
|
29 |
|
30 #include <MsgMedia.hrh> |
|
31 |
|
32 // CONSTANTS |
|
33 const TInt KFocusSize = 2; |
|
34 const TInt KScrollBarSize = 5; |
|
35 const TInt KScrollElevatorSize = 3; |
|
36 |
|
37 // MACROS |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 class DRMCommon; |
|
41 class CDRMHelper; |
|
42 class MSmilMedia; |
|
43 |
|
44 /** |
|
45 * Base class for SMIL Player media renderers |
|
46 * |
|
47 * @lib smilmediarenderer.lib |
|
48 * @since 2.0 |
|
49 */ |
|
50 NONSHARABLE_CLASS(CSmilMediaRendererBase) : public CCoeControl, |
|
51 public MSmilMediaRenderer |
|
52 { |
|
53 public: |
|
54 |
|
55 /** |
|
56 * Destructor. |
|
57 * |
|
58 * @since 2.0 |
|
59 */ |
|
60 virtual ~CSmilMediaRendererBase(); |
|
61 |
|
62 public: // New functions |
|
63 |
|
64 /** |
|
65 * Return renderer type. |
|
66 * |
|
67 * @since 2.0 |
|
68 * |
|
69 * @return Media type of the class. |
|
70 */ |
|
71 IMPORT_C TMsgMediaType MediaType() const; |
|
72 |
|
73 /** |
|
74 * Called by the UI to activate renderer. |
|
75 * |
|
76 * @since 3.0 |
|
77 * |
|
78 * @return void |
|
79 */ |
|
80 IMPORT_C virtual void ActivateRendererL(); |
|
81 |
|
82 public: // Methods from base classes |
|
83 |
|
84 /** |
|
85 * From MSmilMediaRenderer Called by the SMIL engine to signal |
|
86 * that the engine is no more referencing renderer. Default |
|
87 * implementation deletes the renderer. |
|
88 * |
|
89 * @since 2.0 |
|
90 * |
|
91 * @return void |
|
92 */ |
|
93 void Close(); |
|
94 |
|
95 /** |
|
96 * From MSmilMediaRenderer Returns if renderer is visual |
|
97 * (i.e. draws something to the screen). |
|
98 * |
|
99 * @since 2.0 |
|
100 * |
|
101 * @return Default implementation returns EFalse. |
|
102 */ |
|
103 TBool IsVisual() const; |
|
104 |
|
105 /** |
|
106 * From MSmilMediaRenderer Returns if renderer is non-transparent |
|
107 * (i.e. fills all the pixels on specied region). |
|
108 * |
|
109 * @since 2.0 |
|
110 * |
|
111 * @return Default implementation returns EFalse. |
|
112 */ |
|
113 TBool IsOpaque() const; |
|
114 |
|
115 /** |
|
116 * From MSmilMediaRenderer Returns if renderer is scrollable. |
|
117 * |
|
118 * @since 2.0 |
|
119 * |
|
120 * @return Default implementation returns EFalse. |
|
121 */ |
|
122 TBool IsScrollable() const; |
|
123 |
|
124 /** |
|
125 * From MSmilMediaRenderer Returns if renderer is Symbian control. |
|
126 * |
|
127 * @since 2.0 |
|
128 * |
|
129 * @return Default implementation returns ETrue since all the |
|
130 * renderers are implemented as controls. |
|
131 */ |
|
132 TBool IsControl() const; |
|
133 |
|
134 /** |
|
135 * From MSmilMediaRenderer Returns the unscalable size of the |
|
136 * visual media object. |
|
137 * |
|
138 * @since 2.0 |
|
139 * |
|
140 * @return Default implementation returns zero. |
|
141 */ |
|
142 TInt IntrinsicWidth() const; |
|
143 |
|
144 /** |
|
145 * From MSmilMediaRenderer Returns the unscalable size of the |
|
146 * visual media object. |
|
147 * |
|
148 * @since 2.0 |
|
149 * |
|
150 * @return Default implementation returns zero. |
|
151 */ |
|
152 TInt IntrinsicHeight() const; |
|
153 |
|
154 /** |
|
155 * From MSmilMediaRenderer Returns the duration of the media object. |
|
156 * |
|
157 * @since 2.0 |
|
158 * |
|
159 * @return Default implementation returns zero. |
|
160 */ |
|
161 TSmilTime IntrinsicDuration() const; |
|
162 |
|
163 /** |
|
164 * From MSmilMediaRenderer Called by the engine to make a media |
|
165 * renderer draw its content. Default implementation is empty. |
|
166 * |
|
167 * @since 2.0 |
|
168 * |
|
169 * @param aGc IN Graphical context performing the drawing. |
|
170 * @param aRect IN Target rectangle. |
|
171 * @param aTransitionFilter IN Transition effects if present. |
|
172 * @param aFocus IN Focus indication if focussed. |
|
173 * |
|
174 * @return void |
|
175 */ |
|
176 void Draw( CGraphicsContext& aGc, |
|
177 const TRect& aRect, |
|
178 CSmilTransitionFilter* aTransitionFilter, |
|
179 const MSmilFocus* aFocus ); |
|
180 |
|
181 /** |
|
182 * From MSmilMediaRenderer Move scrollable media to given position. |
|
183 * Default implementation is empty. |
|
184 * |
|
185 * @since 2.0 |
|
186 * |
|
187 * @param aDirX IN Amount of pixels to move on X direction. |
|
188 * @param aDirY IN Amount of pixels to move on Y direction. |
|
189 * |
|
190 * @return void |
|
191 */ |
|
192 void Scroll( TInt aDirX, TInt aDirY ); |
|
193 |
|
194 /** |
|
195 * From MSmilMediaRenderer Set volume of the audio media. |
|
196 * Default implmenetation is empty. |
|
197 * |
|
198 * @since 2.0 |
|
199 * |
|
200 * @param aVolume IN A percentage value from maximum value that |
|
201 * the volume should be set. |
|
202 * @return void |
|
203 */ |
|
204 void SetVolume( TInt aVolume ); |
|
205 |
|
206 /** |
|
207 * From CCoeControl. Handles key events. |
|
208 * |
|
209 * @param aKeyEvent IN The key event. |
|
210 * @param aType IN The type of key event |
|
211 * |
|
212 * @return Indicates whether or not the key event was used by this control. |
|
213 */ |
|
214 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, |
|
215 TEventCode aType ); |
|
216 |
|
217 protected: |
|
218 |
|
219 /** |
|
220 * C++ default contsructor. |
|
221 */ |
|
222 CSmilMediaRendererBase(); |
|
223 |
|
224 /** |
|
225 * Constructor. |
|
226 * |
|
227 * @param aMediaType IN Renderer's media type. |
|
228 * @param aMedia IN SMIL media object. |
|
229 * @param aDrmCommon IN DRM Common |
|
230 * @param aDrmHelper IN DRM Helper |
|
231 * |
|
232 * @since 2.0 |
|
233 */ |
|
234 CSmilMediaRendererBase( TMsgMediaType aMediaType, |
|
235 MSmilMedia* aMedia, |
|
236 DRMCommon& aDrmCommon, |
|
237 CDRMHelper& aDrmHelper ); |
|
238 |
|
239 /** |
|
240 * Symbian 2nd phase base class constructor. |
|
241 * |
|
242 * @param aFileHandle IN Source file handle. |
|
243 * |
|
244 * @return void |
|
245 */ |
|
246 void BaseConstructL( RFile& aFileHandle ); |
|
247 |
|
248 /** |
|
249 * Common focus drawing function for all renderers. |
|
250 * |
|
251 * @param aGc IN Reference to graphics context |
|
252 * @param aFocus IN Pointer to focus object |
|
253 * |
|
254 * @return void |
|
255 */ |
|
256 void DrawFocus( CGraphicsContext& aGc, |
|
257 const MSmilFocus* aFocus ) const; |
|
258 |
|
259 /** |
|
260 * Common scroll bar drawing function for all renderers |
|
261 * Draws scroll bar(s) only if necessary. |
|
262 * |
|
263 * @param aGc IN Reference to graphics context |
|
264 * @param aRegionRect IN Rect of the region |
|
265 * @param aMedaRect IN Rect of the full media bitmap |
|
266 * |
|
267 * @return void |
|
268 */ |
|
269 void DrawScrollBars( CGraphicsContext& aGc, |
|
270 const TRect& aRegionRect, |
|
271 const TRect& aMediaRect ) const; |
|
272 |
|
273 /** |
|
274 * Starts CActiveSchedulerWait |
|
275 * |
|
276 * @return void |
|
277 */ |
|
278 void BeginActiveWait(); |
|
279 |
|
280 /** |
|
281 * Stops CActiveSchedulerWait |
|
282 * |
|
283 * @return void |
|
284 */ |
|
285 void EndActiveWait(); |
|
286 |
|
287 /** |
|
288 * Returns correct access intent for the specified media type. |
|
289 * |
|
290 * @return ContentAccess::EPlay, |
|
291 * ContentAccess::EView, |
|
292 * ContentAccess::EExecute, |
|
293 * ContentAccess::EPrint or |
|
294 * ContentAccess::EInstall |
|
295 */ |
|
296 ContentAccess::TIntent Intent() const; |
|
297 |
|
298 /** |
|
299 * Consumes DRM rights from media object if it is DRM protected. |
|
300 * |
|
301 * @return EOk if rights were consumed ok. Otherwise error value. |
|
302 * For error values see DRMCommon.h. |
|
303 */ |
|
304 TInt ConsumeDRMRightsL(); |
|
305 |
|
306 /** |
|
307 * Checks DRM rights from media object if it is DRM protected. |
|
308 * |
|
309 * @return EOk if rights were checked ok. Otherwise error value. |
|
310 * For error values see DRMCommon.h. |
|
311 */ |
|
312 TInt CheckDRMRights(); |
|
313 |
|
314 /** |
|
315 * Retrieves correct icon size from LAF. |
|
316 */ |
|
317 TSize RetrieveIconSize() const; |
|
318 |
|
319 /** |
|
320 * Returns if sending DRM file is allowed |
|
321 * |
|
322 * @since 3.0 |
|
323 * |
|
324 * @param aFileHandle IN Handle to file that preview is wanted. |
|
325 * |
|
326 * @return ETrue if sending is allowed. Otherwise EFalse. |
|
327 */ |
|
328 TBool SendingDrmFileAllowedL( RFile& aFileHandle ); |
|
329 |
|
330 protected: //data |
|
331 |
|
332 /** Wait loop for active wait. */ |
|
333 CActiveSchedulerWait iWait; |
|
334 |
|
335 /** Renderer type. */ |
|
336 TMsgMediaType iMediaType; |
|
337 |
|
338 /** DRM common. */ |
|
339 DRMCommon& iDrmCommon; |
|
340 |
|
341 /** DRM Helper. */ |
|
342 CDRMHelper& iDrmHelper; |
|
343 |
|
344 /** DRM file URI. */ |
|
345 HBufC8* iDrmUri; |
|
346 |
|
347 /** Specifies if DRM right has been consumed. */ |
|
348 TBool iDrmRightConsumed; |
|
349 |
|
350 /** Specifies what drm protectoin is used on media object. */ |
|
351 DRMCommon::TContentProtection iDrmProtection; |
|
352 |
|
353 // Event array to store key events. |
|
354 CArrayFixFlat<TKeyEvent>* iEventArray; |
|
355 |
|
356 // SMIL media object. |
|
357 MSmilMedia* iMedia; |
|
358 |
|
359 // Focus rectangle. |
|
360 TRect iFocusRect; |
|
361 }; |
|
362 |
|
363 #endif // CSMILMEDIARENDERERBASE_H |