Supporting MTP Extensions

Media Transfer Protocol

Media Transfer Protocol (MTP) is an extension to the Picture Transfer Protocol (PTP). As a result, all PTP protocol semantics are valid in MTP.

MTP communicates by using commands and responses between two parties, the initiator and the responder. The roles of the involved devices are very clearly defined. The PC typically is the initiator, and the device is always the responder. A non-PC device could also be an initiator (for example, a car deck or a Microsoft X-box). A device can never assume both roles at the same time.

The initiator starts communication by sending a command to the responder. The responder processes the command and sends back an appropriate response. There might be a data phase associated with the command. If this is the case, the direction of data flow must be known beforehand and accepted by both the initiator and the responder. Be aware that there is not a descriptive header that indicates data flows for new commands.

The responder can start communication independent of the initiator. For example, the responder can send events to the initiator. However, no data can be sent together with the event. If there is any data that needs to be read as part of the event, the initiator must send an MTP command, and the device can then send data in response to the command.

For a complete description of MTP, refer to the MTP specification.

Sending MTP Commands

Applications can send MTP commands to a device by invoking the IPortableDevice::SendCommand method. The command that is sent depends on whether there is a data phase, and, on whether any accompanying data is read from or written to the device. The following table describes the three possible MTP extension commands.

Be aware that these commands are specific to MTP; and are therefore, only implemented by the WPD MTP class driver.

WPD_COMMAND_MTP_EXT_END_DATA_TRANSFER Issues an MTP command that signals the conclusion of a data read or write operation.
WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITHOUT_DATA_PHASE Issues an MTP command without a corresponding data phase.
WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_WRITE Issues an MTP command that is followed by accompanying data, which will be written to the device.
WPD_COMMAND_MTP_EXT_EXECUTE_COMMAND_WITH_DATA_TO_READ Issues an MTP command that is followed by accompanying data, which is read from the device.
WPD_COMMAND_MTP_EXT_READ_DATA Issues an MTP command that sends data from the device to the PC.
WPD_COMMAND_MTP_EXT_WRITE_DATA Issues an MTP command that sends data to the device from the PC.



If the MTP driver was able to send the command to the device, the return values will always contain WPD_PROPERTY_MTP_EXT_RESPONSE_CODE. If the response code indicates success and if the semantics of the command allow for response parameters, WPD_PROPERTY_MTP_EXT_RESPONSE_PARAMS will also be available.

Related topics

Programming Guide