Untergeordnete Seiten
  • Resource Providers

  Wiki Navigation

    Loading...


 Recently Updated


 Latest Releases

 MediaPortal 1.32
            Releasenews | Download
 MediaPortal 2.5
            Releasenews | Download


Table of Contents

Overview

In MediaPortal 2, we use ResourceProviders to get access to resources like movies or music files. Resource providers are compontens which are brought to the system by plugins. They have to support a special interface IResourceProvider and its sub interface IBaseResourceProvider or IChainedResourceProvider , depending on the type of resource provider.

Resource Providers are used by several system parts to get access to resources, for example importers or the media player subsystem.

Base resource providers

Base resource providers provide access to resources specified by a path string. Base resource providers are for example the local file system resource provider, an FTP resource provider or a HTTP resource provider.

Chained resource providers

Chained resource providers read their resources from a given input file, for example from an ISO image or from an archive. The input resource itself is provided by another resource provider. The process of using a resource from another resource provider as input for a second one is called "chaining resource providers".

By chaining resource providers, each base resource provider spans a "virtual file system" which consists of the file system of a base resource provider extended by the sub systems which are spanned by chained resources providers applied on resources of the base resource provider.

Accessing resources

To access resources, we use an abstraction of a "file" and "directory" called resource accessor. The interface IResourceAccessor provides that abstraction. Resource accessors provide read or write streams of the underlaying file, provide other information about that file or directory and, depending on the concrete implemented interface, additional functions.

Each resource provider returns resource accessor instances of interface IResourceAccessor or any sub interface, depending on the type of resource provider. Most often, resource providers will return resource accessor instances of interface IFileSystemResourceAccessor , which can be navigated as a virtual file system.

Using resource providers

All local resource providers can be obtained by the service IMediaAccessor . Basically, a base resource provider could simply be used by calling method CreateResourceAccessor with a path string. The file system provider will provide an instance of an ILocalFsResourceAccessor which makes it possible to navigate through the file system. A chained resource provider could be used by calling its method CreateResourceAccessor with explicitly providing an input resource and a path.

But in most cases, you don't want to navigate through the "virtual file system" by hand. Else you would have to check for each file, if it can be interpreted as input for a chained resource provider. To avoid the need to implement that navigation through the "virtual file system", class FileSystemResourceNavigator can be used.

Class ResourcePath

To store paths which are capable of specifying a whole (local) resource provider resource chain, we use class ResourcePath . That class holds the ID of a base resource provider together with a path and N combinations of (resource provider ID; path) for chained resource providers. The serialized form of such a resource path looks like this, for example:

{E88E64A8-0233-4fdf-BA27-0B44C6A39AE9}:///D:/Media/ISOs/MP3s.iso>{90C92668-DBBF-47b3-935E-B84426A96105}:///R.E.M. - Around The Sun.rar>{10C18F11-854A-470e-9C47-ECF9EF867066}:///R.E.M. - Electron Blue.mp3
  • where {E88E64A8-0233-4fdf-BA27-0B44C6A39AE9} is the ID of the Local HDD provider, {90C92668-DBBF-47b3-935E-B84426A96105} is the ID of the ISO image provider and {10C18F11-854A-470e-9C47-ECF9EF867066} is the ID of the RAR archive provider in that example.

A resource path holds a local resource specification; the path isn't valid any more when transported to another system without the native system information.

Accessing (potential remote) resources

Resources, for example media items, can be accessed via the instances implementing the interface IResourceLocator (see the next section for a hint how to get a resource locator for a media item). With such a resource locator, you can get an instance of an IResourceAccessor to access the resource. To test the "features" of such a resource accessor, you can test the instance for its supported interfaces. For example, if the resource accessor instance supports the interface ILocalFsResourceAccessor , the resource is located in the local file system and can also be accessed via a local path (which is provided as a property by that interface). But it might also be possible that the item has to be extracted from a complex resource like an ISO disk image file or a ZIP file. In this case, the resource accessor instance won't support the interface ILocalFsResourceAccessor , for example.

So when working with resources, you must always be prepared that the resource might come from a complex resource chain - maybe from a remote system. Some players might only be able to access resources located at the local file system; for such cases, you can also request an ILocalFsResourceAccessor from an IResourceLocator by calling method CreateLocalFsAccessor , which will do some internal magic to provide a local file system path for that (potential remote) resource (in fact, it will create a resource bridge from the remote system by opening a stream connection to the remote system and mapping that stream to a local file, which will be made accessible by a virtual filesystem driver).

Accessing media items

To get access to a media item, the service IMediaAccessor provides a method GetResourceLocator to get an IResourceLocator for it.

   

 

This page has no comments.