diff options
author | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-27 20:48:58 +0000 |
---|---|---|
committer | ajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-27 20:48:58 +0000 |
commit | 8372e30b34bcb940203829cf9c23909664f0e6ca (patch) | |
tree | 2207caa141724cd0cbaa55a264635f745583cf22 /remoting/client | |
parent | 3b52c980420f07c2a18c7589873227d5c5ebf49f (diff) | |
download | chromium_src-8372e30b34bcb940203829cf9c23909664f0e6ca.zip chromium_src-8372e30b34bcb940203829cf9c23909664f0e6ca.tar.gz chromium_src-8372e30b34bcb940203829cf9c23909664f0e6ca.tar.bz2 |
Revert "Add in a new FrameConsumer interface, Decode API, and a RectangleUpdateDecoder abstraction."
Reverting r60703 due to build break.
TBR=willchan
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60705 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/client')
-rw-r--r-- | remoting/client/frame_consumer.h | 59 | ||||
-rw-r--r-- | remoting/client/rectangle_update_decoder.cc | 217 | ||||
-rw-r--r-- | remoting/client/rectangle_update_decoder.h | 60 |
3 files changed, 0 insertions, 336 deletions
diff --git a/remoting/client/frame_consumer.h b/remoting/client/frame_consumer.h deleted file mode 100644 index 05c4448..0000000 --- a/remoting/client/frame_consumer.h +++ /dev/null @@ -1,59 +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_CLIENT_FRAME_CONSUMER_H_ -#define REMOTING_CLIENT_FRAME_CONSUMER_H_ - -namespace remoting { - -class FrameConsumer { - public: - FrameConsumer() {} - virtual ~FrameConsumer() {} - - // Request a frame be allocated from the FrameConsumer. - // - // If a frame cannot be allocated to fit the format, and height/width - // requirements, |frame_out| will be set to NULL. - // - // An allocated frame will have at least the width and height requested, but - // may be bigger. Query the retrun frame for the actual frame size, stride, - // etc. - // - // The AllocateFrame call is asynchronous. From invocation, until when the - // |done| callback is invoked, |frame_out| should be considered to be locked - // by the FrameConsumer, must remain a valid pointer, and should not be - // examined or modified. After |done| is called, the |frame_out| will - // contain a result of the allocation. If a frame could not be allocated, - // |frame_out| will be NULL. - // - // All frames retrieved via the AllocateFrame call must be released by a - // corresponding call ReleaseFrame(scoped_refptr<VideoFrame>* frame_out. - virtual void AllocateFrame(media::VideoFrame::Format format, - size_t width, - size_t height, - base::TimeDelta timestamp, - base::TimeDelta duration, - scoped_refptr<media::VideoFrame>* frame_out, - Task* done) = 0; - - virtual void ReleaseFrame(media::VideoFrame* frame) = 0; - - // OnPartialFrameOutput() is called every time at least one rectangle of - // output is produced. The |frame| is guaranteed to have valid data for - // every region included in the |rects| list. - // - // Both |frame| and |rects| are guaranteed to be valid until the |done| - // callback is invoked. - virtual void OnPartialFrameOutput(media::VideoFrame* frame, - UpdatedRects* rects, - Task* done) = 0; - - private: - DISALLOW_COPY_AND_ASSIGN(FrameConsumer); -}; - -} // namespace remoting - -#endif // REMOTING_CLIENT_FRAME_CONSUMER_H_ diff --git a/remoting/client/rectangle_update_decoder.cc b/remoting/client/rectangle_update_decoder.cc deleted file mode 100644 index 2b35b83..0000000 --- a/remoting/client/rectangle_update_decoder.cc +++ /dev/null @@ -1,217 +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/client/rectangle_update_decoder.h" - -#include "base/logging.h" -#include "base/message_loop.h" -#include "media/base/callback.h" -#include "remoting/base/decoder.h" -#include "remoting/base/decoder_verbatim.h" -#include "remoting/base/decoder_zlib.h" -#include "remoting/base/protocol/chromotocol.pb.h" -#include "remoting/base/tracer.h" -#include "remoting/client/frame_consumer.h" - -using media::AutoTaskRunner; - -namespace remoting { - -namespace { - -class PartialFrameCleanup : public Task { - public: - PartialFrameCleanup(media::VideoFrame* frame, UpdatedRects* rects) - : frame_(frame), rects_(rects) { - } - - virtual void Run() { - delete rects_; - frame_ = NULL; - } - - private: - scoped_refptr<media::VideoFrame> frame_; - UpdatedRects* rects_; -}; - -} // namespace - -RectangleUpdateDecoder::RectangleUpdateDecoder(MessageLoop* message_loop, - FrameConsumer* consumer) - : message_loop_(message_loop), - consumer_(consumer) { -} - -RectangleUpdateDecoder::~RectangleUpdateDecoder() { -} - -void RectangleUpdateDecoder::DecodePacket(const RectangleUpdatePacket& packet, - Task* done) { - if (message_loop_ != MessageLoop::current()) { - message_loop_->PostTask( - FROM_HERE, - NewTracedMethod(this, - &RectangleUpdateDecoder::DecodePacket, packet, - done)); - return; - } - AutoTaskRunner done_runner(done); - - TraceContext::tracer()->PrintString("Decode Packet called."); - - if (!IsValidPacket(packet)) { - LOG(ERROR) << "Received invalid packet."; - return; - } - - Task* process_packet_data = - NewTracedMethod(this, - &RectangleUpdateDecoder::ProcessPacketData, - packet, done_runner.release()); - - if (packet.flags() | RectangleUpdatePacket::FIRST_PACKET) { - const RectangleFormat& format = packet.format(); - - InitializeDecoder(format, process_packet_data); - } else { - process_packet_data->Run(); - delete process_packet_data; - } -} - -void RectangleUpdateDecoder::ProcessPacketData( - const RectangleUpdatePacket& packet, - Task* done) { - AutoTaskRunner done_runner(done); - - if (!decoder_->IsReadyForData()) { - // TODO(ajwong): This whole thing should move into an invalid state. - LOG(ERROR) << "Decoder is unable to process data. Dropping packet."; - return; - } - - TraceContext::tracer()->PrintString("Executing Decode."); - decoder_->DecodeBytes(packet.encoded_rect()); - - if (packet.flags() | RectangleUpdatePacket::LAST_PACKET) { - decoder_->Reset(); - - UpdatedRects* rects = new UpdatedRects(); - - // Empty out the list of current updated rects so the decoder can keep - // writing new ones while these are processed. - rects->swap(updated_rects_); - - consumer_->OnPartialFrameOutput(frame_, rects, - new PartialFrameCleanup(frame_, rects)); - } -} - -// static -bool RectangleUpdateDecoder::IsValidPacket( - const RectangleUpdatePacket& packet) { - if (!packet.IsValid()) { - LOG(WARNING) << "Protobuf consistency checks fail."; - return false; - } - - // First packet must have a format. - if (packet.flags() | RectangleUpdatePacket::FIRST_PACKET) { - if (!packet.has_format()) { - LOG(WARNING) << "First packet must have format."; - return false; - } - - const RectangleFormat& format = packet.format(); - if (!format.has_encoding() || - format.encoding() == EncodingInvalid) { - LOG(WARNING) << "Invalid encoding specified."; - return false; - } - } - - // We shouldn't generate null packets. - if (!packet.has_encoded_rect()) { - LOG(WARNING) << "Packet w/o an encoded rectangle received."; - return false; - } - - return true; -} - -void RectangleUpdateDecoder::InitializeDecoder(const RectangleFormat& format, - Task* done) { - if (message_loop_ != MessageLoop::current()) { - message_loop_->PostTask( - FROM_HERE, - NewTracedMethod(this, - &RectangleUpdateDecoder::InitializeDecoder, - format, done)); - return; - } - AutoTaskRunner done_runner(done); - - // Check if we need to request a new frame. - if (!frame_ || - frame_->width() < static_cast<size_t>(format.width()) || - frame_->height() < static_cast<size_t>(format.height())) { - if (frame_) { - TraceContext::tracer()->PrintString("Releasing old frame."); - consumer_->ReleaseFrame(frame_); - frame_ = NULL; - } - TraceContext::tracer()->PrintString("Requesting new frame."); - consumer_->AllocateFrame(media::VideoFrame::RGB32, - format.width(), format.height(), - base::TimeDelta(), base::TimeDelta(), - &frame_, - NewTracedMethod( - this, - &RectangleUpdateDecoder::InitializeDecoder, - format, - done_runner.release())); - return; - } - - // TODO(ajwong): We need to handle the allocator failing to create a frame - // and properly disable this class. - CHECK(frame_); - - if (decoder_.get()) { - // TODO(ajwong): We need to handle changing decoders midstream correctly - // since someone may feed us a corrupt stream, or manually create a - // stream that changes decoders. At the very leask, we should not - // crash the process. - // - // For now though, assume that only one encoding is used throughout. - // - // Note, this may be as simple as just deleting the current decoder. - // However, we need to verify the flushing semantics of the decoder first. - CHECK(decoder_->Encoding() == format.encoding()); - } else { - // Initialize a new decoder based on this message encoding. - if (format.encoding() == EncodingNone) { - TraceContext::tracer()->PrintString("Creating Verbatim decoder."); - decoder_.reset(new DecoderVerbatim()); - } else if (format.encoding() == EncodingZlib) { - TraceContext::tracer()->PrintString("Creating Zlib decoder"); - decoder_.reset(new DecoderZlib()); - } else { - NOTREACHED << "Invalid Encoding found: " << found.encoding(); - } - } - - // TODO(ajwong): This can happen in the face of corrupt input data. Figure - // out the right behavior and make this more resilient. - CHECK(updated_rects_.empty()); - - gfx::Rect rectangle_size(format.x(), format.y(), - format.width(), format.height()); - updated_rects_.push_back(rectangle_size); - decoder_->Initialize(frame_, rectangle_size); - TraceContext::tracer()->PrintString("Decoder is Initialized"); -} - -} // namespace remoting diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h deleted file mode 100644 index 5f18e12..0000000 --- a/remoting/client/rectangle_update_decoder.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_CLIENT_RECTANGLE_UPDATE_DECODER_H -#define REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H - -#include "base/scoped_ptr.h" -#include "base/task.h" -#include "media/base/video_frame.h" -#include "remoting/base/decoder.h" // For UpdatedRects. - -class MessageLoop; - -namespace remoting { - -class FrameConsumer; -class RectangleFormat; -class RectangleUpdatePacket; - -// TODO(ajwong): Re-examine this API, especially with regards to how error -// conditions on each step are reported. Should they be CHECKs? Logs? Other? -class RectangleUpdateDecoder { - public: - RectangleUpdateDecoder(MessageLoop* message_loop, - FrameConsumer* consumer); - ~RectangleUpdateDecoder(); - - // Decodes the contents of |packet| calling OnPartialFrameOutput() in the - // regsitered as data is avaialable. DecodePacket may keep a reference to - // |packet| so the |packet| must remain alive and valid until |done| is - // executed. - // - // TODO(ajwong): Should packet be a const pointer to make the lifetime - // more clear? - void DecodePacket(const RectangleUpdatePacket& packet, Task* done); - - private: - static bool IsValidPacket(const RectangleUpdatePacket& packet); - - void InitializeDecoder(const RectangleFormat& format, Task* done); - - void ProcessPacketData(const RectangleUpdatePacket& packet, Task* done); - - // Pointers to infrastructure objects. Not owned. - MessageLoop* message_loop_; - FrameConsumer* consumer_; - - scoped_ptr<Decoder> decoder_; - UpdatedRects updated_rects_; - - // Framebuffer for the decoder. - scoped_refptr<media::VideoFrame> frame_; -}; - -} // namespace remoting - -DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::RectangleUpdateDecoder); - -#endif // REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H |