Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "media/base/video_frame.h" | |
| 12 #include "remoting/base/decoder.h" | 11 #include "remoting/base/decoder.h" |
| 13 | 12 |
| 14 namespace base { | 13 namespace base { |
| 15 class MessageLoopProxy; | 14 class MessageLoopProxy; |
| 16 } // namespace base | 15 } // namespace base |
| 17 | 16 |
| 17 namespace pp { | |
| 18 class ImageData; | |
| 19 }; | |
| 20 | |
| 18 namespace remoting { | 21 namespace remoting { |
| 19 | 22 |
| 20 class FrameConsumer; | 23 class FrameConsumer; |
| 21 class VideoPacket; | 24 class VideoPacket; |
| 22 | 25 |
| 23 namespace protocol { | 26 namespace protocol { |
| 24 class SessionConfig; | 27 class SessionConfig; |
| 25 } // namespace protocol | 28 } // namespace protocol |
| 26 | 29 |
| 27 // TODO(ajwong): Re-examine this API, especially with regards to how error | 30 // TODO(ajwong): Re-examine this API, especially with regards to how error |
| 28 // conditions on each step are reported. Should they be CHECKs? Logs? Other? | 31 // conditions on each step are reported. Should they be CHECKs? Logs? Other? |
| 29 // TODO(sergeyu): Rename this class. | 32 // TODO(sergeyu): Rename this class. |
| 30 class RectangleUpdateDecoder : | 33 class RectangleUpdateDecoder : |
| 31 public base::RefCountedThreadSafe<RectangleUpdateDecoder> { | 34 public base::RefCountedThreadSafe<RectangleUpdateDecoder> { |
| 32 public: | 35 public: |
| 33 RectangleUpdateDecoder(base::MessageLoopProxy* message_loop, | 36 RectangleUpdateDecoder(base::MessageLoopProxy* message_loop, |
| 34 FrameConsumer* consumer); | 37 FrameConsumer* consumer); |
| 35 | 38 |
| 36 // Initializes decoder with the infromation from the protocol config. | 39 // Initializes decoder with the infromation from the protocol config. |
| 37 void Initialize(const protocol::SessionConfig& config); | 40 void Initialize(const protocol::SessionConfig& config); |
| 38 | 41 |
| 39 // Decodes the contents of |packet| calling OnPartialFrameOutput() in the | 42 // Decodes the contents of |packet| calling OnFrameReady() in the |
| 40 // regsitered as data is avaialable. DecodePacket may keep a reference to | 43 // registered as data is avaialable. DecodePacket may keep a reference to |
|
Wez
2012/02/07 01:56:31
This class doesn't have an OnFrameReady, though?
alexeypa (please no reviews)
2012/02/15 23:06:22
Done.
| |
| 41 // |packet| so the |packet| must remain alive and valid until |done| is | 44 // |packet| so the |packet| must remain alive and valid until |done| is |
| 42 // executed. | 45 // executed. |
|
Wez
2012/02/07 01:56:31
nit: If we pass |packet| as a scoped_ptr<> then we
alexeypa (please no reviews)
2012/02/15 23:06:22
I'd postpone this change till later. This change i
| |
| 43 void DecodePacket(const VideoPacket* packet, const base::Closure& done); | 46 void DecodePacket(const VideoPacket* packet, const base::Closure& done); |
| 44 | 47 |
| 45 // Set the output dimensions to scale video output to. | |
| 46 void SetOutputSize(const SkISize& size); | |
| 47 | |
| 48 // Set a new clipping rectangle for the decoder. Decoder should respect | |
| 49 // this clipping rectangle and only decode content in this rectangle and | |
| 50 // report dirty rectangles accordingly to enhance performance. | |
| 51 void UpdateClipRect(const SkIRect& clip_rect); | |
| 52 | |
| 53 // Force the decoder to output the last decoded video frame without any | 48 // Force the decoder to output the last decoded video frame without any |
| 54 // clipping. | 49 // clipping. |
| 55 void RefreshFullFrame(); | 50 void RefreshFullFrame(); |
| 56 | 51 |
| 57 private: | 52 private: |
| 58 friend class base::RefCountedThreadSafe<RectangleUpdateDecoder>; | 53 friend class base::RefCountedThreadSafe<RectangleUpdateDecoder>; |
| 59 friend class PartialFrameCleanup; | |
| 60 | 54 |
| 61 ~RectangleUpdateDecoder(); | 55 ~RectangleUpdateDecoder(); |
| 62 | 56 |
| 63 void AllocateFrame(const VideoPacket* packet, const base::Closure& done); | |
| 64 void ProcessPacketData(const VideoPacket* packet, const base::Closure& done); | |
| 65 | |
| 66 // Obtain updated rectangles from decoder and submit it to the consumer. | 57 // Obtain updated rectangles from decoder and submit it to the consumer. |
| 67 void SubmitToConsumer(); | 58 void SubmitToConsumer(); |
| 68 | 59 |
| 69 // Use |refresh_rects_| to do a refresh to the backing video frame. | 60 // Callback for FrameConsumer::OnFrameReady() |
| 70 // When done the affected rectangles are submitted to the consumer. | 61 void OnPaintFrame(); |
| 71 void DoRefresh(); | |
| 72 | |
| 73 // Callback for FrameConsumer::OnPartialFrameOutput() | |
| 74 void OnFrameConsumed(SkRegion* region); | |
| 75 | 62 |
| 76 scoped_refptr<base::MessageLoopProxy> message_loop_; | 63 scoped_refptr<base::MessageLoopProxy> message_loop_; |
| 77 FrameConsumer* consumer_; | 64 FrameConsumer* consumer_; |
| 78 | 65 |
| 66 scoped_ptr<Decoder> decoder_; | |
| 67 | |
| 68 // Remote screen size in pixels. | |
| 79 SkISize screen_size_; | 69 SkISize screen_size_; |
| 80 SkIRect clip_rect_; | |
| 81 SkRegion refresh_region_; | |
| 82 | 70 |
| 83 scoped_ptr<Decoder> decoder_; | 71 // True while drawing operation is in progress. |
| 84 bool decoder_needs_reset_; | 72 bool update_pending_; |
| 85 | 73 |
| 86 // The video frame that the decoder writes to. | 74 // Frame consumer's data captured for the duration of drawing to |
| 87 scoped_refptr<media::VideoFrame> frame_; | 75 // the backing store. |
| 76 SkISize view_size_; | |
| 77 SkIRect clip_area_; | |
| 78 scoped_ptr<pp::ImageData> backing_store_; | |
| 88 }; | 79 }; |
| 89 | 80 |
| 90 } // namespace remoting | 81 } // namespace remoting |
| 91 | 82 |
| 92 #endif // REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H_ | 83 #endif // REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H_ |
| OLD | NEW |