Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stream backend: Add StreamBackend, fixes #151
Adds a basic streaming backend simply handles streaming audio and nothing else. I.e. no metadata beyond the URI we where given. #270 still needs to be solved for actual metadata to make sense in this backend.
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,23 @@ | |||
"""A backend for playing music for streaming music. | |||
This backend will handle streaming of URIs in | |||
:attr:`mopidy.settings.STREAM_PROTOCOLS` assuming the right plugins are | |||
installed. | |||
**Issues:** | |||
https://github.com/mopidy/mopidy/issues?labels=Stream+backend | |||
**Dependencies:** | |||
- None | |||
**Settings:** | |||
- :attr:`mopidy.settings.STREAM_PROTOCOLS` | |||
""" | |||
|
|||
from __future__ import unicode_literals | |||
|
|||
# flake8: noqa | |||
from .actor import StreamBackend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,57 @@ | |||
from __future__ import unicode_literals | |||
|
|||
import pygst | |||
pygst.require('0.10') | |||
import gst | |||
|
|||
import logging | |||
import urlparse | |||
|
|||
import pykka | |||
|
|||
from mopidy import settings | |||
from mopidy.backends import base | |||
from mopidy.models import SearchResult, Track | |||
|
|||
logger = logging.getLogger('mopidy.backends.stream') | |||
|
|||
|
|||
class StreamBackend(pykka.ThreadingActor, base.Backend): | |||
def __init__(self, audio): | |||
super(StreamBackend, self).__init__() | |||
|
|||
self.library = StreamLibraryProvider(backend=self) | |||
self.playback = base.BasePlaybackProvider(audio=audio, backend=self) | |||
self.playlists = None | |||
|
|||
available_protocols = set() | |||
|
|||
registry = gst.registry_get_default() | |||
for factory in registry.get_feature_list(gst.TYPE_ELEMENT_FACTORY): | |||
for uri in factory.get_uri_protocols(): | |||
if uri in settings.STREAM_PROTOCOLS: | |||
available_protocols.add(uri) | |||
|
|||
self.uri_schemes = list(available_protocols) | |||
|
|||
|
|||
# TODO: Should we consider letting lookup know how to expand common playlist | |||
# formats (m3u, pls, etc) for http(s) URIs? | |||
class StreamLibraryProvider(base.BaseLibraryProvider): | |||
def lookup(self, uri): | |||
if urlparse.urlsplit(uri).scheme not in self.backend.uri_schemes: | |||
return [] | |||
# TODO: actually lookup the stream metadata by getting tags in same | |||
# way as we do for updating the local library with mopidy.scanner | |||
# Note that we would only want the stream metadata at this stage, | |||
# not the currently playing track's. | |||
return [Track(uri=uri, name=uri)] | |||
|
|||
def find_exact(self, **query): | |||
return SearchResult() | |||
|
|||
def search(self, **query): | |||
return SearchResult() | |||
|
|||
def refresh(self, uri=None): | |||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters