OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/task.h" | 9 #include "base/task.h" |
10 #include "media/base/video_frame.h" | 10 #include "media/base/video_frame.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 RectangleUpdateDecoder(MessageLoop* message_loop, | 31 RectangleUpdateDecoder(MessageLoop* message_loop, |
32 FrameConsumer* consumer); | 32 FrameConsumer* consumer); |
33 | 33 |
34 // Initializes decoder with the infromation from the protocol config. | 34 // Initializes decoder with the infromation from the protocol config. |
35 void Initialize(const protocol::SessionConfig& config); | 35 void Initialize(const protocol::SessionConfig& config); |
36 | 36 |
37 // Decodes the contents of |packet| calling OnPartialFrameOutput() in the | 37 // Decodes the contents of |packet| calling OnPartialFrameOutput() in the |
38 // regsitered as data is avaialable. DecodePacket may keep a reference to | 38 // regsitered as data is avaialable. DecodePacket may keep a reference to |
39 // |packet| so the |packet| must remain alive and valid until |done| is | 39 // |packet| so the |packet| must remain alive and valid until |done| is |
40 // executed. | 40 // executed. |
41 // | 41 void DecodePacket(const VideoPacket* packet, const base::Closure& done); |
42 // TODO(ajwong): Should packet be a const pointer to make the lifetime | |
43 // more clear? | |
44 void DecodePacket(const VideoPacket* packet, Task* done); | |
45 | 42 |
46 // Set the scale ratio for the decoded video frame. Scale ratio greater | 43 // Set the scale ratio for the decoded video frame. Scale ratio greater |
47 // than 1.0 is not supported. | 44 // than 1.0 is not supported. |
48 void SetScaleRatios(double horizontal_ratio, double vertical_ratio); | 45 void SetScaleRatios(double horizontal_ratio, double vertical_ratio); |
49 | 46 |
50 // Set a new clipping rectangle for the decoder. Decoder should respect | 47 // Set a new clipping rectangle for the decoder. Decoder should respect |
51 // this clipping rectangle and only decode content in this rectangle and | 48 // this clipping rectangle and only decode content in this rectangle and |
52 // report dirty rectangles accordingly to enhance performance. | 49 // report dirty rectangles accordingly to enhance performance. |
53 // | 50 // |
54 // If scale ratio is not 1.0 then clipping rectangle is ignored. | 51 // If scale ratio is not 1.0 then clipping rectangle is ignored. |
55 void UpdateClipRect(const SkIRect& clip_rect); | 52 void UpdateClipRect(const SkIRect& clip_rect); |
56 | 53 |
57 // Force the decoder to output the last decoded video frame without any | 54 // Force the decoder to output the last decoded video frame without any |
58 // clipping. | 55 // clipping. |
59 void RefreshFullFrame(); | 56 void RefreshFullFrame(); |
60 | 57 |
61 private: | 58 private: |
62 friend class base::RefCountedThreadSafe<RectangleUpdateDecoder>; | 59 friend class base::RefCountedThreadSafe<RectangleUpdateDecoder>; |
63 friend class PartialFrameCleanup; | 60 friend class PartialFrameCleanup; |
64 | 61 |
65 ~RectangleUpdateDecoder(); | 62 ~RectangleUpdateDecoder(); |
66 | 63 |
67 void AllocateFrame(const VideoPacket* packet, Task* done); | 64 void AllocateFrame(const VideoPacket* packet, const base::Closure& done); |
68 void ProcessPacketData(const VideoPacket* packet, Task* done); | 65 void ProcessPacketData(const VideoPacket* packet, const base::Closure& done); |
69 void RefreshRects(const RectVector& rects); | 66 void RefreshRects(const RectVector& rects); |
70 | 67 |
71 // Obtain updated rectangles from decoder and submit it to the consumer. | 68 // Obtain updated rectangles from decoder and submit it to the consumer. |
72 void SubmitToConsumer(); | 69 void SubmitToConsumer(); |
73 | 70 |
74 // Use |refresh_rects_| to do a refresh to the backing video frame. | 71 // Use |refresh_rects_| to do a refresh to the backing video frame. |
75 // When done the affected rectangles are submitted to the consumer. | 72 // When done the affected rectangles are submitted to the consumer. |
76 void DoRefresh(); | 73 void DoRefresh(); |
77 | 74 |
78 // Called by PartialFrameCleanup when consumer has finished using our | 75 // Callback for FrameConsumer::OnPartialFrameOutput() |
79 // internal frame. | 76 void OnFrameConsumed(RectVector* rects); |
80 void OnFrameConsumed(); | |
81 | 77 |
82 // Pointers to infrastructure objects. Not owned. | 78 // Pointers to infrastructure objects. Not owned. |
83 MessageLoop* message_loop_; | 79 MessageLoop* message_loop_; |
84 FrameConsumer* consumer_; | 80 FrameConsumer* consumer_; |
85 | 81 |
86 SkISize initial_screen_size_; | 82 SkISize initial_screen_size_; |
87 SkIRect clip_rect_; | 83 SkIRect clip_rect_; |
88 RectVector refresh_rects_; | 84 RectVector refresh_rects_; |
89 | 85 |
90 scoped_ptr<Decoder> decoder_; | 86 scoped_ptr<Decoder> decoder_; |
91 | 87 |
92 // The video frame that the decoder writes to. | 88 // The video frame that the decoder writes to. |
93 scoped_refptr<media::VideoFrame> frame_; | 89 scoped_refptr<media::VideoFrame> frame_; |
94 bool frame_is_new_; | 90 bool frame_is_new_; |
95 | 91 |
96 // True if |consumer_| is currently using the frame. | 92 // True if |consumer_| is currently using the frame. |
97 bool frame_is_consuming_; | 93 bool frame_is_consuming_; |
98 }; | 94 }; |
99 | 95 |
100 } // namespace remoting | 96 } // namespace remoting |
101 | 97 |
102 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::RectangleUpdateDecoder); | |
103 | |
104 #endif // REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H | 98 #endif // REMOTING_CLIENT_RECTANGLE_UPDATE_DECODER_H |
OLD | NEW |