|
1 /* |
|
2 * Copyright (c) 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: Remote video handling class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef CVTENGREMOTEVIDEO_H |
|
21 #define CVTENGREMOTEVIDEO_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <w32std.h> |
|
26 #include "MVtEngImageScaler.h" |
|
27 #include "MVtEngDraw.h" |
|
28 #include "TVtEngRendering.h" |
|
29 #include "TVtEngRenderConfig.h" |
|
30 #include <mdisplaysink.h> |
|
31 #include <mvtprotocolhandler.h> |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class CDirectScreenAccess; |
|
35 class CFbsBitmap; |
|
36 class CVtEngStateManager; |
|
37 class MVtEngScalerObserver; |
|
38 |
|
39 class TVtEngRenderingOptionsDSA; |
|
40 class TVtEngRenderingOptionsDP; |
|
41 class TVtEngRenderingOptionsNGA; |
|
42 |
|
43 // Define image sizes. |
|
44 // QCIF. |
|
45 const TInt KVtEngResolutionQCIFWidth = 176; |
|
46 const TInt KVtEngResolutionQCIFHeight = 144; |
|
47 |
|
48 // SQCIF. |
|
49 const TInt KVtEngResolutionSQCIFWidth = 128; |
|
50 const TInt KVtEngResolutionSQCIFHeight = 96; |
|
51 |
|
52 // Default video screen width. |
|
53 const TInt KVtEngRemoteVideoDefaultWidth = 176; |
|
54 |
|
55 // Default video screen height. |
|
56 const TInt KVtEngRemoteVideoDefaultHeight = 144; |
|
57 |
|
58 // Watcher checks point time-out 400 ms. |
|
59 const TInt KVtEngWatcherTimeout = 400000; |
|
60 |
|
61 // When the watcher has timed out 15 times without new frame, send event to UI. |
|
62 const TInt KVtEngWatcherThreshold = 15; |
|
63 |
|
64 // CLASS DECLARATION |
|
65 |
|
66 /** |
|
67 * Class handling remote video. |
|
68 * |
|
69 * @lib videoteleng.lib |
|
70 * @since Series 60 2.6 |
|
71 */ |
|
72 NONSHARABLE_CLASS( CVtEngRemoteVideo ) : |
|
73 public CBase, |
|
74 public MDisplaySinkObserver |
|
75 { |
|
76 public: // Constructors and destructor |
|
77 |
|
78 /** |
|
79 * Two-phased constructor. |
|
80 * @param aPv2Way a reference to PV instance. |
|
81 * @param aStateManager reference to VT state manager |
|
82 * @return instance of CVtEngRemoteVideo |
|
83 */ |
|
84 static CVtEngRemoteVideo* NewL( |
|
85 MVtSessionCommand& aSessionCommand, |
|
86 CVtEngStateManager& aStateManager ); |
|
87 |
|
88 /** |
|
89 * Destructor. |
|
90 */ |
|
91 virtual ~CVtEngRemoteVideo(); |
|
92 |
|
93 public: // From MDisplaySinkObserver |
|
94 |
|
95 /** |
|
96 * @see MDisplaySinkObserver |
|
97 */ |
|
98 void VideoFrameSizeChangedL( const TSize& aFrom, |
|
99 const TSize& aTo ); |
|
100 |
|
101 public: // New functions |
|
102 |
|
103 /** |
|
104 * Sets parameters used when rendering remote video. |
|
105 */ |
|
106 void SetRenderingParametersL( |
|
107 const TVtEngRenderingOptionsNGA& aParams ); |
|
108 |
|
109 /** |
|
110 * Sets parameters used when rendering remote video. |
|
111 * @param aParams direct screen access parameters |
|
112 */ |
|
113 void SetRenderingParametersL( |
|
114 const TVtEngRenderingOptionsDSA& aParams ); |
|
115 |
|
116 /** |
|
117 * Sets parameters used when rendering remote video. |
|
118 * @param aParams direct screen access parameters |
|
119 */ |
|
120 void SetRenderingParametersL( |
|
121 const TVtEngRenderingOptionsDP& aParams ); |
|
122 |
|
123 /** |
|
124 * Starts remote video rendering. |
|
125 */ |
|
126 void StartVideoL(); |
|
127 |
|
128 /** |
|
129 * Stops remote video rendering. |
|
130 */ |
|
131 void StopVideoRendering(); |
|
132 |
|
133 /** |
|
134 * Pauses remote video rendering. |
|
135 * @return command id from PV |
|
136 */ |
|
137 TInt PauseVideoL(); |
|
138 |
|
139 /** |
|
140 * Adds Display sink into PV. |
|
141 * @param Video channel logical channel ID number. |
|
142 * @return PV command ID |
|
143 */ |
|
144 TInt AddVideoSinkL( TInt aChannelId ); |
|
145 |
|
146 /** |
|
147 * Adds Audio sink into PV. |
|
148 * @param Audio channel logical channel ID number. |
|
149 * @return PV command ID |
|
150 */ |
|
151 TInt AddAudioSinkL( TInt aChannelId ); |
|
152 |
|
153 /** |
|
154 * Returns state of Direct Screen Access. |
|
155 * @return state of Direct Screen Access |
|
156 */ |
|
157 TBool GetDsaState() const; |
|
158 |
|
159 /** |
|
160 * Returns the audiosink of nested CVtEngDraw class. |
|
161 * @return the audiosink of nested CVtEngDraw class |
|
162 */ |
|
163 MVTAudioSink* AudioSink(); |
|
164 |
|
165 /** |
|
166 * Sets UI foreground state (i.e. is the Application |
|
167 * current active application or not). |
|
168 * @param aForeground ETrue if the VT application is |
|
169 * in foreground, EFalse otherwise. |
|
170 * @exception May leave with KErrNotReady. |
|
171 */ |
|
172 void SetUIForegroundL( TBool aForeground ); |
|
173 |
|
174 /** |
|
175 * Request update last remote video frame through MVtEngFrameObserver::vtSetFrame |
|
176 */ |
|
177 void RequestLastFrame(); |
|
178 |
|
179 private: |
|
180 |
|
181 /** |
|
182 * C++ constructor. |
|
183 * @param aPv2Way a reference to PV instance |
|
184 * @param aStateManager reference to VT state manager |
|
185 */ |
|
186 CVtEngRemoteVideo( |
|
187 MVtSessionCommand& aSessionCommand, |
|
188 CVtEngStateManager& aStateManager ); |
|
189 |
|
190 /** |
|
191 * By default Symbian 2nd phase constructor is private. |
|
192 */ |
|
193 void ConstructL(); |
|
194 |
|
195 |
|
196 public: |
|
197 |
|
198 /** |
|
199 * Base rendering class |
|
200 */ |
|
201 NONSHARABLE_CLASS( CVtEngDraw ) : |
|
202 public CActive, |
|
203 public MVtEngDraw, |
|
204 public MDirectScreenAccess |
|
205 { |
|
206 |
|
207 protected: // new methods |
|
208 /** |
|
209 * C++ constructor as private. |
|
210 * @param aObserver callback interface for Display Sink |
|
211 */ |
|
212 CVtEngDraw( MDisplaySinkObserver* aObserver ); |
|
213 |
|
214 /** |
|
215 * Destructor |
|
216 */ |
|
217 ~CVtEngDraw(); |
|
218 |
|
219 /** |
|
220 * By default Symbian 2nd phase constructor is private. |
|
221 */ |
|
222 void ConstructL(); |
|
223 |
|
224 /** |
|
225 * If not active, set iStatus to KRequestPending and calls |
|
226 * SetActive(); |
|
227 */ |
|
228 void Activate(); |
|
229 |
|
230 /** |
|
231 * Creates DSA instance. |
|
232 */ |
|
233 void CreateAndStartDSAL(); |
|
234 |
|
235 public: // from MDirectScreenAccess |
|
236 |
|
237 /** |
|
238 * From MDirectScreenAccess, this function is called by the |
|
239 * window server when direct screen access must stop. |
|
240 * @see MDirectScreenAccess::AbortNow |
|
241 */ |
|
242 virtual void AbortNow( |
|
243 RDirectScreenAccess::TTerminationReasons aReason ); |
|
244 |
|
245 /** |
|
246 * From MDirectScreenAccess, this method is called by the direct |
|
247 * screen access instance as soon as direct screen access can |
|
248 * resume. |
|
249 * @see MDirectScreenAccess::Restart |
|
250 */ |
|
251 virtual void Restart( |
|
252 RDirectScreenAccess::TTerminationReasons aReason ); |
|
253 |
|
254 public: // new functions |
|
255 |
|
256 /** |
|
257 * Configuration was updated. |
|
258 */ |
|
259 void ConfigUpdatedL(); |
|
260 |
|
261 /** |
|
262 * Display Sink pointer. |
|
263 * @return instance of MDisplaySink |
|
264 */ |
|
265 MDisplaySink* DisplaySink(); |
|
266 |
|
267 /** |
|
268 * Returns state of Direct Screen Access. |
|
269 * @return true if rendering |
|
270 */ |
|
271 TBool GetDsaState() const; |
|
272 |
|
273 /** |
|
274 * Checks frame watcher expiration. |
|
275 * @param aAny pointer to CVtEngDrawDSA |
|
276 * @return Symbian OS error code |
|
277 */ |
|
278 static TInt WatcherExpired( TAny* aAny ); |
|
279 |
|
280 /** |
|
281 * Handles frame watcher expiration. |
|
282 */ |
|
283 void HandleWatcherExpired(); |
|
284 |
|
285 /** |
|
286 * Sets certain flag on. |
|
287 * @param aFlags flags to turn on. |
|
288 */ |
|
289 void SetFlag( TUint aFlags ); |
|
290 |
|
291 /** |
|
292 * Clears certain flag. |
|
293 * @param aFlags flags to clear. |
|
294 */ |
|
295 void ClearFlag( TUint aFlags ); |
|
296 |
|
297 /** |
|
298 * Checks if certain flag is on. |
|
299 * @param aFlags flags to check. |
|
300 */ |
|
301 TBool IsFlag( TUint aFlag ) const; |
|
302 |
|
303 /** |
|
304 * Called by CVtEngRemoteVideo, when video sink is added |
|
305 * to PV. |
|
306 */ |
|
307 void VideoSinkAdded(); |
|
308 |
|
309 private: // from CActive |
|
310 |
|
311 /** |
|
312 * Handles active object cancellation. |
|
313 * @see CActive::Cancel |
|
314 */ |
|
315 void DoCancel(); |
|
316 |
|
317 /** |
|
318 * Handles active object execution errors. |
|
319 * @see CActive::RunError |
|
320 */ |
|
321 TInt RunError( TInt aError ); |
|
322 |
|
323 protected: |
|
324 |
|
325 /** |
|
326 * Defines if drawing can be done |
|
327 * and if we have not received frames |
|
328 * for some time and observer is notified |
|
329 * (and no new frames since then). |
|
330 */ |
|
331 enum TFlags |
|
332 { |
|
333 // Start the rendering. |
|
334 EStarted = ( 1 << 0 ), |
|
335 // Ready by window server. |
|
336 EReadyForeground = ( 1 << 1 ), |
|
337 // Ready by internal state. |
|
338 EReadyInternal = ( 1 << 2 ), |
|
339 // Ready to draw. |
|
340 EReady = EReadyInternal | EReadyForeground, |
|
341 // Watcher expired because no frames received in time. |
|
342 EFrameWatcherExpired= ( 1 << 3 ), |
|
343 // First frame has been received. |
|
344 EFirstFrameReceived = ( 1 << 4 ), |
|
345 // Drawing ongoing flag |
|
346 ERemoteVideoDrawing = ( 1 << 5 ), |
|
347 // VT UI foreground status (if set, UI is foreground) |
|
348 EFlagUIForeground = ( 1 << 6 ), |
|
349 // Components have been initialized |
|
350 EFlagInitialized = ( 1 << 7 ), |
|
351 // VT UI has been sent to background |
|
352 ESentToBackground = ( 1 << 8 ), |
|
353 // Frame buffer contains data when this flag is set (DP,NGA) |
|
354 EFrameBufferFilled = ( 1 << 9 ), |
|
355 // BaseConstructL() call is pending (DP,NGA) |
|
356 EBaseConstructCalled = ( 1 << 10 ), |
|
357 // BaseSetConfigL() call is pending (DP,NGA) |
|
358 EBaseSetConfigCalled = ( 1 << 11 ), |
|
359 // BaseStartDrawL() call is pending (DP,NGA) |
|
360 EBaseBaseStartDrawCalled = ( 1 << 12 ), |
|
361 // UpdateSinkParamsL() needs to be called (DP,NGA) |
|
362 ESinkParamUpdateRequired = ( 1 << 13 ), |
|
363 // Sink().Resume() needs to be called (DP,NGA) |
|
364 ESinkResumeRequired = ( 1 << 14 ), |
|
365 // InitializePostingSurfaceL() call is pending (DP), CreateSurfaceL call is pending (NGA) |
|
366 EInitializePostingSurfaceCalled = ( 1 << 15 ), |
|
367 // New frame buffer is store, not coverted and scaled yet |
|
368 EFrameBufferNeedsConvertAndScale = ( 1 << 16 ), |
|
369 |
|
370 // Bitmask for all pending calls (DP) |
|
371 EDelayedCallsMask = EBaseConstructCalled | |
|
372 EBaseSetConfigCalled | |
|
373 EBaseBaseStartDrawCalled | |
|
374 ESinkParamUpdateRequired | |
|
375 EInitializePostingSurfaceCalled |
|
376 }; |
|
377 |
|
378 protected : // data |
|
379 |
|
380 // Direct Screen Access. |
|
381 CDirectScreenAccess* iDSA; |
|
382 |
|
383 // Display sink providing bitmaps. |
|
384 MDisplaySink* iDisplaySink; |
|
385 |
|
386 // @see TFlags |
|
387 TInt iFlags; |
|
388 |
|
389 // For checking if display sink stops feeding. |
|
390 // drawer with bitmaps |
|
391 CPeriodic* iWatcher; |
|
392 |
|
393 // to reduce watcher restarts do cancel it |
|
394 // only every 15 frames |
|
395 // Counter for frame expiration. |
|
396 TInt iCheckpoint; |
|
397 |
|
398 // DisplaySink callback interface. |
|
399 MDisplaySinkObserver* iObserver; |
|
400 |
|
401 // Frame watcher callback. |
|
402 TCallBack iCallback; |
|
403 |
|
404 // Container class as a friend. |
|
405 friend class CVtEngRemoteVideo; |
|
406 |
|
407 // Temporarily store image size when size changes on the fly. |
|
408 TSize iSourceSize; |
|
409 |
|
410 // DisplaySink status boolean. |
|
411 TBool iDSUpdated; |
|
412 }; |
|
413 |
|
414 private: // Data |
|
415 // Packet Video interface. |
|
416 MVtSessionCommand& iSessionCommand; |
|
417 |
|
418 // State manager. |
|
419 CVtEngStateManager& iStateManager; |
|
420 |
|
421 // Draws remote video with DSA. |
|
422 CVtEngDraw* iDrawer; |
|
423 |
|
424 // Display sink. |
|
425 MDisplaySink* iDisplaySink; |
|
426 |
|
427 // Audio sink interface. |
|
428 MVTAudioSink* iAudioSink; |
|
429 |
|
430 // Information from PV regarding sink. |
|
431 TInt iTrackId; |
|
432 |
|
433 // @see TFlags |
|
434 TInt iStateFlags; |
|
435 |
|
436 TBool iEnableNGA; |
|
437 }; |
|
438 |
|
439 #endif // CVTENGREMOTEVIDEO_H |
|
440 |
|
441 // End of File |