1 /* |
|
2 * Copyright (c) 2003-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: Camera Application Engine image queue extension processing class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 |
|
22 #include "CaeEngineImp.h" // For LOGTEXT |
|
23 #include <fbs.h> // For CFbsBitmap |
|
24 |
|
25 #include "CaeImageQueueExtPro.h" // Still image burst capturing class. |
|
26 #include "CaeImageItemExtPro.h" // Still image item class. |
|
27 |
|
28 |
|
29 // CONSTANTS |
|
30 const TInt KCaeStillBurstImageQueueGranularity = 6; // optimized count of burst images |
|
31 |
|
32 // ============================ MEMBER FUNCTIONS =============================== |
|
33 |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CCaeImageQueueExtPro::NewL |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CCaeImageQueueExtPro* CCaeImageQueueExtPro::NewL() |
|
40 { |
|
41 LOGTEXT( _L( "Cae: CCaeImageQueueExtPro::NewL() entering" ) ); |
|
42 |
|
43 CCaeImageQueueExtPro* self = new( ELeave ) CCaeImageQueueExtPro; |
|
44 |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL(); |
|
47 CleanupStack::Pop( self ); |
|
48 |
|
49 LOGTEXT( _L( "Cae: CCaeImageQueueExtPro::NewL() returning" ) ); |
|
50 |
|
51 return self; |
|
52 } |
|
53 |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CCaeImageQueueExtPro::CCaeImageQueueExtPro |
|
57 // Destroys image queue. |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 CCaeImageQueueExtPro::~CCaeImageQueueExtPro() |
|
61 { |
|
62 LOGTEXT( _L( "Cae: CCaeImageQueueExtPro::CaeImageQueueExtPro() entering" ) ); |
|
63 |
|
64 ResetAndDestroyImages(); |
|
65 delete iImageQueue; |
|
66 |
|
67 LOGTEXT( _L( "Cae: CCaeImageQueueExtPro::CaeImageQueueExtPro() returning" ) ); |
|
68 } |
|
69 |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // CCaeImageQueueExtPro::CaeImageQueueExtPro |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CCaeImageQueueExtPro::CCaeImageQueueExtPro() |
|
76 { |
|
77 } |
|
78 |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CCaeImageQueueExtPro::ConstructL |
|
82 // Allocates image queue. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CCaeImageQueueExtPro::ConstructL() |
|
86 { |
|
87 LOGTEXT( _L( "Cae: CCaeImageQueueExtPro::ConstructL() entering" ) ); |
|
88 |
|
89 iImageQueue = new( ELeave ) RPointerArray<CCaeImageItemExtPro>( |
|
90 KCaeStillBurstImageQueueGranularity ); |
|
91 |
|
92 LOGTEXT( _L( "Cae: CCaeImageQueueExtPro::ConstructL() returning" ) ); |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CCaeImageQueueExtPro::AppendImage |
|
98 // Appends an image item object to image queue. |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 TInt CCaeImageQueueExtPro::AppendImage( |
|
102 CFbsBitmap* aBitmap, |
|
103 HBufC8* aImageData, |
|
104 TBool aLastImage, |
|
105 TBool aSnapImage ) |
|
106 { |
|
107 LOGTEXT( _L( "Cae: CCaeImageQueueExtPro::AppendImage() entering" ) ); |
|
108 |
|
109 TInt result( KErrNone ); |
|
110 |
|
111 CCaeImageItemExtPro* imageItem = new CCaeImageItemExtPro(); |
|
112 if ( imageItem ) |
|
113 { |
|
114 // Move image data to image item |
|
115 imageItem->iImageData = aImageData; |
|
116 imageItem->iBitmap = aBitmap; |
|
117 imageItem->iLastImage = aLastImage; |
|
118 imageItem->iSnapImage = aSnapImage; |
|
119 |
|
120 // Add image to the queue. |
|
121 result = iImageQueue->Append( imageItem ); |
|
122 if ( result != KErrNone ) |
|
123 { |
|
124 // In case of error, delete only imageItem, not the actual data |
|
125 imageItem->iBitmap = NULL; |
|
126 imageItem->iImageData = NULL; |
|
127 delete imageItem; |
|
128 imageItem = NULL; |
|
129 } |
|
130 } |
|
131 else |
|
132 { |
|
133 result = KErrNoMemory; |
|
134 } |
|
135 |
|
136 LOGTEXT( _L( "Cae: CCaeImageQueueExtPro::AppendImage() returning" ) ); |
|
137 |
|
138 return result; |
|
139 } |
|
140 |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CCaeImageQueueExtPro::ImageCount |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 TInt CCaeImageQueueExtPro::ImageCount() const |
|
147 { |
|
148 // Return the count of image items. |
|
149 return iImageQueue->Count(); |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CCaeImageQueueExtPro::GetNextImage |
|
155 // Fetches and deletes the next image from image queue. |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 TInt CCaeImageQueueExtPro::GetNextImage( |
|
159 CFbsBitmap*& aBitmap, // output |
|
160 HBufC8*& aImageData, // output |
|
161 TBool& aLastImage, // output |
|
162 TBool& aSnapImage ) // output |
|
163 { |
|
164 LOGTEXT2( _L( "Cae: CCaeImageQueueExtPro::GetNextImage() entering, %d images in queue" ), iImageQueue->Count() ); |
|
165 |
|
166 TInt error( KErrNone ); |
|
167 |
|
168 if ( iImageQueue->Count() > 0 ) |
|
169 { |
|
170 // Get image data and bitmap pointer from the queue image item. |
|
171 aImageData = (*iImageQueue)[0]->iImageData; |
|
172 aBitmap = (*iImageQueue)[0]->iBitmap; |
|
173 aLastImage = (*iImageQueue)[0]->iLastImage; |
|
174 aSnapImage = (*iImageQueue)[0]->iSnapImage; |
|
175 |
|
176 // Do not delete the data. Delete the image item and remove from queue. |
|
177 (*iImageQueue)[0]->iBitmap = NULL; |
|
178 (*iImageQueue)[0]->iImageData = NULL; |
|
179 delete (*iImageQueue)[0]; |
|
180 iImageQueue->Remove( 0 ); |
|
181 } |
|
182 else |
|
183 { |
|
184 aBitmap = NULL; |
|
185 aImageData = NULL; |
|
186 aLastImage = EFalse; |
|
187 aSnapImage = EFalse; |
|
188 error = KErrUnderflow; |
|
189 } |
|
190 |
|
191 LOGTEXT2( _L( "Cae: CCaeImageQueueExtPro::GetNextImage() returning: %d" ), error ); |
|
192 |
|
193 return error; |
|
194 } |
|
195 |
|
196 |
|
197 // ----------------------------------------------------------------------------- |
|
198 // CCaeImageQueueExtPro::ResetAndDestroyImages() |
|
199 // Reset and destroy image queue. |
|
200 // ----------------------------------------------------------------------------- |
|
201 // |
|
202 void CCaeImageQueueExtPro::ResetAndDestroyImages() |
|
203 { |
|
204 LOGTEXT( _L( "Cae: CCaeImageQueueExtPro::ResetAndDestroyImages()" ) ); |
|
205 |
|
206 if ( iImageQueue ) |
|
207 { |
|
208 // Reset and destroy the image items from queue. |
|
209 iImageQueue->ResetAndDestroy(); |
|
210 } |
|
211 } |
|
212 |
|
213 |
|
214 // End of File |
|