mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Merge branch 'master' of github.com:abdallahsoliman/moonlight-chrome
This commit is contained in:
commit
e269b73bd3
@ -23,6 +23,11 @@ static int ConvertPPButtonToLiButton(PP_InputEvent_MouseButton ppButton) {
|
||||
|
||||
void MoonlightInstance::DidLockMouse(int32_t result) {
|
||||
m_MouseLocked = (result == PP_OK);
|
||||
if (m_MouseLocked) {
|
||||
// Request an IDR frame to dump the frame queue that may have
|
||||
// built up from the GL pipeline being stalled.
|
||||
g_Instance->m_RequestIdrFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MoonlightInstance::MouseLockLost() {
|
||||
|
@ -53,6 +53,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
||||
pp::MouseLock(this),
|
||||
m_HasNextPicture(false),
|
||||
m_IsPainting(false),
|
||||
m_RequestIdrFrame(false),
|
||||
m_OpusDecoder(NULL),
|
||||
m_CallbackFactory(this),
|
||||
m_MouseLocked(false),
|
||||
@ -122,6 +123,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
||||
void PictureReady(int32_t result, PP_VideoPicture picture);
|
||||
void PaintPicture(void);
|
||||
void InitializeRenderingSurface(int width, int height);
|
||||
void DidChangeFocus(bool got_focus);
|
||||
|
||||
static void VidDecSetup(int videoFormat, int width, int height, int redrawRate, void* context, int drFlags);
|
||||
static void VidDecCleanup(void);
|
||||
@ -159,6 +161,7 @@ class MoonlightInstance : public pp::Instance, public pp::MouseLock {
|
||||
bool m_HasNextPicture;
|
||||
PP_VideoPicture m_CurrentPicture;
|
||||
bool m_IsPainting;
|
||||
bool m_RequestIdrFrame;
|
||||
|
||||
OpusMSDecoder* m_OpusDecoder;
|
||||
pp::Audio m_AudioPlayer;
|
||||
|
@ -3,6 +3,7 @@ var hosts = [];
|
||||
var pairingCert;
|
||||
var myUniqueid;
|
||||
var api;
|
||||
var relaunchSourceEvent;
|
||||
|
||||
// Called by the common.js module.
|
||||
function attachListeners() {
|
||||
@ -104,14 +105,14 @@ function pairTo(host, onSuccess, onFailure) {
|
||||
snackbarLog('ERROR: cert has not been generated yet. Is NaCl initialized?');
|
||||
console.log("User wants to pair, and we still have no cert. Problem = very yes.");
|
||||
onFailure();
|
||||
return;
|
||||
}
|
||||
|
||||
if(!api) {
|
||||
api = new NvHTTP(host, myUniqueid);
|
||||
}
|
||||
|
||||
if(api.paired) {
|
||||
api.refreshServerInfo().then(function (ret) {
|
||||
if (api.paired) {
|
||||
onSuccess();
|
||||
return;
|
||||
}
|
||||
|
||||
var randomNumber = String("0000" + (Math.random()*10000|0)).slice(-4);
|
||||
@ -128,26 +129,21 @@ function pairTo(host, onSuccess, onFailure) {
|
||||
$('#pairingDialogText').html('Error: failed to pair with ' + host + '. failure reason unknown.');
|
||||
}
|
||||
onFailure();
|
||||
return;
|
||||
}
|
||||
|
||||
snackbarLog('Pairing successful');
|
||||
pairingDialog.close();
|
||||
|
||||
var cell = document.createElement('div');
|
||||
cell.className += 'mdl-cell mdl-cell--3-col';
|
||||
cell.id = 'hostgrid-' + hosts[i];
|
||||
cell.innerHTML = hosts[i];
|
||||
$('#host-grid').append(cell);
|
||||
cell.onclick = hostChosen;
|
||||
|
||||
saveHosts();
|
||||
onSuccess();
|
||||
|
||||
}, function (failedPairing) {
|
||||
snackbarLog('Failed pairing to: ' + host);
|
||||
console.log('pairing failed, and returned ' + failedPairing);
|
||||
onFailure();
|
||||
});
|
||||
}, function (failedRefreshInfo) {
|
||||
snackbarLog('Failed to connect to ' + host + '! Are you sure the host is on?');
|
||||
console.log('Returned error was: ' + failedRefreshInfo);
|
||||
});
|
||||
}
|
||||
|
||||
function hostChosen(sourceEvent) {
|
||||
@ -157,24 +153,13 @@ function hostChosen(sourceEvent) {
|
||||
host = sourceEvent.srcElement.innerText;
|
||||
}
|
||||
|
||||
|
||||
if(!api || api.address != host) {
|
||||
api = new NvHTTP(host, myUniqueid);
|
||||
}
|
||||
|
||||
api.refreshServerInfo().then(function (ret) {
|
||||
if(!api.paired) {
|
||||
pairTo(host);
|
||||
}
|
||||
if(hosts.indexOf(host) < 0) { // we don't have this host in our list. add it, and save it.
|
||||
var cell = document.createElement('div');
|
||||
cell.className += 'mdl-cell mdl-cell--3-col';
|
||||
cell.id = 'hostgrid-' + hosts[i];
|
||||
cell.innerHTML = hosts[i];
|
||||
$('#host-grid').append(cell);
|
||||
cell.onclick = hostChosen;
|
||||
}
|
||||
pairTo(host, function(){ showApps(); }, function(){});
|
||||
} else {
|
||||
showApps();
|
||||
}
|
||||
}, function (failedRefreshInfo) {
|
||||
snackbarLog('Failed to connect to ' + host + '! Are you sure the host is on?');
|
||||
console.log('Returned error was: ' + failedRefreshInfo);
|
||||
@ -192,14 +177,30 @@ function cancelAddHost() {
|
||||
document.querySelector('#addHostDialog').close();
|
||||
}
|
||||
|
||||
function addHostToGrid(host) {
|
||||
if(hosts.indexOf(host) < 0) { // we don't have this host in our list. add it, and save it.
|
||||
var cell = document.createElement('div');
|
||||
cell.className += 'mdl-cell mdl-cell--3-col';
|
||||
cell.id = 'hostgrid-' + host;
|
||||
cell.innerHTML = host;
|
||||
$('#host-grid').append(cell);
|
||||
cell.onclick = hostChosen;
|
||||
hosts.push(host);
|
||||
saveHosts();
|
||||
}
|
||||
}
|
||||
|
||||
function continueAddHost() {
|
||||
var inputHost = $('#dialogInputHost').val();
|
||||
|
||||
pairTo(inputHost,
|
||||
function() { document.querySelector('#addHostDialog').close() },
|
||||
function() {snackbarLog('pairing to ' + inputHost + ' failed!');}
|
||||
);
|
||||
|
||||
function() {
|
||||
addHostToGrid(inputHost);
|
||||
document.querySelector('#addHostDialog').close();
|
||||
},
|
||||
function() {
|
||||
snackbarLog('pairing to ' + inputHost + ' failed!');
|
||||
});
|
||||
}
|
||||
|
||||
// locally remove the hostname/ip from the saved `hosts` array.
|
||||
@ -224,14 +225,10 @@ function showApps() {
|
||||
return;
|
||||
}
|
||||
|
||||
api.getAppList().then(function (appList) {
|
||||
|
||||
// if game grid is populated, empty it
|
||||
if($("#game-grid").children().length > 0) {
|
||||
$("#game-grid").empty();
|
||||
}
|
||||
|
||||
|
||||
api.getAppList().then(function (appList) {
|
||||
appList.forEach(function (app) {
|
||||
api.getBoxArt(app.id).then(function (resolvedPromise) {
|
||||
var imageBlob = new Blob([resolvedPromise], {type: "image/png"});
|
||||
@ -310,6 +307,10 @@ function startGame(sourceEvent) {
|
||||
api.refreshServerInfo().then(function (ret) {
|
||||
if(api.currentGame != 0 && api.currentGame != appID) {
|
||||
api.getAppById(api.currentGame).then(function (currentApp) {
|
||||
// This event gets saved and passed back to this callback
|
||||
// after the game is quit
|
||||
relaunchSourceEvent = sourceEvent;
|
||||
|
||||
var quitAppDialog = document.querySelector('#quitAppDialog');
|
||||
document.getElementById('quitAppDialogText').innerHTML =
|
||||
currentApp.title + ' is already running. Would you like to quit ' +
|
||||
@ -337,7 +338,7 @@ function startGame(sourceEvent) {
|
||||
$('#loadingMessage').text('Starting ' + appName + '...');
|
||||
playGameMode();
|
||||
|
||||
if(api.currentGame == appID) // if user wants to launch the already-running app, then we resume it.
|
||||
if(api.currentGame == appID) { // if user wants to launch the already-running app, then we resume it.
|
||||
return api.resumeApp(rikey, rikeyid).then(function (ret) {
|
||||
sendMessage('startRequest', [host, streamWidth, streamHeight, frameRate,
|
||||
bitrate.toString(), api.serverMajorVersion.toString(), rikey, rikeyid.toString()]);
|
||||
@ -346,6 +347,7 @@ function startGame(sourceEvent) {
|
||||
console.log('Returned error was: ' + failedResumeApp);
|
||||
return;
|
||||
});
|
||||
}
|
||||
|
||||
api.launchApp(appID,
|
||||
streamWidth + "x" + streamHeight + "x" + frameRate,
|
||||
@ -365,6 +367,7 @@ function startGame(sourceEvent) {
|
||||
}
|
||||
|
||||
function cancelQuitApp() {
|
||||
relaunchSourceEvent = null;
|
||||
document.querySelector('#quitAppDialog').close();
|
||||
console.log('closing app dialog, and returning');
|
||||
}
|
||||
@ -372,7 +375,18 @@ function cancelQuitApp() {
|
||||
function continueQuitApp(sourceEvent) {
|
||||
// I want the sourceEvent's sourceEvent
|
||||
console.log('stopping game, and closing app dialog, and returning');
|
||||
stopGame();
|
||||
stopGame(
|
||||
function() {
|
||||
if (relaunchSourceEvent != null) {
|
||||
// Save and null relaunchSourceEvent just in case startGame()
|
||||
// wants to set it again.
|
||||
var event = relaunchSourceEvent;
|
||||
relaunchSourceEvent = null;
|
||||
|
||||
startGame(event);
|
||||
}
|
||||
}
|
||||
);
|
||||
document.querySelector('#quitAppDialog').close();
|
||||
}
|
||||
|
||||
@ -408,7 +422,6 @@ function fullscreenNaclModule() {
|
||||
}
|
||||
|
||||
function stopGame(callbackFunction) {
|
||||
|
||||
api.refreshServerInfo().then(function (ret) {
|
||||
api.getAppById(api.currentGame).then(function (runningApp) {
|
||||
if (!runningApp) {
|
||||
@ -542,12 +555,7 @@ function onWindowLoad(){
|
||||
var ips = Object.keys(finder.byService_['_nvstream._tcp']);
|
||||
for (var ip in ips) {
|
||||
if (finder.byService_['_nvstream._tcp'][ip]) {
|
||||
var cell = document.createElement('div');
|
||||
cell.className += 'mdl-cell mdl-cell--3-col';
|
||||
cell.id = 'hostgrid-' + ip;
|
||||
cell.innerHTML = ip;
|
||||
$('#host-grid').append(cell);
|
||||
cell.onclick = hostChosen;
|
||||
addHostToGrid(ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ function handleMessage(msg) {
|
||||
if(msg.data === 'streamTerminated') { // if it's a recognized event, notify the appropriate function
|
||||
$('#loadingSpinner').css('display', 'none'); // This is a fallback for RTSP handshake failing, which immediately terminates the stream.
|
||||
api.refreshServerInfo().then(function (ret) {
|
||||
showAppsMode();
|
||||
showApps();
|
||||
chrome.app.window.current().restore();
|
||||
});
|
||||
} else if(msg.data === 'Connection Established') {
|
||||
|
@ -40,7 +40,6 @@ function NvHTTP(address, clientUid) {
|
||||
this.clientUid = clientUid;
|
||||
this._baseUrlHttps = 'https://' + address + ':47984';
|
||||
this._baseUrlHttp = 'http://' + address + ':47989';
|
||||
this._appListCache = null;
|
||||
this._memCachedBoxArtArray = {};
|
||||
_self = this;
|
||||
};
|
||||
@ -133,13 +132,6 @@ NvHTTP.prototype = {
|
||||
},
|
||||
|
||||
getAppList: function () {
|
||||
if (_self._appListCache) {
|
||||
console.log('Returning app list from cache');
|
||||
return new Promise(function (resolve, reject) {
|
||||
resolve(_self._appListCache);
|
||||
});
|
||||
}
|
||||
|
||||
return sendMessage('openUrl', [_self._baseUrlHttps + '/applist?' + _self._buildUidStr(), false]).then(function (ret) {
|
||||
$xml = _self._parseXML(ret);
|
||||
|
||||
@ -155,9 +147,6 @@ NvHTTP.prototype = {
|
||||
});
|
||||
}
|
||||
|
||||
if (appList)
|
||||
_self._appListCache = appList;
|
||||
|
||||
return appList;
|
||||
});
|
||||
},
|
||||
|
14
viddec.cpp
14
viddec.cpp
@ -62,6 +62,14 @@ static const char k_FragmentShaderExternal[] =
|
||||
" gl_FragColor = texture2D(s_texture, v_texCoord); \n"
|
||||
"}";
|
||||
|
||||
void MoonlightInstance::DidChangeFocus(bool got_focus) {
|
||||
// Request an IDR frame to dump the frame queue that may have
|
||||
// built up from the GL pipeline being stalled.
|
||||
if (got_focus) {
|
||||
g_Instance->m_RequestIdrFrame = true;
|
||||
}
|
||||
}
|
||||
|
||||
void MoonlightInstance::InitializeRenderingSurface(int width, int height) {
|
||||
if (!glInitializePPAPI(pp::Module::Get()->get_browser_interface())) {
|
||||
return;
|
||||
@ -231,6 +239,12 @@ int MoonlightInstance::VidDecSubmitDecodeUnit(PDECODE_UNIT decodeUnit) {
|
||||
bool isPps = false;
|
||||
bool isIframe = false;
|
||||
|
||||
// Request an IDR frame if needed
|
||||
if (g_Instance->m_RequestIdrFrame) {
|
||||
g_Instance->m_RequestIdrFrame = false;
|
||||
return DR_NEED_IDR;
|
||||
}
|
||||
|
||||
// Look at the NALU type
|
||||
if (decodeUnit->bufferList->length > 5) {
|
||||
switch (decodeUnit->bufferList->data[4]) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user