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 afe0f28966e17c1da02632f6d69d1b2198f3aa18..aae853741e53a67e0570ac95ee99b71f507a9d84 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" |
| #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,12 +39,14 @@ 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|. |
|
Wez
2012/08/23 22:10:48
nit: Update this comment to clarify what the two T
kxing
2012/08/24 17:05:22
Done.
|
| // 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. |
| @@ -59,7 +65,25 @@ 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; |
| + |
| + void DropAllPackets(); |
|
Wez
2012/08/23 22:10:48
nit: Move this API up to near Initialize & DecodeP
kxing
2012/08/24 17:05:22
Done.
|
| + |
| + // 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 +92,17 @@ 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 DispatchPacket(); |
| + |
| + // 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<Decoder> decoder_; |
| @@ -87,6 +121,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. |
| + // |
| + // 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 last sequence number bounced back from the host. |
|
Wez
2012/08/23 22:10:48
nit: last -> most recent
kxing
2012/08/24 17:05:22
Done.
|
| + int64 last_sequence_number_; |
| }; |
| } // namespace remoting |