summaryrefslogtreecommitdiffstats
path: root/remoting/base
diff options
context:
space:
mode:
authorsimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-04 12:15:31 +0000
committersimonmorris@chromium.org <simonmorris@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-03-04 12:15:31 +0000
commite1a6c46256722e10c73a3ce6e210cf7b7dbb065f (patch)
treebcbbf08f932c7aa8a239d791d98ee9d93b5a02b1 /remoting/base
parentbcb343aa6775b6b473389c3dcf4d5946b7ae0107 (diff)
downloadchromium_src-e1a6c46256722e10c73a3ce6e210cf7b7dbb065f.zip
chromium_src-e1a6c46256722e10c73a3ce6e210cf7b7dbb065f.tar.gz
chromium_src-e1a6c46256722e10c73a3ce6e210cf7b7dbb065f.tar.bz2
Let the host change resolution.
The screen size flows through the video pipeline, instead of being set statically when that pipeline is constructed. Only the Windows host actually detects when the screen size has changed. BUG=72469 TEST=none Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=76747 Review URL: http://codereview.chromium.org/6573005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/base')
-rw-r--r--remoting/base/capture_data.h4
-rw-r--r--remoting/base/encoder_row_based.cc11
-rw-r--r--remoting/base/encoder_row_based.h4
-rw-r--r--remoting/base/encoder_vp8.cc64
-rw-r--r--remoting/base/encoder_vp8.h4
5 files changed, 57 insertions, 30 deletions
diff --git a/remoting/base/capture_data.h b/remoting/base/capture_data.h
index f399e70..dd6c4b9 100644
--- a/remoting/base/capture_data.h
+++ b/remoting/base/capture_data.h
@@ -38,6 +38,10 @@ class CaptureData : public base::RefCountedThreadSafe<CaptureData> {
// written into |rects|.
const InvalidRects& dirty_rects() const { return dirty_rects_; }
+ // TODO(simonmorris): The next two methods should be replaced by a
+ // gfx::Size size(), and objects that store that size should also
+ // use a gfx::Size to do so.
+
// Get the width of the image captured.
int width() const { return width_; }
diff --git a/remoting/base/encoder_row_based.cc b/remoting/base/encoder_row_based.cc
index e035a42..6159207a 100644
--- a/remoting/base/encoder_row_based.cc
+++ b/remoting/base/encoder_row_based.cc
@@ -42,6 +42,8 @@ EncoderRowBased::EncoderRowBased(Compressor* compressor,
VideoPacketFormat::Encoding encoding)
: encoding_(encoding),
compressor_(compressor),
+ screen_width_(0),
+ screen_height_(0),
packet_size_(kPacketSize) {
}
@@ -50,6 +52,8 @@ EncoderRowBased::EncoderRowBased(Compressor* compressor,
int packet_size)
: encoding_(encoding),
compressor_(compressor),
+ screen_width_(0),
+ screen_height_(0),
packet_size_(packet_size) {
}
@@ -147,6 +151,13 @@ void EncoderRowBased::PrepareUpdateStart(const gfx::Rect& rect,
format->set_width(rect.width());
format->set_height(rect.height());
format->set_encoding(encoding_);
+ if ((capture_data_->width() != screen_width_) ||
+ (capture_data_->height() != screen_height_)) {
+ screen_width_ = capture_data_->width();
+ screen_height_ = capture_data_->height();
+ format->set_screen_width(screen_width_);
+ format->set_screen_height(screen_height_);
+ }
}
uint8* EncoderRowBased::GetOutputBuffer(VideoPacket* packet, size_t size) {
diff --git a/remoting/base/encoder_row_based.h b/remoting/base/encoder_row_based.h
index b3b62d5..fe7f49c 100644
--- a/remoting/base/encoder_row_based.h
+++ b/remoting/base/encoder_row_based.h
@@ -61,6 +61,10 @@ class EncoderRowBased : public Encoder {
scoped_refptr<CaptureData> capture_data_;
scoped_ptr<DataAvailableCallback> callback_;
+ // The most recent screen size.
+ int screen_width_;
+ int screen_height_;
+
int packet_size_;
};
diff --git a/remoting/base/encoder_vp8.cc b/remoting/base/encoder_vp8.cc
index f2db413..8d09d544 100644
--- a/remoting/base/encoder_vp8.cc
+++ b/remoting/base/encoder_vp8.cc
@@ -32,7 +32,9 @@ EncoderVp8::EncoderVp8()
image_(NULL),
active_map_width_(0),
active_map_height_(0),
- last_timestamp_(0) {
+ last_timestamp_(0),
+ width_(0),
+ height_(0) {
}
EncoderVp8::~EncoderVp8() {
@@ -43,6 +45,8 @@ EncoderVp8::~EncoderVp8() {
}
bool EncoderVp8::Init(int width, int height) {
+ width_ = width;
+ height_ = height;
codec_.reset(new vpx_codec_ctx_t());
image_.reset(new vpx_image_t());
memset(image_.get(), 0, sizeof(vpx_image_t));
@@ -55,6 +59,30 @@ bool EncoderVp8::Init(int width, int height) {
image_->d_h = height;
image_->h = height;
+ // YUV image size is 1.5 times of a plane. Multiplication is performed first
+ // to avoid rounding error.
+ const int plane_size = width * height;
+ const int size = plane_size * 3 / 2;
+
+ yuv_image_.reset(new uint8[size]);
+
+ // Reset image value to 128 so we just need to fill in the y plane.
+ memset(yuv_image_.get(), 128, size);
+
+ // Fill in the information for |image_|.
+ unsigned char* image = reinterpret_cast<unsigned char*>(yuv_image_.get());
+ image_->planes[0] = image;
+ image_->planes[1] = image + plane_size;
+
+ // The V plane starts from 1.25 of the plane size.
+ image_->planes[2] = image + plane_size + plane_size / 4;
+
+ // In YV12 Y plane has full width, UV plane has half width because of
+ // subsampling.
+ image_->stride[0] = image_->w;
+ image_->stride[1] = image_->w / 2;
+ image_->stride[2] = image_->w / 2;
+
vpx_codec_enc_cfg_t config;
const vpx_codec_iface_t* algo = vpx_codec_vp8_cx();
CHECK(algo);
@@ -110,34 +138,6 @@ static gfx::Rect AlignRect(const gfx::Rect& rect, int width, int height) {
bool EncoderVp8::PrepareImage(scoped_refptr<CaptureData> capture_data,
std::vector<gfx::Rect>* updated_rects) {
- const int plane_size = capture_data->width() * capture_data->height();
-
- if (!yuv_image_.get()) {
-
- // YUV image size is 1.5 times of a plane. Multiplication is performed first
- // to avoid rounding error.
- const int size = plane_size * 3 / 2;
-
- yuv_image_.reset(new uint8[size]);
-
- // Reset image value to 128 so we just need to fill in the y plane.
- memset(yuv_image_.get(), 128, size);
-
- // Fill in the information for |image_|.
- unsigned char* image = reinterpret_cast<unsigned char*>(yuv_image_.get());
- image_->planes[0] = image;
- image_->planes[1] = image + plane_size;
-
- // The V plane starts from 1.25 of the plane size.
- image_->planes[2] = image + plane_size + plane_size / 4;
-
- // In YV12 Y plane has full width, UV plane has half width because of
- // subsampling.
- image_->stride[0] = image_->w;
- image_->stride[1] = image_->w / 2;
- image_->stride[2] = image_->w / 2;
- }
-
// Perform RGB->YUV conversion.
if (capture_data->pixel_format() != media::VideoFrame::RGB32) {
LOG(ERROR) << "Only RGB32 is supported";
@@ -147,6 +147,7 @@ bool EncoderVp8::PrepareImage(scoped_refptr<CaptureData> capture_data,
const InvalidRects& rects = capture_data->dirty_rects();
const uint8* in = capture_data->data_planes().data[0];
const int in_stride = capture_data->data_planes().strides[0];
+ const int plane_size = capture_data->width() * capture_data->height();
uint8* y_out = yuv_image_.get();
uint8* u_out = yuv_image_.get() + plane_size;
uint8* v_out = yuv_image_.get() + plane_size + plane_size / 4;
@@ -203,7 +204,8 @@ void EncoderVp8::PrepareActiveMap(
void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data,
bool key_frame,
DataAvailableCallback* data_available_callback) {
- if (!initialized_) {
+ if (!initialized_ || (capture_data->width() != width_) ||
+ (capture_data->height() != height_)) {
bool ret = Init(capture_data->width(), capture_data->height());
// TODO(hclam): Handle error better.
DCHECK(ret) << "Initialization of encoder failed";
@@ -267,6 +269,8 @@ void EncoderVp8::Encode(scoped_refptr<CaptureData> capture_data,
message->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8);
message->set_flags(VideoPacket::FIRST_PACKET | VideoPacket::LAST_PACKET |
VideoPacket::LAST_PARTITION);
+ message->mutable_format()->set_screen_width(capture_data->width());
+ message->mutable_format()->set_screen_height(capture_data->height());
for (size_t i = 0; i < updated_rects.size(); ++i) {
Rect* rect = message->add_dirty_rects();
rect->set_x(updated_rects[i].x());
diff --git a/remoting/base/encoder_vp8.h b/remoting/base/encoder_vp8.h
index e283d16..2bf73dc 100644
--- a/remoting/base/encoder_vp8.h
+++ b/remoting/base/encoder_vp8.h
@@ -51,6 +51,10 @@ class EncoderVp8 : public Encoder {
// Buffer for storing the yuv image.
scoped_array<uint8> yuv_image_;
+ // The current frame dimensions.
+ int width_;
+ int height_;
+
DISALLOW_COPY_AND_ASSIGN(EncoderVp8);
};