Using the Encoded H264 Video Frames to Capture Video

This topic describes how to use the encoded H264 video frames in the Ecam video capture function to capture the video data.

You need to be familiar with the Capturing a Video Clip tutorial.

The H264 video encoder provides a new, high quality video data encoding format for Ecam. Ecam allows the device to capture video frames which are encoded in the H264 format. The Ecam video capture function supports the H264 video capture format by default. You can select the H264 video capture format when preparing video capture.

  1. Call the CCamera::CCameraVideoCaptureControl::NewL(CCamera &,MCaptureVideoObserver &) function to create an object that maps the exported call to an internal object of the MCameraVideoCaptureControl function.

  2. Pass a handle to the MCameraVideoCaptureControl function. This implementation creates a handle to the CCamera::CCameraVideoCaptureControl object by the active CCamera during the construction phase. The CCameraVideoCaptureControl object makes an internal call to the CCamera::CustomInterface(TUid) function of the active CCamera implementation. The CustomInterface() function passes a UID KECamMCameraVideoCaptureControlUid value for the CCamera implementation. The CCamera implementation creates the concrete implementation of the MCameraVideoCaptureControl function and passes back a handle to the CCameraVideoCaptureControl object.

  3. Call the MCaptureVideoObserver function to notify when the video capture operations are ready.

  4. Call CCamera::CCameraVideoCaptureControl::GetVideoCaptureSupportInfoL(TInt &)const to identify which video capture modes are supported by the CCamera implementation.

  5. Call the CCamera::CCameraVideoCaptureControl::TPrepareVideoParameters::SetVideoCaptureType(CCamera::CCameraVideoCaptureControl::TVideoCaptureType) function to set the desired video capture mode as the EClientVideoCapture or EDirectVideoCapture mode.

  6. Set the value of CCamera::CCameraVideoCaptureControl::TPrepareVideoParameters::iFormat to the EFormatEncodedH264 value for the CCamera implementation. This CCamera implementation supports the H264 video encoding data format.

  7. Prepare video capture by using the CCamera::CCameraVideoCaptureControl::PrepareVideoCapture(const TPrepareVideoParameters &) asynchronous function. The PrepareVideoCapture() function performs setup and allocation of memory before calling the StartVideoCapture() function, in order to keep minimum latency of the PrepareVideoCapture() function.

  8. Notify the Ecam client to complete the video capture preparation using the KUidECamEventVideoCaptureControlPrepareComplete event.

  9. Call the CCamera::CCameraVideoCaptureControl::StartVideoCaptureL() function to start video capture.

  10. Call the CCamera::CCameraVideoCaptureControl::PauseVideoCapture() function to pause the on-going video capture.

  11. Call the CCamera::CCameraVideoCaptureControl::GetPrepareVideoParametersL(TPrepareVideoParameters &)const function to retrieve the current prepare video parameters. The current video capture type is retrieved by the CCamera::CCameraVideoCaptureControl::TPrepareVideoParameters::VideoCaptureType()const function.

  12. Call the CCamera::CCameraVideoCaptureControl::ResumeVideoCaptureL() function to resume the on-going video capture.

  13. Call the CCamera::CCameraVideoCaptureControl::StopVideoCapture() function to stop video capture.

  14. Call the CCamera::CCameraVideoCaptureControl::ReleaseVideoResource()() function to release the video resource, which is allocated while performing the PrepareVideoCapture() function.

  15. If an error occurs while performing video capture, call the MCaptureVideoObserver::DirectVideoCaptureFailed(TInt) function. Any video capture operation is stopped.


The following example code snippet illustrates video capture using H264 encoding:

CCamera* camera = NULL;
MCameraObserver2* observer2 = NULL;

CCamera::CCameraVideoCaptureControl* videocapture = NULL;
MCaptureVideoObserver* videoObserver = NULL;

camera = CCamera::New2L(*observer2, 0, 0);

videocapture  = CCamera::CCameraVideoCaptureControl::NewL(*camera, *videoObserver);

CCamera::CCameraVideoCaptureControl::TPrepareVideoParameters prepareVideoParameters;

TInt supportedDVCType = -1;

// To retrieve the supported video capture mode
// To set the video capture mode, if supported by the CCamera implementation

// To set encoding for the H264 video data format
prepareVideoParameters.iFormat = CCamera::EFormatEncodedH264; 

// To set aspect ratio for the chosen H264 video format 
prepareVideoParameters.iPixelAspectRatio = CCamera::CCameraAdvancedSettings::EEPixelAspect40To33;  



CCamera::CCameraVideoCaptureControl::TPrepareVideoParameters retrievedVideoParam;

CCamera::CCameraVideoCaptureControl::TVideoCaptureType retrievedVideoCaptureType;
retrievedVideoCaptureType = retrievedVideoParam.VideoCaptureType();

Related concepts
Capturing Still Images
Related information
Camera Preset Support