Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]


How to write an Apparc recognizer for the Content Access Framework

[Top]


Overview

The Apparc framework uses data type recognizers derived from CApaDataRecognizerType to determine the MIME type of files in Symbian OS. Apparc supplies the filename and a buffer containing bytes read from the start of the file. If a file is recognized, the recognizer must return the MIME type and the degree of confidence in recognizing the file — a TInt ranging from KMinInt (Not Recognized) to KMaxInt (Certain).

The implementation of DRM presents a problem when determining the MIME type. Usually, a DRM file stores one or more content objects. For example, an OMA file with MIME type application/vnd.oma.drm.content might store an image file with MIME type image/jpeg. Apparc expects only one MIME type to be returned, not two.

The CAF recognizer RECCAF.DLL uses the ContentAccess::CAgentResolver::DoRecognize() function (see below) to determine whether or not a file is recognized by the content access framework and if so, retrieves these two MIME types.

The mapping of these two MIME types returned by CAF to a single MIME type follows these rules:

File MIME Type

Content MIME Type

Apparc MIME Type

Present

Present

x-caf- ContentMimeType

Present

Not Present

FileMimeType

Present

application/x-caf

application/x-caf

The rationale for the above mapping is as follows:

Note:

The concept of "confidence" has also been eliminated for the files within the Content Access Framework. A file is either recognized by an agent or it is not recognized.

[Top]


How to determine the file and content MIME types of a DRM file

When recognizing a file, Apparc supplies the name of the file to be recognized, and a buffer containing the start of the file, to all CApaDataRecognizerType::DoRecognizeL() implementations. These two parameters can be passed to the ContentAccess::CAgentResolver::DoRecognize() function to determine whether one of the Content Access Agents recognizes the file.

CApaDataRecognizer::DoRecognize(TDesC& aFilename, TDesC8& aBuffer) 
    {
    TBool recognized; 
    CAgentResolver *resolver = CAgentResolver::NewL(); 

    .... 

    recognized = resolver->DoRecognize(filename, buffer, fileMimeType, contentMimeType); 
    ....

ContentAccess::CAgentResolver::DoRecognize() passes the filename and buffer to each of the agents in turn. The agents perform the recognition, and the result is returned as either ETrue if the file was recognized, or EFalse if it was not. If the file is recognized, the fileMimeType and contentMimeType parameters are populated with the correct MIME types.

The recognition is distributed to the agents because they are able to recognize a file belonging to their agent. They are also able to examine the contents to work out the content MIME type. This allows one generic CAF recognizer to be used for all the agents implemented with the content access framework.

The following diagram illustrates the recognition of an OMA file with JPEG content.


[Top]


CAF recognizer configuration file

The CAF recognizer configuration file is stored in the apparc server's private directory \private\10003a3f\RecCaf\RecCafMimeTypes.txt.

It is just a list of all known content MIME types. The list allows the recognizer to return a fixed set of MIME types when apparc calls the recognizer's CApaCafRecognizer::SupportedDataTypeL() function.

image/jpeg 
image/gif 
text/plain 
text/html
... etc

If this file is replaced (to support new content types), the recognizer will only implement the changes during the next power on. Similarly if a new agent is added, the recognizer will only rebuild its list of agents after the next power on.

[Top]


Application registration files

In order to use CAF content, applications will need to update their registration resource files (for example AppName_reg.rss) to include the new CAF MIME types. For example, in the past, an image viewer may have only included image/jpeg in the list of MIME types it could open. If the application is updated to use the Content Access Framework, it should support image/jpeg and x-caf-image/jpeg in order to support unprotected and protected content respectively. See the registration file examples below.

All file operations should be conducted through the CAF framework, so that the application will not need to know anything about a specific DRM scheme.

Registration file that doesn't use CAF

...

datatype_list = 
    {
    DATATYPE { priority= EDataTypePriorityHigh ; type="image/jpeg";}, 
    }

...

Registration file that does use CAF

...

datatype_list = 
    {       
    DATATYPE { priority= EDataTypePriorityHigh ; type="image/jpeg"; }, 
    
    DATATYPE { priority= EDataTypePriorityHigh ; type="x-caf-image/jpeg"; }, 
    }

...