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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H_ 5 #ifndef REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H_
6 #define REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H_ 6 #define REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H_
7 7
8 #include <list> 8 #include <list>
9 9
10 #include "base/callback_forward.h" 10 #include "base/callback.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "remoting/codec/video_decoder.h" 13 #include "remoting/codec/video_decoder.h"
14 #include "remoting/client/chromoting_stats.h"
14 #include "remoting/client/frame_consumer_proxy.h" 15 #include "remoting/client/frame_consumer_proxy.h"
15 #include "remoting/client/frame_producer.h" 16 #include "remoting/client/frame_producer.h"
17 #include "remoting/protocol/video_stub.h"
16 18
17 namespace base { 19 namespace base {
18 class SingleThreadTaskRunner; 20 class SingleThreadTaskRunner;
19 } // namespace base 21 } // namespace base
20 22
21 namespace pp { 23 namespace pp {
22 class ImageData; 24 class ImageData;
23 }; 25 };
24 26
25 namespace remoting { 27 namespace remoting {
26 28
29 class ChromotingStats;
27 class VideoPacket; 30 class VideoPacket;
28 31
29 namespace protocol { 32 namespace protocol {
30 class SessionConfig; 33 class SessionConfig;
31 } // namespace protocol 34 } // namespace protocol
32 35
33 // TODO(ajwong): Re-examine this API, especially with regards to how error 36 // TODO(ajwong): Re-examine this API, especially with regards to how error
34 // conditions on each step are reported. Should they be CHECKs? Logs? Other? 37 // conditions on each step are reported. Should they be CHECKs? Logs? Other?
35 // TODO(sergeyu): Rename this class. 38 // TODO(sergeyu): Rename this class.
36 class RectangleUpdateDecoder 39 class RectangleUpdateDecoder
37 : public base::RefCountedThreadSafe<RectangleUpdateDecoder>, 40 : public base::RefCountedThreadSafe<RectangleUpdateDecoder>,
38 public FrameProducer { 41 public FrameProducer,
42 public protocol::VideoStub {
39 public: 43 public:
40 // Creates an update decoder on |task_runner_|, outputting to |consumer|. 44 // Creates an update decoder on |main_task_runner_| and |decode_task_runner_|,
45 // outputting to |consumer|. The |main_task_runner_| is responsible for
46 // receiving and queueing packets. The |decode_task_runner_| is responsible
47 // for decoding the video packets.
41 // TODO(wez): Replace the ref-counted proxy with an owned FrameConsumer. 48 // TODO(wez): Replace the ref-counted proxy with an owned FrameConsumer.
42 RectangleUpdateDecoder( 49 RectangleUpdateDecoder(
43 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 50 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner,
51 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner,
44 scoped_refptr<FrameConsumerProxy> consumer); 52 scoped_refptr<FrameConsumerProxy> consumer);
45 53
46 // Initializes decoder with the information from the protocol config. 54 // Initializes decoder with the information from the protocol config.
47 void Initialize(const protocol::SessionConfig& config); 55 void Initialize(const protocol::SessionConfig& config);
48 56
49 // Decodes the contents of |packet|. DecodePacket may keep a reference to 57 // Removes all video packets in the queue.
50 // |packet| so the |packet| must remain alive and valid until |done| is 58 void DropAllPackets();
51 // executed.
52 void DecodePacket(scoped_ptr<VideoPacket> packet, const base::Closure& done);
53 59
54 // FrameProducer implementation. These methods may be called before we are 60 // FrameProducer implementation. These methods may be called before we are
55 // Initialize()d, or we know the source screen size. 61 // Initialize()d, or we know the source screen size.
56 virtual void DrawBuffer(pp::ImageData* buffer) OVERRIDE; 62 virtual void DrawBuffer(pp::ImageData* buffer) OVERRIDE;
57 virtual void InvalidateRegion(const SkRegion& region) OVERRIDE; 63 virtual void InvalidateRegion(const SkRegion& region) OVERRIDE;
58 virtual void RequestReturnBuffers(const base::Closure& done) OVERRIDE; 64 virtual void RequestReturnBuffers(const base::Closure& done) OVERRIDE;
59 virtual void SetOutputSizeAndClip(const SkISize& view_size, 65 virtual void SetOutputSizeAndClip(const SkISize& view_size,
60 const SkIRect& clip_area) OVERRIDE; 66 const SkIRect& clip_area) OVERRIDE;
61 67
68 // VideoStub implementation.
69 virtual void ProcessVideoPacket(scoped_ptr<VideoPacket> packet,
70 const base::Closure& done) OVERRIDE;
71 virtual int GetPendingVideoPackets() OVERRIDE;
72
73 // Return the stats recorded by this client.
74 ChromotingStats* GetStats();
75
62 private: 76 private:
77 struct QueuedVideoPacket {
78 QueuedVideoPacket(scoped_ptr<VideoPacket> packet,
79 const base::Closure& done);
80 ~QueuedVideoPacket();
81 VideoPacket* packet;
82 base::Closure done;
83 };
84
63 friend class base::RefCountedThreadSafe<RectangleUpdateDecoder>; 85 friend class base::RefCountedThreadSafe<RectangleUpdateDecoder>;
64 virtual ~RectangleUpdateDecoder(); 86 virtual ~RectangleUpdateDecoder();
65 87
66 // Paints the invalidated region to the next available buffer and returns it 88 // Paints the invalidated region to the next available buffer and returns it
67 // to the consumer. 89 // to the consumer.
68 void SchedulePaint(); 90 void SchedulePaint();
69 void DoPaint(); 91 void DoPaint();
70 92
71 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 93 // If a packet is not being processed, dispatches a single message from the
94 // |received_packets_| queue.
95 void ProcessNextPacket();
96
97 // Decodes the contents of |packet|. DecodePacket may keep a reference to
98 // |packet| so the |packet| must remain alive and valid until |done| is
99 // executed.
100 void DecodePacket(scoped_ptr<VideoPacket> packet, const base::Closure& done);
101
102 // Callback method when a VideoPacket is processed.
103 // If |last_packet| is true then |decode_start| contains the timestamp when
104 // the packet will start to be processed.
105 void OnPacketDone(bool last_packet, base::Time decode_start);
106
107 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_;
108 scoped_refptr<base::SingleThreadTaskRunner> decode_task_runner_;
72 scoped_refptr<FrameConsumerProxy> consumer_; 109 scoped_refptr<FrameConsumerProxy> consumer_;
73 scoped_ptr<VideoDecoder> decoder_; 110 scoped_ptr<VideoDecoder> decoder_;
74 111
75 // Remote screen size in pixels. 112 // Remote screen size in pixels.
76 SkISize source_size_; 113 SkISize source_size_;
77 114
78 // Vertical and horizontal DPI of the remote screen. 115 // Vertical and horizontal DPI of the remote screen.
79 SkIPoint source_dpi_; 116 SkIPoint source_dpi_;
80 117
81 // The current dimentions of the frame consumer view. 118 // The current dimensions of the frame consumer view.
82 SkISize view_size_; 119 SkISize view_size_;
83 SkIRect clip_area_; 120 SkIRect clip_area_;
84 121
85 // The drawing buffers supplied by the frame consumer. 122 // The drawing buffers supplied by the frame consumer.
86 std::list<pp::ImageData*> buffers_; 123 std::list<pp::ImageData*> buffers_;
87 124
88 // Flag used to coalesce runs of SchedulePaint()s into a single DoPaint(). 125 // Flag used to coalesce runs of SchedulePaint()s into a single DoPaint().
89 bool paint_scheduled_; 126 bool paint_scheduled_;
127
128 // Contains all video packets that have been received, but have not yet been
129 // processed.
130 //
131 // Used to serialize sending of messages to the client.
132 // TODO(sergeyu): Simplify this code and remove this list.
133 std::list<QueuedVideoPacket> received_packets_;
134
135 // True if a message is being processed. Can be used to determine if it is
136 // safe to dispatch another message.
137 bool packet_being_processed_;
138
139 ChromotingStats stats_;
140
141 // Keep track of the most recent sequence number bounced back from the host.
142 int64 last_sequence_number_;
Wez 2012/08/24 19:43:30 nit: latest_sequence_number_
kxing 2012/08/24 19:54:42 Done.
90 }; 143 };
91 144
92 } // namespace remoting 145 } // namespace remoting
93 146
94 #endif // REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H_ 147 #endif // REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H_
OLDNEW
« 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