summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--PlexHTTPRequestHandler.cpp34
-rw-r--r--PlexHTTPRequestHandler.h5
-rw-r--r--PlexReqHandlerFactory.cpp4
-rw-r--r--SubscriptionManager.cpp6
-rw-r--r--SubscriptionManager.h12
-rw-r--r--plex.cpp21
-rw-r--r--plex.h7
-rw-r--r--plexSdOsd.cpp18
-rw-r--r--plexSdOsd.h22
-rw-r--r--plexgdm.cpp2
10 files changed, 101 insertions, 30 deletions
diff --git a/PlexHTTPRequestHandler.cpp b/PlexHTTPRequestHandler.cpp
index a157087..4acc0a3 100644
--- a/PlexHTTPRequestHandler.cpp
+++ b/PlexHTTPRequestHandler.cpp
@@ -142,7 +142,7 @@ namespace plexclient {
"<Player title=\"" << Config::GetInstance().GetHostname() << "\""
" protocol=\"plex\""
" protocolVersion=\"1\""
- " protocolCapabilities=\"navigation,playback,timeline\""
+ " protocolCapabilities=\"navigation,playback,timeline,mirror\""
" machineIdentifier=\"" << Config::GetInstance().GetUUID() << "\""
" product=\"" << DESCRIPTION << "\""
" platform=\"Linux\""
@@ -238,7 +238,7 @@ namespace plexclient {
}
- ActionManager::GetInstance().AddAction(Cont->m_vVideos[0]);
+ ActionManager::GetInstance().AddAction(Action{Cont->m_vVideos[0], ActionType::Play});
}
} else if (request.getURI().find("/playback/play") != std::string::npos) {
cRemote::Put(kPlay);
@@ -290,3 +290,33 @@ namespace plexclient {
}
} // namespace
+
+void plexclient::MirrorRequestHandler::handleRequest(Poco::Net::HTTPServerRequest &request,
+ Poco::Net::HTTPServerResponse &response) {
+ ///player/mirror/details?type=video&key=%2Flibrary%2Fmetadata%2F113855&machineIdentifier=fbad3115c2c2d82c53b0205e5aa3c4e639ebaa94&protocol=http&address=192.168.1.175&port=32400&token=transient-5557be74-dcad-4c28-badd-aa01b6224862&commandID=2
+ UpdateCommandId(request);
+
+ Poco::URI uri(request.getURI());
+ std::map<std::string, std::string> query = ParseQuery(uri.getQuery());
+
+ if (request.getMethod() == Poco::Net::HTTPRequest::HTTP_OPTIONS) {
+ AddHeaders(response, request);
+ response.setStatus(Poco::Net::HTTPResponse::HTTPStatus::HTTP_OK);
+ response.send() << " ";
+ return;
+ }
+
+ if (request.getURI().find("/details") != std::string::npos) {
+ std::string protocol = query["protocol"];
+ std::string address = query["address"];
+ std::string port = query["port"];
+ std::string key = query["key"];
+
+ std::string fullUrl = protocol + "://" + address + ":" + port + key; // Metainfo
+ auto Cont = Plexservice::GetMediaContainer(fullUrl);
+ ActionManager::GetInstance().AddAction(Action {Cont->m_vVideos[0], ActionType::Display});
+ AddHeaders(response, request);
+ response.send() << GetOKMsg();
+ }
+}
+
diff --git a/PlexHTTPRequestHandler.h b/PlexHTTPRequestHandler.h
index 9f0d69f..1b4a969 100644
--- a/PlexHTTPRequestHandler.h
+++ b/PlexHTTPRequestHandler.h
@@ -58,7 +58,10 @@ namespace plexclient {
virtual void handleRequest(Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response);
};
-
+ class MirrorRequestHandler : public PlexHTTPRequestHandler {
+ public:
+ virtual void handleRequest(Poco::Net::HTTPServerRequest &request, Poco::Net::HTTPServerResponse &response);
+ };
}
diff --git a/PlexReqHandlerFactory.cpp b/PlexReqHandlerFactory.cpp
index c1d9401..2720e7f 100644
--- a/PlexReqHandlerFactory.cpp
+++ b/PlexReqHandlerFactory.cpp
@@ -9,7 +9,8 @@ namespace plexclient {
}
Poco::Net::HTTPRequestHandler *PlexReqHandlerFactory::createRequestHandler(
- const Poco::Net::HTTPServerRequest &request) { /*
+ const Poco::Net::HTTPServerRequest &request) {
+ /*
if(request.getMethod() == Poco::Net::HTTPRequest::HTTP_GET) {
std::cout << "GET Request: " << request.getURI() << " from: " << request.clientAddress().toString() << std::endl;
} else if(request.getMethod() == Poco::Net::HTTPRequest::HTTP_OPTIONS) {
@@ -22,6 +23,7 @@ namespace plexclient {
}
*/
if (request.getURI().find("/player/timeline") != std::string::npos) return new SubscribeRequestHandler();
+ else if (request.getURI().find("/player/mirror") != std::string::npos) return new MirrorRequestHandler();
else if (request.getURI().find("/resources") != std::string::npos) return new ResourceRequestHandler();
else if (request.getURI().find("/player") != std::string::npos) return new PlayerRequestHandler();
diff --git a/SubscriptionManager.cpp b/SubscriptionManager.cpp
index 4d4311d..4948d99 100644
--- a/SubscriptionManager.cpp
+++ b/SubscriptionManager.cpp
@@ -234,13 +234,13 @@ namespace plexclient {
ActionManager::ActionManager() { }
- void ActionManager::AddAction(cVideo video) {
+ void ActionManager::AddAction(Action action) {
m_myLock.Lock(&m_myMutex);
- m_Action = video;
+ m_Action = action;
m_isAction = true;
}
- cVideo ActionManager::GetAction() {
+ Action ActionManager::GetAction() {
m_myLock.Lock(&m_myMutex);
m_isAction = false;
return m_Action;
diff --git a/SubscriptionManager.h b/SubscriptionManager.h
index fb86e75..9efaa5b 100644
--- a/SubscriptionManager.h
+++ b/SubscriptionManager.h
@@ -94,6 +94,12 @@ namespace plexclient {
std::string GetTimelineXml();
};
+ enum class ActionType { Play, Display };
+ struct Action {
+ cVideo video;
+ ActionType type;
+ };
+
class ActionManager {
public:
static ActionManager &GetInstance() {
@@ -101,9 +107,9 @@ namespace plexclient {
return instance;
}
- void AddAction(cVideo video);
+ void AddAction(Action action);
- cVideo GetAction();
+ Action GetAction();
bool IsAction();
@@ -113,7 +119,7 @@ namespace plexclient {
ActionManager();
- cVideo m_Action;
+ Action m_Action;
bool m_isAction;
};
diff --git a/plex.cpp b/plex.cpp
index 9d9523a..408f01f 100644
--- a/plex.cpp
+++ b/plex.cpp
@@ -203,7 +203,13 @@ const char *cMyPlugin::MainMenuEntry(void) {
cOsdObject *cMyPlugin::MainMenuAction(void) {
//dsyslog("[plex]%s:\n", __FUNCTION__);
#ifdef SKINDESIGNER
- if (bSkindesigner && m_pTestOsd->SdSupport()) return new cPlexSdOsd(m_pPlugStruct);
+ if (bSkindesigner && m_pTestOsd->SdSupport()) {
+ if (m_bShowInfo) {
+ m_bShowInfo = false;
+ return new cPlexSdOsd(m_pPlugStruct, &action.video);
+ }
+ return new cPlexSdOsd(m_pPlugStruct);
+ }
else return cPlexMenu::ProcessMenu();
#else
return cPlexMenu::ProcessMenu();
@@ -217,9 +223,18 @@ cOsdObject *cMyPlugin::MainMenuAction(void) {
void cMyPlugin::MainThreadHook(void) {
// dsyslog("[plex]%s:\n", __FUNCTION__);
// Start Tasks, e.g. Play Video
- if (plexclient::ActionManager::GetInstance().IsAction()) {
- PlayFile(plexclient::ActionManager::GetInstance().GetAction());
+ using namespace plexclient;
+ if (ActionManager::GetInstance().IsAction()) {
+ action = ActionManager::GetInstance().GetAction();
+ if(action.type == ActionType::Play) {
+ PlayFile(action.video);
+ }
+ else if (action.type == ActionType::Display) {
+ m_bShowInfo = true;
+ cRemote::CallPlugin("plex");
+ }
}
+
}
/**
diff --git a/plex.h b/plex.h
index 182c302..c37a9d3 100644
--- a/plex.h
+++ b/plex.h
@@ -22,6 +22,7 @@
#include <libskindesignerapi/skindesignerapi.h>
#include "plexSdOsd.h"
#include "pictureCache.h"
+#include "SubscriptionManager.h"
#endif
@@ -47,9 +48,11 @@ static const char *const MAINMENUENTRY = "Plex for VDR";
class cMyPlugin : public cPlugin {
private:
#ifdef SKINDESIGNER
- skindesignerapi::cPluginStructure *m_pPlugStruct;
- cPlexSdOsd *m_pTestOsd;
+ skindesignerapi::cPluginStructure *m_pPlugStruct = nullptr;
+ cPlexSdOsd *m_pTestOsd = nullptr;
static bool bSkindesigner;
+ plexclient::Action action;
+ bool m_bShowInfo = false;
#endif
public:
diff --git a/plexSdOsd.cpp b/plexSdOsd.cpp
index 0091ff1..e271eef 100644
--- a/plexSdOsd.cpp
+++ b/plexSdOsd.cpp
@@ -7,8 +7,12 @@
cMutex cPlexSdOsd::RedrawMutex;
+cPlexSdOsd::cPlexSdOsd(skindesignerapi::cPluginStructure *plugStruct, plexclient::cVideo* detailVideo) : cPlexSdOsd(plugStruct) {
+ m_pDetailVideo = detailVideo;
+}
+
cPlexSdOsd::cPlexSdOsd(skindesignerapi::cPluginStructure *plugStruct) : cSkindesignerOsdObject(plugStruct) {
- m_pRootView = NULL;
+
}
cPlexSdOsd::~cPlexSdOsd() {
@@ -20,15 +24,18 @@ cPlexSdOsd::~cPlexSdOsd() {
m_pMessage->Clear();
}
+bool cPlexSdOsd::m_bSdSupport = false;
+
bool cPlexSdOsd::SdSupport() {
- if (SkindesignerAvailable()) {
+ if (m_bSdSupport || SkindesignerAvailable()) {
skindesignerapi::cOsdView *rootView = GetOsdView();
if (!rootView) {
esyslog("[plex]: used skindesigner skin does not support plex");
return false;
}
+ delete rootView;
}
- return true;
+ return (m_bSdSupport = true);
}
void cPlexSdOsd::Show(void) {
@@ -45,8 +52,9 @@ void cPlexSdOsd::Show(void) {
m_pBrowserGrid = std::shared_ptr<cBrowserGrid>(new cBrowserGrid(m_pRootView));
m_pMessage = std::shared_ptr<skindesignerapi::cViewElement>(
m_pRootView->GetViewElement((int) eViewElementsRoot::message));
- m_messageDisplayed = false;
- m_detailsActive = false;
+ if(m_pDetailVideo) {
+ ShowDetails(m_pDetailVideo);
+ }
Flush();
}
diff --git a/plexSdOsd.h b/plexSdOsd.h
index 5e299cd..da8482d 100644
--- a/plexSdOsd.h
+++ b/plexSdOsd.h
@@ -24,28 +24,32 @@
class cPlexSdOsd : public skindesignerapi::cSkindesignerOsdObject {
private:
- std::shared_ptr<cBrowserGrid> m_pBrowserGrid;
- std::shared_ptr<cDetailView> m_pDetailGrid;
- std::shared_ptr<skindesignerapi::cViewElement> m_pMessage;
- bool m_messageDisplayed;
- bool m_detailsActive;
+ static bool m_bSdSupport;
+ std::shared_ptr<cBrowserGrid> m_pBrowserGrid = nullptr;
+ std::shared_ptr<cDetailView> m_pDetailGrid = nullptr;
+ std::shared_ptr<skindesignerapi::cViewElement> m_pMessage = nullptr;
+ bool m_messageDisplayed = false;
+ bool m_detailsActive = false;
+ plexclient::cVideo* m_pDetailVideo = nullptr;
- std::shared_ptr<skindesignerapi::cOsdView> m_pRootView;
- std::shared_ptr<skindesignerapi::cOsdView> m_pDetailsView;
+ std::shared_ptr<skindesignerapi::cOsdView> m_pRootView = nullptr;
+ std::shared_ptr<skindesignerapi::cOsdView> m_pDetailsView = nullptr;
void Flush();
void DrawMessage(std::string message);
- void ShowDetails(plexclient::cVideo *vid);
-
public:
cPlexSdOsd(skindesignerapi::cPluginStructure *plugStruct);
+ cPlexSdOsd(skindesignerapi::cPluginStructure *plugStruct, plexclient::cVideo* detailVideo);
+
~cPlexSdOsd();
virtual void Show(void);
+ void ShowDetails(plexclient::cVideo *vid);
+
virtual eOSState ProcessKey(eKeys Key);
eOSState ProcessKeyDetailView(eKeys Key);
diff --git a/plexgdm.cpp b/plexgdm.cpp
index c0d2cb0..c4e0ab1 100644
--- a/plexgdm.cpp
+++ b/plexgdm.cpp
@@ -40,7 +40,7 @@ namespace plexclient {
"Port: " + c_port + "\r\n"
"Product: " + c_product + "\r\n"
"Protocol: plex\r\n"
- "Protocol-Capabilities: navigation,playback,timeline\r\n"
+ "Protocol-Capabilities: navigation,playback,timeline,mirror\r\n"
"Protocol-Version: 1\r\n"
"Version: " + c_version + "\r\n";
_clientId = c_id;