|
1 /* |
|
2 * Copyright (c) 2006-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 thumbnail provider |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <ecom/ecom.h> |
|
21 #include <implementationproxy.h> |
|
22 #include <fbs.h> |
|
23 |
|
24 #include "thumbnailvideoprovider.h" |
|
25 #include "thumbnailmanageruids.hrh" |
|
26 #include "thumbnailmanagerconstants.h" |
|
27 #include "thumbnaillog.h" |
|
28 |
|
29 #ifndef IMPLEMENTATION_PROXY_ENTRY |
|
30 typedef TAny* TProxyNewLPtr; |
|
31 #define IMPLEMENTATION_PROXY_ENTRY(aUid, aFuncPtr) \ |
|
32 { {aUid}, static_cast<TProxyNewLPtr>(aFuncPtr) } |
|
33 #endif |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CThumbnailVideoProvider::NewL() |
|
39 // Two-phased constructor. |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 CThumbnailVideoProvider* CThumbnailVideoProvider::NewL() |
|
43 { |
|
44 CThumbnailVideoProvider* self = new( ELeave )CThumbnailVideoProvider(); |
|
45 return self; |
|
46 } |
|
47 |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CThumbnailImageProvider::CThumbnailImageProvider() |
|
51 // C++ default constructor can NOT contain any code, that might leave. |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CThumbnailVideoProvider::CThumbnailVideoProvider():CActive( EPriorityStandard ) |
|
55 { |
|
56 CActiveScheduler::Add( this ); |
|
57 |
|
58 iTimer.CreateLocal(); |
|
59 iTimeout = EFalse; |
|
60 |
|
61 TN_DEBUG1( "CThumbnailVideoProvider::CThumbnailVideoProvider()" ); |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CThumbnailVideoProvider::~CThumbnailVideoProvider() |
|
67 // Destructor. |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CThumbnailVideoProvider::~CThumbnailVideoProvider() |
|
71 { |
|
72 // run DoCancel even if not active |
|
73 if ( IsActive() ) |
|
74 { |
|
75 Cancel(); |
|
76 } |
|
77 else |
|
78 { |
|
79 DoCancel(); |
|
80 } |
|
81 |
|
82 iTimer.Close(); |
|
83 |
|
84 TN_DEBUG1( "CThumbnailVideoProvider::~CThumbnailVideoProvider()" ); |
|
85 REComSession::DestroyedImplementation( iDtor_ID_Key ); |
|
86 } |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CThumbnailVideoProvider::DoCancel() |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CThumbnailVideoProvider::DoCancel() |
|
92 { |
|
93 iTimer.Cancel(); |
|
94 |
|
95 if ( iVideoClipInfo ) |
|
96 { |
|
97 iVideoClipInfo->CancelThumb(); |
|
98 |
|
99 delete iVideoClipInfo; |
|
100 iVideoClipInfo = NULL; |
|
101 } |
|
102 } |
|
103 |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CThumbnailImageDecoder::RunL() |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CThumbnailVideoProvider::RunL() |
|
110 { |
|
111 DoCancel(); |
|
112 |
|
113 // video thumbnail engine doesn't respond |
|
114 if (iTimeout) |
|
115 { |
|
116 iObserver->ThumbnailProviderReady( KErrNotSupported, NULL, TSize(), EFalse, EFalse); |
|
117 iTimeout = EFalse; |
|
118 |
|
119 TN_DEBUG1( "CThumbnailVideoProvider::RunL() - timeout" ); |
|
120 } |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // CThumbnailVideoProvider::GetThumbnailL() |
|
125 // Provides the thumbnail image of video clip |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void CThumbnailVideoProvider::GetThumbnailL( RFs& /*aFs*/, RFile64& aFile, const |
|
129 TDataType& /*aMimeType*/, const CThumbnailManager::TThumbnailFlags aFlags, |
|
130 const TDisplayMode /*aDisplayMode*/, const CThumbnailManager::TThumbnailQualityPreference /*aQualityPreference */) |
|
131 { |
|
132 TN_DEBUG1( "CThumbnailVideoProvider::GetThumbnailL() start" ); |
|
133 |
|
134 iFlags = aFlags; |
|
135 //set default mode displaymode from global constants |
|
136 iDisplayMode = KStoreDisplayMode; |
|
137 |
|
138 TFileName filename; |
|
139 User::LeaveIfError( aFile.FullName( filename )); |
|
140 |
|
141 TRAPD( err, iVideoClipInfo = CTNEVideoClipInfo::NewL( filename, * this )); |
|
142 |
|
143 if ( err != KErrNone ) |
|
144 { |
|
145 User::Leave( KErrCorrupt ); |
|
146 } |
|
147 |
|
148 TN_DEBUG1( "CThumbnailVideoProvider::GetThumbnailL() end" ); |
|
149 } |
|
150 |
|
151 // --------------------------------------------------------------------------- |
|
152 // CThumbnailVideoProvider::GetThumbnailL() |
|
153 // --------------------------------------------------------------------------- |
|
154 // |
|
155 void CThumbnailVideoProvider::GetThumbnailL( RFs& /*aFs*/, |
|
156 TDesC8* /* aBuffer */, |
|
157 const TDataType& /* aMimeType */, |
|
158 const CThumbnailManager::TThumbnailFlags /*aFlags*/, |
|
159 const TDisplayMode /* aDisplayMode */, |
|
160 const CThumbnailManager::TThumbnailQualityPreference /*aQualityPreference */) |
|
161 { |
|
162 TN_DEBUG1( "CThumbnailVideoProvider::GetThumbnailL() - nothing to do" ); |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------------------------- |
|
166 // CThumbnailVideoProvider::GetThumbnailL() |
|
167 // --------------------------------------------------------------------------- |
|
168 // |
|
169 void CThumbnailVideoProvider::GetThumbnailL( RFs& /*aFs*/, TDesC8& /*aBuffer*/) |
|
170 { |
|
171 TN_DEBUG1( "CThumbnailVideoProvider::GetThumbnailL() - nothing to do" ); |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // Cancel thumbnail request |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 void CThumbnailVideoProvider::CancelGetThumbnail() |
|
179 { |
|
180 // run DoCancel even if not active |
|
181 if ( IsActive() ) |
|
182 { |
|
183 Cancel(); |
|
184 } |
|
185 else |
|
186 { |
|
187 DoCancel(); |
|
188 } |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // CThumbnailVideoProvider::NotifyVideoClipThumbCompleted() |
|
193 // Used to notify when thumbnail image of video clip is ready |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void CThumbnailVideoProvider::NotifyVideoClipThumbCompleted( CTNEVideoClipInfo& |
|
197 /*aInfo*/, TInt aError, CFbsBitmap* aThumb ) |
|
198 { |
|
199 TN_DEBUG2( "CThumbnailVideoProvider::NotifyVideoClipThumbCompleted(aError=%d)", aError ); |
|
200 |
|
201 iTimer.Cancel(); |
|
202 iTimeout = EFalse; |
|
203 |
|
204 if (( aError == KErrNone ) && aThumb ) |
|
205 { |
|
206 iOriginalSize = aThumb->SizeInPixels(); |
|
207 } |
|
208 |
|
209 iObserver->ThumbnailProviderReady( aError, aThumb, iOriginalSize, EFalse, EFalse); |
|
210 } |
|
211 |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // CThumbnailVideoProvider::NotifyVideoClipInfoReady() |
|
215 // Used to notify when information of video clip is available |
|
216 // --------------------------------------------------------------------------- |
|
217 // |
|
218 void CThumbnailVideoProvider::NotifyVideoClipInfoReady( CTNEVideoClipInfo& |
|
219 aInfo, TInt aError ) |
|
220 { |
|
221 TN_DEBUG2( "CThumbnailVideoProvider::NotifyVideoClipInfoReady(aError=%d)", aError ); |
|
222 |
|
223 if ( aError == KErrNone ) |
|
224 { |
|
225 TInt err( KErrNone ); |
|
226 |
|
227 // cannot determine target size, aspect ratio scaling fails |
|
228 TRAP( err, aInfo.GetThumbL( *this, KBestThumbIndex, NULL, iDisplayMode, ETrue )); |
|
229 |
|
230 if ( err != KErrNone ) |
|
231 { |
|
232 TN_DEBUG2( "CThumbnailVideoProvider::NotifyVideoClipInfoReady() -- GetThumbL() left with %d", err ); |
|
233 |
|
234 iObserver->ThumbnailProviderReady( err, NULL, TSize(), EFalse, EFalse); |
|
235 |
|
236 SetActive(); |
|
237 TRequestStatus* statusPtr = &iStatus; |
|
238 User::RequestComplete( statusPtr, KErrNone ); |
|
239 } |
|
240 else |
|
241 { |
|
242 // request timeout |
|
243 iTimeout = ETrue; |
|
244 iTimer.After(iStatus, KVideoDecoderTimeout); |
|
245 SetActive(); |
|
246 } |
|
247 } |
|
248 else |
|
249 { |
|
250 iObserver->ThumbnailProviderReady( aError, NULL, TSize(), EFalse, EFalse); |
|
251 |
|
252 SetActive(); |
|
253 TRequestStatus* statusPtr = &iStatus; |
|
254 User::RequestComplete( statusPtr, KErrNone ); |
|
255 } |
|
256 } |
|
257 |
|
258 |
|
259 // ======== GLOBAL FUNCTIONS ======== |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // ImplementationTable |
|
263 // Define the interface UIDs |
|
264 // ----------------------------------------------------------------------------- |
|
265 // |
|
266 const TImplementationProxy ImplementationTable[] = |
|
267 { |
|
268 IMPLEMENTATION_PROXY_ENTRY( THUMBNAIL_VIDEO_PROVIDER_IMP_UID, |
|
269 CThumbnailVideoProvider::NewL ) |
|
270 }; |
|
271 |
|
272 |
|
273 // ----------------------------------------------------------------------------- |
|
274 // ImplementationGroupProxy |
|
275 // The one and only exported function that is the ECom entry point |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& |
|
279 aTableCount ) |
|
280 { |
|
281 aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); |
|
282 |
|
283 return ImplementationTable; |
|
284 } |
|
285 |
|
286 // End of file |