×
Namespaces

Variants
Actions

MDFDevVideo录制API

From Nokia Developer Wiki
Jump to: navigation, search
Article Metadata

代码示例
文章
hoolee 在 12 Feb 2009 创建
最后由 hamishwillee 在 15 Dec 2011 编辑

CS001065


  • 开发伙伴平台:

S60 3rd Edition, FP2


  • 详细描述

这个API不是公开SDK的一部分。可以在SDK API Plug-in中找到。


视频编码和解码API为DevVideoRecord API,多媒体框架(MMF)插件使用该接口访问视频的解码和平台上的预处理,以及那些硬件独立的方式行为。


头文件

#include <devvideorecord.h>


链接库

LIBRARY   devvideo.lib


源文件 MMMFDevVideoObserver类定义了监控mixin接口,这样任何使用CMMFDevVideoRecord都需要完成它。

//MMMFDevVideoRecordObserver
virtual void MdvroReturnPicture(TVideoPicture* aPicture) = 0;
virtual void MdvroSupplementalInfoSent() = 0;
virtual void MdvroNewBuffers() = 0;
virtual void MdvpoError(TInt aError) = 0;
virtual void MdvroInitializeComplete(TInt aError);
Virtual void MdvroStreamEnd();
 
 
 
//NewL()
delete iDvr;
iDvr = NULL;
iDvr = CMMFDevVideoRecord::NewL(*this);
 
// Find an accelerated encoder if possible, non-accelerated if not
RArray<TUid> encs;
iDvr->FindEncodersL(KMime, 0, encs, EFalse);
TUid enc = TUid::Uid(0);
TBool foundAccel = EFalse;
for ( TInt i = 0; i < encs.Count(); i++ ) {
CVideoEncoderInfo *info = iDvr->VideoEncoderInfoLC(encs[i]);
if ( info->Accelerated() ) {
enc = encs[i];
foundAccel = ETrue;
} else if ( !foundAccel ) {
LFPRINT((_L("Not accelerated, but haven't seen one so far --using this")));
enc = encs[i];
} else {
LFPRINT((_L("Not accelerated and already have one -- skipping")));
}
CleanupStack::PopAndDestroy();
}
 
if ( enc.iUid == 0 ) {
User::Leave(KErrNotSupported);
}
 
// Select encoder
iEnc = iDvr->SelectEncoderL(enc);
 
// Input format
TSize size(176, 144);
TUncompressedVideoFormat fmt;
fmt.iDataFormat = EYuvRawData;
fmt.iYuvFormat.iCoefficients = EYuvBt601Range1;
fmt.iYuvFormat.iPattern = EYuv420Chroma2;
fmt.iYuvFormat.iDataLayout = EYuvDataPlanar;
fmt.iYuvFormat.iYuv2RgbMatrix = NULL;
fmt.iYuvFormat.iRgb2YuvMatrix = NULL;
fmt.iYuvFormat.iAspectRatioNum = 1;
fmt.iYuvFormat.iAspectRatioDenom = 1;
iDvr->SetInputFormatL(iEnc, fmt, size);
 
// Output format
CCompressedVideoFormat *cfmt = CCompressedVideoFormat::NewL(KMime);
CleanupStack::PushL(cfmt);
iDvr->SetOutputFormatL(iEnc, *cfmt, EDuCodedPicture,EDuElementaryStream,
EFalse);
CleanupStack::PopAndDestroy(); //cfmt
 
// Buffer options
TEncoderBufferOptions bopt;
bopt.iMaxPreEncoderBufferPictures = 1;
bopt.iHrdVbvSpec = EHrdVbvNone;
bopt.iHrdVbvParams.Set(NULL, 0);
bopt.iMaxOutputBufferSize = 10240;
bopt.iMaxCodedPictureSize = 10240;
bopt.iMaxCodedSegmentSize = 10240; // ignored in non-segmented mode
bopt.iMinNumOutputBuffers = 2;
iDvr->SetBufferOptionsL(bopt);
 
// Source is memory
iDvr->SetSourceMemoryL(15.0, EFalse, EFalse); // not real-time
 
// Initialize
iDvr->Initialize();
 
 
 
//WRITE PIC
// Generate data
TInt y = iPicNum % 14;
Mem::Fill(iYuv, 176*y*10, 200);
Mem::Fill(iYuv + 176*y*10, 176*144 - 176*y*10, 0);
Mem::Fill(iYuv + 176*144, 176*144/2, 128);
 
// Write picture
iPic.iData.iDataFormat = EYuvRawData;
iPic.iData.iDataSize = TSize(176,144);
iPicDataPtr.Set(iYuv, 176*144*3/2, 176*144*3/2);
iPic.iData.iRawData = &iPicDataPtr;
iPic.iOptions = TVideoPicture::ETimestamp;
iPic.iTimestamp = (1000000 * iPicNum) / 15;
TRAPD(err, iDvr->WritePictureL(&iPic));
if ( err != KErrNone ) {
LFPRINT((_L("WritePictureL failed with %d"), err));
TestComplete(err);
}
iPicNum++;

示例工程 这个程序对一段内存数据进行了最基本的MPEG-4视频编码,并输出到一个文件中。这个只包括了最基本运行所必须的功能,程序运行时,可以自行增加码率控制或其他设置属性。 File:DevvideoEx.zip

This page was last modified on 15 December 2011, at 09:10.
134 page views in the last 30 days.