Delete unused class TransformAdapter.
Bug: webrtc:6424
Change-Id: I75bf0ab0ce4bf2e1197885f06b8a772b5a5a9dfa
Reviewed-on: https://webrtc-review.googlesource.com/84284
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23735}
diff --git a/rtc_base/BUILD.gn b/rtc_base/BUILD.gn
index ceb5b02..28ff3c8 100644
--- a/rtc_base/BUILD.gn
+++ b/rtc_base/BUILD.gn
@@ -862,8 +862,6 @@
"optionsfile.h",
"rollingaccumulator.h",
"sslroots.h",
- "transformadapter.cc",
- "transformadapter.h",
]
if (is_win) {
diff --git a/rtc_base/transformadapter.cc b/rtc_base/transformadapter.cc
deleted file mode 100644
index 0f9c66d..0000000
--- a/rtc_base/transformadapter.cc
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright 2004 The WebRTC Project Authors. All rights reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#include "rtc_base/transformadapter.h"
-
-#include <string.h>
-
-#include "rtc_base/checks.h"
-
-namespace rtc {
-
-///////////////////////////////////////////////////////////////////////////////
-
-TransformAdapter::TransformAdapter(StreamInterface* stream,
- TransformInterface* transform,
- bool direction_read)
- : StreamAdapterInterface(stream),
- transform_(transform),
- direction_read_(direction_read),
- state_(ST_PROCESSING),
- len_(0) {}
-
-TransformAdapter::~TransformAdapter() {
- TransformAdapter::Close();
- delete transform_;
-}
-
-StreamResult TransformAdapter::Read(void* buffer,
- size_t buffer_len,
- size_t* read,
- int* error) {
- if (!direction_read_)
- return SR_EOS;
-
- while (state_ != ST_ERROR) {
- if (state_ == ST_COMPLETE)
- return SR_EOS;
-
- // Buffer more data
- if ((state_ == ST_PROCESSING) && (len_ < sizeof(buffer_))) {
- size_t subread;
- StreamResult result = StreamAdapterInterface::Read(
- buffer_ + len_, sizeof(buffer_) - len_, &subread, &error_);
- if (result == SR_BLOCK) {
- return SR_BLOCK;
- } else if (result == SR_ERROR) {
- state_ = ST_ERROR;
- break;
- } else if (result == SR_EOS) {
- state_ = ST_FLUSHING;
- } else {
- len_ += subread;
- }
- }
-
- // Process buffered data
- size_t in_len = len_;
- size_t out_len = buffer_len;
- StreamResult result = transform_->Transform(
- buffer_, &in_len, buffer, &out_len, (state_ == ST_FLUSHING));
- RTC_DCHECK(result != SR_BLOCK);
- if (result == SR_EOS) {
- // Note: Don't signal SR_EOS this iteration, unless out_len is zero
- state_ = ST_COMPLETE;
- } else if (result == SR_ERROR) {
- state_ = ST_ERROR;
- error_ = -1; // TODO: propagate error
- break;
- } else if ((out_len == 0) && (state_ == ST_FLUSHING)) {
- // If there is no output AND no more input, then something is wrong
- state_ = ST_ERROR;
- error_ = -1; // TODO: better error code?
- break;
- }
-
- len_ -= in_len;
- if (len_ > 0)
- memmove(buffer_, buffer_ + in_len, len_);
-
- if (out_len == 0)
- continue;
-
- if (read)
- *read = out_len;
- return SR_SUCCESS;
- }
-
- if (error)
- *error = error_;
- return SR_ERROR;
-}
-
-StreamResult TransformAdapter::Write(const void* data,
- size_t data_len,
- size_t* written,
- int* error) {
- if (direction_read_)
- return SR_EOS;
-
- size_t bytes_written = 0;
- while (state_ != ST_ERROR) {
- if (state_ == ST_COMPLETE)
- return SR_EOS;
-
- if (len_ < sizeof(buffer_)) {
- // Process buffered data
- size_t in_len = data_len;
- size_t out_len = sizeof(buffer_) - len_;
- StreamResult result = transform_->Transform(
- data, &in_len, buffer_ + len_, &out_len, (state_ == ST_FLUSHING));
-
- RTC_DCHECK(result != SR_BLOCK);
- if (result == SR_EOS) {
- // Note: Don't signal SR_EOS this iteration, unless no data written
- state_ = ST_COMPLETE;
- } else if (result == SR_ERROR) {
- RTC_NOTREACHED(); // When this happens, think about what should be done
- state_ = ST_ERROR;
- error_ = -1; // TODO: propagate error
- break;
- }
-
- len_ = out_len;
- bytes_written = in_len;
- }
-
- size_t pos = 0;
- while (pos < len_) {
- size_t subwritten;
- StreamResult result = StreamAdapterInterface::Write(
- buffer_ + pos, len_ - pos, &subwritten, &error_);
- if (result == SR_BLOCK) {
- RTC_NOTREACHED(); // We should handle this
- return SR_BLOCK;
- } else if (result == SR_ERROR) {
- state_ = ST_ERROR;
- break;
- } else if (result == SR_EOS) {
- state_ = ST_COMPLETE;
- break;
- }
-
- pos += subwritten;
- }
-
- len_ -= pos;
- if (len_ > 0)
- memmove(buffer_, buffer_ + pos, len_);
-
- if (bytes_written == 0)
- continue;
-
- if (written)
- *written = bytes_written;
- return SR_SUCCESS;
- }
-
- if (error)
- *error = error_;
- return SR_ERROR;
-}
-
-void TransformAdapter::Close() {
- if (!direction_read_ && (state_ == ST_PROCESSING)) {
- state_ = ST_FLUSHING;
- do {
- Write(0, 0, nullptr, nullptr);
- } while (state_ == ST_FLUSHING);
- }
- state_ = ST_COMPLETE;
- StreamAdapterInterface::Close();
-}
-
-bool TransformAdapter::GetAvailable(size_t* size) const {
- return false;
-}
-
-bool TransformAdapter::ReserveSize(size_t size) {
- return true;
-}
-
-bool TransformAdapter::Rewind() {
- return false;
-}
-
-} // namespace rtc
diff --git a/rtc_base/transformadapter.h b/rtc_base/transformadapter.h
deleted file mode 100644
index 55f5a06..0000000
--- a/rtc_base/transformadapter.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright 2004 The WebRTC Project Authors. All rights reserved.
- *
- * Use of this source code is governed by a BSD-style license
- * that can be found in the LICENSE file in the root of the source
- * tree. An additional intellectual property rights grant can be found
- * in the file PATENTS. All contributing project authors may
- * be found in the AUTHORS file in the root of the source tree.
- */
-
-#ifndef RTC_BASE_TRANSFORMADAPTER_H_
-#define RTC_BASE_TRANSFORMADAPTER_H_
-
-#include "rtc_base/stream.h"
-
-namespace rtc {
-///////////////////////////////////////////////////////////////////////////////
-
-class TransformInterface {
- public:
- virtual ~TransformInterface() {}
-
- // Transform should convert the in_len bytes of input into the out_len-sized
- // output buffer. If flush is true, there will be no more data following
- // input.
- // After the transformation, in_len contains the number of bytes consumed, and
- // out_len contains the number of bytes ready in output.
- // Note: Transform should not return SR_BLOCK, as there is no asynchronous
- // notification available.
- virtual StreamResult Transform(const void* input,
- size_t* in_len,
- void* output,
- size_t* out_len,
- bool flush) = 0;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-// TransformAdapter causes all data passed through to be transformed by the
-// supplied TransformInterface object, which may apply compression, encryption,
-// etc.
-
-class TransformAdapter : public StreamAdapterInterface {
- public:
- // Note that the transformation is unidirectional, in the direction specified
- // by the constructor. Operations in the opposite direction result in SR_EOS.
- TransformAdapter(StreamInterface* stream,
- TransformInterface* transform,
- bool direction_read);
- ~TransformAdapter() override;
-
- StreamResult Read(void* buffer,
- size_t buffer_len,
- size_t* read,
- int* error) override;
- StreamResult Write(const void* data,
- size_t data_len,
- size_t* written,
- int* error) override;
- void Close() override;
-
- // Apriori, we can't tell what the transformation does to the stream length.
- bool GetAvailable(size_t* size) const override;
- bool ReserveSize(size_t size) override;
-
- // Transformations might not be restartable
- virtual bool Rewind();
-
- private:
- enum State { ST_PROCESSING, ST_FLUSHING, ST_COMPLETE, ST_ERROR };
- enum { BUFFER_SIZE = 1024 };
-
- TransformInterface* transform_;
- bool direction_read_;
- State state_;
- int error_;
-
- char buffer_[BUFFER_SIZE];
- size_t len_;
-};
-
-///////////////////////////////////////////////////////////////////////////////
-
-} // namespace rtc
-
-#endif // RTC_BASE_TRANSFORMADAPTER_H_