diff options
author | Joakim Plate <elupus@ecce.se> | 2012-11-05 02:08:21 +0100 |
---|---|---|
committer | Joakim Plate <elupus@ecce.se> | 2013-01-20 18:31:24 +0100 |
commit | cb4d005258635d70664588dca69a7d89597a2190 (patch) | |
tree | 142eba4ba727965ac4644679acfc5053f4071133 | |
parent | 864bd084aba47de5f84b77cfa59a9a58cf45162a (diff) |
upnp: renderer support for SetNextAVTransportURI
-rw-r--r-- | xbmc/network/upnp/UPnPRenderer.cpp | 68 | ||||
-rw-r--r-- | xbmc/network/upnp/UPnPRenderer.h | 1 |
2 files changed, 69 insertions, 0 deletions
diff --git a/xbmc/network/upnp/UPnPRenderer.cpp b/xbmc/network/upnp/UPnPRenderer.cpp index 80527c9b72..07fb03a027 100644 --- a/xbmc/network/upnp/UPnPRenderer.cpp +++ b/xbmc/network/upnp/UPnPRenderer.cpp @@ -18,6 +18,8 @@ #include "URL.h" #include "utils/URIUtils.h" #include "utils/Variant.h" +#include "playlists/PlayList.h" +#include "GUIUserMessages.h" using namespace ANNOUNCEMENT; @@ -145,6 +147,11 @@ CUPnPRenderer::SetupServices() ",http-get:*:video/x-msvideo:*" ",http-get:*:video/x-xvid:*" ); + + NPT_CHECK_FATAL(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service)); + service->SetStateVariable("NextAVTransportURI", ""); + service->SetStateVariable("NextAVTransportURIMetadata", ""); + return NPT_SUCCESS; } @@ -228,6 +235,10 @@ CUPnPRenderer::Announce(AnnouncementFlag flag, const char *sender, const char *m avt->SetStateVariable("TransportPlaySpeed", NPT_String::FromInteger(data["speed"].asInteger())); avt->SetStateVariable("TransportState", "PLAYING"); + + /* this could be a transition to next track, so clear next */ + avt->SetStateVariable("NextAVTransportURI", ""); + avt->SetStateVariable("NextAVTransportURIMetaData", ""); } else if (strcmp(message, "OnPause") == 0) { avt->SetStateVariable("TransportPlaySpeed", NPT_String::FromInteger(data["speed"].asInteger())); @@ -321,6 +332,8 @@ CUPnPRenderer::UpdateState() avt->SetStateVariable("AbsoluteTimePosition", "00:00:00"); avt->SetStateVariable("CurrentTrackDuration", "00:00:00"); avt->SetStateVariable("CurrentMediaDuration", "00:00:00"); + avt->SetStateVariable("NextAVTransportURI", ""); + avt->SetStateVariable("NextAVTransportURIMetaData", ""); } } @@ -497,6 +510,8 @@ CUPnPRenderer::OnSetAVTransportURI(PLT_ActionReference& action) service->SetStateVariable("TransportPlaySpeed", "1"); service->SetStateVariable("AVTransportURI", uri); service->SetStateVariable("AVTransportURIMetaData", meta); + service->SetStateVariable("NextAVTransportURI", ""); + service->SetStateVariable("NextAVTransportURIMetaData", ""); NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable()); return NPT_SUCCESS; @@ -506,6 +521,56 @@ CUPnPRenderer::OnSetAVTransportURI(PLT_ActionReference& action) } /*---------------------------------------------------------------------- + | CUPnPRenderer::OnSetAVTransportURI + +---------------------------------------------------------------------*/ +NPT_Result +CUPnPRenderer::OnSetNextAVTransportURI(PLT_ActionReference& action) +{ + NPT_String uri, meta; + PLT_Service* service; + NPT_CHECK_SEVERE(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service)); + + NPT_CHECK_SEVERE(action->GetArgumentValue("NextURI", uri)); + NPT_CHECK_SEVERE(action->GetArgumentValue("NextURIMetaData", meta)); + + CFileItemPtr item = GetFileItem(uri, meta); + if (!item) { + return NPT_FAILURE; + } + + if (g_application.IsPlaying()) { + + int playlist = PLAYLIST_MUSIC; + if(item->IsVideo()) + playlist = PLAYLIST_VIDEO; + + { CSingleLock lock(g_graphicsContext); + g_playlistPlayer.ClearPlaylist(playlist); + g_playlistPlayer.Add(playlist, item); + + g_playlistPlayer.SetCurrentSong(-1); + g_playlistPlayer.SetCurrentPlaylist(playlist); + } + + CGUIMessage msg(GUI_MSG_PLAYLIST_CHANGED, 0, 0); + g_windowManager.SendThreadMessage(msg); + + + service->SetStateVariable("NextAVTransportURI", uri); + service->SetStateVariable("NextAVTransportURIMetaData", meta); + + NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable()); + + return NPT_SUCCESS; + + } else if (g_windowManager.GetActiveWindow() == WINDOW_SLIDESHOW) { + return NPT_FAILURE; + } else { + return NPT_FAILURE; + } +} + +/*---------------------------------------------------------------------- | CUPnPRenderer::PlayMedia +---------------------------------------------------------------------*/ NPT_Result @@ -542,6 +607,9 @@ CUPnPRenderer::PlayMedia(const NPT_String& uri, const NPT_String& meta, PLT_Acti service->SetStateVariable("TransportStatus", "ERROR_OCCURRED"); } + service->SetStateVariable("NextAVTransportURI", ""); + service->SetStateVariable("NextAVTransportURIMetaData", ""); + if (action) { NPT_CHECK_SEVERE(action->SetArgumentsOutFromStateVariable()); } diff --git a/xbmc/network/upnp/UPnPRenderer.h b/xbmc/network/upnp/UPnPRenderer.h index 29a905560d..41d1c8e9a6 100644 --- a/xbmc/network/upnp/UPnPRenderer.h +++ b/xbmc/network/upnp/UPnPRenderer.h @@ -57,6 +57,7 @@ public: virtual NPT_Result OnStop(PLT_ActionReference& action); virtual NPT_Result OnSeek(PLT_ActionReference& action); virtual NPT_Result OnSetAVTransportURI(PLT_ActionReference& action); + virtual NPT_Result OnSetNextAVTransportURI(PLT_ActionReference& action); // RenderingControl methods virtual NPT_Result OnSetVolume(PLT_ActionReference& action); |