summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--remoting/base/compressor.h60
-rw-r--r--remoting/base/compressor_verbatim.cc32
-rw-r--r--remoting/base/compressor_verbatim.h33
-rw-r--r--remoting/base/compressor_zlib.cc84
-rw-r--r--remoting/base/compressor_zlib.h38
-rw-r--r--remoting/base/compressor_zlib_unittest.cc70
-rw-r--r--remoting/base/decompressor.h44
-rw-r--r--remoting/base/decompressor_verbatim.cc31
-rw-r--r--remoting/base/decompressor_verbatim.h29
-rw-r--r--remoting/base/decompressor_zlib.cc66
-rw-r--r--remoting/base/decompressor_zlib.h35
-rw-r--r--remoting/base/decompressor_zlib_unittest.cc142
-rw-r--r--remoting/client/rectangle_update_decoder.cc6
-rw-r--r--remoting/codec/video_decoder_verbatim.cc (renamed from remoting/codec/video_decoder_row_based.cc)56
-rw-r--r--remoting/codec/video_decoder_verbatim.h (renamed from remoting/codec/video_decoder_row_based.h)29
-rw-r--r--remoting/codec/video_encode_decode_unittest.cc38
-rw-r--r--remoting/codec/video_encoder_row_based.h73
-rw-r--r--remoting/codec/video_encoder_row_based_unittest.cc24
-rw-r--r--remoting/codec/video_encoder_verbatim.cc (renamed from remoting/codec/video_encoder_row_based.cc)106
-rw-r--r--remoting/codec/video_encoder_verbatim.h56
-rw-r--r--remoting/codec/video_encoder_verbatim_unittest.cc37
-rw-r--r--remoting/host/client_session.cc6
-rw-r--r--remoting/remoting.gyp24
23 files changed, 163 insertions, 956 deletions
diff --git a/remoting/base/compressor.h b/remoting/base/compressor.h
deleted file mode 100644
index 1678255..0000000
--- a/remoting/base/compressor.h
+++ /dev/null
@@ -1,60 +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_COMPRESSOR_H_
-#define REMOTING_BASE_COMPRESSOR_H_
-
-#include "base/basictypes.h"
-
-namespace remoting {
-
-// An object to compress data losslessly. Compressed data can be fully
-// recovered by a Decompressor.
-//
-// Note that a Compressor can only be used on one stream during its
-// lifetime. This object should be destroyed after use.
-class Compressor {
- public:
-
- // Defines the flush modes for a compressor.
- enum CompressorFlush {
- CompressorNoFlush,
- CompressorSyncFlush,
- CompressorFinish,
- };
- 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
- // size of |output_data|. |output_size| must be greater than 0.
- //
- // |flush| is set to one of the three value:
- // - CompressorNoFlush
- // No flushing is requested
- // - CompressorSyncFlush
- // Write all pending output and write a synchronization point in the
- // output data stream.
- // - CompressorFinish
- // Mark the end of stream.
- //
- // Compressed data is written to |output_data|. |consumed| will
- // contain the number of bytes consumed from the input. |written|
- // contains the number of bytes written to output.
- //
- // Returns true if this method needs to be called again because
- // there is more data to be written out. This is particularly
- // useful for end of the compression stream.
- virtual bool Process(const uint8* input_data, int input_size,
- uint8* output_data, int output_size,
- CompressorFlush flush, int* consumed, int* written) = 0;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_BASE_COMPRESSOR_H_
diff --git a/remoting/base/compressor_verbatim.cc b/remoting/base/compressor_verbatim.cc
deleted file mode 100644
index 97b71e1..0000000
--- a/remoting/base/compressor_verbatim.cc
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) 2012 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 (flush != CompressorFinish) || (output_size < bytes_to_copy);
-}
-
-} // namespace remoting
diff --git a/remoting/base/compressor_verbatim.h b/remoting/base/compressor_verbatim.h
deleted file mode 100644
index 93cbd3c..0000000
--- a/remoting/base/compressor_verbatim.h
+++ /dev/null
@@ -1,33 +0,0 @@
-// Copyright (c) 2011 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 "base/compiler_specific.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) OVERRIDE;
-
- virtual void Reset() OVERRIDE;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_BASE_COMPRESSOR_VERBATIM_H_
diff --git a/remoting/base/compressor_zlib.cc b/remoting/base/compressor_zlib.cc
deleted file mode 100644
index 05ad621..0000000
--- a/remoting/base/compressor_zlib.cc
+++ /dev/null
@@ -1,84 +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/compressor_zlib.h"
-
-#if defined(USE_SYSTEM_ZLIB)
-#include <zlib.h>
-#else
-#include "third_party/zlib/zlib.h"
-#endif
-#include "base/logging.h"
-
-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;
- stream_->zalloc = Z_NULL;
- stream_->zfree = Z_NULL;
- stream_->opaque = Z_NULL;
-
- deflateInit(stream_.get(), Z_BEST_SPEED);
-}
-
-bool CompressorZlib::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);
-
- // Setup I/O parameters.
- stream_->avail_in = input_size;
- stream_->next_in = (Bytef*)input_data;
- stream_->avail_out = output_size;
- stream_->next_out = (Bytef*)output_data;
-
- int z_flush = 0;
- if (flush == CompressorSyncFlush) {
- z_flush = Z_SYNC_FLUSH;
- } else if (flush == CompressorFinish) {
- z_flush = Z_FINISH;
- } else if (flush == CompressorNoFlush) {
- z_flush = Z_NO_FLUSH;
- } else {
- NOTREACHED() << "Unsupported flush mode";
- }
-
- int ret = deflate(stream_.get(), z_flush);
- if (ret == Z_STREAM_ERROR) {
- NOTREACHED() << "zlib compression failed";
- }
-
- *consumed = input_size - stream_->avail_in;
- *written = output_size - stream_->avail_out;
-
- // If |ret| equals Z_STREAM_END we have reached the end of stream.
- // If |ret| equals Z_BUF_ERROR we have the end of the synchronication point.
- // For these two cases we need to stop compressing.
- if (ret == Z_OK) {
- return true;
- } else if (ret == Z_STREAM_END) {
- return false;
- } else if (ret == Z_BUF_ERROR) {
- return stream_->avail_out == 0;
- } else {
- NOTREACHED() << "Unexpected zlib error: " << ret;
- return false;
- }
-}
-
-} // namespace remoting
diff --git a/remoting/base/compressor_zlib.h b/remoting/base/compressor_zlib.h
deleted file mode 100644
index 32ac6c4..0000000
--- a/remoting/base/compressor_zlib.h
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) 2011 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_ZLIB_H_
-#define REMOTING_BASE_COMPRESSOR_ZLIB_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "remoting/base/compressor.h"
-
-typedef struct z_stream_s z_stream;
-
-namespace remoting {
-
-// A lossless compressor using zlib.
-class CompressorZlib : public Compressor {
- public:
- CompressorZlib();
- virtual ~CompressorZlib();
-
- // Compressor implementations.
- virtual bool Process(const uint8* input_data,
- int input_size,
- uint8* output_data,
- int output_size,
- CompressorFlush flush,
- int* consumed,
- int* written) OVERRIDE;
-
- virtual void Reset() OVERRIDE;
-
- private:
- scoped_ptr<z_stream> stream_;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_BASE_COMPRESSOR_ZLIB_H_
diff --git a/remoting/base/compressor_zlib_unittest.cc b/remoting/base/compressor_zlib_unittest.cc
deleted file mode 100644
index 0b9eade..0000000
--- a/remoting/base/compressor_zlib_unittest.cc
+++ /dev/null
@@ -1,70 +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 <stdlib.h>
-
-#include "remoting/base/compressor_zlib.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace remoting {
-
-static void GenerateTestData(uint8* data, int size, int seed) {
- srand(seed);
- for (int i = 0; i < size; ++i)
- data[i] = rand() % 256;
-}
-
-// Keep compressing |input_data| into |output_data| until the last
-// bytes is consumed.
-static void Compress(remoting::Compressor* compressor,
- const uint8* input_data, int input_size,
- uint8* output_data, int output_size) {
-
- // Feed data into the compress until the end.
- // This loop will rewrite |output_data| continuously.
- int consumed = 0;
- int written = 0;
- while (compressor->Process(
- input_data, input_size, output_data, output_size,
- input_size == 0 ?
- Compressor::CompressorFinish : Compressor::CompressorNoFlush,
- &consumed, &written)) {
- input_data += consumed;
- input_size -= consumed;
- }
-}
-
-TEST(CompressorZlibTest, Compress) {
- static const int kRawDataSize = 1024 * 128;
- static const int kCompressedDataSize = 256;
- uint8 raw_data[kRawDataSize];
- uint8 compressed_data[kCompressedDataSize];
-
- // Generate the test data.g
- GenerateTestData(raw_data, kRawDataSize, 99);
-
- // Then use the compressor to compress.
- remoting::CompressorZlib compressor;
- Compress(&compressor, raw_data, kRawDataSize,
- compressed_data, kCompressedDataSize);
-}
-
-// Checks that zlib can work with a small output buffer by reading
-// less from the input.
-TEST(CompressorZlibTest, SmallOutputBuffer) {
- static const int kRawDataSize = 1024 * 128;
- static const int kCompressedDataSize = 1;
- uint8 raw_data[kRawDataSize];
- uint8 compressed_data[kCompressedDataSize];
-
- // Generate the test data.g
- GenerateTestData(raw_data, kRawDataSize, 99);
-
- // Then use the compressor to compress.
- remoting::CompressorZlib compressor;
- Compress(&compressor, raw_data, kRawDataSize,
- compressed_data, kCompressedDataSize);
-}
-
-} // namespace remoting
diff --git a/remoting/base/decompressor.h b/remoting/base/decompressor.h
deleted file mode 100644
index 025850e..0000000
--- a/remoting/base/decompressor.h
+++ /dev/null
@@ -1,44 +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_DECOMPRESSOR_H_
-#define REMOTING_BASE_DECOMPRESSOR_H_
-
-#include "base/basictypes.h"
-
-namespace remoting {
-
-// An object to decompress data losslessly. This is used in pair with
-// a compressor.
-//
-// Note that a decompressor can only be used on one stream during its
-// lifetime. This object should be destroyed after use.
-class Decompressor {
- public:
- virtual ~Decompressor() {}
-
- // Resets all the internal state so the decompressor behaves as if it was
- // just created.
- virtual void Reset() = 0;
-
- // Decompress |input_data| with |input_size| bytes.
- //
- // |output_data| is provided by the caller and |output_size| is the
- // size of |output_data|. |output_size| must be greater than 0.
- //
- // Decompressed data is written to |output_data|. |consumed| will
- // contain the number of bytes consumed from the input. |written|
- // contains the number of bytes written to output.
- //
- // Returns true if this method needs to be called again because
- // there is more bytes to be decompressed or more input data is
- // needed.
- virtual bool Process(const uint8* input_data, int input_size,
- uint8* output_data, int output_size,
- int* consumed, int* written) = 0;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_BASE_DECOMPRESSOR_H_
diff --git a/remoting/base/decompressor_verbatim.cc b/remoting/base/decompressor_verbatim.cc
deleted file mode 100644
index d0d2271..0000000
--- a/remoting/base/decompressor_verbatim.cc
+++ /dev/null
@@ -1,31 +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/decompressor_verbatim.h"
-
-#include "base/logging.h"
-
-namespace remoting {
-
-DecompressorVerbatim::DecompressorVerbatim() {
-}
-
-DecompressorVerbatim::~DecompressorVerbatim() {
-}
-
-void DecompressorVerbatim::Reset() {
-}
-
-bool DecompressorVerbatim::Process(const uint8* input_data, int input_size,
- uint8* output_data, int output_size,
- 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/decompressor_verbatim.h b/remoting/base/decompressor_verbatim.h
deleted file mode 100644
index 7cc8885..0000000
--- a/remoting/base/decompressor_verbatim.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright (c) 2012 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_DECOMPRESSOR_VERBATIM_H_
-#define REMOTING_BASE_DECOMPRESSOR_VERBATIM_H_
-
-#include "base/compiler_specific.h"
-#include "remoting/base/decompressor.h"
-
-namespace remoting {
-
-// A lossless decompressor using zlib.
-class DecompressorVerbatim : public Decompressor {
- public:
- DecompressorVerbatim();
- virtual ~DecompressorVerbatim();
-
- virtual void Reset() OVERRIDE;
-
- // Decompressor implementations.
- virtual bool Process(const uint8* input_data, int input_size,
- uint8* output_data, int output_size,
- int* consumed, int* written) OVERRIDE;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_BASE_DECOMPRESSOR_VERBATIM_H_
diff --git a/remoting/base/decompressor_zlib.cc b/remoting/base/decompressor_zlib.cc
deleted file mode 100644
index 6dbc21b..0000000
--- a/remoting/base/decompressor_zlib.cc
+++ /dev/null
@@ -1,66 +0,0 @@
-// Copyright (c) 2011 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/decompressor_zlib.h"
-
-#if defined(USE_SYSTEM_ZLIB)
-#include <zlib.h>
-#else
-#include "third_party/zlib/zlib.h"
-#endif
-#include "base/logging.h"
-
-namespace remoting {
-
-DecompressorZlib::DecompressorZlib() {
- InitStream();
-}
-
-DecompressorZlib::~DecompressorZlib() {
- inflateEnd(stream_.get());
-}
-
-void DecompressorZlib::Reset() {
- inflateEnd(stream_.get());
- InitStream();
-}
-
-bool DecompressorZlib::Process(const uint8* input_data, int input_size,
- uint8* output_data, int output_size,
- int* consumed, int* written) {
- DCHECK_GT(output_size, 0);
-
- // Setup I/O parameters.
- stream_->avail_in = input_size;
- stream_->next_in = (Bytef*)input_data;
- stream_->avail_out = output_size;
- stream_->next_out = (Bytef*)output_data;
-
- int ret = inflate(stream_.get(), Z_NO_FLUSH);
- if (ret == Z_STREAM_ERROR) {
- NOTREACHED() << "zlib compression failed";
- }
-
- *consumed = input_size - stream_->avail_in;
- *written = output_size - stream_->avail_out;
-
- // Since we check that output is always greater than 0, the only
- // reason for us to get Z_BUF_ERROR is when zlib requires more input
- // data.
- return ret == Z_OK || ret == Z_BUF_ERROR;
-}
-
-void DecompressorZlib::InitStream() {
- stream_.reset(new z_stream());
-
- stream_->next_in = Z_NULL;
- stream_->zalloc = Z_NULL;
- stream_->zfree = Z_NULL;
- stream_->opaque = Z_NULL;
-
- int ret = inflateInit(stream_.get());
- DCHECK_EQ(ret, Z_OK);
-}
-
-} // namespace remoting
diff --git a/remoting/base/decompressor_zlib.h b/remoting/base/decompressor_zlib.h
deleted file mode 100644
index 5d1a88b..0000000
--- a/remoting/base/decompressor_zlib.h
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2011 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_DECOMPRESSOR_ZLIB_H_
-#define REMOTING_BASE_DECOMPRESSOR_ZLIB_H_
-
-#include "base/memory/scoped_ptr.h"
-#include "remoting/base/decompressor.h"
-
-typedef struct z_stream_s z_stream;
-
-namespace remoting {
-
-// A lossless decompressor using zlib.
-class DecompressorZlib : public Decompressor {
- public:
- DecompressorZlib();
- virtual ~DecompressorZlib();
-
- virtual void Reset() OVERRIDE;
-
- // Decompressor implementations.
- virtual bool Process(const uint8* input_data, int input_size,
- uint8* output_data, int output_size,
- int* consumed, int* written) OVERRIDE;
-
- private:
- void InitStream();
- scoped_ptr<z_stream> stream_;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_BASE_DECOMPRESSOR_ZLIB_H_
diff --git a/remoting/base/decompressor_zlib_unittest.cc b/remoting/base/decompressor_zlib_unittest.cc
deleted file mode 100644
index aebaa5a..0000000
--- a/remoting/base/decompressor_zlib_unittest.cc
+++ /dev/null
@@ -1,142 +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 <stdlib.h>
-
-#include "remoting/base/compressor_zlib.h"
-#include "remoting/base/decompressor_zlib.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace remoting {
-
-static void GenerateTestData(uint8* data, int size, int seed) {
- srand(seed);
- for (int i = 0; i < size; ++i)
- data[i] = rand() % 256;
-}
-
-// Keep compressing |input_data| into |output_data| until the last
-// bytes is consumed.
-//
-// The compressed size is written to |compressed_size|.
-static void Compress(remoting::Compressor* compressor,
- const uint8* input_data, int input_size,
- uint8* output_data, int output_size,
- int* compressed_size) {
- *compressed_size = 0;
- while (true) {
- int consumed, written;
- bool ret = compressor->Process(
- input_data, input_size, output_data, output_size,
- input_size == 0 ?
- Compressor::CompressorFinish : Compressor::CompressorNoFlush,
- &consumed, &written);
- input_data += consumed;
- input_size -= consumed;
- output_data += written;
- output_size -= written;
- *compressed_size += written;
-
- if (!ret)
- break;
- }
-}
-
-// The decompressed size is written to |decompressed_size|.
-static void Decompress(remoting::Decompressor* decompressor,
- const uint8* input_data, int input_size,
- uint8* output_data, int output_size,
- int* decompressed_size) {
- *decompressed_size = 0;
- while (true) {
- int consumed, written;
- bool ret = decompressor->Process(input_data, input_size,
- output_data, output_size,
- &consumed, &written);
- input_data += consumed;
- input_size -= consumed;
- output_data += written;
- output_size -= written;
- *decompressed_size += written;
-
- if (!ret)
- break;
- }
-}
-
-TEST(DecompressorZlibTest, CompressAndDecompress) {
- static const int kRawDataSize = 1024 * 128;
- static const int kCompressedDataSize = 2 * kRawDataSize;
- static const int kDecompressedDataSize = kRawDataSize;
-
- uint8 raw_data[kRawDataSize];
- uint8 compressed_data[kCompressedDataSize];
- uint8 decompressed_data[kDecompressedDataSize];
-
- // Generate the test data.g
- GenerateTestData(raw_data, kRawDataSize, 99);
-
- // Then use the compressor.
- remoting::CompressorZlib compressor;
- int compressed_size = 0;
- Compress(&compressor, raw_data, kRawDataSize,
- compressed_data, kCompressedDataSize,
- &compressed_size);
-
- // Then use the decompressor.
- remoting::DecompressorZlib decompressor;
- int decompressed_size = 0;
- Decompress(&decompressor, compressed_data, compressed_size,
- decompressed_data, kDecompressedDataSize,
- &decompressed_size);
-
- EXPECT_EQ(kRawDataSize, decompressed_size);
- EXPECT_EQ(0, memcmp(raw_data, decompressed_data, decompressed_size));
-}
-
-// Checks that zlib can work with a small output buffer by limiting
-// number of bytes it gets from the input.
-TEST(DecompressorZlibTest, SmallOutputBuffer) {
- static const int kRawDataSize = 1024 * 128;
- static const int kCompressedDataSize = 2 * kRawDataSize;
-
- uint8 raw_data[kRawDataSize];
- uint8 compressed_data[kCompressedDataSize];
-
- // Generate the test data.
- GenerateTestData(raw_data, kRawDataSize, 99);
-
- // Then use the compressor to compress.
- remoting::CompressorZlib compressor;
- int compressed_size = 0;
- Compress(&compressor, raw_data, kRawDataSize,
- compressed_data, kCompressedDataSize,
- &compressed_size);
-
- // Then use the decompressor. We decompress into a 1 byte buffer
- // every time.
- remoting::DecompressorZlib decompressor;
- uint8* input_data = compressed_data;
- int input_size = compressed_size;
- int decompressed_size = 0;
- while (true) {
- int consumed, written;
- uint8 output_data;
- bool ret = decompressor.Process(input_data, input_size,
- &output_data, 1,
- &consumed, &written);
- input_data += consumed;
- input_size -= consumed;
-
- // Expect that there's only one byte written.
- EXPECT_EQ(1, written);
- decompressed_size += written;
-
- if (!ret)
- break;
- }
- EXPECT_EQ(kRawDataSize, decompressed_size);
-}
-
-} // namespace remoting
diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc
index 3a7fddc..4f301ce 100644
--- a/remoting/client/rectangle_update_decoder.cc
+++ b/remoting/client/rectangle_update_decoder.cc
@@ -13,7 +13,7 @@
#include "ppapi/cpp/image_data.h"
#include "remoting/base/util.h"
#include "remoting/codec/video_decoder.h"
-#include "remoting/codec/video_decoder_row_based.h"
+#include "remoting/codec/video_decoder_verbatim.h"
#include "remoting/codec/video_decoder_vp8.h"
#include "remoting/client/frame_consumer.h"
#include "remoting/protocol/session_config.h"
@@ -46,9 +46,7 @@ void RectangleUpdateDecoder::Initialize(const SessionConfig& config) {
// Initialize decoder based on the selected codec.
ChannelConfig::Codec codec = config.video_config().codec;
if (codec == ChannelConfig::CODEC_VERBATIM) {
- decoder_.reset(VideoDecoderRowBased::CreateVerbatimDecoder());
- } else if (codec == ChannelConfig::CODEC_ZIP) {
- decoder_.reset(VideoDecoderRowBased::CreateZlibDecoder());
+ decoder_.reset(new VideoDecoderVerbatim());
} else if (codec == ChannelConfig::CODEC_VP8) {
decoder_.reset(new VideoDecoderVp8());
} else {
diff --git a/remoting/codec/video_decoder_row_based.cc b/remoting/codec/video_decoder_verbatim.cc
index 35ed573..f9a5e11 100644
--- a/remoting/codec/video_decoder_row_based.cc
+++ b/remoting/codec/video_decoder_verbatim.cc
@@ -2,12 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/codec/video_decoder_row_based.h"
+#include "remoting/codec/video_decoder_verbatim.h"
#include "base/logging.h"
-#include "remoting/base/decompressor.h"
-#include "remoting/base/decompressor_zlib.h"
-#include "remoting/base/decompressor_verbatim.h"
#include "remoting/base/util.h"
namespace remoting {
@@ -15,33 +12,21 @@ namespace remoting {
namespace {
// Both input and output data are assumed to be RGBA32.
const int kBytesPerPixel = 4;
-}
+} // namespace
-VideoDecoderRowBased* VideoDecoderRowBased::CreateZlibDecoder() {
- return new VideoDecoderRowBased(new DecompressorZlib(),
- VideoPacketFormat::ENCODING_ZLIB);
-}
-VideoDecoderRowBased* VideoDecoderRowBased::CreateVerbatimDecoder() {
- return new VideoDecoderRowBased(new DecompressorVerbatim(),
- VideoPacketFormat::ENCODING_VERBATIM);
-}
-
-VideoDecoderRowBased::VideoDecoderRowBased(Decompressor* decompressor,
- VideoPacketFormat::Encoding encoding)
+VideoDecoderVerbatim::VideoDecoderVerbatim()
: state_(kUninitialized),
clip_(SkIRect::MakeEmpty()),
- decompressor_(decompressor),
- encoding_(encoding),
row_pos_(0),
row_y_(0),
screen_size_(SkISize::Make(0, 0)) {
}
-VideoDecoderRowBased::~VideoDecoderRowBased() {
+VideoDecoderVerbatim::~VideoDecoderVerbatim() {
}
-bool VideoDecoderRowBased::IsReadyForData() {
+bool VideoDecoderVerbatim::IsReadyForData() {
switch (state_) {
case kUninitialized:
case kError:
@@ -56,8 +41,7 @@ bool VideoDecoderRowBased::IsReadyForData() {
return false;
}
-void VideoDecoderRowBased::Initialize(const SkISize& screen_size) {
- decompressor_->Reset();
+void VideoDecoderVerbatim::Initialize(const SkISize& screen_size) {
updated_region_.setEmpty();
screen_buffer_.reset(NULL);
@@ -71,7 +55,7 @@ void VideoDecoderRowBased::Initialize(const SkISize& screen_size) {
state_ = kReady;
}
-VideoDecoder::DecodeResult VideoDecoderRowBased::DecodePacket(
+VideoDecoder::DecodeResult VideoDecoderVerbatim::DecodePacket(
const VideoPacket* packet) {
UpdateStateForPacket(packet);
@@ -88,22 +72,19 @@ VideoDecoder::DecodeResult VideoDecoderRowBased::DecodePacket(
kBytesPerPixel * clip_.left();
// Consume all the data in the message.
- bool decompress_again = true;
int used = 0;
- while (decompress_again && used < in_size) {
+ while (used < in_size) {
if (row_y_ >= clip_.height()) {
state_ = kError;
LOG(WARNING) << "Too much data is received for the given rectangle.";
return DECODE_ERROR;
}
- int written = 0;
- int consumed = 0;
- decompress_again = decompressor_->Process(
- in + used, in_size - used, out + row_pos_, row_size - row_pos_,
- &consumed, &written);
- used += consumed;
- row_pos_ += written;
+ int bytes_to_copy = std::min(in_size - used, row_size - row_pos_);
+ memcpy(out + row_pos_, in + used, bytes_to_copy);
+
+ used += bytes_to_copy;
+ row_pos_ += bytes_to_copy;
// If this row is completely filled then move onto the next row.
if (row_pos_ == row_size) {
@@ -121,7 +102,6 @@ VideoDecoder::DecodeResult VideoDecoderRowBased::DecodePacket(
}
updated_region_.op(clip_, SkRegion::kUnion_Op);
- decompressor_->Reset();
}
if (state_ == kDone) {
@@ -131,7 +111,7 @@ VideoDecoder::DecodeResult VideoDecoderRowBased::DecodePacket(
}
}
-void VideoDecoderRowBased::UpdateStateForPacket(const VideoPacket* packet) {
+void VideoDecoderVerbatim::UpdateStateForPacket(const VideoPacket* packet) {
if (state_ == kError) {
return;
}
@@ -184,16 +164,16 @@ void VideoDecoderRowBased::UpdateStateForPacket(const VideoPacket* packet) {
return;
}
-VideoPacketFormat::Encoding VideoDecoderRowBased::Encoding() {
- return encoding_;
+VideoPacketFormat::Encoding VideoDecoderVerbatim::Encoding() {
+ return VideoPacketFormat::ENCODING_VERBATIM;
}
-void VideoDecoderRowBased::Invalidate(const SkISize& view_size,
+void VideoDecoderVerbatim::Invalidate(const SkISize& view_size,
const SkRegion& region) {
updated_region_.op(region, SkRegion::kUnion_Op);
}
-void VideoDecoderRowBased::RenderFrame(const SkISize& view_size,
+void VideoDecoderVerbatim::RenderFrame(const SkISize& view_size,
const SkIRect& clip_area,
uint8* image_buffer,
int image_stride,
diff --git a/remoting/codec/video_decoder_row_based.h b/remoting/codec/video_decoder_verbatim.h
index 3e017e3..8c25013 100644
--- a/remoting/codec/video_decoder_row_based.h
+++ b/remoting/codec/video_decoder_verbatim.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef REMOTING_CODEC_VIDEO_DECODER_ROW_BASED_H_
-#define REMOTING_CODEC_VIDEO_DECODER_ROW_BASED_H_
+#ifndef REMOTING_CODEC_VIDEO_DECODER_VERBATIM_H_
+#define REMOTING_CODEC_VIDEO_DECODER_VERBATIM_H_
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
@@ -11,14 +11,14 @@
namespace remoting {
-class Decompressor;
-
-class VideoDecoderRowBased : public VideoDecoder {
+// Video decoder implementations that decodes video packet encoded by
+// VideoEncoderVerbatim. It just copies data from incoming packets to the
+// video frames.
+class VideoDecoderVerbatim : public VideoDecoder {
public:
- virtual ~VideoDecoderRowBased();
+ virtual ~VideoDecoderVerbatim();
- static VideoDecoderRowBased* CreateZlibDecoder();
- static VideoDecoderRowBased* CreateVerbatimDecoder();
+ VideoDecoderVerbatim();
// VideoDecoder implementation.
virtual bool IsReadyForData() OVERRIDE;
@@ -43,9 +43,6 @@ class VideoDecoderRowBased : public VideoDecoder {
kError,
};
- VideoDecoderRowBased(Decompressor* decompressor,
- VideoPacketFormat::Encoding encoding);
-
// Helper method. Called from DecodePacket to updated state of the decoder.
void UpdateStateForPacket(const VideoPacket* packet);
@@ -55,12 +52,6 @@ class VideoDecoderRowBased : public VideoDecoder {
// Keeps track of the updating rect.
SkIRect clip_;
- // The compression for the input byte stream.
- scoped_ptr<Decompressor> decompressor_;
-
- // The encoding of the incoming stream.
- VideoPacketFormat::Encoding encoding_;
-
// The position in the row that we are updating.
int row_pos_;
@@ -76,9 +67,9 @@ class VideoDecoderRowBased : public VideoDecoder {
// The bitmap holding the remote screen bits.
scoped_array<uint8> screen_buffer_;
- DISALLOW_COPY_AND_ASSIGN(VideoDecoderRowBased);
+ DISALLOW_COPY_AND_ASSIGN(VideoDecoderVerbatim);
};
} // namespace remoting
-#endif // REMOTING_CODEC_VIDEO_DECODER_ROW_BASED_H_
+#endif // REMOTING_CODEC_VIDEO_DECODER_VERBATIM_H_
diff --git a/remoting/codec/video_encode_decode_unittest.cc b/remoting/codec/video_encode_decode_unittest.cc
deleted file mode 100644
index 5b24293..0000000
--- a/remoting/codec/video_encode_decode_unittest.cc
+++ /dev/null
@@ -1,38 +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/codec/video_encoder_row_based.h"
-
-#include "media/base/video_frame.h"
-#include "remoting/codec/codec_test.h"
-#include "remoting/codec/video_decoder_row_based.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace remoting {
-
-TEST(EncodeDecodeTest, EncodeAndDecodeZlib) {
- scoped_ptr<VideoEncoderRowBased> encoder(
- VideoEncoderRowBased::CreateZlibEncoder());
- scoped_ptr<VideoDecoderRowBased> decoder(
- VideoDecoderRowBased::CreateZlibDecoder());
- TestVideoEncoderDecoder(encoder.get(), decoder.get(), true);
-}
-
-TEST(EncodeDecodeTest, EncodeAndDecodeSmallOutputBufferZlib) {
- scoped_ptr<VideoEncoderRowBased> encoder(
- VideoEncoderRowBased::CreateZlibEncoder(64));
- scoped_ptr<VideoDecoderRowBased> decoder(
- VideoDecoderRowBased::CreateZlibDecoder());
- TestVideoEncoderDecoder(encoder.get(), decoder.get(), true);
-}
-
-TEST(EncodeDecodeTest, EncodeAndDecodeNoneStrictZlib) {
- scoped_ptr<VideoEncoderRowBased> encoder(
- VideoEncoderRowBased::CreateZlibEncoder());
- scoped_ptr<VideoDecoderRowBased> decoder(
- VideoDecoderRowBased::CreateZlibDecoder());
- TestVideoEncoderDecoder(encoder.get(), decoder.get(), false);
-}
-
-} // namespace remoting
diff --git a/remoting/codec/video_encoder_row_based.h b/remoting/codec/video_encoder_row_based.h
deleted file mode 100644
index 342327b..0000000
--- a/remoting/codec/video_encoder_row_based.h
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright (c) 2011 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_CODEC_VIDEO_ENCODER_ROW_BASED_H_
-#define REMOTING_CODEC_VIDEO_ENCODER_ROW_BASED_H_
-
-#include "remoting/codec/video_encoder.h"
-#include "remoting/proto/video.pb.h"
-#include "third_party/skia/include/core/SkRect.h"
-
-namespace remoting {
-
-class Compressor;
-
-// VideoEncoderRowBased implements a VideoEncoder 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 VideoEncoderRowBased : public VideoEncoder {
- public:
- static VideoEncoderRowBased* CreateZlibEncoder();
- static VideoEncoderRowBased* CreateZlibEncoder(int packet_size);
- static VideoEncoderRowBased* CreateVerbatimEncoder();
- static VideoEncoderRowBased* CreateVerbatimEncoder(int packet_size);
-
- virtual ~VideoEncoderRowBased();
-
- virtual void Encode(
- scoped_refptr<CaptureData> capture_data,
- bool key_frame,
- const DataAvailableCallback& data_available_callback) OVERRIDE;
-
- private:
- VideoEncoderRowBased(Compressor* compressor,
- VideoPacketFormat::Encoding encoding);
- VideoEncoderRowBased(Compressor* compressor,
- VideoPacketFormat::Encoding encoding,
- int packet_size);
-
- // Encode a single dirty rect using compressor.
- void EncodeRect(const SkIRect& rect, bool last);
-
- // Marks a packet as the first in a series of rectangle updates.
- void PrepareUpdateStart(const SkIRect& 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_;
- DataAvailableCallback callback_;
-
- // The most recent screen size.
- SkISize screen_size_;
-
- int packet_size_;
-};
-
-} // namespace remoting
-
-#endif // REMOTING_CODEC_VIDEO_ENCODER_ROW_BASED_H_
diff --git a/remoting/codec/video_encoder_row_based_unittest.cc b/remoting/codec/video_encoder_row_based_unittest.cc
deleted file mode 100644
index e94d18d..0000000
--- a/remoting/codec/video_encoder_row_based_unittest.cc
+++ /dev/null
@@ -1,24 +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/codec/video_encoder_row_based.h"
-
-#include "remoting/codec/codec_test.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-namespace remoting {
-
-TEST(VideoEncoderZlibTest, TestVideoEncoder) {
- scoped_ptr<VideoEncoderRowBased> encoder(
- VideoEncoderRowBased::CreateZlibEncoder());
- TestVideoEncoder(encoder.get(), true);
-}
-
-TEST(VideoEncoderZlibTest, TestVideoEncoderSmallOutputBuffer) {
- scoped_ptr<VideoEncoderRowBased> encoder(
- VideoEncoderRowBased::CreateZlibEncoder(16));
- TestVideoEncoder(encoder.get(), true);
-}
-
-} // namespace remoting
diff --git a/remoting/codec/video_encoder_row_based.cc b/remoting/codec/video_encoder_verbatim.cc
index b2454aa..25f2217 100644
--- a/remoting/codec/video_encoder_row_based.cc
+++ b/remoting/codec/video_encoder_verbatim.cc
@@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "remoting/codec/video_encoder_row_based.h"
+#include "remoting/codec/video_encoder_verbatim.h"
#include "base/logging.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,49 +13,19 @@ namespace remoting {
static const int kPacketSize = 1024 * 1024;
-VideoEncoderRowBased* VideoEncoderRowBased::CreateZlibEncoder() {
- return new VideoEncoderRowBased(new CompressorZlib(),
- VideoPacketFormat::ENCODING_ZLIB);
+VideoEncoderVerbatim::VideoEncoderVerbatim()
+ : screen_size_(SkISize::Make(0,0)),
+ max_packet_size_(kPacketSize) {
}
-VideoEncoderRowBased* VideoEncoderRowBased::CreateZlibEncoder(int packet_size) {
- return new VideoEncoderRowBased(new CompressorZlib(),
- VideoPacketFormat::ENCODING_ZLIB,
- packet_size);
+void VideoEncoderVerbatim::SetMaxPacketSize(int size) {
+ max_packet_size_ = size;
}
-VideoEncoderRowBased* VideoEncoderRowBased::CreateVerbatimEncoder() {
- return new VideoEncoderRowBased(new CompressorVerbatim(),
- VideoPacketFormat::ENCODING_VERBATIM);
+VideoEncoderVerbatim::~VideoEncoderVerbatim() {
}
-VideoEncoderRowBased* VideoEncoderRowBased::CreateVerbatimEncoder(
- int packet_size) {
- return new VideoEncoderRowBased(new CompressorVerbatim(),
- VideoPacketFormat::ENCODING_VERBATIM,
- packet_size);
-}
-
-VideoEncoderRowBased::VideoEncoderRowBased(Compressor* compressor,
- VideoPacketFormat::Encoding encoding)
- : encoding_(encoding),
- compressor_(compressor),
- screen_size_(SkISize::Make(0,0)),
- packet_size_(kPacketSize) {
-}
-
-VideoEncoderRowBased::VideoEncoderRowBased(Compressor* compressor,
- VideoPacketFormat::Encoding encoding,
- int packet_size)
- : encoding_(encoding),
- compressor_(compressor),
- screen_size_(SkISize::Make(0,0)),
- packet_size_(packet_size) {
-}
-
-VideoEncoderRowBased::~VideoEncoderRowBased() {}
-
-void VideoEncoderRowBased::Encode(
+void VideoEncoderVerbatim::Encode(
scoped_refptr<CaptureData> capture_data,
bool key_frame,
const DataAvailableCallback& data_available_callback) {
@@ -79,48 +47,49 @@ void VideoEncoderRowBased::Encode(
callback_.Reset();
}
-void VideoEncoderRowBased::EncodeRect(const SkIRect& rect, bool last) {
+void VideoEncoderVerbatim::EncodeRect(const SkIRect& rect, bool last) {
CHECK(capture_data_->data_planes().data[0]);
CHECK_EQ(capture_data_->pixel_format(), media::VideoFrame::RGB32);
const int strides = capture_data_->data_planes().strides[0];
const int bytes_per_pixel = 4;
const int row_size = bytes_per_pixel * rect.width();
- compressor_->Reset();
-
scoped_ptr<VideoPacket> packet(new VideoPacket());
PrepareUpdateStart(rect, packet.get());
const uint8* in = capture_data_->data_planes().data[0] +
rect.fTop * strides + rect.fLeft * bytes_per_pixel;
// TODO(hclam): Fill in the sequence number.
- uint8* out = GetOutputBuffer(packet.get(), packet_size_);
+ uint8* out = GetOutputBuffer(packet.get(), max_packet_size_);
int filled = 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) {
+ while (row_y < rect.height()) {
// Prepare a message for sending out.
if (!packet.get()) {
packet.reset(new VideoPacket());
- out = GetOutputBuffer(packet.get(), packet_size_);
+ out = GetOutputBuffer(packet.get(), max_packet_size_);
filled = 0;
}
- Compressor::CompressorFlush flush = Compressor::CompressorNoFlush;
- if (row_y == rect.height() - 1) {
- flush = Compressor::CompressorFinish;
+ if (row_y < rect.height()) {
+ int bytes_to_copy =
+ std::min(row_size - row_pos, max_packet_size_ - filled);
+ memcpy(out + filled, in + row_pos, bytes_to_copy);
+ row_pos += bytes_to_copy;
+ filled += bytes_to_copy;
+
+ // Jump to the next row when we've reached the end of the current row.
+ if (row_pos == row_size) {
+ row_pos = 0;
+ in += strides;
+ ++row_y;
+ }
}
- int consumed = 0;
- int written = 0;
- compress_again = compressor_->Process(in + row_pos, row_size - row_pos,
- out + filled, packet_size_ - filled,
- flush, &consumed, &written);
- row_pos += consumed;
- filled += written;
+ if (row_y == rect.height()) {
+ DCHECK_EQ(row_pos, 0);
- // We have reached the end of stream.
- if (!compress_again) {
+ packet->mutable_data()->resize(filled);
packet->set_flags(packet->flags() | VideoPacket::LAST_PACKET);
packet->set_capture_time_ms(capture_data_->capture_time_ms());
packet->set_client_sequence_number(
@@ -132,26 +101,17 @@ void VideoEncoderRowBased::EncodeRect(const SkIRect& rect, bool last) {
packet->mutable_format()->set_y_dpi(dpi.y());
if (last)
packet->set_flags(packet->flags() | VideoPacket::LAST_PARTITION);
- 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) {
+ // If we have filled the current packet, then send it.
+ if (filled == max_packet_size_ || row_y == rect.height()) {
packet->mutable_data()->resize(filled);
callback_.Run(packet.Pass());
}
-
- // Reached the end of input row and we're not at the last row.
- if (row_pos == row_size && row_y < rect.height() - 1) {
- row_pos = 0;
- in += strides;
- ++row_y;
- }
}
}
-void VideoEncoderRowBased::PrepareUpdateStart(const SkIRect& rect,
+void VideoEncoderVerbatim::PrepareUpdateStart(const SkIRect& rect,
VideoPacket* packet) {
packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET);
@@ -160,7 +120,7 @@ void VideoEncoderRowBased::PrepareUpdateStart(const SkIRect& rect,
format->set_y(rect.fTop);
format->set_width(rect.width());
format->set_height(rect.height());
- format->set_encoding(encoding_);
+ format->set_encoding(VideoPacketFormat::ENCODING_VERBATIM);
if (capture_data_->size() != screen_size_) {
screen_size_ = capture_data_->size();
format->set_screen_width(screen_size_.width());
@@ -168,7 +128,7 @@ void VideoEncoderRowBased::PrepareUpdateStart(const SkIRect& rect,
}
}
-uint8* VideoEncoderRowBased::GetOutputBuffer(VideoPacket* packet, size_t size) {
+uint8* VideoEncoderVerbatim::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*>(
diff --git a/remoting/codec/video_encoder_verbatim.h b/remoting/codec/video_encoder_verbatim.h
new file mode 100644
index 0000000..02c5814
--- /dev/null
+++ b/remoting/codec/video_encoder_verbatim.h
@@ -0,0 +1,56 @@
+// Copyright (c) 2011 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_CODEC_VIDEO_ENCODER_VERBATIM_H_
+#define REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_
+
+#include "remoting/codec/video_encoder.h"
+#include "remoting/proto/video.pb.h"
+#include "third_party/skia/include/core/SkRect.h"
+
+namespace remoting {
+
+// VideoEncoderVerbatim implements a VideoEncoder that sends image data as a
+// sequence of RGB values, without compression.
+class VideoEncoderVerbatim : public VideoEncoder {
+ public:
+ VideoEncoderVerbatim();
+ virtual ~VideoEncoderVerbatim();
+
+ // Sets maximum size of data in video packets. Used by unittests.
+ void SetMaxPacketSize(int size);
+
+ // VideoEncoder interface.
+ virtual void Encode(
+ scoped_refptr<CaptureData> capture_data,
+ bool key_frame,
+ const DataAvailableCallback& data_available_callback) OVERRIDE;
+
+ private:
+ // Encode a single dirty |rect|.
+ void EncodeRect(const SkIRect& rect, bool last);
+
+ // Initializes first packet in a sequence of video packets to update screen
+ // rectangle |rect|.
+ void PrepareUpdateStart(const SkIRect& rect, VideoPacket* packet);
+
+ // Allocates a buffer of the specified |size| inside |packet| and returns the
+ // pointer to it.
+ uint8* GetOutputBuffer(VideoPacket* packet, size_t size);
+
+ // Submit |packet| to |callback_|.
+ void SubmitMessage(VideoPacket* packet, size_t rect_index);
+
+ scoped_refptr<CaptureData> capture_data_;
+ DataAvailableCallback callback_;
+
+ // The most recent screen size.
+ SkISize screen_size_;
+
+ int max_packet_size_;
+};
+
+} // namespace remoting
+
+#endif // REMOTING_CODEC_VIDEO_ENCODER_VERBATIM_H_
diff --git a/remoting/codec/video_encoder_verbatim_unittest.cc b/remoting/codec/video_encoder_verbatim_unittest.cc
new file mode 100644
index 0000000..d6315ee
--- /dev/null
+++ b/remoting/codec/video_encoder_verbatim_unittest.cc
@@ -0,0 +1,37 @@
+// 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/codec/video_encoder_verbatim.h"
+
+#include "remoting/codec/codec_test.h"
+#include "remoting/codec/video_decoder_verbatim.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace remoting {
+
+TEST(VideoEncoderVerbatimTest, TestVideoEncoder) {
+ scoped_ptr<VideoEncoderVerbatim> encoder(new VideoEncoderVerbatim());
+ TestVideoEncoder(encoder.get(), true);
+}
+
+TEST(VideoEncoderVerbatimTest, TestVideoEncoderSmallOutputBuffer) {
+ scoped_ptr<VideoEncoderVerbatim> encoder(new VideoEncoderVerbatim());
+ encoder->SetMaxPacketSize(16);
+ TestVideoEncoder(encoder.get(), true);
+}
+
+TEST(VideoEncoderVerbatimTest, EncodeAndDecode) {
+ scoped_ptr<VideoEncoderVerbatim> encoder(new VideoEncoderVerbatim());
+ scoped_ptr<VideoDecoderVerbatim> decoder(new VideoDecoderVerbatim());
+ TestVideoEncoderDecoder(encoder.get(), decoder.get(), false);
+}
+
+TEST(VideoEncoderVerbatimTest, EncodeAndDecodeSmallOutputBuffer) {
+ scoped_ptr<VideoEncoderVerbatim> encoder(new VideoEncoderVerbatim());
+ encoder->SetMaxPacketSize(16);
+ scoped_ptr<VideoDecoderVerbatim> decoder(new VideoDecoderVerbatim());
+ TestVideoEncoderDecoder(encoder.get(), decoder.get(), false);
+}
+
+} // namespace remoting
diff --git a/remoting/host/client_session.cc b/remoting/host/client_session.cc
index 8a9b842..a851129 100644
--- a/remoting/host/client_session.cc
+++ b/remoting/host/client_session.cc
@@ -11,7 +11,7 @@
#include "remoting/codec/audio_encoder_speex.h"
#include "remoting/codec/audio_encoder_verbatim.h"
#include "remoting/codec/video_encoder.h"
-#include "remoting/codec/video_encoder_row_based.h"
+#include "remoting/codec/video_encoder_verbatim.h"
#include "remoting/codec/video_encoder_vp8.h"
#include "remoting/host/audio_scheduler.h"
#include "remoting/host/desktop_environment.h"
@@ -273,9 +273,7 @@ VideoEncoder* ClientSession::CreateVideoEncoder(
const protocol::ChannelConfig& video_config = config.video_config();
if (video_config.codec == protocol::ChannelConfig::CODEC_VERBATIM) {
- return VideoEncoderRowBased::CreateVerbatimEncoder();
- } else if (video_config.codec == protocol::ChannelConfig::CODEC_ZIP) {
- return VideoEncoderRowBased::CreateZlibEncoder();
+ return new remoting::VideoEncoderVerbatim();
} else if (video_config.codec == protocol::ChannelConfig::CODEC_VP8) {
return new remoting::VideoEncoderVp8();
}
diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp
index aaaf0ea..6395b43 100644
--- a/remoting/remoting.gyp
+++ b/remoting/remoting.gyp
@@ -1377,7 +1377,6 @@
'../third_party/libvpx/libvpx.gyp:libvpx',
'../third_party/protobuf/protobuf.gyp:protobuf_lite',
'../third_party/speex/speex.gyp:libspeex',
- '../third_party/zlib/zlib.gyp:zlib',
'../media/media.gyp:yuv_convert',
'remoting_jingle_glue',
'remoting_resources',
@@ -1404,18 +1403,8 @@
'base/capture_data.h',
'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',
'base/constants.h',
- 'base/decompressor.h',
- 'base/decompressor_verbatim.cc',
- 'base/decompressor_verbatim.h',
- 'base/decompressor_zlib.cc',
- 'base/decompressor_zlib.h',
'base/plugin_thread_task_runner.cc',
'base/plugin_thread_task_runner.h',
'base/rate_counter.cc',
@@ -1440,15 +1429,15 @@
'codec/audio_encoder_verbatim.cc',
'codec/audio_encoder_verbatim.h',
'codec/video_decoder.h',
+ 'codec/video_decoder_verbatim.cc',
+ 'codec/video_decoder_verbatim.h',
'codec/video_decoder_vp8.cc',
'codec/video_decoder_vp8.h',
- 'codec/video_decoder_row_based.cc',
- 'codec/video_decoder_row_based.h',
'codec/video_encoder.h',
+ 'codec/video_encoder_verbatim.cc',
+ 'codec/video_encoder_verbatim.h',
'codec/video_encoder_vp8.cc',
'codec/video_encoder_vp8.h',
- 'codec/video_encoder_row_based.cc',
- 'codec/video_encoder_row_based.h',
],
}, # end of target 'remoting_base'
@@ -2065,8 +2054,6 @@
'base/auto_thread_task_runner_unittest.cc',
'base/breakpad_win_unittest.cc',
'base/compound_buffer_unittest.cc',
- 'base/compressor_zlib_unittest.cc',
- 'base/decompressor_zlib_unittest.cc',
'base/resources_unittest.cc',
'base/util_unittest.cc',
'client/audio_player_unittest.cc',
@@ -2075,8 +2062,7 @@
'codec/codec_test.cc',
'codec/codec_test.h',
'codec/video_decoder_vp8_unittest.cc',
- 'codec/video_encode_decode_unittest.cc',
- 'codec/video_encoder_row_based_unittest.cc',
+ 'codec/video_encoder_verbatim_unittest.cc',
'codec/video_encoder_vp8_unittest.cc',
'host/audio_capturer_win_unittest.cc',
'host/branding.cc',