summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 22:46:27 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-06 22:46:27 +0000
commitb53ab229bdba6cd50585c8fcaad011998b02f82c (patch)
treeef27ab8c08211d13d0ae86d1ec819b0b233b218f
parentc0d56a6c6bd730aecaf124d738f266c691a2a6b2 (diff)
downloadchromium_src-b53ab229bdba6cd50585c8fcaad011998b02f82c.zip
chromium_src-b53ab229bdba6cd50585c8fcaad011998b02f82c.tar.gz
chromium_src-b53ab229bdba6cd50585c8fcaad011998b02f82c.tar.bz2
Refactor ZLib and Verbatim encoders.
Added EncoderRowBased that implements encoding for both ZLib and Verbatim. BUG=None TEST=None Review URL: http://codereview.chromium.org/5382008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68394 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/base/compressor.h4
-rw-r--r--remoting/base/compressor_verbatim.cc32
-rw-r--r--remoting/base/compressor_verbatim.h28
-rw-r--r--remoting/base/compressor_zlib.cc15
-rw-r--r--remoting/base/compressor_zlib.h2
-rw-r--r--remoting/base/encoder_row_based.cc (renamed from remoting/base/encoder_zlib.cc)88
-rw-r--r--remoting/base/encoder_row_based.h67
-rw-r--r--remoting/base/encoder_row_based_unittest.cc (renamed from remoting/base/encoder_zlib_unittest.cc)0
-rw-r--r--remoting/base/encoder_verbatim.cc102
-rw-r--r--remoting/base/encoder_verbatim.h50
-rw-r--r--remoting/base/encoder_verbatim_unittest.cc16
-rw-r--r--remoting/base/encoder_vp8.cc3
-rw-r--r--remoting/base/encoder_zlib.h52
-rw-r--r--remoting/host/chromoting_host.cc7
-rw-r--r--remoting/protocol/mock_objects.h1
-rw-r--r--remoting/remoting.gyp11
16 files changed, 205 insertions, 273 deletions
diff --git a/remoting/base/compressor.h b/remoting/base/compressor.h
index edb64f8..1678255 100644
--- a/remoting/base/compressor.h
+++ b/remoting/base/compressor.h
@@ -25,6 +25,10 @@ class Compressor {
};
virtual ~Compressor() {}
+ // Resets all the internal state so the compressor behaves as if it
+ // was just created.
+ virtual void Reset() = 0;
+
// Compress |input_data| with |input_size| bytes.
//
// |output_data| is provided by the caller and |output_size| is the
diff --git a/remoting/base/compressor_verbatim.cc b/remoting/base/compressor_verbatim.cc
new file mode 100644
index 0000000..7058b52
--- /dev/null
+++ b/remoting/base/compressor_verbatim.cc
@@ -0,0 +1,32 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/logging.h"
+#include "remoting/base/compressor_verbatim.h"
+
+namespace remoting {
+
+CompressorVerbatim::CompressorVerbatim() {
+}
+
+CompressorVerbatim::~CompressorVerbatim() {
+}
+
+void CompressorVerbatim::Reset() {
+}
+
+bool CompressorVerbatim::Process(const uint8* input_data, int input_size,
+ uint8* output_data, int output_size,
+ CompressorFlush flush, int* consumed,
+ int* written) {
+ DCHECK_GT(output_size, 0);
+ int bytes_to_copy = std::min(input_size, output_size);
+ memcpy(output_data, input_data, bytes_to_copy);
+
+ // Since we're just a memcpy, consumed and written are the same.
+ *consumed = *written = bytes_to_copy;
+ return true;
+}
+
+} // namespace remoting
diff --git a/remoting/base/compressor_verbatim.h b/remoting/base/compressor_verbatim.h
new file mode 100644
index 0000000..f7e7224
--- /dev/null
+++ b/remoting/base/compressor_verbatim.h
@@ -0,0 +1,28 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_BASE_COMPRESSOR_VERBATIM_H_
+#define REMOTING_BASE_COMPRESSOR_VERBATIM_H_
+
+#include "remoting/base/compressor.h"
+
+namespace remoting {
+
+// Compressor for verbatim streams.
+class CompressorVerbatim : public Compressor {
+ public:
+ CompressorVerbatim();
+ virtual ~CompressorVerbatim();
+
+ // Compressor implementations.
+ virtual bool Process(const uint8* input_data, int input_size,
+ uint8* output_data, int output_size,
+ CompressorFlush flush, int* consumed, int* written);
+
+ virtual void Reset();
+};
+
+} // namespace remoting
+
+#endif // REMOTING_BASE_COMPRESSOR_VERBATIM_H_
diff --git a/remoting/base/compressor_zlib.cc b/remoting/base/compressor_zlib.cc
index 6f700731..0128361 100644
--- a/remoting/base/compressor_zlib.cc
+++ b/remoting/base/compressor_zlib.cc
@@ -21,6 +21,17 @@
namespace remoting {
CompressorZlib::CompressorZlib() {
+ Reset();
+}
+
+CompressorZlib::~CompressorZlib() {
+ deflateEnd(stream_.get());
+}
+
+void CompressorZlib::Reset() {
+ if (stream_.get())
+ deflateEnd(stream_.get());
+
stream_.reset(new z_stream());
stream_->next_in = Z_NULL;
@@ -31,10 +42,6 @@ CompressorZlib::CompressorZlib() {
deflateInit(stream_.get(), Z_BEST_SPEED);
}
-CompressorZlib::~CompressorZlib() {
- deflateEnd(stream_.get());
-}
-
bool CompressorZlib::Process(const uint8* input_data, int input_size,
uint8* output_data, int output_size,
CompressorFlush flush, int* consumed,
diff --git a/remoting/base/compressor_zlib.h b/remoting/base/compressor_zlib.h
index d2cc82b..3371d22 100644
--- a/remoting/base/compressor_zlib.h
+++ b/remoting/base/compressor_zlib.h
@@ -23,6 +23,8 @@ class CompressorZlib : public Compressor {
uint8* output_data, int output_size,
CompressorFlush flush, int* consumed, int* written);
+ virtual void Reset();
+
private:
scoped_ptr<z_stream> stream_;
};
diff --git a/remoting/base/encoder_zlib.cc b/remoting/base/encoder_row_based.cc
index 5fc1afe..a7919e1 100644
--- a/remoting/base/encoder_zlib.cc
+++ b/remoting/base/encoder_row_based.cc
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/base/encoder_zlib.h"
+#include "remoting/base/encoder_row_based.h"
#include "base/logging.h"
#include "gfx/rect.h"
#include "remoting/base/capture_data.h"
+#include "remoting/base/compressor_verbatim.h"
#include "remoting/base/compressor_zlib.h"
#include "remoting/base/util.h"
#include "remoting/proto/video.pb.h"
@@ -15,52 +16,70 @@ namespace remoting {
static const int kPacketSize = 1024 * 1024;
-EncoderZlib::EncoderZlib() : packet_size_(kPacketSize) {
+EncoderRowBased* EncoderRowBased::CreateZlibEncoder() {
+ return new EncoderRowBased(new CompressorZlib(),
+ VideoPacketFormat::ENCODING_ZLIB);
}
-EncoderZlib::EncoderZlib(int packet_size) : packet_size_(packet_size) {
+EncoderRowBased* EncoderRowBased::CreateVerbatimEncoder() {
+ return new EncoderRowBased(new CompressorVerbatim(),
+ VideoPacketFormat::ENCODING_VERBATIM);
}
-EncoderZlib::~EncoderZlib() {}
+EncoderRowBased::EncoderRowBased(Compressor* compressor,
+ VideoPacketFormat::Encoding encoding)
+ : encoding_(encoding),
+ compressor_(compressor),
+ packet_size_(kPacketSize) {
+}
+
+EncoderRowBased::EncoderRowBased(Compressor* compressor,
+ VideoPacketFormat::Encoding encoding,
+ int packet_size)
+ : encoding_(encoding),
+ compressor_(compressor),
+ packet_size_(packet_size) {
+}
+
+EncoderRowBased::~EncoderRowBased() {}
-void EncoderZlib::Encode(scoped_refptr<CaptureData> capture_data,
- bool key_frame,
- DataAvailableCallback* data_available_callback) {
+void EncoderRowBased::Encode(scoped_refptr<CaptureData> capture_data,
+ bool key_frame,
+ DataAvailableCallback* data_available_callback) {
CHECK(capture_data->pixel_format() == media::VideoFrame::RGB32)
- << "Zlib Encoder only works with RGB32. Got "
+ << "RowBased Encoder only works with RGB32. Got "
<< capture_data->pixel_format();
capture_data_ = capture_data;
callback_.reset(data_available_callback);
- CompressorZlib compressor;
const InvalidRects& rects = capture_data->dirty_rects();
int index = 0;
for (InvalidRects::const_iterator r = rects.begin();
- r != rects.end(); ++r, ++index) {
- EncodeRect(&compressor, *r, index);
+ r != rects.end(); ++r, ++index) {
+ EncodeRect(*r, index);
}
capture_data_ = NULL;
callback_.reset();
}
-void EncoderZlib::EncodeRect(CompressorZlib* compressor,
- const gfx::Rect& rect, size_t rect_index) {
+void EncoderRowBased::EncodeRect(const gfx::Rect& rect, size_t rect_index) {
CHECK(capture_data_->data_planes().data[0]);
const int strides = capture_data_->data_planes().strides[0];
const int bytes_per_pixel = GetBytesPerPixel(capture_data_->pixel_format());
const int row_size = bytes_per_pixel * rect.width();
+ compressor_->Reset();
+
VideoPacket* packet = new VideoPacket();
PrepareUpdateStart(rect, packet);
const uint8* in = capture_data_->data_planes().data[0] +
- rect.y() * strides +
- rect.x() * bytes_per_pixel;
+ rect.y() * strides + rect.x() * bytes_per_pixel;
// TODO(hclam): Fill in the sequence number.
uint8* out = GetOutputBuffer(packet, packet_size_);
int filled = 0;
- int row_x = 0;
- int row_y = 0;
+ int row_pos = 0; // Position in the current row in bytes.
+ int row_y = 0; // Current row.
bool compress_again = true;
while (compress_again) {
// Prepare a message for sending out.
@@ -72,63 +91,58 @@ void EncoderZlib::EncodeRect(CompressorZlib* compressor,
Compressor::CompressorFlush flush = Compressor::CompressorNoFlush;
if (row_y == rect.height() - 1) {
- if (rect_index == capture_data_->dirty_rects().size() - 1) {
- flush = Compressor::CompressorFinish;
- } else {
- flush = Compressor::CompressorSyncFlush;
- }
+ flush = Compressor::CompressorFinish;
}
int consumed = 0;
int written = 0;
- compress_again = compressor->Process(in + row_x, row_size - row_x,
- out + filled, packet_size_ - filled,
- flush, &consumed, &written);
- row_x += consumed;
+ compress_again = compressor_->Process(in + row_pos, row_size - row_pos,
+ out + filled, packet_size_ - filled,
+ flush, &consumed, &written);
+ row_pos += consumed;
filled += written;
// We have reached the end of stream.
if (!compress_again) {
packet->set_flags(packet->flags() | VideoPacket::LAST_PACKET);
+ DCHECK(row_pos == row_size);
+ DCHECK(row_y == rect.height() - 1);
}
// If we have filled the message or we have reached the end of stream.
if (filled == packet_size_ || !compress_again) {
packet->mutable_data()->resize(filled);
- SubmitMessage(packet, rect_index);
+ callback_->Run(packet);
packet = NULL;
}
// Reached the end of input row and we're not at the last row.
- if (row_x == row_size && row_y < rect.height() - 1) {
- row_x = 0;
+ if (row_pos == row_size && row_y < rect.height() - 1) {
+ row_pos = 0;
in += strides;
++row_y;
}
}
}
-void EncoderZlib::PrepareUpdateStart(const gfx::Rect& rect,
- VideoPacket* packet) {
+void EncoderRowBased::PrepareUpdateStart(const gfx::Rect& rect,
+ VideoPacket* packet) {
packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET);
- VideoPacketFormat* format = packet->mutable_format();
+ VideoPacketFormat* format = packet->mutable_format();
format->set_x(rect.x());
format->set_y(rect.y());
format->set_width(rect.width());
format->set_height(rect.height());
- format->set_encoding(VideoPacketFormat::ENCODING_ZLIB);
+ format->set_encoding(encoding_);
}
-uint8* EncoderZlib::GetOutputBuffer(VideoPacket* packet, size_t size) {
+uint8* EncoderRowBased::GetOutputBuffer(VideoPacket* packet, size_t size) {
packet->mutable_data()->resize(size);
// TODO(ajwong): Is there a better way to do this at all???
return const_cast<uint8*>(reinterpret_cast<const uint8*>(
packet->mutable_data()->data()));
}
-void EncoderZlib::SubmitMessage(VideoPacket* packet, size_t rect_index) {
- callback_->Run(packet);
-}
} // namespace remoting
diff --git a/remoting/base/encoder_row_based.h b/remoting/base/encoder_row_based.h
new file mode 100644
index 0000000..bdc992d
--- /dev/null
+++ b/remoting/base/encoder_row_based.h
@@ -0,0 +1,67 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef REMOTING_BASE_ENCODER_ROW_BASED_H_
+#define REMOTING_BASE_ENCODER_ROW_BASED_H_
+
+#include "remoting/base/encoder.h"
+#include "remoting/proto/video.pb.h"
+
+#include "gfx/rect.h"
+
+namespace remoting {
+
+class Compressor;
+class UpdateStreamPacket;
+
+// EncoderRowBased implements an Encoder using zlib or verbatim
+// compression. Zlib-based encoder must be created using
+// CreateZlibEncoder(), verbatim encoder is created with
+// CreateVerbatimEncoder().
+//
+// Compressor is reset before encoding each rectangle, so that each
+// rectangle can be decoded independently.
+class EncoderRowBased : public Encoder {
+ public:
+ static EncoderRowBased* CreateZlibEncoder();
+ static EncoderRowBased* CreateVerbatimEncoder();
+
+ virtual ~EncoderRowBased();
+
+ virtual void Encode(scoped_refptr<CaptureData> capture_data,
+ bool key_frame,
+ DataAvailableCallback* data_available_callback);
+
+ private:
+ EncoderRowBased(Compressor* compressor, VideoPacketFormat::Encoding encoding);
+ EncoderRowBased(Compressor* compressor, VideoPacketFormat::Encoding encoding,
+ int packet_size);
+
+ // Encode a single dirty rect using compressor.
+ void EncodeRect(const gfx::Rect& rect, size_t rect_index);
+
+ // Marks a packet as the first in a series of rectangle updates.
+ void PrepareUpdateStart(const gfx::Rect& rect, VideoPacket* packet);
+
+ // Retrieves a pointer to the output buffer in |update| used for storing the
+ // encoded rectangle data. Will resize the buffer to |size|.
+ uint8* GetOutputBuffer(VideoPacket* packet, size_t size);
+
+ // Submit |message| to |callback_|.
+ void SubmitMessage(VideoPacket* packet, size_t rect_index);
+
+ // The encoding of the incoming stream.
+ VideoPacketFormat::Encoding encoding_;
+
+ scoped_ptr<Compressor> compressor_;
+
+ scoped_refptr<CaptureData> capture_data_;
+ scoped_ptr<DataAvailableCallback> callback_;
+
+ int packet_size_;
+};
+
+} // namespace remoting
+
+#endif // REMOTING_BASE_ENCODER_ROW_BASED_H_
diff --git a/remoting/base/encoder_zlib_unittest.cc b/remoting/base/encoder_row_based_unittest.cc
index 8f54e82..8f54e82 100644
--- a/remoting/base/encoder_zlib_unittest.cc
+++ b/remoting/base/encoder_row_based_unittest.cc
diff --git a/remoting/base/encoder_verbatim.cc b/remoting/base/encoder_verbatim.cc
deleted file mode 100644
index 1185bff..0000000
--- a/remoting/base/encoder_verbatim.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "remoting/base/encoder_verbatim.h"
-
-#include "base/logging.h"
-#include "gfx/rect.h"
-#include "net/base/io_buffer.h"
-#include "remoting/base/capture_data.h"
-#include "remoting/base/util.h"
-#include "remoting/proto/video.pb.h"
-
-namespace remoting {
-
-// TODO(garykac): Move up into shared location. Share value with encoder_zlib.
-// TODO(garykac): 10* is added to ensure that rects fit in a single packet.
-// Add support for splitting across packets and remove the 10*.
-static const int kPacketSize = 10 * 1024 * 1024;
-
-EncoderVerbatim::EncoderVerbatim()
- : packet_size_(kPacketSize) {
-}
-
-EncoderVerbatim::EncoderVerbatim(int packet_size)
- : packet_size_(packet_size) {
-}
-
-void EncoderVerbatim::Encode(scoped_refptr<CaptureData> capture_data,
- bool key_frame,
- DataAvailableCallback* data_available_callback) {
- capture_data_ = capture_data;
- callback_.reset(data_available_callback);
-
- const InvalidRects& rects = capture_data->dirty_rects();
- int index = 0;
- for (InvalidRects::const_iterator r = rects.begin();
- r != rects.end(); ++r, ++index) {
- EncodeRect(*r, index);
- }
-
- capture_data_ = NULL;
- callback_.reset();
-}
-
-// TODO(garykac): This assumes that the rect fits into a single packet.
-// Fix this by modeling after code in encoder_zlib.cc
-void EncoderVerbatim::EncodeRect(const gfx::Rect& rect, size_t rect_index) {
- CHECK(capture_data_->data_planes().data[0]);
- const int stride = capture_data_->data_planes().strides[0];
- const int bytes_per_pixel = GetBytesPerPixel(capture_data_->pixel_format());
- const int row_size = bytes_per_pixel * rect.width();
-
- VideoPacket* packet = new VideoPacket();
- PrepareUpdateStart(rect, packet);
-
- const uint8* in = capture_data_->data_planes().data[0] +
- rect.y() * stride +
- rect.x() * bytes_per_pixel;
- // TODO(hclam): Fill in the sequence number.
- uint8* out = GetOutputBuffer(packet, packet_size_);
- int total_bytes = 0;
- for (int y = 0; y < rect.height(); y++) {
- memcpy(out, in, row_size);
- out += row_size;
- in += stride;
- total_bytes += row_size;
- }
-
- // We have reached the end of stream.
- packet->set_flags(packet->flags() | VideoPacket::LAST_PACKET);
-
- // If we have filled the message or we have reached the end of stream.
- packet->mutable_data()->resize(total_bytes);
- SubmitMessage(packet, rect_index);
-}
-
-void EncoderVerbatim::PrepareUpdateStart(const gfx::Rect& rect,
- VideoPacket* packet) {
-
- packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET);
- VideoPacketFormat* format = packet->mutable_format();
-
- format->set_x(rect.x());
- format->set_y(rect.y());
- format->set_width(rect.width());
- format->set_height(rect.height());
- format->set_encoding(VideoPacketFormat::ENCODING_VERBATIM);
-}
-
-uint8* EncoderVerbatim::GetOutputBuffer(VideoPacket* packet, size_t size) {
- packet->mutable_data()->resize(size);
- // TODO(ajwong): Is there a better way to do this at all???
- return const_cast<uint8*>(reinterpret_cast<const uint8*>(
- packet->mutable_data()->data()));
-}
-
-void EncoderVerbatim::SubmitMessage(VideoPacket* packet, size_t rect_index) {
- callback_->Run(packet);
-}
-
-} // namespace remoting
diff --git a/remoting/base/encoder_verbatim.h b/remoting/base/encoder_verbatim.h
deleted file mode 100644
index 81d109d..0000000
--- a/remoting/base/encoder_verbatim.h
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef REMOTING_BASE_ENCODER_VERBATIM_H_
-#define REMOTING_BASE_ENCODER_VERBATIM_H_
-
-#include "remoting/base/encoder.h"
-
-#include "gfx/rect.h"
-
-namespace remoting {
-
-class UpdateStreamPacket;
-
-// EncoderVerbatim implements Encoder and simply copies input to the output
-// buffer verbatim.
-class EncoderVerbatim : public Encoder {
- public:
- EncoderVerbatim();
- EncoderVerbatim(int packet_size);
-
- virtual ~EncoderVerbatim() {}
-
- virtual void Encode(scoped_refptr<CaptureData> capture_data,
- bool key_frame,
- DataAvailableCallback* data_available_callback);
-
- private:
- // Encode a single dirty rect.
- void EncodeRect(const gfx::Rect& rect, size_t rect_index);
-
- // Marks a packets as the first in a series of rectangle updates.
- void PrepareUpdateStart(const gfx::Rect& rect, VideoPacket* packet);
-
- // Retrieves a pointer to the output buffer in |update| used for storing the
- // encoded rectangle data. Will resize the buffer to |size|.
- uint8* GetOutputBuffer(VideoPacket* packet, size_t size);
-
- // Submit |message| to |callback_|.
- void SubmitMessage(VideoPacket* packet, size_t rect_index);
-
- scoped_refptr<CaptureData> capture_data_;
- scoped_ptr<DataAvailableCallback> callback_;
- int packet_size_;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_BASE_ENCODER_VERBATIM_H_
diff --git a/remoting/base/encoder_verbatim_unittest.cc b/remoting/base/encoder_verbatim_unittest.cc
deleted file mode 100644
index 1d4735c..0000000
--- a/remoting/base/encoder_verbatim_unittest.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "remoting/base/codec_test.h"
-#include "remoting/base/encoder_verbatim.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace remoting {
-
-TEST(EncoderVerbatimTest, TestEncoder) {
- EncoderVerbatim encoder;
- TestEncoder(&encoder, true);
-}
-
-} // namespace remoting
diff --git a/remoting/base/encoder_vp8.cc b/remoting/base/encoder_vp8.cc
index 61883e2..ea02add 100644
--- a/remoting/base/encoder_vp8.cc
+++ b/remoting/base/encoder_vp8.cc
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "remoting/base/encoder_vp8.h"
+
#include "base/logging.h"
#include "media/base/callback.h"
#include "media/base/media.h"
#include "remoting/base/capture_data.h"
-#include "remoting/base/encoder_vp8.h"
#include "remoting/proto/video.pb.h"
extern "C" {
diff --git a/remoting/base/encoder_zlib.h b/remoting/base/encoder_zlib.h
deleted file mode 100644
index 6699f03..0000000
--- a/remoting/base/encoder_zlib.h
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef REMOTING_BASE_ENCODER_ZLIB_H_
-#define REMOTING_BASE_ENCODER_ZLIB_H_
-
-#include "remoting/base/encoder.h"
-
-#include "gfx/rect.h"
-
-namespace remoting {
-
-class CompressorZlib;
-class UpdateStreamPacket;
-
-// EncoderZlib implements an Encoder using Zlib for compression.
-class EncoderZlib : public Encoder {
- public:
- EncoderZlib();
- EncoderZlib(int packet_size);
-
- virtual ~EncoderZlib();
-
- virtual void Encode(scoped_refptr<CaptureData> capture_data,
- bool key_frame,
- DataAvailableCallback* data_available_callback);
-
- private:
- // Encode a single dirty rect using compressor.
- void EncodeRect(CompressorZlib* compressor, const gfx::Rect& rect,
- size_t rect_index);
-
- // Marks a packets as the first in a series of rectangle updates.
- void PrepareUpdateStart(const gfx::Rect& rect, VideoPacket* packet);
-
- // Retrieves a pointer to the output buffer in |update| used for storing the
- // encoded rectangle data. Will resize the buffer to |size|.
- uint8* GetOutputBuffer(VideoPacket* packet, size_t size);
-
- // Submit |message| to |callback_|.
- void SubmitMessage(VideoPacket* packet, size_t rect_index);
-
- scoped_refptr<CaptureData> capture_data_;
- scoped_ptr<DataAvailableCallback> callback_;
- //size_t current_rect_;
- int packet_size_;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_BASE_ENCODER_ZLIB_H_
diff --git a/remoting/host/chromoting_host.cc b/remoting/host/chromoting_host.cc
index 34ec893..d55b244 100644
--- a/remoting/host/chromoting_host.cc
+++ b/remoting/host/chromoting_host.cc
@@ -9,9 +9,8 @@
#include "build/build_config.h"
#include "remoting/base/constants.h"
#include "remoting/base/encoder.h"
-#include "remoting/base/encoder_verbatim.h"
+#include "remoting/base/encoder_row_based.h"
#include "remoting/base/encoder_vp8.h"
-#include "remoting/base/encoder_zlib.h"
#include "remoting/host/capturer.h"
#include "remoting/host/chromoting_host_context.h"
#include "remoting/host/event_executor.h"
@@ -324,9 +323,9 @@ Encoder* ChromotingHost::CreateEncoder(const protocol::SessionConfig* config) {
const protocol::ChannelConfig& video_config = config->video_config();
if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) {
- return new remoting::EncoderVerbatim();
+ return EncoderRowBased::CreateVerbatimEncoder();
} else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) {
- return new remoting::EncoderZlib();
+ return EncoderRowBased::CreateZlibEncoder();
}
// TODO(sergeyu): Enable VP8 on ARM builds.
#if !defined(ARCH_CPU_ARM_FAMILY)
diff --git a/remoting/protocol/mock_objects.h b/remoting/protocol/mock_objects.h
index 587d415..676a608 100644
--- a/remoting/protocol/mock_objects.h
+++ b/remoting/protocol/mock_objects.h
@@ -22,7 +22,6 @@ class MockConnectionToClient : public ConnectionToClient {
MockConnectionToClient() {}
MOCK_METHOD1(Init, void(ChromotocolConnection* connection));
- MOCK_METHOD2(SendInitClientMessage, void(int width, int height));
MOCK_METHOD0(video_stub, VideoStub*());
MOCK_METHOD0(Disconnect, void());
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index e46154b..9b2afd7 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -135,6 +135,8 @@
'base/compound_buffer.cc',
'base/compound_buffer.h',
'base/compressor.h',
+ 'base/compressor_verbatim.cc',
+ 'base/compressor_verbatim.h',
'base/compressor_zlib.cc',
'base/compressor_zlib.h',
'base/constants.cc',
@@ -150,12 +152,10 @@
'base/decompressor_zlib.cc',
'base/decompressor_zlib.h',
'base/encoder.h',
- 'base/encoder_verbatim.cc',
- 'base/encoder_verbatim.h',
'base/encoder_vp8.cc',
'base/encoder_vp8.h',
- 'base/encoder_zlib.cc',
- 'base/encoder_zlib.h',
+ 'base/encoder_row_based.cc',
+ 'base/encoder_row_based.h',
'base/tracer.cc',
'base/tracer.h',
'base/types.h',
@@ -457,9 +457,8 @@
# BUG57351 'base/decoder_vp8_unittest.cc',
'base/decompressor_zlib_unittest.cc',
# BUG57351 'base/encode_decode_unittest.cc',
-# BUG57351 'base/encoder_verbatim_unittest.cc',
# BUG57351 'base/encoder_vp8_unittest.cc',
-# BUG57351 'base/encoder_zlib_unittest.cc',
+# BUG57351 'base/encoder_row_based_unittest.cc',
'base/mock_objects.h',
# BUG57351 'client/chromoting_view_unittest.cc',
'client/mock_objects.h',