Skip to content

Commit

Permalink
Client-side changes to support requesting lossless encode & color.
Browse files Browse the repository at this point in the history
This adds setLosslessEncode() and setLosslessColor() calls to the
ClientPlugin API, which future updates to the app can use to request
lossless frames if desired.

BUG=260879,134202

Review URL: https://codereview.chromium.org/307463005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273995 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
wez@chromium.org committed May 31, 2014
1 parent 7790f9d commit 43ab14c
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
27 changes: 22 additions & 5 deletions remoting/client/plugin/chromoting_instance.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,8 @@ logging::LogMessageHandlerFunction g_logging_old_handler = NULL;
const char ChromotingInstance::kApiFeatures[] =
"highQualityScaling injectKeyEvent sendClipboardItem remapKey trapKey "
"notifyClientResolution pauseVideo pauseAudio asyncPin thirdPartyAuth "
"pinlessAuth extensionMessage allowMouseLock mediaSourceRendering";
"pinlessAuth extensionMessage allowMouseLock mediaSourceRendering "
"videoControl";

const char ChromotingInstance::kRequestedCapabilities[] = "";
const char ChromotingInstance::kSupportedCapabilities[] = "desktopShape";
Expand Down Expand Up @@ -350,6 +351,8 @@ void ChromotingInstance::HandleMessage(const pp::Var& message) {
HandleNotifyClientResolution(*data);
} else if (method == "pauseVideo") {
HandlePauseVideo(*data);
} else if (method == "videoControl") {
HandleVideoControl(*data);
} else if (method == "pauseAudio") {
HandlePauseAudio(*data);
} else if (method == "useAsyncPinDialog") {
Expand Down Expand Up @@ -874,16 +877,30 @@ void ChromotingInstance::HandleNotifyClientResolution(
}

void ChromotingInstance::HandlePauseVideo(const base::DictionaryValue& data) {
bool pause = false;
if (!data.GetBoolean("pause", &pause)) {
if (!data.HasKey("pause")) {
LOG(ERROR) << "Invalid pauseVideo.";
return;
}
HandleVideoControl(data);
}

void ChromotingInstance::HandleVideoControl(const base::DictionaryValue& data) {
protocol::VideoControl video_control;
bool pause_video = false;
if (data.GetBoolean("pause", &pause_video)) {
video_control.set_enable(!pause_video);
}
bool lossless_encode = false;
if (data.GetBoolean("losslessEncode", &lossless_encode)) {
video_control.set_lossless_encode(lossless_encode);
}
bool lossless_color = false;
if (data.GetBoolean("losslessColor", &lossless_color)) {
video_control.set_lossless_color(lossless_color);
}
if (!IsConnected()) {
return;
}
protocol::VideoControl video_control;
video_control.set_enable(!pause);
host_connection_->host_stub()->ControlVideo(video_control);
}

Expand Down
1 change: 1 addition & 0 deletions remoting/client/plugin/chromoting_instance.h
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ class ChromotingInstance :
void HandleSendClipboardItem(const base::DictionaryValue& data);
void HandleNotifyClientResolution(const base::DictionaryValue& data);
void HandlePauseVideo(const base::DictionaryValue& data);
void HandleVideoControl(const base::DictionaryValue& data);
void HandlePauseAudio(const base::DictionaryValue& data);
void HandleOnPinFetched(const base::DictionaryValue& data);
void HandleOnThirdPartyTokenFetched(const base::DictionaryValue& data);
Expand Down
41 changes: 36 additions & 5 deletions remoting/webapp/client_plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ remoting.ClientPlugin.Feature = {
TRAP_KEY: 'trapKey',
PINLESS_AUTH: 'pinlessAuth',
EXTENSION_MESSAGE: 'extensionMessage',
MEDIA_SOURCE_RENDERING: 'mediaSourceRendering'
MEDIA_SOURCE_RENDERING: 'mediaSourceRendering',
VIDEO_CONTROL: 'videoControl'
};

/**
Expand Down Expand Up @@ -548,11 +549,13 @@ remoting.ClientPlugin.prototype.notifyClientResolution =
*/
remoting.ClientPlugin.prototype.pauseVideo =
function(pause) {
if (!this.hasFeature(remoting.ClientPlugin.Feature.PAUSE_VIDEO)) {
return;
if (this.hasFeature(remoting.ClientPlugin.Feature.VIDEO_CONTROL)) {
this.plugin.postMessage(JSON.stringify(
{ method: 'videoControl', data: { pause: pause }}));
} else if (this.hasFeature(remoting.ClientPlugin.Feature.PAUSE_VIDEO)) {
this.plugin.postMessage(JSON.stringify(
{ method: 'pauseVideo', data: { pause: pause }}));
}
this.plugin.postMessage(JSON.stringify(
{ method: 'pauseVideo', data: { pause: pause }}));
};

/**
Expand All @@ -569,6 +572,34 @@ remoting.ClientPlugin.prototype.pauseAudio =
{ method: 'pauseAudio', data: { pause: pause }}));
};

/**
* Requests that the host configure the video codec for lossless encode.
*
* @param {boolean} wantLossless True to request lossless encoding.
*/
remoting.ClientPlugin.prototype.setLosslessEncode =
function(wantLossless) {
if (!this.hasFeature(remoting.ClientPlugin.Feature.VIDEO_CONTROL)) {
return;
}
this.plugin.postMessage(JSON.stringify(
{ method: 'videoControl', data: { losslessEncode: wantLossless }}));
};

/**
* Requests that the host configure the video codec for lossless color.
*
* @param {boolean} wantLossless True to request lossless color.
*/
remoting.ClientPlugin.prototype.setLosslessColor =
function(wantLossless) {
if (!this.hasFeature(remoting.ClientPlugin.Feature.VIDEO_CONTROL)) {
return;
}
this.plugin.postMessage(JSON.stringify(
{ method: 'videoControl', data: { losslessColor: wantLossless }}));
};

/**
* Called when a PIN is obtained from the user.
*
Expand Down

0 comments on commit 43ab14c

Please sign in to comment.