|
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: TNE Video Clip Info Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __HXTNEVIDEOCLIPINFOIMP_H__ |
|
22 #define __HXTNEVIDEOCLIPINFOIMP_H__ |
|
23 |
|
24 |
|
25 #include <e32base.h> |
|
26 #include "HXTneclientservercommon.h" |
|
27 #include "DisplayChain.h" |
|
28 #include <TNEVideoClipInfo.h> |
|
29 |
|
30 |
|
31 #include "HXTneClientObserver.h" |
|
32 |
|
33 class CFbsBitmap; |
|
34 |
|
35 class CTNEClientObserver; |
|
36 class CTNEVideoClipInfo; |
|
37 |
|
38 /** |
|
39 * class for getting information about video clip files and generating thumbnails. |
|
40 */ |
|
41 |
|
42 class CHXTNEVideoClipInfoImp : public CTNEVideoClipInfo |
|
43 ,public RSessionBase |
|
44 { |
|
45 |
|
46 public: |
|
47 |
|
48 static CTNEVideoClipInfo* NewL(const RFile& aFileHandle, |
|
49 MTNEVideoClipInfoObserver& aObserver); |
|
50 /** |
|
51 * Destroys the object and releases all resources. |
|
52 */ |
|
53 ~CHXTNEVideoClipInfoImp(); |
|
54 |
|
55 |
|
56 /* General property methods. */ |
|
57 |
|
58 /** |
|
59 * Returns the file name of the clip. Panics if there is no file |
|
60 * associated with this clip or info is not yet ready for reading. |
|
61 * |
|
62 * @return file name of the clip |
|
63 */ |
|
64 TPtrC FileName() const; |
|
65 |
|
66 /** |
|
67 * Returns the resolution clip. Panics if the |
|
68 * info is not yet ready for reading. |
|
69 * |
|
70 * @return TSize of the clip |
|
71 */ |
|
72 TSize GetResolution() const; |
|
73 |
|
74 /* Thumb methods. */ |
|
75 |
|
76 /** |
|
77 * Returns the number of video frames in this clip. Panics if info |
|
78 * is not yet ready for reading. |
|
79 * |
|
80 * @return number of video frames in this clip |
|
81 */ |
|
82 TInt VideoFrameCount() const; |
|
83 |
|
84 /* Thumbnail methods. */ |
|
85 |
|
86 /** |
|
87 * Generates a bitmap of the given frame from video clip. |
|
88 * The frame bitmap is scaled to the specified resolution and converted |
|
89 * to the specified display mode. This method is asynchronous. The frame |
|
90 * is generated in background and the observer is notified when the frame |
|
91 * is complete. This method panics if info is not yet ready for reading or |
|
92 * the resolution is illegal. |
|
93 * |
|
94 * Possible leave codes: |
|
95 * - <code>KErrNoMemory</code> if memory allocation fails |
|
96 * - <code>KErrNotSupported</code>, if the specified combination of |
|
97 * parameters is not supported |
|
98 * |
|
99 * @param aObserver observer to be notified when the frame is completed |
|
100 * @param aIndex index of frame, or KFrameIndexBestThumb to look for |
|
101 * most suitable thumbnail frame. |
|
102 * @param aResolution resolution of the desired frame bitmap, or |
|
103 * <code>NULL</code> if the frame should be |
|
104 * in the original resolution |
|
105 * @param aDisplayMode desired display mode; or <code>ENone</code> if |
|
106 * any display mode is acceptable |
|
107 * @param aEnhance apply image enhancement algorithms to improve |
|
108 * frame quality; note that this may considerably |
|
109 * increase the processing time needed to prepare |
|
110 * the frame |
|
111 * @param aPriority priority of the frame generation |
|
112 */ |
|
113 |
|
114 void GetThumbL(MTNEVideoClipThumbObserver& aObserver, |
|
115 TInt aIndex, |
|
116 TSize* const aResolution, |
|
117 TDisplayMode aDisplayMode, |
|
118 TBool aEnhance, |
|
119 TInt aPriority); |
|
120 |
|
121 /** |
|
122 * Cancels Thumbnail generation. If no thumb is currently being |
|
123 * generated, the function does nothing. |
|
124 */ |
|
125 void CancelThumb(); |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 // client state - This will be the client side states for maintaining the signals from clientobserver |
|
131 enum EThumbnailClientState // this holds |
|
132 { |
|
133 EStartGettingMetadata = 0, |
|
134 EStartGettingThumbNail, |
|
135 EStartGettingThumbNailWithIndex, |
|
136 ECancelling |
|
137 }; |
|
138 |
|
139 |
|
140 |
|
141 //Client server |
|
142 TInt CreateServer(); |
|
143 |
|
144 |
|
145 |
|
146 TVersion Version() const; |
|
147 |
|
148 //callback from observer |
|
149 |
|
150 void ServiceCompleted(TInt aError); |
|
151 |
|
152 |
|
153 //sendrecieve functions - rest are not implemented for simplicity |
|
154 |
|
155 TInt OpenFile(const RFile& aFileHandle, TInt aPosition); |
|
156 |
|
157 TInt OpenFile(TInt aPosition); |
|
158 |
|
159 private: |
|
160 CHXTNEVideoClipInfoImp (); |
|
161 |
|
162 /** |
|
163 * Constructor for CHXTNEVideoClipInfoImp using RFile handle. |
|
164 */ |
|
165 void ConstructL(const RFile& aFileHandle, |
|
166 MTNEVideoClipInfoObserver& aObserver); |
|
167 |
|
168 /** |
|
169 * Constructor for CHXTNEVideoClipInfoImp using file name. |
|
170 */ |
|
171 void ConstructL(const TDesC& aFileName, |
|
172 MTNEVideoClipInfoObserver& aObserver); |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 void FetchAndSendMetaData(TInt err); // Gets the metadata from the server and sents an event to the App |
|
178 |
|
179 void NotifyIfGetThumbPending(TInt aError, CFbsBitmap *&pBitMap); |
|
180 |
|
181 void GenerateThumbNail(); |
|
182 |
|
183 TBool HandleThumbnailError(TInt aError); |
|
184 void EnhanceThumbnailL(const CFbsBitmap* aInBitmap, |
|
185 CFbsBitmap* aTargetBitmap); |
|
186 |
|
187 |
|
188 // Observers MTNEVideoClipInfoObserver and MTNEVideoClipThumbObserver |
|
189 MTNEVideoClipInfoObserver* iClipInfoObserver; |
|
190 MTNEVideoClipThumbObserver* iThumbObserver; |
|
191 |
|
192 // Storage for metadata between client and server |
|
193 TNEMetaData iMetaData; |
|
194 TNEThumbRequest iThumbRequestData; |
|
195 |
|
196 //server name variable |
|
197 HBufC* iServerName; |
|
198 |
|
199 //Client state |
|
200 EThumbnailClientState c_State; |
|
201 |
|
202 TInt m_LastError; |
|
203 TBool iCloseHandle; |
|
204 RFs* iFs; |
|
205 RFile iFileHandle; |
|
206 |
|
207 |
|
208 |
|
209 CFbsBitmap* iOutBitmap; |
|
210 |
|
211 TUint8* iRgbBuf; |
|
212 TFileName iFileName; |
|
213 //server thread |
|
214 RThread iServerThread; |
|
215 TSize iOutputThumbResolution; |
|
216 // Thumbnail index |
|
217 TInt iThumbIndex; |
|
218 // Thumbnail display mode |
|
219 TDisplayMode iThumbDisplayMode; |
|
220 TInt iPriority; |
|
221 // Thumbnail enhance |
|
222 TBool iThumbEnhance; |
|
223 // frame enhancement |
|
224 CDisplayChain* iEnhancer; |
|
225 |
|
226 //observer |
|
227 CTNEClientObserver* iObserver; |
|
228 friend class CTNEVideoClipInfo; |
|
229 friend class CTNEClientObserver; |
|
230 |
|
231 }; |
|
232 |
|
233 #endif // __HXTNEVIDEOCLIPINFOIMP_H__ |
|
234 |
|
235 |