|
1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * Transcoder. |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 #ifndef CTRTRANSCODER_H |
|
22 #define CTRTRANSCODER_H |
|
23 |
|
24 |
|
25 // INCLUDES |
|
26 #include <e32base.h> |
|
27 #include <e32cmn.h> |
|
28 #include <BITDEV.H> // for CFbsScreenDevice |
|
29 #include <CCMRMediaSink.h> |
|
30 #include "ctrcommon.h" |
|
31 |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class MTRVideoPictureSink; |
|
35 class MTRTranscoderObserver; |
|
36 class MCMRMediaSink; |
|
37 |
|
38 |
|
39 // CLASS DECLARATION |
|
40 /** |
|
41 * CTranscoder interface class |
|
42 * Using CTRTranscoder: |
|
43 * - Create the transcoder instance |
|
44 * - Open the transcoder with specified options |
|
45 * - Give settings |
|
46 * - Initialize the transcoder with given options |
|
47 * - Start transcoding after initializing is completed with MtroInitializeComplete observer callback. |
|
48 * - Stop transcoding |
|
49 * - Delete the transcoder instance |
|
50 * @lib TRANSCODER.LIB |
|
51 * @since 3.1 |
|
52 */ |
|
53 class CTRTranscoder : public CBase |
|
54 { |
|
55 public: |
|
56 |
|
57 // Video data format |
|
58 enum TTRVideoDataType |
|
59 { |
|
60 ETRDuCodedPicture = 0, // Each data unit contains one coded video picture |
|
61 ETRDuVideoSegment, // Each data unit contains one coded video segment (according resync value (MPEG4) and GOB header in H.263) |
|
62 ETRYuvRawData420, // Each data unit represents uncompressed video picture in YUV 4:2:0 format |
|
63 ETRYuvRawData422 // Each data unit represents uncompressed video picture in YUV 4:2:2 format |
|
64 }; |
|
65 |
|
66 // Transcoder operational mode |
|
67 enum TTROperationalMode |
|
68 { |
|
69 EFullTranscoding = 0, // Full transcoding operation |
|
70 EDecoding, // Decoding only (picture resampling is possible) |
|
71 EEncoding, // Encoding only (picture resampling is possible) |
|
72 EResampling, // Picture resampling only (for YUV In / Out data) |
|
73 EOperationNone // None |
|
74 }; |
|
75 |
|
76 public: // Constructors and destructor |
|
77 /** |
|
78 * Two-phased constructor. Create an instance the transcoder instance |
|
79 * @param aObserver Transcoder observer |
|
80 * @return CTranscoder instance. Can leave with Symbian error code |
|
81 */ |
|
82 IMPORT_C static CTRTranscoder* NewL(MTRTranscoderObserver& aObserver); |
|
83 |
|
84 /** |
|
85 * Destructor. |
|
86 */ |
|
87 virtual ~CTRTranscoder(); |
|
88 |
|
89 |
|
90 public: |
|
91 /** |
|
92 * Open the transcoder. Instantiates other submodules based on the selected operational mode. |
|
93 * @param aMediaSink MCMRMediaSink for encoded data output |
|
94 * @param aMode Mode for the transcoder, operation to perform |
|
95 * @param aMimeTypeInputFormat Mime type for input format |
|
96 * @param aMimeTypeOutputFormat Mime type for otput format |
|
97 * @param aRealTimeProcessing Specifies how to process data. ETrue - Real-time processing; EFalse - non-real time. |
|
98 * If the processing cannot be performed in real-time, the transcoder process data as fast as it can. |
|
99 * @return void. Can leave (KErrNotSupported - selected operation or codecs are not supported, |
|
100 * @ or any other Symbian error code ) |
|
101 */ |
|
102 virtual void OpenL( MCMRMediaSink* aMediaSink, |
|
103 CTRTranscoder::TTROperationalMode aMode, |
|
104 const TDesC8& aInputMimeType, |
|
105 const TDesC8& aOutputMimeType, |
|
106 const TTRVideoFormat& aVideoInputFormat, |
|
107 const TTRVideoFormat& aVideoOutputFormat, |
|
108 TBool aRealTime ) = 0; |
|
109 |
|
110 // Information methods |
|
111 /** |
|
112 * |
|
113 * @param |
|
114 * @return |
|
115 */ |
|
116 virtual TBool SupportsInputVideoFormat(const TDesC8& aMimeType) = 0; |
|
117 |
|
118 /** |
|
119 * |
|
120 * @param |
|
121 * @return |
|
122 */ |
|
123 virtual TBool SupportsOutputVideoFormat(const TDesC8& aMimeType) = 0; |
|
124 |
|
125 /** |
|
126 * Initializes the transcoder. Initializing completes asynchronously with MtroInitializeComplete observer callback. |
|
127 * @param none |
|
128 * @return void |
|
129 */ |
|
130 virtual void InitializeL() = 0; |
|
131 |
|
132 /** |
|
133 * Starts transcoding. |
|
134 * @param none |
|
135 * @return void. Can leave with Symbian error code in case of an error. |
|
136 */ |
|
137 virtual void StartL() = 0; |
|
138 |
|
139 /** |
|
140 * Stops transcoding synchronously. Use this method to stop data processing synchronously. In this case |
|
141 * all active requests are cancelled and data that was not processed is returned to data owner immediately. |
|
142 * @param none |
|
143 * @return void. Can leave with Symbian error code in case of an error. |
|
144 */ |
|
145 virtual void StopL() = 0; |
|
146 |
|
147 /** |
|
148 * Stops transcoding asynchronously. The transcoder use this signal to ensure that the remaining data gets processed, |
|
149 * without waiting for new data. This method is mainly useful for file-to-file conversions and other non-realtime |
|
150 * processing. |
|
151 * @param none |
|
152 * @return void. Can leave with Symbian error code in case of an error. |
|
153 */ |
|
154 virtual void AsyncStopL() = 0; |
|
155 |
|
156 /** |
|
157 * Pauses transcoding. |
|
158 * @param |
|
159 * @return void. Can leave with Symbian error code in case of an error. |
|
160 */ |
|
161 virtual void PauseL() = 0; |
|
162 |
|
163 /** |
|
164 * Resumes transcoding. |
|
165 * @param |
|
166 * @return void. Can leave with Symbian error code in case of an error. |
|
167 */ |
|
168 virtual void Resume() = 0; |
|
169 |
|
170 |
|
171 // AA |
|
172 virtual void SetDecoderInitDataL(TPtrC8& aInitData) = 0; |
|
173 |
|
174 /** |
|
175 * Sets bit rate parameter for transcoded bitstream. Can be run-time setting |
|
176 * @param aBitRate Bitrate |
|
177 * @return void Can leave with KErrNotSupported |
|
178 */ |
|
179 virtual void SetVideoBitRateL(TUint aBitRate) = 0; |
|
180 |
|
181 /** |
|
182 * Sets frame rate for decoded bitstream. Can be run-time setting. |
|
183 * @param aFrameRate Frame rate |
|
184 * @return void Can leave with KErrNotSupported |
|
185 */ |
|
186 virtual void SetFrameRateL(TReal aFrameRate) = 0; |
|
187 |
|
188 /** |
|
189 * Sets channel bit error rate. Can be run-time setting |
|
190 * @param aErrorRate Channel expected error rate. |
|
191 * aErrorRate = 0.0 - low bit error rate or error is not expected |
|
192 * aErrorRate = 0.00001 - medium bit error rate |
|
193 * aErrorRate = 0.0001 - high bit error rate |
|
194 * @return void |
|
195 */ |
|
196 virtual void SetChannelBitErrorRateL(TReal aErrorRate) = 0; |
|
197 |
|
198 /** |
|
199 * Sets misc video coding options |
|
200 * @param aOptions Coding options |
|
201 * @return void |
|
202 */ |
|
203 virtual void SetVideoCodingOptionsL(TTRVideoCodingOptions& aOptions) = 0; |
|
204 |
|
205 /** |
|
206 * Makes a request to retrieve the intermediate content from the transcoder |
|
207 * @param aRetrieve: ETrue - retrieve; EFalse - don't retrieve. |
|
208 * @param aSize Requested picture size for intermediate decoded picture |
|
209 * @param aSink |
|
210 * @return void Can leave with KErrNotSupported, if the intermediate picture size is not supported |
|
211 */ |
|
212 //virtual void RetrieveIntermediateContentL(TSize& aSize, MTRVideoPictureSink* aSink) = 0; |
|
213 virtual void SetVideoPictureSinkOptionsL(TSize& aSize, MTRVideoPictureSink* aSink) = 0; |
|
214 |
|
215 /** |
|
216 * Makes a request to use direct screen access |
|
217 * @param aUseDSA Use Direct Screen Access (DSA). ETrue - use DSA; EFalse - don't use DSA. |
|
218 * @param aOptions Display options, valid only if aUseDSA is set to ETrue |
|
219 * @return void Can leave with KErrNotSupported, the DSA is not supported. |
|
220 */ |
|
221 virtual void UseDirectScreenAccessL(TBool aUseDSA, CFbsScreenDevice& aScreenDevice, TTRDisplayOptions& aOptions) = 0; |
|
222 |
|
223 /** |
|
224 * Gets the current output bit rate for transcoded bit stream |
|
225 * @param none |
|
226 * @return TUint Bit rate |
|
227 */ |
|
228 virtual TUint GetVideoBitRateL() = 0; |
|
229 |
|
230 /** |
|
231 * Gets the current frame rate for transcoded stream |
|
232 * @param none |
|
233 * @return TReal Framerate |
|
234 */ |
|
235 virtual TReal GetFrameRateL() = 0; |
|
236 |
|
237 /** |
|
238 * Retrieve currently used codec for transcoding stream |
|
239 * @param aVideoMimeType video mime type |
|
240 * @return void |
|
241 */ |
|
242 virtual void GetVideoCodecL(TDes8& aVideoMimeType) = 0; |
|
243 |
|
244 /** |
|
245 * Get transcoded picture size |
|
246 * @param aSize Picture size |
|
247 * @return void |
|
248 */ |
|
249 virtual void GetTranscodedPictureSizeL(TSize& aSize) = 0; |
|
250 |
|
251 // Data transfer methods |
|
252 /** |
|
253 * Sends filled buffer with new portion of the bitstream to transcoder. Note, this is asynchronous operation, |
|
254 * and this bufer is returned back with Transcoder Observer call MtroReturnCodedBuffer(aBuffer); |
|
255 * @param aBuffer Media buffer. It is not allowed to use this buffer on the client side until it is returned back |
|
256 * from the transcoder with MtroReturnCodedBuffer(aBuffer). |
|
257 * @return void |
|
258 */ |
|
259 virtual void WriteCodedBufferL(CCMRMediaBuffer* aBuffer) = 0; |
|
260 |
|
261 /** |
|
262 * Sends video picture to transcoder / releases decoded picture (Decode mode) |
|
263 * @param aPicture Video picture |
|
264 * @return void |
|
265 */ |
|
266 virtual void SendPictureToTranscoderL(TTRVideoPicture* aPicture) = 0; |
|
267 |
|
268 /** |
|
269 * Resample picture in Resampling only mode. The client should specify souce picture and buffer for target |
|
270 * resampled picture |
|
271 * @param aSrc Source picture |
|
272 * @param aTrg Target picture |
|
273 * @return void |
|
274 */ |
|
275 virtual void ResampleL(TPtr8& aSrc, TPtr8& aTrg) = 0; |
|
276 |
|
277 |
|
278 // Video Editor specific API: |
|
279 /** |
|
280 * Gets coding-standard specific initialization output. The buffer is pushed to the cleanup stack, |
|
281 * and the caller is responsible for deallocating it. |
|
282 * @param none |
|
283 * @return HBufC8 Coding options (VOL header) |
|
284 */ |
|
285 virtual HBufC8* GetCodingStandardSpecificInitOutputLC() = 0; |
|
286 |
|
287 /** |
|
288 * Enables / Disables use of picture sink; Note: This method is relevant only for full transcoding use cases; |
|
289 * This cnage is applied for the next written coded buffer with WriteCodedBufferL |
|
290 * @param aEnable ETrue: Picture sink is enabled; EFalse: Picture sink is disabled |
|
291 * @return none |
|
292 */ |
|
293 virtual void EnablePictureSink(TBool aEnable) = 0; |
|
294 |
|
295 /** |
|
296 * Enable / Disable use of Encoder; Note: This method is relevant only for full transcoding use cases; |
|
297 * By default encoding is always enabled in FullTranscoding mode |
|
298 * This cnage is applied for the next written coded buffer with WriteCodedBufferL |
|
299 * @param aEnable ETue: Encoder is enabled; EFalse: Encoder is disabled |
|
300 * @return none |
|
301 */ |
|
302 virtual void EnableEncoder(TBool aEnable) = 0; |
|
303 |
|
304 /** |
|
305 * Requests random access point to the following transcoded picture |
|
306 * This change is applied for the next written coded buffer with WriteCodedBufferL |
|
307 * @param none |
|
308 * @return none |
|
309 */ |
|
310 virtual void SetRandomAccessPoint() = 0; |
|
311 |
|
312 /** |
|
313 * Returns a time estimate of how long it takes to process one second of the input video with the |
|
314 * current transcoder settings. OpenL must be called before calling this function. Estimate |
|
315 * will be more accurate if InitializeL is called before calling this function. |
|
316 * @param aInput Input video format |
|
317 * @param aOutput Output video format |
|
318 * @return TReal Time estimate in seconds |
|
319 */ |
|
320 virtual TReal EstimateTranscodeTimeFactorL(const TTRVideoFormat& aInput, const TTRVideoFormat& aOutput) = 0; |
|
321 |
|
322 /** |
|
323 * Get max number of frames in processing. |
|
324 * This is just a recommendation, not a hard limit. |
|
325 * @return TInt Number of frames |
|
326 */ |
|
327 virtual TInt GetMaxFramesInProcessing() = 0; |
|
328 |
|
329 /** |
|
330 * Enable / Disable pausing of transcoding if resources are lost. If enabled transcoder |
|
331 * will notify the observer about resource losses by calling MtroSuspend / MtroResume |
|
332 * @param aEnable ETrue: Pausing is enabled |
|
333 * EFalse: Pausing is disabled and resource losses will cause a fatal error |
|
334 * @return none |
|
335 */ |
|
336 virtual void EnablePausing(TBool aEnable) = 0; |
|
337 }; |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 #endif |