Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
19 #include "t_cmmfdevvideorecorddata.h"
22 //LIT's to identify commands
23 _LIT(KCmdNewL, "NewL");
24 _LIT(KCmdDestructor, "~");
25 _LIT(KCmdSelectEncoderL, "SelectEncoderL");
26 _LIT(KCmdSetInputFormatL, "SetInputFormatL");
27 _LIT(KCmdSetOutputFormatL, "SetOutputFormatL");
28 _LIT(KCmdSetBufferOptionsL, "SetBufferOptionsL");
29 _LIT(KCmdSetSourceMemoryL, "SetSourceMemoryL");
30 _LIT(KCmdSetMinRandomAccessRate, "SetMinRandomAccessRate");
31 _LIT(KCmdInitialize, "Initialize");
32 _LIT(KCmdSetComplexityLevel, "SetComplexityLevel");
33 _LIT(KCmdStart, "Start");
34 _LIT(KCmdPause, "Pause");
35 _LIT(KCmdResume, "Resume");
36 _LIT(KCmdStop, "Stop");
37 _LIT(KCmdUtilityGetEnvironment, "UtilityGetEnvironment");
38 _LIT(KCmdSetRateControlOptions, "SetRateControlOptions");
44 //LIT's to get params from ini files
45 _LIT(KInputFile, "inputfile");
46 _LIT(KOutputFile, "outputfile");
47 _LIT(KInputPath, "inputPath");
48 _LIT(KOutputPath, "outputPath");
49 _LIT(KFrameRate, "framerate");
51 _LIT(KMimeType, "mimeType");
52 _LIT(KDataUnitType, "DataUnitType");
53 _LIT(KDataEncapsulation, "DataEncapsulation");
54 _LIT(KHrdVbvSpecification, "HrdVbvSpecification");
55 _LIT(KMaxPictureSize, "maxPictureSize");
56 _LIT(KRandomAccessRate, "randomAccessRate");
57 _LIT(KComplexityLevel, "complexityLevel");
58 _LIT(KRawPicLength , "rawPicLength");
59 _LIT(KPicWidth, "picWidth");
60 _LIT(KPicHeight, "picHeight");
61 _LIT(KHrdVbvNone, "EHrdVbvNone");
62 _LIT(KHrdVbvCodingStandard, "EHrdVbvCodingStandard");
63 _LIT(KHrdVbv3GPP, "EHrdVbv3GPP");
64 _LIT(KLayer, "layer");
65 _LIT(KBitrateControlType, "bitrateControlType");
66 _LIT(KBitrate, "bitrate");
67 _LIT(KPictureQuality, "pictureQuality");
68 _LIT(KPicRate, "picRate");
69 _LIT(KQualityTempTradeOff, "qualityTempTradeOff");
70 _LIT(KLatencyQuality, "latencyQuality");
73 const CDataWrapperBase::TEnumEntryTable CT_MMFDevVideoRecordData::iHrdVbvSpecification[] =
75 KHrdVbvNone, EHrdVbvNone,
76 KHrdVbvCodingStandard, EHrdVbvCodingStandard,
77 KHrdVbv3GPP, EHrdVbv3GPP
81 * Two phase constructor
83 * @leave system wide error
85 CT_MMFDevVideoRecordData* CT_MMFDevVideoRecordData::NewL()
87 CT_MMFDevVideoRecordData* self = new(ELeave)CT_MMFDevVideoRecordData();
88 CleanupStack::PushL (self);
90 CleanupStack::Pop (self);
97 CT_MMFDevVideoRecordData::~CT_MMFDevVideoRecordData()
99 INFO_PRINTF1(_L("Destroying data..."));
101 INFO_PRINTF1(_L("Data destroyed"));
105 * Protected constructor. First phase construction
107 CT_MMFDevVideoRecordData::CT_MMFDevVideoRecordData()
112 iReturnedPictures(0),
113 iCompressedBuffers(0),
114 iBufferedPictures(0),
115 iStopAfterAllFramesReturned(EFalse),
124 void CT_MMFDevVideoRecordData::ConstructL()
130 * Returns a pointer to the object that the data wraps
131 * @return wrapped object
133 TAny* CT_MMFDevVideoRecordData::GetObject()
144 * Process a command read from the ini file
146 * @param aCommand The command to process
147 * @param aSection The section in the ini containing data for the command
148 * @param aAsyncErrorIndex Command index for async calls to return errors to
149 * @return ETrue if the command is processed *
150 * @leave System wide error
152 TBool CT_MMFDevVideoRecordData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
154 TBool cmdProcessed = ETrue;
155 if(aCommand == KCmdNewL())
159 else if(aCommand == KCmdDestructor())
163 else if(aCommand == KCmdSelectEncoderL())
165 DoCmdSelectEncoderL(aSection);
167 else if(aCommand == KCmdSetInputFormatL())
169 DoCmdSetInputFormatL();
171 else if(aCommand == KCmdSetOutputFormatL())
173 DoCmdSetOutputFormatL(aSection);
175 else if(aCommand == KCmdSetBufferOptionsL())
177 DoCmdSetBufferOptionsL(aSection);
179 else if(aCommand == KCmdSetSourceMemoryL())
181 DoCmdSetSourceMemoryL();
183 else if(aCommand == KCmdSetMinRandomAccessRate())
185 DoCmdSetMinRandomAccessRate(aSection);
187 else if(aCommand == KCmdInitialize())
189 DoCmdInitialize(aAsyncErrorIndex);
191 else if(aCommand == KCmdSetComplexityLevel())
193 DoCmdSetComplexityLevel(aSection);
195 else if(aCommand == KCmdStart())
197 DoCmdStart(aAsyncErrorIndex);
199 else if(aCommand == KCmdPause())
203 else if(aCommand == KCmdResume())
207 else if(aCommand == KCmdStop())
211 else if ( aCommand==KCmdUtilityGetEnvironment )
213 DoCmdUtilityGetEnvironmentL();
215 else if ( aCommand==KCmdSetRateControlOptions )
217 DoCmdSetRateControlOptions(aSection);
221 cmdProcessed = EFalse;
229 * @param aSection The section in the ini containing data for the command
231 void CT_MMFDevVideoRecordData::DoCmdNewL(const TTEFSectionName& aSection)
233 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdNewL"));
235 TRAPD(error,iDevvr = CMMFDevVideoRecord::NewL( *this ));
238 ERR_PRINTF2(_L("Error creating CMMFDevVideoRecord %i"), error);
245 if(CreateFiles(aSection)!= KErrNone)
247 ERR_PRINTF1(_L("Error creating input/output files"));
248 SetBlockResult(EFail);
251 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdNewL"));
257 void CT_MMFDevVideoRecordData::DoCmdDestructor()
259 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdDestructor"));
263 REComSession::FinalClose();
265 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdDestructor"));
269 * DoCmdSelectEncoderL
270 * Selects the video encoder to be used. This method must be called before any other video encoder related
271 * methods are used. The encoder can be changed by calling this method again before the system has been
272 * initialized with Initialize().
273 * All video encoder settings are reset to their default values. By default no pre-processing is performed.
274 * @param aSection The section in the ini containing data for the command
276 void CT_MMFDevVideoRecordData::DoCmdSelectEncoderL(const TTEFSectionName& aSection)
278 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSelectEncoderL"));
281 if(!GetHexFromConfig(aSection, KUid(), hUid))
283 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KUid());
284 SetBlockResult(EFail);
288 TUid Uid = TUid::Uid(hUid);
289 SetPictureTypeL(aSection);
290 TRAPD(error,iEncHWDevId = iDevvr->SelectEncoderL(Uid));
294 ERR_PRINTF2(_L("Error Selecting encoder: %i"), error);
298 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSelectEncoderL"));
302 * Sets the input format for a hardware device. If both a pre-processor and an encoder are used, the
303 * pre-processor output format and the encoder input format must be the same. The input format for the
304 * first device in the system is the input format for video input data.
306 void CT_MMFDevVideoRecordData::DoCmdSetInputFormatL()
308 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetInputFormatL"));
309 TUncompressedVideoFormat unCompressedFormat;
311 unCompressedFormat.iDataFormat = EYuvRawData;
312 unCompressedFormat.iYuvFormat.iDataLayout = EYuvDataPlanar;
313 unCompressedFormat.iYuvFormat.iPattern = EYuv420Chroma1;
314 unCompressedFormat.iYuvFormat.iYuv2RgbMatrix = NULL;
315 unCompressedFormat.iYuvFormat.iRgb2YuvMatrix = NULL;
316 unCompressedFormat.iYuvFormat.iAspectRatioNum = 1;
317 unCompressedFormat.iYuvFormat.iAspectRatioDenom = 1;
318 unCompressedFormat.iYuvFormat.iCoefficients = EYuvBt601Range0;
320 TRAPD(error,iDevvr->SetInputFormatL( iEncHWDevId, unCompressedFormat, iPictSize ));
323 ERR_PRINTF2(_L("Error Setting input format: %i"), error);
326 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetInputFormatL"));
330 * Sets the output format for a hardware device to a compressed video format. Only applicable for encoder
331 * devices. The picture size depends on the input data format and possible scaling performed.
332 * @param aSection The section in the ini containing data for the command
334 void CT_MMFDevVideoRecordData::DoCmdSetOutputFormatL(const TTEFSectionName& aSection)
336 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetOutputFormatL"));
338 TVideoDataUnitType dataUnitType;
339 TVideoDataUnitEncapsulation dataEncapsulation;
340 TBool dataOk = ETrue;
341 TInt iDataUnitType = 0;
342 TInt iDataEncapsulation = 0;
345 if(!GetStringFromConfig(aSection, KMimeType(), mimeType))
347 ERR_PRINTF1(_L("Mime type not retrieved, command will not be executed"));
348 SetBlockResult(EFail);
351 if(!GetHexFromConfig(aSection, KDataUnitType(), iDataUnitType))
353 ERR_PRINTF2(_L("check parameter: %S"), &KDataUnitType());
354 SetBlockResult(EFail);
357 if(!GetHexFromConfig(aSection, KDataEncapsulation(), iDataEncapsulation))
359 ERR_PRINTF2(_L("check parameter: %S"), &KDataEncapsulation());
360 SetBlockResult(EFail);
365 mimetype.Append(mimeType);
366 CCompressedVideoFormat* compressedFormat=NULL;
367 TRAPD(cfError, compressedFormat = CCompressedVideoFormat::NewL(mimetype));
368 CleanupStack::PushL(compressedFormat);
369 if(cfError != KErrNone)
371 ERR_PRINTF2(_L("Error selecting compressed video format, check selected mimeType: %i"), cfError);
376 dataUnitType = static_cast<TVideoDataUnitType>(iDataUnitType);
377 dataEncapsulation = static_cast<TVideoDataUnitEncapsulation>(iDataEncapsulation);
379 TRAPD(error,iDevvr->SetOutputFormatL(iEncHWDevId, *compressedFormat, dataUnitType, dataEncapsulation, EFalse));
380 if(error != KErrNone)
382 ERR_PRINTF2(_L("Couldn't set OutputFormat %i"), error);
388 CleanupStack::PopAndDestroy(compressedFormat);
390 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetOutputFormatL"));
394 * Sets encoder buffering options.
395 * @param aSection The section in the ini containing data for the command
397 void CT_MMFDevVideoRecordData::DoCmdSetBufferOptionsL(const TTEFSectionName& aSection)
399 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetBufferOptionsL"));
400 TEncoderBufferOptions bufferOptions;
401 TInt HrdVbvSpecification = 0;
402 TInt maxPictureSize = 0;
403 TBool dataOk = ETrue;
404 if(!GetEnumFromConfig(aSection, KHrdVbvSpecification(), iHrdVbvSpecification, HrdVbvSpecification))
406 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KHrdVbvSpecification());
407 SetBlockResult(EFail);
410 if(!GetIntFromConfig(aSection, KMaxPictureSize(), maxPictureSize))
412 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMaxPictureSize());
413 SetBlockResult(EFail);
418 bufferOptions.iHrdVbvParams.Set(NULL, 0);
419 bufferOptions.iHrdVbvSpec = (THrdVbvSpecification)HrdVbvSpecification;
420 bufferOptions.iMaxPreEncoderBufferPictures = KNumPictures;
421 bufferOptions.iMaxCodedPictureSize = maxPictureSize;
422 bufferOptions.iMaxOutputBufferSize = maxPictureSize;
423 bufferOptions.iMaxCodedSegmentSize = maxPictureSize;
425 //Not needed more that 4 input buffers for normal fileRead test cases
426 bufferOptions.iMinNumOutputBuffers = KNumPictures - 2;
427 TRAPD(error, iDevvr->SetBufferOptionsL( bufferOptions ));
430 ERR_PRINTF2(_L("Error Setting buffer options: %i"), error);
434 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetBufferOptionsL"));
437 * Sets the data source to be memory buffers.
439 void CT_MMFDevVideoRecordData::DoCmdSetSourceMemoryL()
441 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetSourceMemoryL"));
443 TRAPD(error, iDevvr->SetSourceMemoryL(iFrameRate, EFalse, EFalse));
444 if(error != KErrNone)
446 ERR_PRINTF2(_L("Error Setting Source Memory: %i"), error);
449 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetSourceMemoryL"));
453 * Sets the minimum frequency (in time) for instantaneous random access points in the bitstream.
454 * An instantaneous random access point is such where the encoder can achieve a full output picture
455 * immediately by encoding data starting from the random access point. The random access point frequency
456 * may be higher than signalled, if the sequence contains scene cuts which typically cause a coding of
457 * a random access point.
458 * @param aSection The section in the ini containing data for the command
460 void CT_MMFDevVideoRecordData::DoCmdSetMinRandomAccessRate(const TTEFSectionName& aSection)
462 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetMinRandomAccessRate"));
463 TReal randomAccessRate = 0;
465 if(!GetRealFromConfig(aSection, KRandomAccessRate(), randomAccessRate))
467 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRandomAccessRate());
468 SetBlockResult(EFail);
472 iDevvr->SetMinRandomAccessRate( randomAccessRate );
474 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetMinRandomAccessRate"));
478 * Initializes the video devices, and reserves hardware resources. This method is asynchronous,
479 * DevVideoRecord will call MMMFDevVideoRecordObserver::MdvroInitializeComplete() after initialization has
480 * completed. If direct capture is used, this method also prepares the camera API for capture by calling
481 * PrepareVideoCaptureL(). No DevVideoRecord method may be called while initialization is in progress, the
482 * initialization process can only be cancelled by destroying the DevVideoRecord object.
483 * @param a AsyncErrorIndex Command index for async calls to return errors to
485 void CT_MMFDevVideoRecordData::DoCmdInitialize(const TInt aAsyncErrorIndex)
487 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdInitialize"));
488 iAsyncErrorIndex = aAsyncErrorIndex;
490 iDevvr->Initialize();
491 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdInitialize"));
495 * Sets the complexity level to use for video processing in a hardware device. The level can be changed at
497 * @param a AsyncErrorIndex Command index for async calls to return errors to
499 void CT_MMFDevVideoRecordData::DoCmdSetComplexityLevel(const TTEFSectionName& aSection)
501 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdSetComplexityLevel"));
502 TInt complexityLevel = 0;
504 INFO_PRINTF1(_L("SET COMPLEXITY LEVEL begin"));
506 if(!GetIntFromConfig(aSection, KComplexityLevel(), complexityLevel))
508 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KComplexityLevel());
509 SetBlockResult(EFail);
513 iDevvr->SetComplexityLevel( iEncHWDevId, complexityLevel );
514 INFO_PRINTF1(_L("SET COMPLEXITY LEVEL stop"));
516 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdSetComplexityLevel"));
520 * Starts recording video. This includes capturing pictures from the camera (if direct capture is used),
521 * pre-processing and encoding. Recording will proceed until it is stopped or paused. Initally recording
523 * @param a AsyncErrorIndex Command index for async calls to return errors to
525 void CT_MMFDevVideoRecordData::DoCmdStart(const TInt aAsyncErrorIndex)
527 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdStart"));
528 iAsyncErrorIndex = aAsyncErrorIndex;
533 if ( FillAndSendBuffer() == 0 )
535 iStopAfterAllFramesReturned = ETrue;
538 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdStart"));
542 * Pauses video recording. Recording can be resumed using Resume().
544 void CT_MMFDevVideoRecordData::DoCmdPause()
546 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdPause"));
548 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdPause"));
552 * Resumes video recording after a pause.
554 void CT_MMFDevVideoRecordData::DoCmdResume()
556 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdResume"));
558 HandleReturnedPicture();
559 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdResume"));
563 * Stops recording video. No new pictures will be captured, pre-processed, or encoded.
565 void CT_MMFDevVideoRecordData::DoCmdStop()
567 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdStop"));
569 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdStop"));
577 * Returns a used input video picture back to the caller. The picture memory can be re-used or freed.
579 * @param aPicture the picture to return
581 void CT_MMFDevVideoRecordData::MdvroReturnPicture(TVideoPicture* aPicture)
588 for ( index = 0; index < KBufferInputPictures; index++)
590 if ( &(iPicture[index]) == aPicture )
592 iPicture[index].iOptions = 0;
595 HandleReturnedPicture();
603 void CT_MMFDevVideoRecordData::MdvroSupplementalInfoSent()
608 * Observer callback in Custom interface Buffer management.
609 * Client is notified a new buffer(s) is available
613 void CT_MMFDevVideoRecordData::MdvroNewBuffers()
615 iCompressedBuffers ++;
620 * Reports a fatal decoding or playback error to the client.
622 * @param aError The error code
626 void CT_MMFDevVideoRecordData::MdvroFatalError(TInt aError)
628 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::MdvroFatalError"));
632 ERR_PRINTF2(_L("A fatal error ocurred %i"), aError);
633 SetAsyncError (iAsyncErrorIndex, aError);
640 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::MdvroFatalError"));
644 * Reports that DevVideoRecord initialization has completed. The interface can now be used for video recording.
646 * @param aError Initialization error code, KErrNone if no error occurred
650 void CT_MMFDevVideoRecordData::MdvroInitializeComplete(TInt aError)
652 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::MdvroInitializeComplete"));
654 if ( aError != KErrNone )
656 SetAsyncError (iAsyncErrorIndex, aError);
657 ERR_PRINTF2(_L("Error at MdvroInitializeComplete %i"), aError);
659 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::MdvroInitializeComplete"));
663 * Reports that the input video stream end has been reached and all pictures have been processed.
664 * This method is only called after the client has called InputEnd(). No more output pictures will be available.
668 void CT_MMFDevVideoRecordData::MdvroStreamEnd()
670 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::MdvroStreamEnd"));
672 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::MdvroStreamEnd"));
680 * Sets the Picture Type for the test
681 * @param aSection The section in the ini containing data for the command
683 void CT_MMFDevVideoRecordData::SetPictureTypeL(const TTEFSectionName& aSection)
685 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::SetPictureTypeL"));
690 if(!GetIntFromConfig(aSection, KFrameRate(), iFrameRate))
692 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFrameRate());
693 SetBlockResult(EFail);
696 if(!GetIntFromConfig(aSection, KRawPicLength(), rawPicLength))
698 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRawPicLength());
699 SetBlockResult(EFail);
702 if(!GetIntFromConfig(aSection, KPicWidth(), picWidth))
704 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRawPicLength());
705 SetBlockResult(EFail);
708 if(!GetIntFromConfig(aSection, KPicHeight(), picHeight))
710 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRawPicLength());
711 SetBlockResult(EFail);
714 iPictSize.SetSize(picHeight,picWidth);
716 INFO_PRINTF1(_L("Creating Data buffers"));
717 TUint8* pointer = NULL;
720 //iDatabuf = new (ELeave) TUint8*[KBufferInputPictures];
721 iDatabuf = new RPointerArray<TUint8>[KBufferInputPictures];
723 for ( TInt i = 0; i < KBufferInputPictures; i ++ )
725 pointer = new (ELeave) TUint8[rawPicLength];
726 iDatabuf[i].Append(pointer);
727 iPicture[i].iData.iRawData = new (ELeave) TPtr8(0, 0, 0);
728 iPicture[i].iData.iRawData->Set(pointer, rawPicLength, rawPicLength );
729 iPicture[i].iData.iDataSize.SetSize(iPictSize.iWidth, iPictSize.iHeight);
732 INFO_PRINTF1(_L("Data buffers created"));
733 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::SetPictureTypeL"));
737 * create buffers to read data
739 void CT_MMFDevVideoRecordData::CreateBuffers()
741 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::CreateBuffers"));
742 for (TInt i = 0; i < KBufferInputPictures; i ++)
744 INFO_PRINTF1(_L("creating buffers"));
745 iPicture[i].iData.iRawData = NULL;
746 INFO_PRINTF1(_L("buffers created"));
748 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::CreateBuffers"));
753 *checks for input file and creates output files
754 * @param aSection The section in the ini containing data for the command
756 int CT_MMFDevVideoRecordData::CreateFiles(const TTEFSectionName& aSection)
758 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::CreateFiles"));
764 if(!GetStringFromConfig(aSection, KInputFile(), inputFile))
766 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputFile());
767 SetBlockResult(EFail);
770 if(!GetStringFromConfig(aSection, KOutputFile(), outputFile))
772 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutputFile());
773 SetBlockResult(EFail);
776 if(!GetStringFromConfig(aSection, KInputPath(), inputPath))
778 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KInputPath());
779 SetBlockResult(EFail);
782 if(!GetStringFromConfig(aSection, KOutputPath(), outputPath))
784 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KOutputFile());
785 SetBlockResult(EFail);
791 TFileName inFileName(inputPath);
792 inFileName.Append(inputFile);
793 TFileName outFileName(outputPath);
794 outFileName.Append(outputFile);
796 err = OpenFile(outFileName, inFileName);
798 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::CreateFiles"));
804 * Creates output file.
805 * @param aOutFileName the output file
806 * @param aInFileName the input file
808 int CT_MMFDevVideoRecordData::OpenFile(TFileName& aOutFileName, TFileName& aInFileName)
810 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::OpenFile"));
812 if ( (err=iInFile.Open(iFs, aInFileName, EFileRead | EFileShareReadersOnly)) != KErrNone)
814 ERR_PRINTF2(_L("Couldn't open input file: %i"),err);
818 if((err=iOutFile.Replace(iFs, aOutFileName, EFileShareExclusive|EFileWrite))!= KErrNone)
820 ERR_PRINTF2(_L("Couldn't open output file: %i"),err);
823 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::OpenFile"));
828 * gets new buffers from buffer array
830 void CT_MMFDevVideoRecordData::HandleNewBuffer()
832 TVideoOutputBuffer* tmp=NULL;
833 TRAPD(error, tmp = iDevvr->NextBufferL());
834 if (error != KErrNone)
836 ERR_PRINTF2(_L("Error in getting NextBufferL, Error: %d"), error);
837 SetBlockResult(EFail);
841 SaveAndReturnBuffer( tmp );
846 * handles the returned pictures
848 void CT_MMFDevVideoRecordData::HandleReturnedPicture()
850 if ( iStopAfterAllFramesReturned )
856 if ( FillAndSendBuffer() == 0 )
858 iStopAfterAllFramesReturned = ETrue;
864 *handles out to file requests
865 *@param aNumberOfPictures number of pictures to write
867 TInt CT_MMFDevVideoRecordData::HandleOutputRequest()
870 if ( FillAndSendBuffer() == 0 )
872 //all data read => stop
873 iStopAfterAllFramesReturned = ETrue;
880 *writes buffer to file
881 *@param tmp current buffer
883 void CT_MMFDevVideoRecordData::SaveAndReturnBuffer(TVideoOutputBuffer* tmp)
885 iOutFile.Write( tmp->iData );
886 iDevvr->ReturnBuffer( tmp );
890 *fills buffer data buffer and process it
892 TInt CT_MMFDevVideoRecordData::FillAndSendBuffer()
896 TInt status = KErrNone;
898 if (iStopAfterAllFramesReturned)
904 for ( index = 0; index < KBufferInputPictures; index++ )
905 {// find a free buffer
906 if ( iPicture[index].iOptions == 0 )
912 if ( index == KBufferInputPictures )
913 {// all buffers in use, hold on for now
918 // Reset buffer length
919 iPicture[index].iData.iRawData->SetMax();
921 status = iInFile.Read( *(iPicture[index].iData.iRawData));
922 if ( status != KErrNone )
924 iStopAfterAllFramesReturned = ETrue;
930 // If the buffer is 0 or incomplete, stop test case
931 if ( iPicture[index].iData.iRawData->Length() == 0 || iPicture[index].iData.iRawData->Length() < iPicture[index].iData.iRawData->MaxLength() )
933 iStopAfterAllFramesReturned = ETrue;
940 tsValue = TReal(iTimeStamp) * TReal(1000000) / TReal(KVEDSPH263TimerResolution);
941 iPicture[index].iTimestamp = tsValue;
942 iPicture[index].iData.iDataFormat = EYuvRawData;
945 iPicture[index].iOptions = 1;//mark to be used
946 // send it as usually
947 TRAPD(error, iDevvr->WritePictureL( &(iPicture[index]) ));
950 ERR_PRINTF2(_L("Error int WritePictureL Error: %d"), error);
961 void CT_MMFDevVideoRecordData::DoCmdUtilityGetEnvironmentL()
963 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DoCmdUtilityGetEnvironmentL"));
964 RArray<TUid> decoders;
965 RArray<TPictureRateAndSize> maxPictureRates;
967 CleanupClosePushL (decoders);
968 iDevvr->GetEncoderListL(decoders);
969 CVideoEncoderInfo* info = NULL;
970 for (TInt i = 0; i < decoders.Count ();i++)
972 info =iDevvr->VideoEncoderInfoLC(decoders[i]);
973 TSize maxSize = info->MaxPictureSize();
974 INFO_PRINTF6(_L("\n%S\nManufacturer%S\nUid: 0x%x\nAccelerated: %i\nSupports Direct Capture: %i"),
976 &info->Manufacturer(),
979 info->SupportsDirectCapture());
981 INFO_PRINTF3(_L("\nMax width %i, Max height %i"),maxSize.iWidth, maxSize.iHeight);
983 maxPictureRates = info->MaxPictureRates();
985 INFO_PRINTF4(_L("\nData unit types supported:%d\nData unit encapsulations:%d\nMaximum number of bitrate layers supported:%d"),
986 info->SupportedDataUnitTypes(),
987 info->SupportedDataUnitEncapsulations(),
988 info->MaxBitrateLayers()
992 INFO_PRINTF4(_L("\nPicture options supported:%d\nSupportsPictureLoss:%i\nSupportsSliceLoss:%i"),
993 info->SupportedPictureOptions(),
994 info->SupportsPictureLoss(),
995 info->SupportsSliceLoss()
998 INFO_PRINTF4(_L("\nSupplemental enhancement info:%i\nMaximum unequal error protection level:%d\nMaxBitrate:%d"),
999 info->SupportsSupplementalEnhancementInfo(),
1000 info->MaxUnequalErrorProtectionLevels(),
1004 INFO_PRINTF2(_L("Coding-standard specific information: %S"),&info->CodingStandardSpecificInfo());
1006 for (j = 0; j < maxPictureRates.Count(); j++)
1008 TSize pictureSize=maxPictureRates[j].iPictureSize;
1009 INFO_PRINTF4(_L("max width: %i, max height %i, max rate %f"),
1010 pictureSize.iWidth, pictureSize.iHeight, maxPictureRates[j].iPictureRate);
1013 const RPointerArray<CCompressedVideoFormat>& outputFormats =info->SupportedOutputFormats();
1014 for (j = 0; j < outputFormats.Count(); j++)
1016 mime.Copy(outputFormats[j]->MimeType());
1017 INFO_PRINTF3(_L("Supported type %d MIMETYPE: %S"),j,&mime);
1019 CleanupStack::Pop (info);
1021 CleanupStack::PopAndDestroy(&decoders);
1022 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DoCmdUtilityGetEnvironmentL"));
1025 void CT_MMFDevVideoRecordData::DoCmdSetRateControlOptions(const TTEFSectionName& aSection)
1027 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::SetRateControlOptions"));
1031 TInt bitrateControlInt = 0;
1033 TInt pictureQuality = 0;
1035 TReal qualityTemporalTradeoff;
1036 TReal latencyQualityTradeoff;
1038 if(!GetIntFromConfig(aSection, KLayer(), layer))
1040 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLayer());
1041 SetBlockResult(EFail);
1043 if(!GetIntFromConfig(aSection, KBitrateControlType(), bitrateControlInt))
1045 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KBitrateControlType());
1046 SetBlockResult(EFail);
1048 if(!GetIntFromConfig(aSection, KBitrate(), bitrate))
1050 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLayer());
1051 SetBlockResult(EFail);
1053 if(!GetIntFromConfig(aSection, KPictureQuality(), pictureQuality))
1055 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPictureQuality());
1056 SetBlockResult(EFail);
1058 if(!GetRealFromConfig(aSection, KPicRate(), pictureRate))
1060 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPicRate());
1061 SetBlockResult(EFail);
1063 if(!GetRealFromConfig(aSection, KQualityTempTradeOff(), qualityTemporalTradeoff))
1065 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KQualityTempTradeOff());
1066 SetBlockResult(EFail);
1068 if(!GetRealFromConfig(aSection, KLatencyQuality(), latencyQualityTradeoff))
1070 ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLatencyQuality());
1071 SetBlockResult(EFail);
1074 TBitrateControlType bitrateControlType;
1075 switch (bitrateControlInt)
1077 case 1: bitrateControlType = EBrControlNone;
1079 case 2: bitrateControlType = EBrControlStream;
1081 case 3: bitrateControlType = EBrControlPicture;
1083 default:bitrateControlType = EBrControlStream;
1087 TRateControlOptions rateControlOptions;
1088 rateControlOptions.iControl = bitrateControlType;
1089 rateControlOptions.iBitrate = bitrate;
1090 rateControlOptions.iPictureQuality = pictureQuality;
1091 rateControlOptions.iPictureRate = pictureRate;
1092 rateControlOptions.iQualityTemporalTradeoff = qualityTemporalTradeoff;
1093 rateControlOptions.iLatencyQualityTradeoff = latencyQualityTradeoff;
1095 iDevvr->SetRateControlOptions(layer, rateControlOptions);
1097 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::SetRateControlOptions"));
1105 void CT_MMFDevVideoRecordData::DestroyData()
1107 INFO_PRINTF1(_L("*START*CT_MMFDevVideoRecordData::DestroyData"));
1110 INFO_PRINTF1(_L("*END*CT_MMFDevVideoRecordData::DestroyData"));