MTP Client Overview

The MTP Client controls the startup and termination of MTP services and MTP transports.

MTP Client library details

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

DLL LIB Short description

mtpclient.dll

mtpclient.lib

These files are used to start and stop an MTP transport plug-in.

Architecture

MTP Client is a standard IPC client derived from RSessionBase. It is implemented as a standard Symbian client interface. The server side is the MTP daemon process (mtpserver.exe). For more information about the MTP architecture, refer to MTP Framework Overview.

Using MTP Client

To start or stop an MTP transport transport, pass the transport plug-in UID to the StartTransport() or StopTransport() function.

// iMTPSession is an instance of RMTPClient 
RMTPClient iMTPSession;
iMTPSession.Connect();

    // Start the USB transport
        err = iMTPSession.StartTransport(TUid::Uid(KMTPUsbTransportImplementation));
        if (err != KErrNone) 
            {
            ...
            User::Leave(err);
            }
 ...
    // Stop the USB transport
err = iMTPSession.StopTransport(TUid::Uid(KMTPUsbTransportImplementation));
    if(err != KErrServerTerminated)
        {
        if (err != KErrNone) 
            {
            ...
            User::Leave(err);
            }
iMTPSession.Close();

For the host to communicate with the daemon through MTP, any one transport plug-in must be loaded. Only one transport plug-in may be loaded at a given time.

At least one client must be connected for the MTP Daemon to be running. When the last client closes the daemon starts a timer. When the timer expires the daemon shuts itself down.

Related tasks
Enabling MTP over USB