summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-22 01:53:39 +0000
committerwez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-22 01:53:39 +0000
commit87196ce1202e3fdbaff773b40374995f8a14aca3 (patch)
tree71c696306305596a3ae31230dc9628c6fc8a5cbb
parent6be0c2a3d8906f07f98a55212633c91c913b0d6f (diff)
downloadchromium_src-87196ce1202e3fdbaff773b40374995f8a14aca3.zip
chromium_src-87196ce1202e3fdbaff773b40374995f8a14aca3.tar.gz
chromium_src-87196ce1202e3fdbaff773b40374995f8a14aca3.tar.bz2
Add VP9 decode support to the remoting client.
BUG=260879 Review URL: https://codereview.chromium.org/26921005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230003 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/client/rectangle_update_decoder.cc2
-rw-r--r--remoting/codec/video_decoder_vpx.cc20
-rw-r--r--remoting/codec/video_decoder_vpx.h3
-rw-r--r--remoting/codec/video_encoder_vpx.cc5
-rw-r--r--remoting/codec/video_encoder_vpx.h3
-rw-r--r--remoting/host/chromoting_host.cc4
-rw-r--r--remoting/host/plugin/host_script_object.cc5
-rw-r--r--remoting/proto/video.proto1
-rw-r--r--remoting/protocol/content_description.cc1
-rw-r--r--remoting/protocol/session_config.cc21
-rw-r--r--remoting/protocol/session_config.h5
-rw-r--r--remoting/protocol/video_reader.cc3
12 files changed, 68 insertions, 5 deletions
diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc
index 53541b7..3482527 100644
--- a/remoting/client/rectangle_update_decoder.cc
+++ b/remoting/client/rectangle_update_decoder.cc
@@ -102,6 +102,8 @@ void RectangleUpdateDecoder::Initialize(const SessionConfig& config) {
decoder_.reset(new VideoDecoderVerbatim());
} else if (codec == ChannelConfig::CODEC_VP8) {
decoder_ = VideoDecoderVpx::CreateForVP8();
+ } else if (codec == ChannelConfig::CODEC_VP9) {
+ decoder_ = VideoDecoderVpx::CreateForVP9();
} else {
NOTREACHED() << "Invalid Encoding found: " << codec;
}
diff --git a/remoting/codec/video_decoder_vpx.cc b/remoting/codec/video_decoder_vpx.cc
index ba65e88..156c233 100644
--- a/remoting/codec/video_decoder_vpx.cc
+++ b/remoting/codec/video_decoder_vpx.cc
@@ -61,6 +61,26 @@ scoped_ptr<VideoDecoderVpx> VideoDecoderVpx::CreateForVP8() {
return scoped_ptr<VideoDecoderVpx>(new VideoDecoderVpx(codec.Pass()));
}
+// static
+scoped_ptr<VideoDecoderVpx> VideoDecoderVpx::CreateForVP9() {
+ ScopedVpxCodec codec(new vpx_codec_ctx_t);
+
+ // TODO(hclam): Scale the number of threads with number of cores of the
+ // machine.
+ vpx_codec_dec_cfg config;
+ config.w = 0;
+ config.h = 0;
+ config.threads = 2;
+ vpx_codec_err_t ret =
+ vpx_codec_dec_init(codec.get(), vpx_codec_vp9_dx(), &config, 0);
+ if (ret != VPX_CODEC_OK) {
+ LOG(INFO) << "Cannot initialize codec.";
+ return scoped_ptr<VideoDecoderVpx>();
+ }
+
+ return scoped_ptr<VideoDecoderVpx>(new VideoDecoderVpx(codec.Pass()));
+}
+
VideoDecoderVpx::~VideoDecoderVpx() {}
void VideoDecoderVpx::Initialize(const webrtc::DesktopSize& screen_size) {
diff --git a/remoting/codec/video_decoder_vpx.h b/remoting/codec/video_decoder_vpx.h
index 800c873..3f2fcfb 100644
--- a/remoting/codec/video_decoder_vpx.h
+++ b/remoting/codec/video_decoder_vpx.h
@@ -18,8 +18,9 @@ namespace remoting {
class VideoDecoderVpx : public VideoDecoder {
public:
- // Creates a decoder for VP8.
+ // Create decoders for the specified protocol.
static scoped_ptr<VideoDecoderVpx> CreateForVP8();
+ static scoped_ptr<VideoDecoderVpx> CreateForVP9();
virtual ~VideoDecoderVpx();
diff --git a/remoting/codec/video_encoder_vpx.cc b/remoting/codec/video_encoder_vpx.cc
index 6c39d47..02df60b 100644
--- a/remoting/codec/video_encoder_vpx.cc
+++ b/remoting/codec/video_encoder_vpx.cc
@@ -197,6 +197,11 @@ bool VideoEncoderVpx::Initialize(const webrtc::DesktopSize& size) {
image_->d_h = size.height();
image_->h = size.height();
+ // libvpx should derive this from|fmt| but currently has a bug:
+ // https://code.google.com/p/webm/issues/detail?id=627
+ image_->x_chroma_shift = 1;
+ image_->y_chroma_shift = 1;
+
// Initialize active map.
active_map_width_ = (image_->w + kMacroBlockSize - 1) / kMacroBlockSize;
active_map_height_ = (image_->h + kMacroBlockSize - 1) / kMacroBlockSize;
diff --git a/remoting/codec/video_encoder_vpx.h b/remoting/codec/video_encoder_vpx.h
index 2e76532..f847bb5 100644
--- a/remoting/codec/video_encoder_vpx.h
+++ b/remoting/codec/video_encoder_vpx.h
@@ -18,10 +18,9 @@ class DesktopSize;
namespace remoting {
-// A class that uses VP8 to perform encoding.
class VideoEncoderVpx : public VideoEncoder {
public:
- // Creates a encoder for VP8.
+ // Create encoder for the specified protocol.
static scoped_ptr<VideoEncoderVpx> CreateForVP8();
virtual ~VideoEncoderVpx();
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index d7780f1..80cd8b5 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -86,6 +86,10 @@ ChromotingHost::ChromotingHost(
DCHECK(network_task_runner_->BelongsToCurrentThread());
DCHECK(signal_strategy);
+ // VP9 encode is not yet supported.
+ protocol::CandidateSessionConfig::DisableVideoCodec(
+ protocol_config_.get(), protocol::ChannelConfig::CODEC_VP9);
+
if (!desktop_environment_factory_->SupportsAudioCapture()) {
protocol::CandidateSessionConfig::DisableAudioChannel(
protocol_config_.get());
diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc
index ddcb1cb..3459bf8 100644
--- a/remoting/host/plugin/host_script_object.cc
+++ b/remoting/host/plugin/host_script_object.cc
@@ -380,6 +380,11 @@ void HostNPScriptObject::It2MeImpl::FinishConnect() {
scoped_ptr<protocol::CandidateSessionConfig> protocol_config =
protocol::CandidateSessionConfig::CreateDefault();
protocol::CandidateSessionConfig::DisableAudioChannel(protocol_config.get());
+
+ // VP9 encode is not yet supported.
+ protocol::CandidateSessionConfig::DisableVideoCodec(
+ protocol_config.get(), protocol::ChannelConfig::CODEC_VP9);
+
host_->set_protocol_config(protocol_config.Pass());
// Create event logger.
diff --git a/remoting/proto/video.proto b/remoting/proto/video.proto
index 0ee5c97..95998be 100644
--- a/remoting/proto/video.proto
+++ b/remoting/proto/video.proto
@@ -17,6 +17,7 @@ message VideoPacketFormat {
ENCODING_VERBATIM = 0;
ENCODING_ZLIB = 1;
ENCODING_VP8 = 2;
+ ENCODING_VP9 = 3;
};
// The encoding used for this image update.
diff --git a/remoting/protocol/content_description.cc b/remoting/protocol/content_description.cc
index e2c2c86..7a2db7d 100644
--- a/remoting/protocol/content_description.cc
+++ b/remoting/protocol/content_description.cc
@@ -47,6 +47,7 @@ const NameMapElement<ChannelConfig::TransportType> kTransports[] = {
const NameMapElement<ChannelConfig::Codec> kCodecs[] = {
{ ChannelConfig::CODEC_VERBATIM, "verbatim" },
{ ChannelConfig::CODEC_VP8, "vp8" },
+ { ChannelConfig::CODEC_VP9, "vp9" },
{ ChannelConfig::CODEC_ZIP, "zip" },
{ ChannelConfig::CODEC_OPUS, "opus" },
{ ChannelConfig::CODEC_SPEEX, "speex" },
diff --git a/remoting/protocol/session_config.cc b/remoting/protocol/session_config.cc
index 7e3100a..bee25d0 100644
--- a/remoting/protocol/session_config.cc
+++ b/remoting/protocol/session_config.cc
@@ -195,6 +195,10 @@ scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() {
result->mutable_video_configs()->push_back(
ChannelConfig(ChannelConfig::TRANSPORT_STREAM,
kDefaultStreamVersion,
+ ChannelConfig::CODEC_VP9));
+ result->mutable_video_configs()->push_back(
+ ChannelConfig(ChannelConfig::TRANSPORT_STREAM,
+ kDefaultStreamVersion,
ChannelConfig::CODEC_VP8));
// Audio channel.
@@ -209,10 +213,25 @@ scoped_ptr<CandidateSessionConfig> CandidateSessionConfig::CreateDefault() {
// static
void CandidateSessionConfig::DisableAudioChannel(
- CandidateSessionConfig* config) {
+ CandidateSessionConfig* config) {
config->mutable_audio_configs()->clear();
config->mutable_audio_configs()->push_back(ChannelConfig());
}
+// static
+void CandidateSessionConfig::DisableVideoCodec(
+ CandidateSessionConfig* config,
+ ChannelConfig::Codec codec) {
+ std ::vector<ChannelConfig>::iterator i;
+ for (i = config->mutable_video_configs()->begin();
+ i != config->mutable_video_configs()->end();) {
+ if (i->codec == codec) {
+ i = config->mutable_video_configs()->erase(i);
+ } else {
+ ++i;
+ }
+ }
+}
+
} // namespace protocol
} // namespace remoting
diff --git a/remoting/protocol/session_config.h b/remoting/protocol/session_config.h
index ac5f0c1..b3fa90a 100644
--- a/remoting/protocol/session_config.h
+++ b/remoting/protocol/session_config.h
@@ -32,6 +32,7 @@ struct ChannelConfig {
CODEC_VERBATIM,
CODEC_ZIP,
CODEC_VP8,
+ CODEC_VP9,
CODEC_OPUS,
CODEC_SPEEX,
};
@@ -157,8 +158,10 @@ class CandidateSessionConfig {
const SessionConfig& config);
static scoped_ptr<CandidateSessionConfig> CreateDefault();
- // Helper method that modifies |config| to disable audio support.
+ // Modifies |config| to disable specific features.
static void DisableAudioChannel(CandidateSessionConfig* config);
+ static void DisableVideoCodec(CandidateSessionConfig* config,
+ ChannelConfig::Codec codec);
private:
CandidateSessionConfig();
diff --git a/remoting/protocol/video_reader.cc b/remoting/protocol/video_reader.cc
index 8fd3afe5..0dfa10a 100644
--- a/remoting/protocol/video_reader.cc
+++ b/remoting/protocol/video_reader.cc
@@ -19,6 +19,9 @@ scoped_ptr<VideoReader> VideoReader::Create(const SessionConfig& config) {
if (video_config.codec == ChannelConfig::CODEC_VP8) {
return scoped_ptr<VideoReader>(
new ProtobufVideoReader(VideoPacketFormat::ENCODING_VP8));
+ } else if (video_config.codec == ChannelConfig::CODEC_VP9) {
+ return scoped_ptr<VideoReader>(
+ new ProtobufVideoReader(VideoPacketFormat::ENCODING_VP9));
} else if (video_config.codec == ChannelConfig::CODEC_ZIP) {
return scoped_ptr<VideoReader>(
new ProtobufVideoReader(VideoPacketFormat::ENCODING_ZLIB));