sl@0
|
1 |
/*
|
sl@0
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
3 |
* All rights reserved.
|
sl@0
|
4 |
* This component and the accompanying materials are made available
|
sl@0
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
sl@0
|
6 |
* which accompanies this distribution, and is available
|
sl@0
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
8 |
*
|
sl@0
|
9 |
* Initial Contributors:
|
sl@0
|
10 |
* Nokia Corporation - initial contribution.
|
sl@0
|
11 |
*
|
sl@0
|
12 |
* Contributors:
|
sl@0
|
13 |
*
|
sl@0
|
14 |
* Description:
|
sl@0
|
15 |
*
|
sl@0
|
16 |
*/
|
sl@0
|
17 |
|
sl@0
|
18 |
|
sl@0
|
19 |
#include "t_cmmfdevvideorecorddata.h"
|
sl@0
|
20 |
|
sl@0
|
21 |
/*@{*/
|
sl@0
|
22 |
//LIT's to identify commands
|
sl@0
|
23 |
_LIT(KCmdNewL, "NewL");
|
sl@0
|
24 |
_LIT(KCmdDestructor, "~");
|
sl@0
|
25 |
_LIT(KCmdSelectEncoderL, "SelectEncoderL");
|
sl@0
|
26 |
_LIT(KCmdSetInputFormatL, "SetInputFormatL");
|
sl@0
|
27 |
_LIT(KCmdSetOutputFormatL, "SetOutputFormatL");
|
sl@0
|
28 |
_LIT(KCmdSetBufferOptionsL, "SetBufferOptionsL");
|
sl@0
|
29 |
_LIT(KCmdSetSourceMemoryL, "SetSourceMemoryL");
|
sl@0
|
30 |
_LIT(KCmdSetMinRandomAccessRate, "SetMinRandomAccessRate");
|
sl@0
|
31 |
_LIT(KCmdInitialize, "Initialize");
|
sl@0
|
32 |
_LIT(KCmdSetComplexityLevel, "SetComplexityLevel");
|
sl@0
|
33 |
_LIT(KCmdStart, "Start");
|
sl@0
|
34 |
_LIT(KCmdPause, "Pause");
|
sl@0
|
35 |
_LIT(KCmdResume, "Resume");
|
sl@0
|
36 |
_LIT(KCmdStop, "Stop");
|
sl@0
|
37 |
_LIT(KCmdUtilityGetEnvironment, "UtilityGetEnvironment");
|
sl@0
|
38 |
_LIT(KCmdSetRateControlOptions, "SetRateControlOptions");
|
sl@0
|
39 |
|
sl@0
|
40 |
|
sl@0
|
41 |
/*@}*/
|
sl@0
|
42 |
|
sl@0
|
43 |
/*@{*/
|
sl@0
|
44 |
//LIT's to get params from ini files
|
sl@0
|
45 |
_LIT(KInputFile, "inputfile");
|
sl@0
|
46 |
_LIT(KOutputFile, "outputfile");
|
sl@0
|
47 |
_LIT(KInputPath, "inputPath");
|
sl@0
|
48 |
_LIT(KOutputPath, "outputPath");
|
sl@0
|
49 |
_LIT(KFrameRate, "framerate");
|
sl@0
|
50 |
_LIT(KUid, "uid");
|
sl@0
|
51 |
_LIT(KMimeType, "mimeType");
|
sl@0
|
52 |
_LIT(KDataUnitType, "DataUnitType");
|
sl@0
|
53 |
_LIT(KDataEncapsulation, "DataEncapsulation");
|
sl@0
|
54 |
_LIT(KHrdVbvSpecification, "HrdVbvSpecification");
|
sl@0
|
55 |
_LIT(KMaxPictureSize, "maxPictureSize");
|
sl@0
|
56 |
_LIT(KRandomAccessRate, "randomAccessRate");
|
sl@0
|
57 |
_LIT(KComplexityLevel, "complexityLevel");
|
sl@0
|
58 |
_LIT(KRawPicLength , "rawPicLength");
|
sl@0
|
59 |
_LIT(KPicWidth, "picWidth");
|
sl@0
|
60 |
_LIT(KPicHeight, "picHeight");
|
sl@0
|
61 |
_LIT(KHrdVbvNone, "EHrdVbvNone");
|
sl@0
|
62 |
_LIT(KHrdVbvCodingStandard, "EHrdVbvCodingStandard");
|
sl@0
|
63 |
_LIT(KHrdVbv3GPP, "EHrdVbv3GPP");
|
sl@0
|
64 |
_LIT(KLayer, "layer");
|
sl@0
|
65 |
_LIT(KBitrateControlType, "bitrateControlType");
|
sl@0
|
66 |
_LIT(KBitrate, "bitrate");
|
sl@0
|
67 |
_LIT(KPictureQuality, "pictureQuality");
|
sl@0
|
68 |
_LIT(KPicRate, "picRate");
|
sl@0
|
69 |
_LIT(KQualityTempTradeOff, "qualityTempTradeOff");
|
sl@0
|
70 |
_LIT(KLatencyQuality, "latencyQuality");
|
sl@0
|
71 |
/*@{*/
|
sl@0
|
72 |
|
sl@0
|
73 |
const CDataWrapperBase::TEnumEntryTable CT_MMFDevVideoRecordData::iHrdVbvSpecification[] =
|
sl@0
|
74 |
{
|
sl@0
|
75 |
KHrdVbvNone, EHrdVbvNone,
|
sl@0
|
76 |
KHrdVbvCodingStandard, EHrdVbvCodingStandard,
|
sl@0
|
77 |
KHrdVbv3GPP, EHrdVbv3GPP
|
sl@0
|
78 |
};
|
sl@0
|
79 |
|
sl@0
|
80 |
/**
|
sl@0
|
81 |
* Two phase constructor
|
sl@0
|
82 |
*
|
sl@0
|
83 |
* @leave system wide error
|
sl@0
|
84 |
*/
|
sl@0
|
85 |
CT_MMFDevVideoRecordData* CT_MMFDevVideoRecordData::NewL()
|
sl@0
|
86 |
{
|
sl@0
|
87 |
CT_MMFDevVideoRecordData* self = new(ELeave)CT_MMFDevVideoRecordData();
|
sl@0
|
88 |
CleanupStack::PushL (self);
|
sl@0
|
89 |
self->ConstructL ();
|
sl@0
|
90 |
CleanupStack::Pop (self);
|
sl@0
|
91 |
return self;
|
sl@0
|
92 |
}
|
sl@0
|
93 |
|
sl@0
|
94 |
/**
|
sl@0
|
95 |
* Public destructor
|
sl@0
|
96 |
*/
|
sl@0
|
97 |
CT_MMFDevVideoRecordData::~CT_MMFDevVideoRecordData()
|
sl@0
|
98 |
{
|
sl@0
|
99 |
INFO_PRINTF1(_L("Destroying data..."));
|
sl@0
|
100 |
DestroyData();
|
sl@0
|
101 |
INFO_PRINTF1(_L("Data destroyed"));
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
/**
|
sl@0
|
105 |
* Protected constructor. First phase construction
|
sl@0
|
106 |
*/
|
sl@0
|
107 |
CT_MMFDevVideoRecordData::CT_MMFDevVideoRecordData()
|
sl@0
|
108 |
:
|
sl@0
|
109 |
iBufferCount(0),
|
sl@0
|
110 |
iTimeStamp(0),
|
sl@0
|
111 |
iWrittenPictures(0),
|
sl@0
|
112 |
iReturnedPictures(0),
|
sl@0
|
113 |
iCompressedBuffers(0),
|
sl@0
|
114 |
iBufferedPictures(0),
|
sl@0
|
115 |
iStopAfterAllFramesReturned(EFalse),
|
sl@0
|
116 |
iInputEnd(EFalse),
|
sl@0
|
117 |
iDatabuf(),
|
sl@0
|
118 |
iRequests(0),
|
sl@0
|
119 |
iOutputRequests(0)
|
sl@0
|
120 |
{
|
sl@0
|
121 |
}
|
sl@0
|
122 |
|
sl@0
|
123 |
|
sl@0
|
124 |
void CT_MMFDevVideoRecordData::ConstructL()
|
sl@0
|
125 |
{
|
sl@0
|
126 |
iFs.Connect();
|
sl@0
|
127 |
}
|
sl@0
|
128 |
|
sl@0
|
129 |
/**
|
sl@0
|
130 |
* Returns a pointer to the object that the data wraps
|
sl@0
|
131 |
* @return wrapped object
|
sl@0
|
132 |
*/
|
sl@0
|
133 |
TAny* CT_MMFDevVideoRecordData::GetObject()
|
sl@0
|
134 |
{
|
sl@0
|
135 |
return iDevvr;
|
sl@0
|
136 |
}
|
sl@0
|
137 |
|
sl@0
|
138 |
|
sl@0
|
139 |
/*
|
sl@0
|
140 |
* COMMANDS
|
sl@0
|
141 |
*/
|
sl@0
|
142 |
|
sl@0
|
143 |
/**
|
sl@0
|
144 |
* Process a command read from the ini file
|
sl@0
|
145 |
*
|
sl@0
|
146 |
* @param aCommand The command to process
|
sl@0
|
147 |
* @param aSection The section in the ini containing data for the command
|
sl@0
|
148 |
* @param aAsyncErrorIndex Command index for async calls to return errors to
|
sl@0
|
149 |
* @return ETrue if the command is processed *
|
sl@0
|
150 |
* @leave System wide error
|
sl@0
|
151 |
*/
|
sl@0
|
152 |
TBool CT_MMFDevVideoRecordData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
|
sl@0
|
153 |
{
|
sl@0
|
154 |
TBool cmdProcessed = ETrue;
|
sl@0
|
155 |
if(aCommand == KCmdNewL())
|
sl@0
|
156 |
{
|
sl@0
|
157 |
DoCmdNewL(aSection);
|
sl@0
|
158 |
}
|
sl@0
|
159 |
else if(aCommand == KCmdDestructor())
|
sl@0
|
160 |
{
|
sl@0
|
161 |
DoCmdDestructor();
|
sl@0
|
162 |
}
|
sl@0
|
163 |
else if(aCommand == KCmdSelectEncoderL())
|
sl@0
|
164 |
{
|
sl@0
|
165 |
DoCmdSelectEncoderL(aSection);
|
sl@0
|
166 |
}
|
sl@0
|
167 |
else if(aCommand == KCmdSetInputFormatL())
|
sl@0
|
168 |
{
|
sl@0
|
169 |
DoCmdSetInputFormatL();
|
sl@0
|
170 |
}
|
sl@0
|
171 |
else if(aCommand == KCmdSetOutputFormatL())
|
sl@0
|
172 |
{
|
sl@0
|
173 |
DoCmdSetOutputFormatL(aSection);
|
sl@0
|
174 |
}
|
sl@0
|
175 |
else if(aCommand == KCmdSetBufferOptionsL())
|
sl@0
|
176 |
{
|
sl@0
|
177 |
DoCmdSetBufferOptionsL(aSection);
|
sl@0
|
178 |
}
|
sl@0
|
179 |
else if(aCommand == KCmdSetSourceMemoryL())
|
sl@0
|
180 |
{
|
sl@0
|
181 |
DoCmdSetSourceMemoryL();
|
sl@0
|
182 |
}
|
sl@0
|
183 |
else if(aCommand == KCmdSetMinRandomAccessRate())
|
sl@0
|
184 |
{
|
sl@0
|
185 |
DoCmdSetMinRandomAccessRate(aSection);
|
sl@0
|
186 |
}
|
sl@0
|
187 |
else if(aCommand == KCmdInitialize())
|
sl@0
|
188 |
{
|
sl@0
|
189 |
DoCmdInitialize(aAsyncErrorIndex);
|
sl@0
|
190 |
}
|
sl@0
|
191 |
else if(aCommand == KCmdSetComplexityLevel())
|
sl@0
|
192 |
{
|
sl@0
|
193 |
DoCmdSetComplexityLevel(aSection);
|
sl@0
|
194 |
}
|
sl@0
|
195 |
else if(aCommand == KCmdStart())
|
sl@0
|
196 |
{
|
sl@0
|
197 |
DoCmdStart(aAsyncErrorIndex);
|
sl@0
|
198 |
}
|
sl@0
|
199 |
else if(aCommand == KCmdPause())
|
sl@0
|
200 |
{
|
sl@0
|
201 |
DoCmdPause();
|
sl@0
|
202 |
}
|
sl@0
|
203 |
else if(aCommand == KCmdResume())
|
sl@0
|
204 |
{
|
sl@0
|
205 |
DoCmdResume();
|
sl@0
|
206 |
}
|
sl@0
|
207 |
else if(aCommand == KCmdStop())
|
sl@0
|
208 |
{
|
sl@0
|
209 |
DoCmdStop();
|
sl@0
|
210 |
}
|
sl@0
|
211 |
else if ( aCommand==KCmdUtilityGetEnvironment )
|
sl@0
|
212 |
{
|
sl@0
|
213 |
DoCmdUtilityGetEnvironmentL();
|
sl@0
|
214 |
}
|
sl@0
|
215 |
else if ( aCommand==KCmdSetRateControlOptions )
|
sl@0
|
216 |
{
|
sl@0
|
217 |
DoCmdSetRateControlOptions(aSection);
|
sl@0
|
218 |
}
|
sl@0
|
219 |
else
|
sl@0
|
220 |
{
|
sl@0
|
221 |
cmdProcessed = EFalse;
|
sl@0
|
222 |
}
|
sl@0
|
223 |
|
sl@0
|
224 |
return cmdProcessed;
|
sl@0
|
225 |
}
|
sl@0
|
226 |
|
sl@0
|
227 |
/**
|
sl@0
|
228 |
* DoCmdNewL
|
sl@0
|
229 |
* @param aSection The section in the ini containing data for the command
|
sl@0
|
230 |
*/
|
sl@0
|
231 |
void CT_MMFDevVideoRecordData::DoCmdNewL(const TTEFSectionName& aSection)
|
sl@0
|
232 |
{
|
sl@0
|
233 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdNewL"));
|
sl@0
|
234 |
DestroyData();
|
sl@0
|
235 |
TRAPD(error,iDevvr = CMMFDevVideoRecord::NewL( *this ));
|
sl@0
|
236 |
if(error!=KErrNone)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
ERR_PRINTF2(_L("Error creating CMMFDevVideoRecord %i"), error);
|
sl@0
|
239 |
SetError(error);
|
sl@0
|
240 |
}
|
sl@0
|
241 |
else
|
sl@0
|
242 |
{
|
sl@0
|
243 |
CreateBuffers();
|
sl@0
|
244 |
|
sl@0
|
245 |
if(CreateFiles(aSection)!= KErrNone)
|
sl@0
|
246 |
{
|
sl@0
|
247 |
ERR_PRINTF1(_L("Error creating input/output files"));
|
sl@0
|
248 |
SetBlockResult(EFail);
|
sl@0
|
249 |
}
|
sl@0
|
250 |
}
|
sl@0
|
251 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdNewL"));
|
sl@0
|
252 |
}
|
sl@0
|
253 |
|
sl@0
|
254 |
/**
|
sl@0
|
255 |
* DoCmdDestructor
|
sl@0
|
256 |
*/
|
sl@0
|
257 |
void CT_MMFDevVideoRecordData::DoCmdDestructor()
|
sl@0
|
258 |
{
|
sl@0
|
259 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdDestructor"));
|
sl@0
|
260 |
iInFile.Close();
|
sl@0
|
261 |
iOutFile.Close();
|
sl@0
|
262 |
iFs.Close();
|
sl@0
|
263 |
REComSession::FinalClose();
|
sl@0
|
264 |
DestroyData();
|
sl@0
|
265 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdDestructor"));
|
sl@0
|
266 |
}
|
sl@0
|
267 |
|
sl@0
|
268 |
/**
|
sl@0
|
269 |
* DoCmdSelectEncoderL
|
sl@0
|
270 |
* Selects the video encoder to be used. This method must be called before any other video encoder related
|
sl@0
|
271 |
* methods are used. The encoder can be changed by calling this method again before the system has been
|
sl@0
|
272 |
* initialized with Initialize().
|
sl@0
|
273 |
* All video encoder settings are reset to their default values. By default no pre-processing is performed.
|
sl@0
|
274 |
* @param aSection The section in the ini containing data for the command
|
sl@0
|
275 |
*/
|
sl@0
|
276 |
void CT_MMFDevVideoRecordData::DoCmdSelectEncoderL(const TTEFSectionName& aSection)
|
sl@0
|
277 |
{
|
sl@0
|
278 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSelectEncoderL"));
|
sl@0
|
279 |
TInt hUid = 0;
|
sl@0
|
280 |
|
sl@0
|
281 |
if(!GetHexFromConfig(aSection, KUid(), hUid))
|
sl@0
|
282 |
{
|
sl@0
|
283 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUid());
|
sl@0
|
284 |
SetBlockResult(EFail);
|
sl@0
|
285 |
}
|
sl@0
|
286 |
else
|
sl@0
|
287 |
{
|
sl@0
|
288 |
TUid Uid = TUid::Uid(hUid);
|
sl@0
|
289 |
SetPictureTypeL(aSection);
|
sl@0
|
290 |
TRAPD(error,iEncHWDevId = iDevvr->SelectEncoderL(Uid));
|
sl@0
|
291 |
if(error!=KErrNone)
|
sl@0
|
292 |
{
|
sl@0
|
293 |
iEncHWDevId = NULL;
|
sl@0
|
294 |
ERR_PRINTF2(_L("Error Selecting encoder: %i"), error);
|
sl@0
|
295 |
SetError(error);
|
sl@0
|
296 |
}
|
sl@0
|
297 |
}
|
sl@0
|
298 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSelectEncoderL"));
|
sl@0
|
299 |
}
|
sl@0
|
300 |
|
sl@0
|
301 |
/*
|
sl@0
|
302 |
* Sets the input format for a hardware device. If both a pre-processor and an encoder are used, the
|
sl@0
|
303 |
* pre-processor output format and the encoder input format must be the same. The input format for the
|
sl@0
|
304 |
* first device in the system is the input format for video input data.
|
sl@0
|
305 |
*/
|
sl@0
|
306 |
void CT_MMFDevVideoRecordData::DoCmdSetInputFormatL()
|
sl@0
|
307 |
{
|
sl@0
|
308 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetInputFormatL"));
|
sl@0
|
309 |
TUncompressedVideoFormat unCompressedFormat;
|
sl@0
|
310 |
|
sl@0
|
311 |
unCompressedFormat.iDataFormat = EYuvRawData;
|
sl@0
|
312 |
unCompressedFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
|
sl@0
|
313 |
unCompressedFormat.iYuvFormat.iPattern = EYuv420Chroma1;
|
sl@0
|
314 |
unCompressedFormat.iYuvFormat.iYuv2RgbMatrix = NULL;
|
sl@0
|
315 |
unCompressedFormat.iYuvFormat.iRgb2YuvMatrix = NULL;
|
sl@0
|
316 |
unCompressedFormat.iYuvFormat.iAspectRatioNum = 1;
|
sl@0
|
317 |
unCompressedFormat.iYuvFormat.iAspectRatioDenom = 1;
|
sl@0
|
318 |
unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt601Range0;
|
sl@0
|
319 |
|
sl@0
|
320 |
TRAPD(error,iDevvr->SetInputFormatL( iEncHWDevId, unCompressedFormat, iPictSize ));
|
sl@0
|
321 |
if(error!=KErrNone)
|
sl@0
|
322 |
{
|
sl@0
|
323 |
ERR_PRINTF2(_L("Error Setting input format: %i"), error);
|
sl@0
|
324 |
SetError(error);
|
sl@0
|
325 |
}
|
sl@0
|
326 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetInputFormatL"));
|
sl@0
|
327 |
}
|
sl@0
|
328 |
|
sl@0
|
329 |
/*
|
sl@0
|
330 |
* Sets the output format for a hardware device to a compressed video format. Only applicable for encoder
|
sl@0
|
331 |
* devices. The picture size depends on the input data format and possible scaling performed.
|
sl@0
|
332 |
* @param aSection The section in the ini containing data for the command
|
sl@0
|
333 |
*/
|
sl@0
|
334 |
void CT_MMFDevVideoRecordData::DoCmdSetOutputFormatL(const TTEFSectionName& aSection)
|
sl@0
|
335 |
{
|
sl@0
|
336 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetOutputFormatL"));
|
sl@0
|
337 |
TBuf8<50> mimetype;
|
sl@0
|
338 |
TVideoDataUnitType dataUnitType;
|
sl@0
|
339 |
TVideoDataUnitEncapsulation dataEncapsulation;
|
sl@0
|
340 |
TBool dataOk = ETrue;
|
sl@0
|
341 |
TInt iDataUnitType = 0;
|
sl@0
|
342 |
TInt iDataEncapsulation = 0;
|
sl@0
|
343 |
|
sl@0
|
344 |
TPtrC mimeType;
|
sl@0
|
345 |
if(!GetStringFromConfig(aSection, KMimeType(), mimeType))
|
sl@0
|
346 |
{
|
sl@0
|
347 |
ERR_PRINTF1(_L("Mime type not retrieved, command will not be executed"));
|
sl@0
|
348 |
SetBlockResult(EFail);
|
sl@0
|
349 |
dataOk = EFalse;
|
sl@0
|
350 |
}
|
sl@0
|
351 |
if(!GetHexFromConfig(aSection, KDataUnitType(), iDataUnitType))
|
sl@0
|
352 |
{
|
sl@0
|
353 |
ERR_PRINTF2(_L("check parameter: %S"), &KDataUnitType());
|
sl@0
|
354 |
SetBlockResult(EFail);
|
sl@0
|
355 |
dataOk = EFalse;
|
sl@0
|
356 |
}
|
sl@0
|
357 |
if(!GetHexFromConfig(aSection, KDataEncapsulation(), iDataEncapsulation))
|
sl@0
|
358 |
{
|
sl@0
|
359 |
ERR_PRINTF2(_L("check parameter: %S"), &KDataEncapsulation());
|
sl@0
|
360 |
SetBlockResult(EFail);
|
sl@0
|
361 |
dataOk = EFalse;
|
sl@0
|
362 |
}
|
sl@0
|
363 |
if(dataOk)
|
sl@0
|
364 |
{
|
sl@0
|
365 |
mimetype.Append(mimeType);
|
sl@0
|
366 |
CCompressedVideoFormat* compressedFormat=NULL;
|
sl@0
|
367 |
TRAPD(cfError, compressedFormat = CCompressedVideoFormat::NewL(mimetype));
|
sl@0
|
368 |
CleanupStack::PushL(compressedFormat);
|
sl@0
|
369 |
if(cfError != KErrNone)
|
sl@0
|
370 |
{
|
sl@0
|
371 |
ERR_PRINTF2(_L("Error selecting compressed video format, check selected mimeType: %i"), cfError);
|
sl@0
|
372 |
SetError(cfError);
|
sl@0
|
373 |
}
|
sl@0
|
374 |
else
|
sl@0
|
375 |
{
|
sl@0
|
376 |
dataUnitType = static_cast<TVideoDataUnitType>(iDataUnitType);
|
sl@0
|
377 |
dataEncapsulation = static_cast<TVideoDataUnitEncapsulation>(iDataEncapsulation);
|
sl@0
|
378 |
|
sl@0
|
379 |
TRAPD(error,iDevvr->SetOutputFormatL(iEncHWDevId, *compressedFormat, dataUnitType, dataEncapsulation, EFalse));
|
sl@0
|
380 |
if(error != KErrNone)
|
sl@0
|
381 |
{
|
sl@0
|
382 |
ERR_PRINTF2(_L("Couldn't set OutputFormat %i"), error);
|
sl@0
|
383 |
delete iDevvr;
|
sl@0
|
384 |
iDevvr = NULL;
|
sl@0
|
385 |
SetError(error);
|
sl@0
|
386 |
}
|
sl@0
|
387 |
}
|
sl@0
|
388 |
CleanupStack::PopAndDestroy(compressedFormat);
|
sl@0
|
389 |
}
|
sl@0
|
390 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetOutputFormatL"));
|
sl@0
|
391 |
}
|
sl@0
|
392 |
|
sl@0
|
393 |
/*
|
sl@0
|
394 |
* Sets encoder buffering options.
|
sl@0
|
395 |
* @param aSection The section in the ini containing data for the command
|
sl@0
|
396 |
*/
|
sl@0
|
397 |
void CT_MMFDevVideoRecordData::DoCmdSetBufferOptionsL(const TTEFSectionName& aSection)
|
sl@0
|
398 |
{
|
sl@0
|
399 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetBufferOptionsL"));
|
sl@0
|
400 |
TEncoderBufferOptions bufferOptions;
|
sl@0
|
401 |
TInt HrdVbvSpecification = 0;
|
sl@0
|
402 |
TInt maxPictureSize = 0;
|
sl@0
|
403 |
TBool dataOk = ETrue;
|
sl@0
|
404 |
if(!GetEnumFromConfig(aSection, KHrdVbvSpecification(), iHrdVbvSpecification, HrdVbvSpecification))
|
sl@0
|
405 |
{
|
sl@0
|
406 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHrdVbvSpecification());
|
sl@0
|
407 |
SetBlockResult(EFail);
|
sl@0
|
408 |
dataOk = EFalse;
|
sl@0
|
409 |
}
|
sl@0
|
410 |
if(!GetIntFromConfig(aSection, KMaxPictureSize(), maxPictureSize))
|
sl@0
|
411 |
{
|
sl@0
|
412 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMaxPictureSize());
|
sl@0
|
413 |
SetBlockResult(EFail);
|
sl@0
|
414 |
dataOk = EFalse;
|
sl@0
|
415 |
}
|
sl@0
|
416 |
if(dataOk)
|
sl@0
|
417 |
{
|
sl@0
|
418 |
bufferOptions.iHrdVbvParams.Set(NULL, 0);
|
sl@0
|
419 |
bufferOptions.iHrdVbvSpec = (THrdVbvSpecification)HrdVbvSpecification;
|
sl@0
|
420 |
bufferOptions.iMaxPreEncoderBufferPictures = KNumPictures;
|
sl@0
|
421 |
bufferOptions.iMaxCodedPictureSize = maxPictureSize;
|
sl@0
|
422 |
bufferOptions.iMaxOutputBufferSize = maxPictureSize;
|
sl@0
|
423 |
bufferOptions.iMaxCodedSegmentSize = maxPictureSize;
|
sl@0
|
424 |
|
sl@0
|
425 |
//Not needed more that 4 input buffers for normal fileRead test cases
|
sl@0
|
426 |
bufferOptions.iMinNumOutputBuffers = KNumPictures - 2;
|
sl@0
|
427 |
TRAPD(error, iDevvr->SetBufferOptionsL( bufferOptions ));
|
sl@0
|
428 |
if(error!=KErrNone)
|
sl@0
|
429 |
{
|
sl@0
|
430 |
ERR_PRINTF2(_L("Error Setting buffer options: %i"), error);
|
sl@0
|
431 |
SetError(error);
|
sl@0
|
432 |
}
|
sl@0
|
433 |
}
|
sl@0
|
434 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetBufferOptionsL"));
|
sl@0
|
435 |
}
|
sl@0
|
436 |
/*
|
sl@0
|
437 |
* Sets the data source to be memory buffers.
|
sl@0
|
438 |
*/
|
sl@0
|
439 |
void CT_MMFDevVideoRecordData::DoCmdSetSourceMemoryL()
|
sl@0
|
440 |
{
|
sl@0
|
441 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetSourceMemoryL"));
|
sl@0
|
442 |
|
sl@0
|
443 |
TRAPD(error, iDevvr->SetSourceMemoryL(iFrameRate, EFalse, EFalse));
|
sl@0
|
444 |
if(error != KErrNone)
|
sl@0
|
445 |
{
|
sl@0
|
446 |
ERR_PRINTF2(_L("Error Setting Source Memory: %i"), error);
|
sl@0
|
447 |
SetError(error);
|
sl@0
|
448 |
}
|
sl@0
|
449 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetSourceMemoryL"));
|
sl@0
|
450 |
}
|
sl@0
|
451 |
|
sl@0
|
452 |
/*
|
sl@0
|
453 |
* Sets the minimum frequency (in time) for instantaneous random access points in the bitstream.
|
sl@0
|
454 |
* An instantaneous random access point is such where the encoder can achieve a full output picture
|
sl@0
|
455 |
* immediately by encoding data starting from the random access point. The random access point frequency
|
sl@0
|
456 |
* may be higher than signalled, if the sequence contains scene cuts which typically cause a coding of
|
sl@0
|
457 |
* a random access point.
|
sl@0
|
458 |
* @param aSection The section in the ini containing data for the command
|
sl@0
|
459 |
*/
|
sl@0
|
460 |
void CT_MMFDevVideoRecordData::DoCmdSetMinRandomAccessRate(const TTEFSectionName& aSection)
|
sl@0
|
461 |
{
|
sl@0
|
462 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetMinRandomAccessRate"));
|
sl@0
|
463 |
TReal randomAccessRate = 0;
|
sl@0
|
464 |
|
sl@0
|
465 |
if(!GetRealFromConfig(aSection, KRandomAccessRate(), randomAccessRate))
|
sl@0
|
466 |
{
|
sl@0
|
467 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRandomAccessRate());
|
sl@0
|
468 |
SetBlockResult(EFail);
|
sl@0
|
469 |
}
|
sl@0
|
470 |
else
|
sl@0
|
471 |
{
|
sl@0
|
472 |
iDevvr->SetMinRandomAccessRate( randomAccessRate );
|
sl@0
|
473 |
}
|
sl@0
|
474 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetMinRandomAccessRate"));
|
sl@0
|
475 |
}
|
sl@0
|
476 |
|
sl@0
|
477 |
/*
|
sl@0
|
478 |
* Initializes the video devices, and reserves hardware resources. This method is asynchronous,
|
sl@0
|
479 |
* DevVideoRecord will call MMMFDevVideoRecordObserver::MdvroInitializeComplete() after initialization has
|
sl@0
|
480 |
* completed. If direct capture is used, this method also prepares the camera API for capture by calling
|
sl@0
|
481 |
* PrepareVideoCaptureL(). No DevVideoRecord method may be called while initialization is in progress, the
|
sl@0
|
482 |
* initialization process can only be cancelled by destroying the DevVideoRecord object.
|
sl@0
|
483 |
* @param a AsyncErrorIndex Command index for async calls to return errors to
|
sl@0
|
484 |
*/
|
sl@0
|
485 |
void CT_MMFDevVideoRecordData::DoCmdInitialize(const TInt aAsyncErrorIndex)
|
sl@0
|
486 |
{
|
sl@0
|
487 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdInitialize"));
|
sl@0
|
488 |
iAsyncErrorIndex = aAsyncErrorIndex;
|
sl@0
|
489 |
IncOutstanding();
|
sl@0
|
490 |
iDevvr->Initialize();
|
sl@0
|
491 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdInitialize"));
|
sl@0
|
492 |
}
|
sl@0
|
493 |
|
sl@0
|
494 |
/*
|
sl@0
|
495 |
* Sets the complexity level to use for video processing in a hardware device. The level can be changed at
|
sl@0
|
496 |
* any time.
|
sl@0
|
497 |
* @param a AsyncErrorIndex Command index for async calls to return errors to
|
sl@0
|
498 |
*/
|
sl@0
|
499 |
void CT_MMFDevVideoRecordData::DoCmdSetComplexityLevel(const TTEFSectionName& aSection)
|
sl@0
|
500 |
{
|
sl@0
|
501 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetComplexityLevel"));
|
sl@0
|
502 |
TInt complexityLevel = 0;
|
sl@0
|
503 |
|
sl@0
|
504 |
INFO_PRINTF1(_L("SET COMPLEXITY LEVEL begin"));
|
sl@0
|
505 |
|
sl@0
|
506 |
if(!GetIntFromConfig(aSection, KComplexityLevel(), complexityLevel))
|
sl@0
|
507 |
{
|
sl@0
|
508 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KComplexityLevel());
|
sl@0
|
509 |
SetBlockResult(EFail);
|
sl@0
|
510 |
}
|
sl@0
|
511 |
else
|
sl@0
|
512 |
{
|
sl@0
|
513 |
iDevvr->SetComplexityLevel( iEncHWDevId, complexityLevel );
|
sl@0
|
514 |
INFO_PRINTF1(_L("SET COMPLEXITY LEVEL stop"));
|
sl@0
|
515 |
}
|
sl@0
|
516 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetComplexityLevel"));
|
sl@0
|
517 |
}
|
sl@0
|
518 |
|
sl@0
|
519 |
/*
|
sl@0
|
520 |
* Starts recording video. This includes capturing pictures from the camera (if direct capture is used),
|
sl@0
|
521 |
* pre-processing and encoding. Recording will proceed until it is stopped or paused. Initally recording
|
sl@0
|
522 |
* is stopped.
|
sl@0
|
523 |
* @param a AsyncErrorIndex Command index for async calls to return errors to
|
sl@0
|
524 |
*/
|
sl@0
|
525 |
void CT_MMFDevVideoRecordData::DoCmdStart(const TInt aAsyncErrorIndex)
|
sl@0
|
526 |
{
|
sl@0
|
527 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdStart"));
|
sl@0
|
528 |
iAsyncErrorIndex = aAsyncErrorIndex;
|
sl@0
|
529 |
|
sl@0
|
530 |
iDevvr->Start();
|
sl@0
|
531 |
|
sl@0
|
532 |
iRequests++;
|
sl@0
|
533 |
if ( FillAndSendBuffer() == 0 )
|
sl@0
|
534 |
{
|
sl@0
|
535 |
iStopAfterAllFramesReturned = ETrue;
|
sl@0
|
536 |
}
|
sl@0
|
537 |
IncOutstanding();
|
sl@0
|
538 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdStart"));
|
sl@0
|
539 |
}
|
sl@0
|
540 |
|
sl@0
|
541 |
/*
|
sl@0
|
542 |
* Pauses video recording. Recording can be resumed using Resume().
|
sl@0
|
543 |
*/
|
sl@0
|
544 |
void CT_MMFDevVideoRecordData::DoCmdPause()
|
sl@0
|
545 |
{
|
sl@0
|
546 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdPause"));
|
sl@0
|
547 |
iDevvr->Pause();
|
sl@0
|
548 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdPause"));
|
sl@0
|
549 |
}
|
sl@0
|
550 |
|
sl@0
|
551 |
/*
|
sl@0
|
552 |
* Resumes video recording after a pause.
|
sl@0
|
553 |
*/
|
sl@0
|
554 |
void CT_MMFDevVideoRecordData::DoCmdResume()
|
sl@0
|
555 |
{
|
sl@0
|
556 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdResume"));
|
sl@0
|
557 |
iDevvr->Resume();
|
sl@0
|
558 |
HandleReturnedPicture();
|
sl@0
|
559 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdResume"));
|
sl@0
|
560 |
}
|
sl@0
|
561 |
|
sl@0
|
562 |
/**
|
sl@0
|
563 |
* Stops recording video. No new pictures will be captured, pre-processed, or encoded.
|
sl@0
|
564 |
*/
|
sl@0
|
565 |
void CT_MMFDevVideoRecordData::DoCmdStop()
|
sl@0
|
566 |
{
|
sl@0
|
567 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdStop"));
|
sl@0
|
568 |
iDevvr->Stop();
|
sl@0
|
569 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdStop"));
|
sl@0
|
570 |
}
|
sl@0
|
571 |
|
sl@0
|
572 |
/*
|
sl@0
|
573 |
* CALLBACKS
|
sl@0
|
574 |
*/
|
sl@0
|
575 |
|
sl@0
|
576 |
/**
|
sl@0
|
577 |
* Returns a used input video picture back to the caller. The picture memory can be re-used or freed.
|
sl@0
|
578 |
*
|
sl@0
|
579 |
* @param aPicture the picture to return
|
sl@0
|
580 |
*/
|
sl@0
|
581 |
void CT_MMFDevVideoRecordData::MdvroReturnPicture(TVideoPicture* aPicture)
|
sl@0
|
582 |
{
|
sl@0
|
583 |
TInt index = 0;
|
sl@0
|
584 |
|
sl@0
|
585 |
iReturnedPictures++;
|
sl@0
|
586 |
iBufferedPictures--;
|
sl@0
|
587 |
|
sl@0
|
588 |
for ( index = 0; index < KBufferInputPictures; index++)
|
sl@0
|
589 |
{
|
sl@0
|
590 |
if ( &(iPicture[index]) == aPicture )
|
sl@0
|
591 |
{//set it free
|
sl@0
|
592 |
iPicture[index].iOptions = 0;
|
sl@0
|
593 |
}
|
sl@0
|
594 |
}
|
sl@0
|
595 |
HandleReturnedPicture();
|
sl@0
|
596 |
}
|
sl@0
|
597 |
|
sl@0
|
598 |
/**
|
sl@0
|
599 |
* Callback not used.
|
sl@0
|
600 |
*
|
sl@0
|
601 |
* @return None
|
sl@0
|
602 |
*/
|
sl@0
|
603 |
void CT_MMFDevVideoRecordData::MdvroSupplementalInfoSent()
|
sl@0
|
604 |
{
|
sl@0
|
605 |
}
|
sl@0
|
606 |
|
sl@0
|
607 |
/**
|
sl@0
|
608 |
* Observer callback in Custom interface Buffer management.
|
sl@0
|
609 |
* Client is notified a new buffer(s) is available
|
sl@0
|
610 |
*
|
sl@0
|
611 |
* @return None
|
sl@0
|
612 |
*/
|
sl@0
|
613 |
void CT_MMFDevVideoRecordData::MdvroNewBuffers()
|
sl@0
|
614 |
{
|
sl@0
|
615 |
iCompressedBuffers ++;
|
sl@0
|
616 |
HandleNewBuffer();
|
sl@0
|
617 |
}
|
sl@0
|
618 |
|
sl@0
|
619 |
/**
|
sl@0
|
620 |
* Reports a fatal decoding or playback error to the client.
|
sl@0
|
621 |
*
|
sl@0
|
622 |
* @param aError The error code
|
sl@0
|
623 |
*
|
sl@0
|
624 |
* @return None
|
sl@0
|
625 |
*/
|
sl@0
|
626 |
void CT_MMFDevVideoRecordData::MdvroFatalError(TInt aError)
|
sl@0
|
627 |
{
|
sl@0
|
628 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::MdvroFatalError"));
|
sl@0
|
629 |
|
sl@0
|
630 |
DecOutstanding();
|
sl@0
|
631 |
|
sl@0
|
632 |
ERR_PRINTF2(_L("A fatal error ocurred %i"), aError);
|
sl@0
|
633 |
SetAsyncError (iAsyncErrorIndex, aError);
|
sl@0
|
634 |
|
sl@0
|
635 |
if(iDevvr != NULL)
|
sl@0
|
636 |
{
|
sl@0
|
637 |
delete iDevvr;
|
sl@0
|
638 |
iDevvr = NULL;
|
sl@0
|
639 |
}
|
sl@0
|
640 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::MdvroFatalError"));
|
sl@0
|
641 |
}
|
sl@0
|
642 |
|
sl@0
|
643 |
/**
|
sl@0
|
644 |
* Reports that DevVideoRecord initialization has completed. The interface can now be used for video recording.
|
sl@0
|
645 |
*
|
sl@0
|
646 |
* @param aError Initialization error code, KErrNone if no error occurred
|
sl@0
|
647 |
*
|
sl@0
|
648 |
* @return None
|
sl@0
|
649 |
*/
|
sl@0
|
650 |
void CT_MMFDevVideoRecordData::MdvroInitializeComplete(TInt aError)
|
sl@0
|
651 |
{
|
sl@0
|
652 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::MdvroInitializeComplete"));
|
sl@0
|
653 |
DecOutstanding();
|
sl@0
|
654 |
if ( aError != KErrNone )
|
sl@0
|
655 |
{
|
sl@0
|
656 |
SetAsyncError (iAsyncErrorIndex, aError);
|
sl@0
|
657 |
ERR_PRINTF2(_L("Error at MdvroInitializeComplete %i"), aError);
|
sl@0
|
658 |
}
|
sl@0
|
659 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::MdvroInitializeComplete"));
|
sl@0
|
660 |
}
|
sl@0
|
661 |
|
sl@0
|
662 |
/**
|
sl@0
|
663 |
* Reports that the input video stream end has been reached and all pictures have been processed.
|
sl@0
|
664 |
* This method is only called after the client has called InputEnd(). No more output pictures will be available.
|
sl@0
|
665 |
*
|
sl@0
|
666 |
* @return None
|
sl@0
|
667 |
*/
|
sl@0
|
668 |
void CT_MMFDevVideoRecordData::MdvroStreamEnd()
|
sl@0
|
669 |
{
|
sl@0
|
670 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::MdvroStreamEnd"));
|
sl@0
|
671 |
DecOutstanding();
|
sl@0
|
672 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::MdvroStreamEnd"));
|
sl@0
|
673 |
}
|
sl@0
|
674 |
|
sl@0
|
675 |
/*
|
sl@0
|
676 |
* HELPERS
|
sl@0
|
677 |
*/
|
sl@0
|
678 |
|
sl@0
|
679 |
/**
|
sl@0
|
680 |
* Sets the Picture Type for the test
|
sl@0
|
681 |
* @param aSection The section in the ini containing data for the command
|
sl@0
|
682 |
*/
|
sl@0
|
683 |
void CT_MMFDevVideoRecordData::SetPictureTypeL(const TTEFSectionName& aSection)
|
sl@0
|
684 |
{
|
sl@0
|
685 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::SetPictureTypeL"));
|
sl@0
|
686 |
TInt rawPicLength=0;
|
sl@0
|
687 |
TInt picWidth=0;
|
sl@0
|
688 |
TInt picHeight=0;
|
sl@0
|
689 |
|
sl@0
|
690 |
if(!GetIntFromConfig(aSection, KFrameRate(), iFrameRate))
|
sl@0
|
691 |
{
|
sl@0
|
692 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFrameRate());
|
sl@0
|
693 |
SetBlockResult(EFail);
|
sl@0
|
694 |
}
|
sl@0
|
695 |
|
sl@0
|
696 |
if(!GetIntFromConfig(aSection, KRawPicLength(), rawPicLength))
|
sl@0
|
697 |
{
|
sl@0
|
698 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRawPicLength());
|
sl@0
|
699 |
SetBlockResult(EFail);
|
sl@0
|
700 |
}
|
sl@0
|
701 |
|
sl@0
|
702 |
if(!GetIntFromConfig(aSection, KPicWidth(), picWidth))
|
sl@0
|
703 |
{
|
sl@0
|
704 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRawPicLength());
|
sl@0
|
705 |
SetBlockResult(EFail);
|
sl@0
|
706 |
}
|
sl@0
|
707 |
|
sl@0
|
708 |
if(!GetIntFromConfig(aSection, KPicHeight(), picHeight))
|
sl@0
|
709 |
{
|
sl@0
|
710 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRawPicLength());
|
sl@0
|
711 |
SetBlockResult(EFail);
|
sl@0
|
712 |
}
|
sl@0
|
713 |
|
sl@0
|
714 |
iPictSize.SetSize(picHeight,picWidth);
|
sl@0
|
715 |
|
sl@0
|
716 |
INFO_PRINTF1(_L("Creating Data buffers"));
|
sl@0
|
717 |
TUint8* pointer = NULL;
|
sl@0
|
718 |
if (!iDatabuf)
|
sl@0
|
719 |
{
|
sl@0
|
720 |
//iDatabuf = new (ELeave) TUint8*[KBufferInputPictures];
|
sl@0
|
721 |
iDatabuf = new RPointerArray<TUint8>[KBufferInputPictures];
|
sl@0
|
722 |
|
sl@0
|
723 |
for ( TInt i = 0; i < KBufferInputPictures; i ++ )
|
sl@0
|
724 |
{
|
sl@0
|
725 |
pointer = new (ELeave) TUint8[rawPicLength];
|
sl@0
|
726 |
iDatabuf[i].Append(pointer);
|
sl@0
|
727 |
iPicture[i].iData.iRawData = new (ELeave) TPtr8(0, 0, 0);
|
sl@0
|
728 |
iPicture[i].iData.iRawData->Set(pointer, rawPicLength, rawPicLength );
|
sl@0
|
729 |
iPicture[i].iData.iDataSize.SetSize(iPictSize.iWidth, iPictSize.iHeight);
|
sl@0
|
730 |
}
|
sl@0
|
731 |
}
|
sl@0
|
732 |
INFO_PRINTF1(_L("Data buffers created"));
|
sl@0
|
733 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::SetPictureTypeL"));
|
sl@0
|
734 |
}
|
sl@0
|
735 |
|
sl@0
|
736 |
/**
|
sl@0
|
737 |
* create buffers to read data
|
sl@0
|
738 |
*/
|
sl@0
|
739 |
void CT_MMFDevVideoRecordData::CreateBuffers()
|
sl@0
|
740 |
{
|
sl@0
|
741 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::CreateBuffers"));
|
sl@0
|
742 |
for (TInt i = 0; i < KBufferInputPictures; i ++)
|
sl@0
|
743 |
{
|
sl@0
|
744 |
INFO_PRINTF1(_L("creating buffers"));
|
sl@0
|
745 |
iPicture[i].iData.iRawData = NULL;
|
sl@0
|
746 |
INFO_PRINTF1(_L("buffers created"));
|
sl@0
|
747 |
}
|
sl@0
|
748 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::CreateBuffers"));
|
sl@0
|
749 |
}
|
sl@0
|
750 |
|
sl@0
|
751 |
|
sl@0
|
752 |
/**
|
sl@0
|
753 |
*checks for input file and creates output files
|
sl@0
|
754 |
* @param aSection The section in the ini containing data for the command
|
sl@0
|
755 |
*/
|
sl@0
|
756 |
int CT_MMFDevVideoRecordData::CreateFiles(const TTEFSectionName& aSection)
|
sl@0
|
757 |
{
|
sl@0
|
758 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::CreateFiles"));
|
sl@0
|
759 |
TInt err = KErrNone;
|
sl@0
|
760 |
TPtrC inputFile;
|
sl@0
|
761 |
TPtrC outputFile;
|
sl@0
|
762 |
TPtrC inputPath;
|
sl@0
|
763 |
TPtrC outputPath;
|
sl@0
|
764 |
if(!GetStringFromConfig(aSection, KInputFile(), inputFile))
|
sl@0
|
765 |
{
|
sl@0
|
766 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputFile());
|
sl@0
|
767 |
SetBlockResult(EFail);
|
sl@0
|
768 |
err = KErrNotFound;
|
sl@0
|
769 |
}
|
sl@0
|
770 |
if(!GetStringFromConfig(aSection, KOutputFile(), outputFile))
|
sl@0
|
771 |
{
|
sl@0
|
772 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutputFile());
|
sl@0
|
773 |
SetBlockResult(EFail);
|
sl@0
|
774 |
err = KErrNotFound;
|
sl@0
|
775 |
}
|
sl@0
|
776 |
if(!GetStringFromConfig(aSection, KInputPath(), inputPath))
|
sl@0
|
777 |
{
|
sl@0
|
778 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputPath());
|
sl@0
|
779 |
SetBlockResult(EFail);
|
sl@0
|
780 |
err = KErrNotFound;
|
sl@0
|
781 |
}
|
sl@0
|
782 |
if(!GetStringFromConfig(aSection, KOutputPath(), outputPath))
|
sl@0
|
783 |
{
|
sl@0
|
784 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutputFile());
|
sl@0
|
785 |
SetBlockResult(EFail);
|
sl@0
|
786 |
err = KErrNotFound;
|
sl@0
|
787 |
}
|
sl@0
|
788 |
|
sl@0
|
789 |
if(err == KErrNone)
|
sl@0
|
790 |
{
|
sl@0
|
791 |
TFileName inFileName(inputPath);
|
sl@0
|
792 |
inFileName.Append(inputFile);
|
sl@0
|
793 |
TFileName outFileName(outputPath);
|
sl@0
|
794 |
outFileName.Append(outputFile);
|
sl@0
|
795 |
|
sl@0
|
796 |
err = OpenFile(outFileName, inFileName);
|
sl@0
|
797 |
}
|
sl@0
|
798 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::CreateFiles"));
|
sl@0
|
799 |
return err;
|
sl@0
|
800 |
}
|
sl@0
|
801 |
|
sl@0
|
802 |
/**
|
sl@0
|
803 |
* Opens input file.
|
sl@0
|
804 |
* Creates output file.
|
sl@0
|
805 |
* @param aOutFileName the output file
|
sl@0
|
806 |
* @param aInFileName the input file
|
sl@0
|
807 |
*/
|
sl@0
|
808 |
int CT_MMFDevVideoRecordData::OpenFile(TFileName& aOutFileName, TFileName& aInFileName)
|
sl@0
|
809 |
{
|
sl@0
|
810 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::OpenFile"));
|
sl@0
|
811 |
TInt err = KErrNone;
|
sl@0
|
812 |
if ( (err=iInFile.Open(iFs, aInFileName, EFileRead | EFileShareReadersOnly)) != KErrNone)
|
sl@0
|
813 |
{
|
sl@0
|
814 |
ERR_PRINTF2(_L("Couldn't open input file: %i"),err);
|
sl@0
|
815 |
}
|
sl@0
|
816 |
else
|
sl@0
|
817 |
{
|
sl@0
|
818 |
if((err=iOutFile.Replace(iFs, aOutFileName, EFileShareExclusive|EFileWrite))!= KErrNone)
|
sl@0
|
819 |
{
|
sl@0
|
820 |
ERR_PRINTF2(_L("Couldn't open output file: %i"),err);
|
sl@0
|
821 |
}
|
sl@0
|
822 |
}
|
sl@0
|
823 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::OpenFile"));
|
sl@0
|
824 |
return err;
|
sl@0
|
825 |
}
|
sl@0
|
826 |
|
sl@0
|
827 |
/**
|
sl@0
|
828 |
* gets new buffers from buffer array
|
sl@0
|
829 |
*/
|
sl@0
|
830 |
void CT_MMFDevVideoRecordData::HandleNewBuffer()
|
sl@0
|
831 |
{
|
sl@0
|
832 |
TVideoOutputBuffer* tmp=NULL;
|
sl@0
|
833 |
TRAPD(error, tmp = iDevvr->NextBufferL());
|
sl@0
|
834 |
if (error != KErrNone)
|
sl@0
|
835 |
{
|
sl@0
|
836 |
ERR_PRINTF2(_L("Error in getting NextBufferL, Error: %d"), error);
|
sl@0
|
837 |
SetBlockResult(EFail);
|
sl@0
|
838 |
}
|
sl@0
|
839 |
else
|
sl@0
|
840 |
{
|
sl@0
|
841 |
SaveAndReturnBuffer( tmp );
|
sl@0
|
842 |
}
|
sl@0
|
843 |
}
|
sl@0
|
844 |
|
sl@0
|
845 |
/**
|
sl@0
|
846 |
* handles the returned pictures
|
sl@0
|
847 |
*/
|
sl@0
|
848 |
void CT_MMFDevVideoRecordData::HandleReturnedPicture()
|
sl@0
|
849 |
{
|
sl@0
|
850 |
if ( iStopAfterAllFramesReturned )
|
sl@0
|
851 |
{
|
sl@0
|
852 |
}
|
sl@0
|
853 |
else
|
sl@0
|
854 |
{
|
sl@0
|
855 |
//iOutputRequests++;
|
sl@0
|
856 |
if ( FillAndSendBuffer() == 0 )
|
sl@0
|
857 |
{
|
sl@0
|
858 |
iStopAfterAllFramesReturned = ETrue;
|
sl@0
|
859 |
}
|
sl@0
|
860 |
}
|
sl@0
|
861 |
}
|
sl@0
|
862 |
|
sl@0
|
863 |
/**
|
sl@0
|
864 |
*handles out to file requests
|
sl@0
|
865 |
*@param aNumberOfPictures number of pictures to write
|
sl@0
|
866 |
*/
|
sl@0
|
867 |
TInt CT_MMFDevVideoRecordData::HandleOutputRequest()
|
sl@0
|
868 |
{
|
sl@0
|
869 |
TInt request = 1;
|
sl@0
|
870 |
if ( FillAndSendBuffer() == 0 )
|
sl@0
|
871 |
{
|
sl@0
|
872 |
//all data read => stop
|
sl@0
|
873 |
iStopAfterAllFramesReturned = ETrue;
|
sl@0
|
874 |
request = 0;
|
sl@0
|
875 |
}
|
sl@0
|
876 |
return request;
|
sl@0
|
877 |
}
|
sl@0
|
878 |
|
sl@0
|
879 |
/**
|
sl@0
|
880 |
*writes buffer to file
|
sl@0
|
881 |
*@param tmp current buffer
|
sl@0
|
882 |
*/
|
sl@0
|
883 |
void CT_MMFDevVideoRecordData::SaveAndReturnBuffer(TVideoOutputBuffer* tmp)
|
sl@0
|
884 |
{
|
sl@0
|
885 |
iOutFile.Write( tmp->iData );
|
sl@0
|
886 |
iDevvr->ReturnBuffer( tmp );
|
sl@0
|
887 |
}
|
sl@0
|
888 |
|
sl@0
|
889 |
/**
|
sl@0
|
890 |
*fills buffer data buffer and process it
|
sl@0
|
891 |
*/
|
sl@0
|
892 |
TInt CT_MMFDevVideoRecordData::FillAndSendBuffer()
|
sl@0
|
893 |
{
|
sl@0
|
894 |
TInt64 tsValue = 0;
|
sl@0
|
895 |
TInt index = 0;
|
sl@0
|
896 |
TInt status = KErrNone;
|
sl@0
|
897 |
TInt error = 1;
|
sl@0
|
898 |
if (iStopAfterAllFramesReturned)
|
sl@0
|
899 |
{
|
sl@0
|
900 |
error = 0;
|
sl@0
|
901 |
}
|
sl@0
|
902 |
else
|
sl@0
|
903 |
{
|
sl@0
|
904 |
for ( index = 0; index < KBufferInputPictures; index++ )
|
sl@0
|
905 |
{// find a free buffer
|
sl@0
|
906 |
if ( iPicture[index].iOptions == 0 )
|
sl@0
|
907 |
{
|
sl@0
|
908 |
break;
|
sl@0
|
909 |
}
|
sl@0
|
910 |
}
|
sl@0
|
911 |
|
sl@0
|
912 |
if ( index == KBufferInputPictures )
|
sl@0
|
913 |
{// all buffers in use, hold on for now
|
sl@0
|
914 |
error = -1;
|
sl@0
|
915 |
}
|
sl@0
|
916 |
else
|
sl@0
|
917 |
{
|
sl@0
|
918 |
// Reset buffer length
|
sl@0
|
919 |
iPicture[index].iData.iRawData->SetMax();
|
sl@0
|
920 |
|
sl@0
|
921 |
status = iInFile.Read( *(iPicture[index].iData.iRawData));
|
sl@0
|
922 |
if ( status != KErrNone )
|
sl@0
|
923 |
{
|
sl@0
|
924 |
iStopAfterAllFramesReturned = ETrue;
|
sl@0
|
925 |
iDevvr->InputEnd();
|
sl@0
|
926 |
error = 0;
|
sl@0
|
927 |
}
|
sl@0
|
928 |
else
|
sl@0
|
929 |
{
|
sl@0
|
930 |
// If the buffer is 0 or incomplete, stop test case
|
sl@0
|
931 |
if ( iPicture[index].iData.iRawData->Length() == 0 || iPicture[index].iData.iRawData->Length() < iPicture[index].iData.iRawData->MaxLength() )
|
sl@0
|
932 |
{
|
sl@0
|
933 |
iStopAfterAllFramesReturned = ETrue;
|
sl@0
|
934 |
iDevvr->InputEnd();
|
sl@0
|
935 |
error = 0;
|
sl@0
|
936 |
}
|
sl@0
|
937 |
else
|
sl@0
|
938 |
{
|
sl@0
|
939 |
// write data
|
sl@0
|
940 |
tsValue = TReal(iTimeStamp) * TReal(1000000) / TReal(KVEDSPH263TimerResolution);
|
sl@0
|
941 |
iPicture[index].iTimestamp = tsValue;
|
sl@0
|
942 |
iPicture[index].iData.iDataFormat = EYuvRawData;
|
sl@0
|
943 |
iWrittenPictures++;
|
sl@0
|
944 |
iBufferedPictures++;
|
sl@0
|
945 |
iPicture[index].iOptions = 1;//mark to be used
|
sl@0
|
946 |
// send it as usually
|
sl@0
|
947 |
TRAPD(error, iDevvr->WritePictureL( &(iPicture[index]) ));
|
sl@0
|
948 |
if(error!=KErrNone)
|
sl@0
|
949 |
{
|
sl@0
|
950 |
ERR_PRINTF2(_L("Error int WritePictureL Error: %d"), error);
|
sl@0
|
951 |
SetError(error);
|
sl@0
|
952 |
}
|
sl@0
|
953 |
iTimeStamp ++;
|
sl@0
|
954 |
}
|
sl@0
|
955 |
}
|
sl@0
|
956 |
}
|
sl@0
|
957 |
}
|
sl@0
|
958 |
return error;
|
sl@0
|
959 |
}
|
sl@0
|
960 |
|
sl@0
|
961 |
void CT_MMFDevVideoRecordData::DoCmdUtilityGetEnvironmentL()
|
sl@0
|
962 |
{
|
sl@0
|
963 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdUtilityGetEnvironmentL"));
|
sl@0
|
964 |
RArray<TUid> decoders;
|
sl@0
|
965 |
RArray<TPictureRateAndSize> maxPictureRates;
|
sl@0
|
966 |
TBuf<255> mime;
|
sl@0
|
967 |
CleanupClosePushL (decoders);
|
sl@0
|
968 |
iDevvr->GetEncoderListL(decoders);
|
sl@0
|
969 |
CVideoEncoderInfo* info = NULL;
|
sl@0
|
970 |
for (TInt i = 0; i < decoders.Count ();i++)
|
sl@0
|
971 |
{
|
sl@0
|
972 |
info =iDevvr->VideoEncoderInfoLC(decoders[i]);
|
sl@0
|
973 |
TSize maxSize = info->MaxPictureSize();
|
sl@0
|
974 |
INFO_PRINTF6(_L("\n%S\nManufacturer%S\nUid: 0x%x\nAccelerated: %i\nSupports Direct Capture: %i"),
|
sl@0
|
975 |
&info->Identifier(),
|
sl@0
|
976 |
&info->Manufacturer(),
|
sl@0
|
977 |
decoders[i].iUid,
|
sl@0
|
978 |
info->Accelerated(),
|
sl@0
|
979 |
info->SupportsDirectCapture());
|
sl@0
|
980 |
|
sl@0
|
981 |
INFO_PRINTF3(_L("\nMax width %i, Max height %i"),maxSize.iWidth, maxSize.iHeight);
|
sl@0
|
982 |
|
sl@0
|
983 |
maxPictureRates = info->MaxPictureRates();
|
sl@0
|
984 |
|
sl@0
|
985 |
INFO_PRINTF4(_L("\nData unit types supported:%d\nData unit encapsulations:%d\nMaximum number of bitrate layers supported:%d"),
|
sl@0
|
986 |
info->SupportedDataUnitTypes(),
|
sl@0
|
987 |
info->SupportedDataUnitEncapsulations(),
|
sl@0
|
988 |
info->MaxBitrateLayers()
|
sl@0
|
989 |
);
|
sl@0
|
990 |
|
sl@0
|
991 |
|
sl@0
|
992 |
INFO_PRINTF4(_L("\nPicture options supported:%d\nSupportsPictureLoss:%i\nSupportsSliceLoss:%i"),
|
sl@0
|
993 |
info->SupportedPictureOptions(),
|
sl@0
|
994 |
info->SupportsPictureLoss(),
|
sl@0
|
995 |
info->SupportsSliceLoss()
|
sl@0
|
996 |
);
|
sl@0
|
997 |
|
sl@0
|
998 |
INFO_PRINTF4(_L("\nSupplemental enhancement info:%i\nMaximum unequal error protection level:%d\nMaxBitrate:%d"),
|
sl@0
|
999 |
info->SupportsSupplementalEnhancementInfo(),
|
sl@0
|
1000 |
info->MaxUnequalErrorProtectionLevels(),
|
sl@0
|
1001 |
info->MaxBitrate()
|
sl@0
|
1002 |
);
|
sl@0
|
1003 |
|
sl@0
|
1004 |
INFO_PRINTF2(_L("Coding-standard specific information: %S"),&info->CodingStandardSpecificInfo());
|
sl@0
|
1005 |
TInt j = 0;
|
sl@0
|
1006 |
for (j = 0; j < maxPictureRates.Count(); j++)
|
sl@0
|
1007 |
{
|
sl@0
|
1008 |
TSize pictureSize=maxPictureRates[j].iPictureSize;
|
sl@0
|
1009 |
INFO_PRINTF4(_L("max width: %i, max height %i, max rate %f"),
|
sl@0
|
1010 |
pictureSize.iWidth, pictureSize.iHeight, maxPictureRates[j].iPictureRate);
|
sl@0
|
1011 |
}
|
sl@0
|
1012 |
|
sl@0
|
1013 |
const RPointerArray<CCompressedVideoFormat>& outputFormats =info->SupportedOutputFormats();
|
sl@0
|
1014 |
for (j = 0; j < outputFormats.Count(); j++)
|
sl@0
|
1015 |
{
|
sl@0
|
1016 |
mime.Copy(outputFormats[j]->MimeType());
|
sl@0
|
1017 |
INFO_PRINTF3(_L("Supported type %d MIMETYPE: %S"),j,&mime);
|
sl@0
|
1018 |
}
|
sl@0
|
1019 |
CleanupStack::Pop (info);
|
sl@0
|
1020 |
}
|
sl@0
|
1021 |
CleanupStack::PopAndDestroy(&decoders);
|
sl@0
|
1022 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdUtilityGetEnvironmentL"));
|
sl@0
|
1023 |
}
|
sl@0
|
1024 |
|
sl@0
|
1025 |
void CT_MMFDevVideoRecordData::DoCmdSetRateControlOptions(const TTEFSectionName& aSection)
|
sl@0
|
1026 |
{
|
sl@0
|
1027 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::SetRateControlOptions"));
|
sl@0
|
1028 |
|
sl@0
|
1029 |
|
sl@0
|
1030 |
TInt layer = 0;
|
sl@0
|
1031 |
TInt bitrateControlInt = 0;
|
sl@0
|
1032 |
TInt bitrate = 0;
|
sl@0
|
1033 |
TInt pictureQuality = 0;
|
sl@0
|
1034 |
TReal pictureRate;
|
sl@0
|
1035 |
TReal qualityTemporalTradeoff;
|
sl@0
|
1036 |
TReal latencyQualityTradeoff;
|
sl@0
|
1037 |
|
sl@0
|
1038 |
if(!GetIntFromConfig(aSection, KLayer(), layer))
|
sl@0
|
1039 |
{
|
sl@0
|
1040 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLayer());
|
sl@0
|
1041 |
SetBlockResult(EFail);
|
sl@0
|
1042 |
}
|
sl@0
|
1043 |
if(!GetIntFromConfig(aSection, KBitrateControlType(), bitrateControlInt))
|
sl@0
|
1044 |
{
|
sl@0
|
1045 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBitrateControlType());
|
sl@0
|
1046 |
SetBlockResult(EFail);
|
sl@0
|
1047 |
}
|
sl@0
|
1048 |
if(!GetIntFromConfig(aSection, KBitrate(), bitrate))
|
sl@0
|
1049 |
{
|
sl@0
|
1050 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLayer());
|
sl@0
|
1051 |
SetBlockResult(EFail);
|
sl@0
|
1052 |
}
|
sl@0
|
1053 |
if(!GetIntFromConfig(aSection, KPictureQuality(), pictureQuality))
|
sl@0
|
1054 |
{
|
sl@0
|
1055 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPictureQuality());
|
sl@0
|
1056 |
SetBlockResult(EFail);
|
sl@0
|
1057 |
}
|
sl@0
|
1058 |
if(!GetRealFromConfig(aSection, KPicRate(), pictureRate))
|
sl@0
|
1059 |
{
|
sl@0
|
1060 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPicRate());
|
sl@0
|
1061 |
SetBlockResult(EFail);
|
sl@0
|
1062 |
}
|
sl@0
|
1063 |
if(!GetRealFromConfig(aSection, KQualityTempTradeOff(), qualityTemporalTradeoff))
|
sl@0
|
1064 |
{
|
sl@0
|
1065 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KQualityTempTradeOff());
|
sl@0
|
1066 |
SetBlockResult(EFail);
|
sl@0
|
1067 |
}
|
sl@0
|
1068 |
if(!GetRealFromConfig(aSection, KLatencyQuality(), latencyQualityTradeoff))
|
sl@0
|
1069 |
{
|
sl@0
|
1070 |
ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLatencyQuality());
|
sl@0
|
1071 |
SetBlockResult(EFail);
|
sl@0
|
1072 |
}
|
sl@0
|
1073 |
|
sl@0
|
1074 |
TBitrateControlType bitrateControlType;
|
sl@0
|
1075 |
switch (bitrateControlInt)
|
sl@0
|
1076 |
{
|
sl@0
|
1077 |
case 1: bitrateControlType = EBrControlNone;
|
sl@0
|
1078 |
break;
|
sl@0
|
1079 |
case 2: bitrateControlType = EBrControlStream;
|
sl@0
|
1080 |
break;
|
sl@0
|
1081 |
case 3: bitrateControlType = EBrControlPicture;
|
sl@0
|
1082 |
break;
|
sl@0
|
1083 |
default:bitrateControlType = EBrControlStream;
|
sl@0
|
1084 |
}
|
sl@0
|
1085 |
|
sl@0
|
1086 |
|
sl@0
|
1087 |
TRateControlOptions rateControlOptions;
|
sl@0
|
1088 |
rateControlOptions.iControl = bitrateControlType;
|
sl@0
|
1089 |
rateControlOptions.iBitrate = bitrate;
|
sl@0
|
1090 |
rateControlOptions.iPictureQuality = pictureQuality;
|
sl@0
|
1091 |
rateControlOptions.iPictureRate = pictureRate;
|
sl@0
|
1092 |
rateControlOptions.iQualityTemporalTradeoff = qualityTemporalTradeoff;
|
sl@0
|
1093 |
rateControlOptions.iLatencyQualityTradeoff = latencyQualityTradeoff;
|
sl@0
|
1094 |
|
sl@0
|
1095 |
iDevvr->SetRateControlOptions(layer, rateControlOptions);
|
sl@0
|
1096 |
|
sl@0
|
1097 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::SetRateControlOptions"));
|
sl@0
|
1098 |
|
sl@0
|
1099 |
}
|
sl@0
|
1100 |
|
sl@0
|
1101 |
|
sl@0
|
1102 |
|
sl@0
|
1103 |
|
sl@0
|
1104 |
|
sl@0
|
1105 |
void CT_MMFDevVideoRecordData::DestroyData()
|
sl@0
|
1106 |
{
|
sl@0
|
1107 |
INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DestroyData"));
|
sl@0
|
1108 |
delete iDevvr;
|
sl@0
|
1109 |
iDevvr = NULL;
|
sl@0
|
1110 |
INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DestroyData"));
|
sl@0
|
1111 |
}
|