diff --git a/index.html b/index.html index 3a1a69a..217de20 100644 --- a/index.html +++ b/index.html @@ -19,7 +19,7 @@ +
@@ -28,9 +28,8 @@
diff --git a/main.cpp b/main.cpp index 5c2405d..1245725 100644 --- a/main.cpp +++ b/main.cpp @@ -135,11 +135,37 @@ void MoonlightInstance::HandleMessage(const pp::Var& var_message) { } } +void split(const std::string& s, char c, std::vector& v) { + std::string::size_type i = 0; + std::string::size_type j = s.find(c); + + while (j != std::string::npos) { + v.push_back(s.substr(i, j-i)); + i = ++j; + j = s.find(c, j); + + if (j == std::string::npos) v.push_back(s.substr(i, s.length())); + } + +} + void MoonlightInstance::handleStartStream(std::string startStreamMessage) { + // request:host:width:height:fps:bitrate + std::vector splitString; + split(startStreamMessage, ':', splitString); + + pp::Var response("Setting stream width to: " + splitString.at(2)); + PostMessage(response); + response = ("Setting stream height to: " + splitString.at(3)); + PostMessage(response); + response = ("Setting stream fps to: " + splitString.at(4)); + PostMessage(response); + response = ("Setting stream host to: " + splitString.at(1)); + PostMessage(response); // Populate the stream configuration - m_StreamConfig.width = 1280; - m_StreamConfig.height = 720; - m_StreamConfig.fps = 60; + m_StreamConfig.width = stoi(splitString.at(2)); + m_StreamConfig.height = stoi(splitString.at(3)); + m_StreamConfig.fps = stoi(splitString.at(4)); m_StreamConfig.bitrate = 15000; // kilobits per second m_StreamConfig.packetSize = 1024; m_StreamConfig.streamingRemotely = 0; @@ -148,7 +174,7 @@ void MoonlightInstance::handleStartStream(std::string startStreamMessage) { m_ServerMajorVersion = 4; // Store the host from the start message - m_Host = startStreamMessage.substr(strlen(MSG_START_REQUEST)); + m_Host = splitString.at(1); // Start the worker thread to establish the connection pthread_create(&m_ConnectionThread, NULL, MoonlightInstance::ConnectionThreadFunc, this); diff --git a/static/js/index.js b/static/js/index.js index 181ffc0..46551f3 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -63,7 +63,10 @@ function startPushed() { var e = document.getElementById("selectHost"); target = e.options[e.selectedIndex].value; } - common.naclModule.postMessage('startRequest:' + target); + var frameRate = document.getElementById('selectFramerate').value; + var resolution = document.getElementById('selectResolution').value; + console.log('startRequest:' + target + ":" + resolution + ":" + frameRate); + common.naclModule.postMessage('startRequest:' + target + ":" + resolution + ":" + frameRate + ":"); // we just finished the gameSelection section. only expose the NaCl section playGameMode(); } @@ -133,7 +136,7 @@ function readData(key, callbackFunction) { } function loadResolution(previousValue) { - document.getElementById('selectResolution').value = previousValue.resolution != null ? previousValue.resolution : '720'; + document.getElementById('selectResolution').value = previousValue.resolution != null ? previousValue.resolution : '1280:720'; } function saveResolution() {