Permalink
Browse files

upnp: renderer support for SetNextAVTransportURI

  • Loading branch information...
elupus committed Nov 5, 2012
1 parent 1f057a1 commit ac25ba70efdfd996b6e7f161fdb1c1a20c2bcd03
Showing with 69 additions and 0 deletions.
  1. +68 −0 xbmc/network/upnp/UPnPRenderer.cpp
  2. +1 −0 xbmc/network/upnp/UPnPRenderer.h
@@ -17,6 +17,8 @@
#include "URL.h"
#include "utils/URIUtils.h"
#include "utils/Variant.h"
+#include "PlayList.h"
+#include "GUIUserMessages.h"
using namespace ANNOUNCEMENT;
@@ -140,6 +142,11 @@ CUPnPRenderer::SetupServices()
",http-get:*:video/x-ms-wvx:*"
",http-get:*:video/x-msvideo:*"
);
+
+ NPT_CHECK_FATAL(FindServiceByType("urn:schemas-upnp-org:service:AVTransport:1", service));
+ service->SetStateVariable("NextAVTransportURI", "");
+ service->SetStateVariable("NextAVTransportURIMetadata", "");
+
return NPT_SUCCESS;
}
@@ -223,6 +230,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()));
@@ -316,6 +327,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", "");
}
}
@@ -492,6 +505,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;
@@ -500,6 +515,56 @@ CUPnPRenderer::OnSetAVTransportURI(PLT_ActionReference& action)
return PlayMedia(uri, meta, action.AsPointer());
}
+/*----------------------------------------------------------------------
+ | 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
+---------------------------------------------------------------------*/
@@ -537,6 +602,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());
}
@@ -57,6 +57,7 @@ class CUPnPRenderer : public PLT_MediaRenderer
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);

0 comments on commit ac25ba7

Please sign in to comment.