Creating a Service Provider

A service provider is component that serves as a middleman between an application and a device. Windows Media Device Manager routes requests from the application to the service provider, which is then responsible for communicating with the device or performing the requested action. A service provider usually communicates with a driver to enable communication with the device. A service provider is a COM component that implements the interfaces called by Windows Media Device Manager. The root interface of the service provider object is IMDServiceProvider. After obtaining this interface, Windows Media Device Manager can obtain other interfaces through the service provider's implementation of various methods. The interfaces that a service provider must implement are listed in Mandatory and Optional Interfaces. The hierarchy of interfaces is shown in Interfaces for Service Providers.

Note

You should not try to create an MTP service provider; instead, you should use the MTP service provider and drivers provided by Microsoft.

 

Before trying to create a service provider, you should thoroughly understand what calls an application will make on a service provider. Read Creating a Windows Media Device Manager Application to get some idea of the basic tasks and calls that an application will make on a service provider when it is attempting to communicate with a device.

The following list shows the key steps in developing a service provider:

  1. Include (and optionally compile) the required header and library files for your project. See Required Libraries and Headers for a Service Provider for the list of required files.
  2. Implement all the other required or optional service provider interfaces (see Mandatory and Optional Interfaces). Typically, interfaces will be called in this order:
  3. Be sure your service provider or device installs the proper registry keys during installation. These keys specify device parameters, register the service provider as a plug-in, and enable Plug and Play notifications for device arrival and removal. See Device Parameters, Registering the Service Provider, and Enabling PnP for Devices.
  4. On instantiation of your class, authenticate the service provider in the constructor. To do this, create a CSecureChannelServer class and set the certificate. Implement the IComponentAuthenticate interface and call the methods of the CSecureChannelServer class instantiated previously. See Authenticating the Service Provider to learn how to instantiate the CSecureChannelServer class and implement the IComponentAuthenticate methods.
  5. Windows Media Device Manager will query your service provider for a list of connected devices by calling IMDServiceProvider2::CreateDevice or IMDServiceProvider::EnumDevices, depending on whether the service provider handles Plug and Play devices. The service provider must return a list of IMDSPDevice objects representing connected devices. See Enumerating Devices for more details.
  6. Before handling any call, verify that a secure channel has been established. Call CSecureChannelServer::fIsAuthenticated before performing any actions. If this call fails, return WMDM_E_NOTCERTIFIED.
  7. You will need a certificate/key pair issued by Microsoft to be able to handle DRM-protected material. See Handling Protected Content in the Service Provider for more information.
  8. To enable your device to synchronize automatically with Windows Media Player, it must fulfill the requirements listed in Enabling Synchronization with Windows Media Player.
  9. To enable your device to appear in Windows Explorer, you must take a few special steps, detailed in Requirements for Portable Audio Players to Appear in Windows Explorer.

Programming Guide