summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchriszero <zerov83@gmail.com>2015-02-10 21:13:51 +0100
committerchriszero <zerov83@gmail.com>2015-02-10 21:13:51 +0100
commit158d1055599205ccca462f97c190994fa28af8f0 (patch)
tree02c5645bf48595d182eeb2dee81884173d634a03
parent9b62917c4da85e5ec403792fd9a198b1cb005013 (diff)
downloadvdr-plugin-plex-158d1055599205ccca462f97c190994fa28af8f0.tar.gz
vdr-plugin-plex-158d1055599205ccca462f97c190994fa28af8f0.tar.bz2
Support for Plex Channels (Youtube, Vimeo, ZDF Mediathek, etc...)
-rw-r--r--PlexHTTPRequestHandler.cpp22
-rw-r--r--Plexservice.cpp4
-rw-r--r--hlsPlayer.cpp17
-rw-r--r--hlsPlayerControl.cpp14
4 files changed, 29 insertions, 28 deletions
diff --git a/PlexHTTPRequestHandler.cpp b/PlexHTTPRequestHandler.cpp
index 90e8f69..f07bce4 100644
--- a/PlexHTTPRequestHandler.cpp
+++ b/PlexHTTPRequestHandler.cpp
@@ -44,9 +44,9 @@ std::map<std::string, std::string> PlexHTTPRequestHandler::ParseQuery(std::strin
{
std::map<std::string, std::string> querymap;
Poco::StringTokenizer queryTokens(query, "&");
- for(Poco::StringTokenizer::Iterator token = queryTokens.begin(); token != queryTokens.end(); ++token) {
- Poco::StringTokenizer subTokens(*token, "=");
- querymap[subTokens[0]] = subTokens[1];
+ for(Poco::StringTokenizer::Iterator token = queryTokens.begin(); token != queryTokens.end(); token++) {
+ int pos = token->find("=");
+ querymap[token->substr(0, pos)] = token->substr(pos+1, std::string::npos);
}
return querymap;
}
@@ -207,7 +207,7 @@ void PlayerRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request,
cRemote::Put(kBack);
}
response.send() << GetOKMsg();
-
+
} else if(request.getURI().find("/playback") != std::string::npos) {
if(request.getURI().find("/playback/seekTo") != std::string::npos) {
cHlsPlayerControl* control = dynamic_cast<cHlsPlayerControl*>(cControl::Control(true));
@@ -224,9 +224,9 @@ void PlayerRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request,
std::string address = query["address"];
std::string port = query["port"];
std::string key = query["key"];
-
+
std::string fullUrl = protocol + "://" + address + ":" + port + key; // Metainfo
-
+ std::cout << fullUrl << std::endl;
MediaContainer* pCont = Plexservice::GetMediaContainer(fullUrl);
// MUSS im Maintread des Plugins/VDR gestartet werden
@@ -235,11 +235,11 @@ void PlayerRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request,
}
ActionManager::GetInstance().AddAction(&pCont->m_vVideos[0]); // MemoryLeak?
} else if(request.getURI().find("/playback/play") != std::string::npos) {
- cRemote::Put(kPlay);
+ cRemote::Put(kPlay);
} else if(request.getURI().find("/playback/pause") != std::string::npos) {
- cRemote::Put(kPause);
+ cRemote::Put(kPause);
} else if(request.getURI().find("/playback/stop") != std::string::npos) {
- cRemote::Put(kStop);
+ cRemote::Put(kStop);
} else if(request.getURI().find("/playback/stepForward") != std::string::npos) {
cHlsPlayerControl* control = dynamic_cast<cHlsPlayerControl*>(cControl::Control(true));
if(control) {
@@ -257,11 +257,11 @@ void PlayerRequestHandler::handleRequest(Poco::Net::HTTPServerRequest& request,
} else if(request.getURI().find("/playback/skipPrevious") != std::string::npos) {
cRemote::Put(kFastRew);
}
-
+
SubscriptionManager::GetInstance().Notify();
response.send() << GetOKMsg();
}
-
+
} catch(Poco::Exception& e) {
std::cerr << e.displayText() << std::endl;
}
diff --git a/Plexservice.cpp b/Plexservice.cpp
index f156550..c5e028a 100644
--- a/Plexservice.cpp
+++ b/Plexservice.cpp
@@ -184,7 +184,7 @@ MediaContainer* Plexservice::GetMediaContainer(std::string fullUrl)
Poco::URI fileuri(fullUrl);
Poco::Net::HTTPRequest* pRequest = new Poco::Net::HTTPRequest(Poco::Net::HTTPRequest::HTTP_GET,
- fileuri.getPath(), Poco::Net::HTTPMessage::HTTP_1_1);
+ fileuri.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
pRequest->add("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.52 Safari/537.17");
@@ -205,8 +205,6 @@ MediaContainer* Plexservice::GetMediaContainer(std::string fullUrl)
Poco::Net::HTTPResponse response;
std::istream &rs = session->receiveResponse(response);
- //std::cout << "URI: " << session->getHost() << "[" << pRequest->getURI() << "]" << std::endl;
-
MediaContainer* pAllsections = new MediaContainer(&rs, new PlexServer(fileuri.getHost(), fileuri.getPort()));
delete pRequest;
diff --git a/hlsPlayer.cpp b/hlsPlayer.cpp
index 8feb8f0..96c0f55 100644
--- a/hlsPlayer.cpp
+++ b/hlsPlayer.cpp
@@ -75,13 +75,14 @@ void cHlsSegmentLoader::Action(void)
isyslog("[plex] Ringbuffer Cleared, loading new segments");
hlsMutex.Unlock();
}
- if (!DoLoad()) {
- isyslog("[plex] No further segments to load");
- StopLoader();
+ if (!DoLoad() && m_pRingbuffer->Available() < TS_SIZE) {
+ isyslog("[plex] No further segments to load and buffer empty, end of stream!");
Cancel();
+
}
cCondWait::SleepMs(3);
}
+ StopLoader();
}
bool cHlsSegmentLoader::LoadLists(void)
@@ -348,7 +349,7 @@ void cHlsSegmentLoader::ResizeRingbuffer(int newsize)
hlsMutex.Lock();
isyslog("[plex] %s, Oldsize: %d, Newsize: %d", __FUNCTION__, m_ringBufferSize, newsize);
//Create new Ringbuffer
- cRingBufferLinear* newBuffer = new cRingBufferLinear(newsize, 2*TS_SIZE);
+ cRingBufferLinear* newBuffer = new cRingBufferLinear(newsize, TS_SIZE);
// Copy old data
int count = 0;
uchar* pData = m_pRingbuffer->Get(count);
@@ -622,14 +623,12 @@ void cHlsPlayer::ReportProgress(bool stopped)
std::string state;
if(stopped) {
state = "stopped";
- }
- else if (playMode == pmPlay) {
+ } else if (playMode == pmPlay) {
state = "playing";
- }
- else {
+ } else {
state = "paused";
}
-
+
Poco::Net::HTTPClientSession session(m_pVideo->m_pServer->GetIpAdress(), m_pVideo->m_pServer->GetPort());
std::string uri = "/:/progress?key=" + std::string(itoa(m_pVideo->m_iRatingKey)) + "&identifier=com.plexapp.plugins.library&time=" + std::string(itoa(GetPlayedSeconds()*1000)) + "&state=" + state;
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, uri);
diff --git a/hlsPlayerControl.cpp b/hlsPlayerControl.cpp
index b76fb63..dff1a30 100644
--- a/hlsPlayerControl.cpp
+++ b/hlsPlayerControl.cpp
@@ -12,9 +12,9 @@ cControl* cHlsPlayerControl::Create(plexclient::Video* Video)
{
if(!Video->m_pServer)
return NULL;
-
+
// Stop already playing stream
- cHlsPlayerControl* c = dynamic_cast<cHlsPlayerControl*>(cControl::Control(true));
+ cHlsPlayerControl* c = dynamic_cast<cHlsPlayerControl*>(cControl::Control(true));
if(c) {
c->Stop();
}
@@ -207,13 +207,13 @@ void cHlsPlayerControl::SeekTo(int offset)
void cHlsPlayerControl::JumpRelative(int offset)
{
- if (player)
+ if (player)
player->JumpRelative(offset);
}
void cHlsPlayerControl::ShowMode(void)
{
- //dsyslog("[plex]: '%s'\n", __FUNCTION__);
+ dsyslog("[plex]: '%s'\n", __FUNCTION__);
if (visible || Setup.ShowReplayMode && !cOsd::IsOpen()) {
bool Play, Forward;
int Speed;
@@ -241,7 +241,7 @@ bool cHlsPlayerControl::ShowProgress(bool Initial)
{
int Current, Total;
- if (GetIndex(Current, Total) && Total > 0) {
+ if (GetIndex(Current, Total)) {
if (!visible) {
displayReplay = Skins.Current()->DisplayReplay(modeOnly);
//displayReplay->SetMarks(player->Marks());
@@ -256,10 +256,14 @@ bool cHlsPlayerControl::ShowProgress(bool Initial)
int Index = Total;
if (Setup.ShowRemainingTime)
Index = Current - Index;
+ if(Total == 0) // Webstreams
+ Index = Current;
displayReplay->SetTotal(IndexToHMSF(Index, false, FramesPerSecond()));
if (!Initial)
displayReplay->Flush();
}
+ if(Total == 0) // Webstreams
+ Total = Current;
displayReplay->SetProgress(Current, Total);
if (!Initial)
displayReplay->Flush();