Both BRisa Media Server and BRisa Media Renderer applications support DBus, allowing them to integrate with a wide range of media systems. In this section we specify both interfaces.
- Object path: /br/edu/ufcg/embedded/brisa/MediaServer
- Interface: br.edu.ufcg.embedded.brisa.MediaServer
Note
A watched folder is a folder whose files are being watched, that is, are served by the media server.
Note
- Object path: /br/edu/ufcg/embedded/brisa/MediaRenderer
- Interface: br.edu.ufcg.embedded.brisa.MediaRenderer
Note
BRisa Media Server can be easily extended to serve more content with plugins. We have a few plugins already implemented which can serve as code example:
- Flickr: enables access to Flickr pictures, such as user pictures or even featured ones.
- Youtube: enables access to Youtube user and featured videos.
Examples: Media Library Plugin.
Concerning files, your plugin must be placed in $PREFIX/brisa_media_server/plugins/yourplugin, where $PREFIX is usually /usr/lib/python2.5/site-packages or /usr/local/lib/python2.6/dist-packages and so on. On your __init__.py file you must import your plugin individual module, so that your plugin class is visible as subclass of our plugin interface (future plan is to have an automatic plugin install mechanism).
BRisa Media Server basic directory structure is composed only by a root folder, which belongs to what we call RootPlugin. When plugins are being loaded, they can add folders to the root folder or register themselves on other folders.
Plugins must be implemented using the brisa.core.plugin.PluginInterface interface.
Attributes that must be set during construction:
name: plugin name
- usage: True if your plugin is supposed to load, False otherwise. This is
usually loaded from a configuration file.
- has_browse_filter: can be True or False. If your plugin
implements the browse() function with slicing/sorting capabilities (i.e. it uses starting_index, requested_count, sort_criteria parameters), this attribute must be True.
Methods that must be implemented (part of the interface):
If your plugin folder was correctly copied into brisa_media_server/plugins/your_plugin and on your file /your_plugin/__init__.py you import the module that contains your plugin class implementation, then the media server should load it automatically. For examples on that, please refer to our media_library example, currently on our SVN repository <https://garage.maemo.org/svn/brisa> under trunk/app/media-server/src/plugins/media_library.
Once your plugin is created, python-brisa automatically sets the plugin_manager attribute of your plugin, which points to our PluginManager. You will be using the PluginManager for retrieving the RootPlugin, which contains the root directory, for adding your plugin’s own custom folders.
For retrieving the root plugin, consider the following code:
from brisa.core.plugin import PluginInterface
class MyPlugin(PluginInterface):
(implement as the description we gave above)
def load(self):
# Retrieve the root plugin
root_plugin = self.plugin_manager.root_plugin
audio_container = root_plugin.get_container('Audio')
if not audio_container:
# Does not exist yet, add it
audio_container = root_plugin.add_container('Audio')
(...)
Specific implementation details of browse and search methods are better visualized on the media library example, as it uses everything that a plugin can do. In a nutshell, you should keep a dictionary of containers you added, keys being the container id attribute and values the container itself. When browsed, you query on this dictionary, and do the appropriate action that may vary from a plugin to another.
For instance, on a Flickr plugin we do not have actual files, but links to the web, so, you can cache the links on your containers (expensive) or just fetch the links when the browse() function tells it wants the contents of a container.
Plugins can also serve local files, which is also illustrated on the media library example.