Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(239)

Unified Diff: remoting/client/rectangle_update_decoder.h

Issue 10867039: Moved video stub implementation to RectangleUpdateDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comment Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/client/plugin/chromoting_instance.cc ('k') | remoting/client/rectangle_update_decoder.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..af91267a6d0b6e80f5dbefccc3d4490c7acf1fa5 100644
--- a/remoting/client/rectangle_update_decoder.h
+++ b/remoting/client/rectangle_update_decoder.h
@@ -7,12 +7,14 @@
#include <list>
-#include "base/callback_forward.h"
+#include "base/callback.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 +26,7 @@ class ImageData;
namespace remoting {
+class ChromotingStats;
class VideoPacket;
namespace protocol {
@@ -35,21 +38,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 +65,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 +90,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 +115,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 +124,22 @@ 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.
+ // TODO(sergeyu): Simplify this code and remove this list.
+ 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 latest_sequence_number_;
};
} // namespace remoting
« no previous file with comments | « remoting/client/plugin/chromoting_instance.cc ('k') | remoting/client/rectangle_update_decoder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698