MTP data providers are implemented as ECOM plug-ins loaded into the MTP framework. The MTP Data Provider APIs enable device creators to create data provider plug-ins and support specific media and data types. Data providers interact with the MTP framework using the API/SPI interface pair.
MMTPDataCodeGenerator::AllocateServiceID() generates a datacode for a service GUID.
MMTPDataCodeGenerator::AllocateServicePropertyCode() generates datacodes for service property GUIDs.
MMTPDataCodeGenerator::AllocateServiceFormatCode() generates datacodes service format GUIDs.
MMTPDataCodeGenerator::AllocateServiceMethodFormatCode() generates datacodes for service method format GUIDs.
void CMTPTaskDataProvider::ConstructL() { … //Get the reference of the Datacode Generator. MMTPDataCodeGenerator& datacodeGenerator(Framework().DataCodeGenerator()); // Generate a datacode for the Windows task service GUID. TUint taskServiceID(0); const TMTPTypeUint128 KMTPTaskDpPersistentServiceID( MAKE_TUINT64(0x10287013,0x00000001), MAKE_TUINT64(0x00000000,0x00000000)); User::LeaveIfError(datacodeGenerator.AllocateServiceID( KMTPTaskDpPersistentServiceID, 0, taskServiceID)); … //Generate a datacode for the service AbstractTask format. TUint16 abstractTaskFormatcode(0); const TMTPTypeUint128 KAbstractTaskGUID( MAKE_TUINT64(0x522979c0,0x74cf44ab), MAKE_TUINT64(0x975455bc,0x596a67df)); User::LeaveIfError(datacodeGenerator.AllocateServiceFormatCode( KMTPTaskDpPersistentServiceID, KAbstractTaskGUID, abstractTaskFormatcode)); … }
void CMTPImageDataProvider::ProcessNotificationL(TMTPNotification aNotification, const TAny* aParams) { __FLOG(_L8("ProcessNotificationL - Entry")); switch (aNotification) { case EMTPSessionClosed: SessionClosedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams)); break; case EMTPSessionOpened: SessionOpenedL(*reinterpret_cast<const TMTPNotificationParamsSessionChange*>(aParams)); break; case EMTPDisconnected: { __FLOG(_L8("USB - Disconnected")); } break; default: // Ignore all other notifications. break; } __FLOG(_L8("ProcessNotificationL - Exit")); }
Option | Description |
---|---|
For data providers included in the ROM. |
|
For data providers installed via SIS file. |
If the data provider is included in the ROM (z: drive), edit the configuration files directly as follows:
RESOURCE MTP_FILEDP_CONFIG fileConfig { enumeration_iteration_length = 32; format_exclusion_list = { //Association 0x3001, 0x3009 //mp3 code added to exclusion list, handled by Music Data Provider. }; extension_map = { ... MTP_FILEDP_EXTENSION_MAP // mp3 added to extension map, handled by Music Data Provider. { file_extension = "mp3"; mtp_object_format = 0x3009; }, ... }; }
RESOURCE MTP_DEVICEDP_CONFIG folderConfig { enumeration_iteration_length = 32; folder_exclusion_list = { ... "c:\\media\\music\\", ... }; }
Data provider installed via SIS file
If the data provider is installed via SIS file, MMTPDataProvider::Supported() and MMTPDataProvider::SupportedL() must be implemented for the folder and file exclusion lists.
For example after a phone is shipped, the Music Data Provider can be installed via SIS files to the phone. The Music Data Provider supports .mp3, whose file format code is 0x3009. MP3 files are saved under c:\media\music. The following snippet of code shows an implementation of the two methods.
/** define all the operations that are supported by the music data provider */ static const TUint16 KMTPMusicDpSupportedFormats[] = { EMTPFormatCodeWMA, EMTPFormatCodeMP3 }; ... void CMTPMusicDataProvider::Supported(TMTPSupportCategory aCategory, RArray<TUint>& aArray) const { switch (aCategory) { case EObjectCaptureFormats: case EObjectPlaybackFormats: { TInt count = sizeof(KMTPMusicDpSupportedFormats) / sizeof(TUint16); for(TInt i = 0; i < count; i++) { aArray.Append(KMTPMusicDpSupportedFormats[i]); } } break; default: break; } } void CMTPMusicDataProvider::SupportedL(TMTPSupportCategory aCategory, CDesCArray& aStrings) const { switch (aCategory) { case EFolderExclusionSets: { //Hardcoded path, can be read from a resource file. _LIT(KMusicDPRootDir, "c:\\media\\music\\*"); aStrings.AppendL(KMusicDPRootDir); } break; case EFormatExtensionSets: { _LIT(KFormatExtensionMP3, "0x3009:MP3"); aStrings.AppendL(KFormatExtensionMP3); } break; default: break; } } ...
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.