Chromium Code Reviews| Index: remoting/client/rectangle_update_decoder.h |
| diff --git a/remoting/client/rectangle_update_decoder.h b/remoting/client/rectangle_update_decoder.h |
| index 3d61b972f20228bd5e6df05ff2e9eb796b65041a..4d7cff6f5fb8ea07e4456e900cf65ca8b7fb38f8 100644 |
| --- a/remoting/client/rectangle_update_decoder.h |
| +++ b/remoting/client/rectangle_update_decoder.h |
| @@ -7,12 +7,15 @@ |
| #include <list> |
| +#include "base/callback.h" |
|
Sergey Ulanov
2012/08/24 18:44:12
Don't need this include - you already have callbac
kxing
2012/08/24 19:35:51
Done.
|
| #include "base/callback_forward.h" |
| #include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "remoting/codec/video_decoder.h" |
| +#include "remoting/client/chromoting_stats.h" |
| #include "remoting/client/frame_consumer_proxy.h" |
| #include "remoting/client/frame_producer.h" |
| +#include "remoting/protocol/video_stub.h" |
| namespace base { |
| class SingleThreadTaskRunner; |
| @@ -24,6 +27,7 @@ class ImageData; |
| namespace remoting { |
| +class ChromotingStats; |
| class VideoPacket; |
| namespace protocol { |
| @@ -35,21 +39,24 @@ class SessionConfig; |
| // TODO(sergeyu): Rename this class. |
| class RectangleUpdateDecoder |
| : public base::RefCountedThreadSafe<RectangleUpdateDecoder>, |
| - public FrameProducer { |
| + public FrameProducer, |
| + public protocol::VideoStub { |
| public: |
| - // Creates an update decoder on |task_runner_|, outputting to |consumer|. |
| + // Creates an update decoder on |main_task_runner_| and |decode_task_runner_|, |
| + // outputting to |consumer|. The |main_task_runner_| is responsible for |
| + // receiving and queueing packets. The |decode_task_runner_| is responsible |
| + // for decoding the video packets. |
| // TODO(wez): Replace the ref-counted proxy with an owned FrameConsumer. |
| RectangleUpdateDecoder( |
| - scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| + scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner, |
| scoped_refptr<FrameConsumerProxy> consumer); |
| // Initializes decoder with the information from the protocol config. |
| void Initialize(const protocol::SessionConfig& config); |
| - // Decodes the contents of |packet|. DecodePacket may keep a reference to |
| - // |packet| so the |packet| must remain alive and valid until |done| is |
| - // executed. |
| - void DecodePacket(scoped_ptr<VideoPacket> packet, const base::Closure& done); |
| + // Removes all video packets in the queue. |
| + void DropAllPackets(); |
| // FrameProducer implementation. These methods may be called before we are |
| // Initialize()d, or we know the source screen size. |
| @@ -59,7 +66,23 @@ class RectangleUpdateDecoder |
| virtual void SetOutputSizeAndClip(const SkISize& view_size, |
| const SkIRect& clip_area) OVERRIDE; |
| + // VideoStub implementation. |
| + virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> packet, |
| + const base::Closure& done) OVERRIDE; |
| + virtual int GetPendingVideoPackets() OVERRIDE; |
| + |
| + // Return the stats recorded by this client. |
| + ChromotingStats* GetStats(); |
| + |
| private: |
| + struct QueuedVideoPacket { |
| + QueuedVideoPacket(scoped_ptr<VideoPacket> packet, |
| + const base::Closure& done); |
| + ~QueuedVideoPacket(); |
| + VideoPacket* packet; |
| + base::Closure done; |
| + }; |
| + |
| friend class base::RefCountedThreadSafe<RectangleUpdateDecoder>; |
| virtual ~RectangleUpdateDecoder(); |
| @@ -68,7 +91,22 @@ class RectangleUpdateDecoder |
| void SchedulePaint(); |
| void DoPaint(); |
| - scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| + // If a packet is not being processed, dispatches a single message from the |
| + // |received_packets_| queue. |
| + void ProcessNextPacket(); |
| + |
| + // Decodes the contents of |packet|. DecodePacket may keep a reference to |
| + // |packet| so the |packet| must remain alive and valid until |done| is |
| + // executed. |
| + void DecodePacket(scoped_ptr<VideoPacket> packet, const base::Closure& done); |
| + |
| + // Callback method when a VideoPacket is processed. |
| + // If |last_packet| is true then |decode_start| contains the timestamp when |
| + // the packet will start to be processed. |
| + void OnPacketDone(bool last_packet, base::Time decode_start); |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| + scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_; |
| scoped_refptr<FrameConsumerProxy> consumer_; |
| scoped_ptr<VideoDecoder> decoder_; |
| @@ -78,7 +116,7 @@ class RectangleUpdateDecoder |
| // Vertical and horizontal DPI of the remote screen. |
| SkIPoint source_dpi_; |
| - // The current dimentions of the frame consumer view. |
| + // The current dimensions of the frame consumer view. |
| SkISize view_size_; |
| SkIRect clip_area_; |
| @@ -87,6 +125,21 @@ class RectangleUpdateDecoder |
| // Flag used to coalesce runs of SchedulePaint()s into a single DoPaint(). |
| bool paint_scheduled_; |
| + |
| + // Contains all video packets that have been received, but have not yet been |
| + // processed. |
|
Sergey Ulanov
2012/08/24 18:45:40
Please add TODO(sergeyu) to simplify this code and
kxing
2012/08/24 19:35:51
Done.
|
| + // |
| + // Used to serialize sending of messages to the client. |
| + std::list<QueuedVideoPacket> received_packets_; |
| + |
| + // True if a message is being processed. Can be used to determine if it is |
| + // safe to dispatch another message. |
| + bool packet_being_processed_; |
| + |
| + ChromotingStats stats_; |
| + |
| + // Keep track of the most recent sequence number bounced back from the host. |
| + int64 last_sequence_number_; |
| }; |
| } // namespace remoting |