1 /* |
|
2 * Copyright (c) 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: Image Encoder class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CAM_IMAGEENCODER_H |
|
20 #define CAM_IMAGEENCODER_H |
|
21 |
|
22 // =========================================================================== |
|
23 // Included headers |
|
24 #include <e32std.h> |
|
25 #include <f32file.h> |
|
26 |
|
27 // =========================================================================== |
|
28 // Forward declarations |
|
29 class CImageEncoder; |
|
30 class CCamBufferShare; |
|
31 |
|
32 |
|
33 // =========================================================================== |
|
34 // Classes |
|
35 |
|
36 /** |
|
37 * Interface for Image Encoder Observers |
|
38 */ |
|
39 class MCamImageEncoderObserver |
|
40 { |
|
41 public: |
|
42 |
|
43 /** |
|
44 * Notify observer that the image has been encoded. |
|
45 * @param aStatus Status code describing the success of the operation. |
|
46 * KErrNone if all went as planned. |
|
47 * @param aData Encoded image data. NULL if errors in decoding. |
|
48 * Ownership transferred to observer. |
|
49 */ |
|
50 virtual void ImageEncoded( TInt aStatus, HBufC8* aData ) = 0; |
|
51 }; |
|
52 |
|
53 |
|
54 /** |
|
55 * Image Encoder class |
|
56 */ |
|
57 class CCamImageEncoder : public CActive |
|
58 { |
|
59 // ======================================================= |
|
60 public: |
|
61 |
|
62 /** |
|
63 * 2-phase constructor. |
|
64 */ |
|
65 static CCamImageEncoder* NewL( MCamImageEncoderObserver& aObserver ); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 virtual ~CCamImageEncoder(); |
|
71 |
|
72 // ------------------------------------------------------- |
|
73 // From CActive |
|
74 protected: |
|
75 |
|
76 /** |
|
77 * Called when Cancel is requested and this AO is active. |
|
78 * @see CActive |
|
79 */ |
|
80 virtual void DoCancel(); |
|
81 |
|
82 /** |
|
83 * We get notified of the decoding success by a call to RunL |
|
84 * when decoding finishes. |
|
85 * @see CActive |
|
86 */ |
|
87 virtual void RunL(); |
|
88 |
|
89 /** |
|
90 * If a leave occurs in RunL, RunError gets called by the |
|
91 * Active Scheduler. |
|
92 * @param aError Leave code from RunL. |
|
93 * @see CActive |
|
94 */ |
|
95 virtual TInt RunError( TInt aError ); |
|
96 |
|
97 // ------------------------------------------------------- |
|
98 public: |
|
99 |
|
100 void StartConversionL( CCamBufferShare* aBuffer ); |
|
101 |
|
102 private: |
|
103 |
|
104 /** |
|
105 * Store the buffer and release any previous buffer. |
|
106 * Can be called with NULL to release current buffer. |
|
107 */ |
|
108 void SetInputBuffer( CCamBufferShare* aBuffer ); |
|
109 |
|
110 /** |
|
111 * Free all encoding related resources. |
|
112 */ |
|
113 void ReleaseEncoder(); |
|
114 |
|
115 /** |
|
116 * Notify observer. |
|
117 * Transfers the encoding data ownership to the observer. |
|
118 */ |
|
119 void NotifyObserver( TInt aStatus ); |
|
120 |
|
121 private: |
|
122 |
|
123 /** |
|
124 * 2nd phase constructor. |
|
125 */ |
|
126 void ConstructL(); |
|
127 |
|
128 /** |
|
129 * 1st phase constructor. |
|
130 * Cannot leave. |
|
131 */ |
|
132 CCamImageEncoder( MCamImageEncoderObserver& aObserver ); |
|
133 |
|
134 // ======================================================= |
|
135 // Data |
|
136 private: |
|
137 |
|
138 MCamImageEncoderObserver& iObserver; |
|
139 |
|
140 CCamBufferShare* iSharedInput; |
|
141 HBufC8* iEncodedData; |
|
142 |
|
143 CImageEncoder* iEncoder; |
|
144 |
|
145 // ======================================================= |
|
146 }; |
|
147 |
|
148 // =========================================================================== |
|
149 #endif // CAM_IMAGEENCODER_H |
|
150 |
|
151 // end of file |
|