Embedding camera applications

In your applications, you can embed other applications that provide services, such as image capture and voice recording. For example, a multimedia messaging service (MMS) editor could embed the camera application to capture images and insert them in multimedia messages.

Use the New File Service Client API to create a service client.

Note:

The binary compatibility of the API plug-ins is not guaranteed either between platform versions or within a platform version. Test your application on each device model that the application can be installed on to ensure the best possible user experience. To prevent application installation on other than tested devices, define the product IDs (also called manufacturer IDs) in the package file . For more information, see Hardware/UI platform dependency .

To embed camera applications

  1. Use the CNewFileServiceClient method to create a new file service client.

             CNewFileServiceClient* fileClient = NewFileServiceFactory::NewClientL();
    CleanupStack::PushL( fileClient );
            
  2. Create an array to hold the file names for the resulting files.

             CDesCArray* fileNames = new ( ELeave ) CDesCArrayFlat( 1 );
    CleanupStack::PushL( fileNames );
            
  3. Use generic parameters to control the service.

             CAiwGenericParamList* paramList = CAiwGenericParamList::NewLC();
            
  4. Specify image resolution. The application matches the value that you enter to the closest resolution supported (in pixels). Use the value (0,0) for the default MMS resolution, which is the lowest quality.

             TSize resolution( 1600, 1200 ); // 2 megapixels
            

    If the device has two cameras, the camera available at the time of launching the service client is used. You cannot select whether to launch the primary or secondary camera. Users cannot switch from the primary camera to the secondary one after launching the service client. The secondary camera always uses a fixed resolution that you cannot specify.

  5. Package the object.

             TPckgBuf<TSize> buffer( resolution );
    TAiwVariant resolutionVariant( buffer );
    TAiwGenericParam param( EGenericParamResolution, resolutionVariant );
    paramList->AppendL( param );
            
  6. Specify the application to launch. The application UID identifies the application to be started as a server application.

             const TUid KUidCamera = { 0x101F857A }; // Camera UID for S60 5th edition
    
    ...
    
    TBool result = fileClient->NewFileL( KUidCamera, *fileNames, paramList,
                                   ENewFileServiceImage, EFalse );
            
  7. Access the images. The fileNames array can hold more than one item.

             if ( result )
        {
        CEikonEnv::InfoWinL(_L("Success"),_L(""));
        for(TInt i=0;iCount();i++)
           {
           TPtrC fileName=fileNames->MdcaPoint(i);
           ...
    }
    else
        {
        CEikonEnv::InfoWinL(_L("Failed"),_L(""));
        }
    
    CleanupStack::PopAndDestroy( fileClient );
    CleanupStack::PopAndDestroy( paramList );
    CleanupStack::PopAndDestroy( fileNames );