MTP Data Types Overview

The MTP Data Types library implements the MTP data types. The implemented data types closely represent the raw MTP data streaming encoding and are optimized for the streaming performance.

MTP Data Types library details

The DLL that provides the functionality and the library to which your code must link is identified below.

DLL LIB Short description

mtpdatatypes.dll

mtpdatatypes.lib

This file is used to represent the MTP data types or provide a common interface for writing new data types.

Description

There are two kinds of MTP data defined in the MTP specification:

  • Data used in MTP operations, responses or events. It can be data passed as a parameter to an MTP operation, response or event, or dataset transferred for an operation request. For example, if a host PC sends the GetServiceInfo operation request to a device, the host PC expects the ServiceInfo dataset from the device.

  • Media data file transferred between an initiator and a responder. The MTP specification refers it to as binary object data or object data. The GetObject operation and SendObject operations transfer the object binary data.

The MTP Data Types library supports the above kinds of MTP data. When the Symbian MTP Framework receives a request (from a host PC or a device) for MTP data, it loads the corresponding data providers. The data providers process the dataset or binary data file using the Data Types library and pass it to the Framework. The Framework can then transfer the data to the host PC, or use it as a parameter in an operation, response or event.

The Data Types library provides four types of data: Simple, Flat, Complex and Compound. Simple data type implements MTP integer data types while Flat, Complex and Compound data types implement MMTPType interface.

Note: Binary object data is represented by CMTPTypeFile which is a complex data type.

APIs

Simple data type –a single integer value.

API Description

TMTPTypeInt8,

TMTPTypeInt16,

TMTPTypeInt32,

TMTPTypeInt64,

TMTPTypeInt128

Implements the MTP signed 8, 16, 32, 64, and 128-bit integer data types respectively.

TMTPTypeUint8,

TMTPTypeUint16,

TMTPTypeUint32,

TMTPTypeUint64,

TMTPTypeUint128

Implements the MTP unsigned 8, 16, 32, 64, and 128-bit integer data types respectively.

Flat data type –a fixed-length collection of simple descrete data values. For example,TMTPTypeEvent consists of seven elements. Each is a simple data type which can be different.

class TMTPTypeEvent : public TMTPTypeFlatBase
    {    
public: 
    /**
    MTP event dataset element identifiers.
    */
    enum TElements
        {        
        /**
        Event Code, 
        */
        EEventCode,  //TMTPTypeUint32 
        
        /**
        SessionID.
        */
        EEventSessionID,  //TMTPTypeUint32
        
        /**
        TransactionID  
        */
        EEventTransactionID,  //TMTPTypeUint32
        
        /**
        Parameter 1.
        */
        EEventParameter1,  //TMTPTypeUint32
        
        /**
        Parameter 2.
        */
        EEventParameter2,  //TMTPTypeUint32
        
        /**
        Parameter 3.
        */
        EEventParameter3,  //TMTPTypeUint32
        
        /**
        The number of dataset elements.
        */
        ENumElements,  //TMTPTypeUint32
        };

The following diagram shows the flat classes and their relationships.

Figure 1. Flat data type
API Description

TMTPTypeFlatBase

The base class of MTP flat data types.

TMTPTypeEvent

Represents MTP event dataset.

TMTPTypeRequest

Represents MTP operation request dataset.

TMTPTypeResponse

Represents MTP operation response dataset.

Complex data type –a variable-length contiguous array or string. The following diagram shows the complex classes and their relationships.

Figure 2. Complex data type
API Description

CMTPTypeArray

Represents MTP array data type.

CMTPTypeFile

Represents MTP binary object data type.

CMTPTypeString

Represents MTP string data type.

Compound data type –a mixed sequence of simple, flat, complex and compound types.

Compound classes were initially derived from CMTPTypeCompoundBase. The derived class can represent a list dataset or an element of a list dataset. For example, CMTPTypeObjectPropListElement is an element of CMTPTypeObjectPropList. They are both derived from CMTPTypeCompoundBase.

CMTTypeList is then added to represent list dataset. It derives from CMTPTypeCompoundBase. The list classes added later are derived from CMTTypeList. For example, CMTPTypeServicePropertyList is derived from CMTTypeList and its elment CMTPTypeServicePropertyElement is derived from CMTPTypeCompoundBase.

Note:CMTPTypeCompoundBase::ChunkAppendL() can be used to append any MMTPType data types to the compound data.

The following diagram and table describe the compound base classes. For a complete set of the derived classes, refer the MTP API references.

Figure 3. Compound data type-base classes
API Description

CMTPTypeCompoundBase

The base class of MTP compound data types.

CMTPTypeList

The base class of MTP list dataset.

RMTPType

The general class for containing, accessing, and manipulating a reference to any MMTPType -derived data type.

Using MTP Data Types library

MTP data providers use the MTP Data Types library to process datasets for MTP operations and events. Device creators can provide their extended data types.