OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_CHROMOTING_VIEW_H_ | 5 #ifndef REMOTING_CLIENT_CHROMOTING_VIEW_H_ |
6 #define REMOTING_CLIENT_CHROMOTING_VIEW_H_ | 6 #define REMOTING_CLIENT_CHROMOTING_VIEW_H_ |
7 | 7 |
8 #include "base/ref_counted.h" | 8 #include "base/ref_counted.h" |
9 #include "remoting/base/decoder.h" | 9 #include "media/base/video_frame.h" |
| 10 |
| 11 class MessageLoop; |
| 12 |
| 13 namespace base { |
| 14 class WaitableEvent; |
| 15 } // namespace base |
10 | 16 |
11 namespace remoting { | 17 namespace remoting { |
12 | 18 |
13 // ChromotingView defines the behavior of an object that draws a view of the | 19 // ChromotingView defines the behavior of an object that draws a view of the |
14 // remote desktop. Its main function is to choose the right decoder and render | 20 // remote desktop. Its main function is to render the update stream onto the |
15 // the update stream onto the screen. | 21 // screen. |
16 class ChromotingView { | 22 class ChromotingView { |
17 public: | 23 public: |
18 ChromotingView(); | 24 ChromotingView(); |
19 virtual ~ChromotingView() {} | 25 virtual ~ChromotingView() {} |
20 | 26 |
21 // Get screen dimensions. | 27 // Get screen dimensions. |
22 // TODO(garykac): This will need to be extended to support multi-monitors. | 28 // TODO(garykac): This will need to be extended to support multi-monitors. |
23 void GetScreenSize(int* width, int* height); | 29 void GetScreenSize(int* width, int* height); |
24 | 30 |
25 // Initialize the common structures for the view. | 31 // Initialize the common structures for the view. |
(...skipping 11 matching lines...) Expand all Loading... |
37 virtual void SetSolidFill(uint32 color) = 0; | 43 virtual void SetSolidFill(uint32 color) = 0; |
38 | 44 |
39 // Removes a previously set solid fill. If no fill was previous set, this | 45 // Removes a previously set solid fill. If no fill was previous set, this |
40 // does nothing. | 46 // does nothing. |
41 virtual void UnsetSolidFill() = 0; | 47 virtual void UnsetSolidFill() = 0; |
42 | 48 |
43 // Reposition and resize the viewport into the backing store. If the viewport | 49 // Reposition and resize the viewport into the backing store. If the viewport |
44 // extends past the end of the backing store, it is filled with black. | 50 // extends past the end of the backing store, it is filled with black. |
45 virtual void SetViewport(int x, int y, int width, int height) = 0; | 51 virtual void SetViewport(int x, int y, int width, int height) = 0; |
46 | 52 |
47 // Resize the underlying image that contains the host screen buffer. | |
48 // This should match the size of the output from the decoder. | |
49 // | |
50 // TODO(garykac): This handles only 1 screen. We need multi-screen support. | |
51 virtual void SetHostScreenSize(int width, int height) = 0; | |
52 | |
53 // Handle the BeginUpdateStream message. | |
54 // This method should perform the following tasks: | |
55 // (1) Perform any platform-specific tasks for start of update stream. | |
56 // (2) Make sure the |frame_| has been initialized. | |
57 // (3) Delete the HostMessage. | |
58 virtual void HandleBeginUpdateStream(ChromotingHostMessage* msg) = 0; | |
59 | |
60 // Handle the UpdateStreamPacket message. | |
61 // This method should perform the following tasks: | |
62 // (1) Extract the decoding from the update packet message. | |
63 // (2) Call SetupDecoder with the encoding to lazily initialize the decoder. | |
64 // We don't do this in BeginUpdateStream because the begin message | |
65 // doesn't contain the encoding. | |
66 // (3) Call BeginDecoding if this is the first packet of the stream. | |
67 // (4) Call the decoder's PartialDecode() method to decode the packet. | |
68 // This call will delete the HostMessage. | |
69 // Note: | |
70 // * For a given begin/end update stream, the encodings specified in the | |
71 // update packets must all match. We may revisit this constraint at a | |
72 // later date. | |
73 virtual void HandleUpdateStreamPacket(ChromotingHostMessage* msg) = 0; | |
74 | |
75 // Handle the EndUpdateStream message. | |
76 // This method should perform the following tasks: | |
77 // (1) Call EndDecoding(). | |
78 // (2) Perform any platform-specific tasks for end of update stream. | |
79 // (3) Delete the HostMessage. | |
80 virtual void HandleEndUpdateStream(ChromotingHostMessage* msg) = 0; | |
81 | |
82 protected: | 53 protected: |
83 // Setup the decoder based on the given encoding. | |
84 // Returns true if a new decoder has already been started (with a call to | |
85 // BeginDecoding). | |
86 bool SetupDecoder(UpdateStreamEncoding encoding); | |
87 | |
88 // Prepare the decoder to start decoding a chunk of data. | |
89 // This needs to be called if SetupDecoder() returns false. | |
90 bool BeginDecoding(Task* partial_decode_done, Task* decode_done); | |
91 | |
92 // Decode the given message. | |
93 // BeginDecoding() must be called before any calls to Decode(). | |
94 bool Decode(ChromotingHostMessage* msg); | |
95 | |
96 // Finish decoding and send notifications to update the view. | |
97 bool EndDecoding(); | |
98 | |
99 // Decoder used to decode the video frames (or frame fragements). | |
100 scoped_ptr<Decoder> decoder_; | |
101 | |
102 // Framebuffer for the decoder. | 54 // Framebuffer for the decoder. |
103 scoped_refptr<media::VideoFrame> frame_; | 55 scoped_refptr<media::VideoFrame> frame_; |
104 | 56 |
105 // Dimensions of |frame_| bitmap. | 57 // Dimensions of |frame_| bitmap. |
106 int frame_width_; | 58 int frame_width_; |
107 int frame_height_; | 59 int frame_height_; |
108 | |
109 UpdatedRects update_rects_; | |
110 UpdatedRects all_update_rects_; | |
111 }; | 60 }; |
112 | 61 |
113 } // namespace remoting | 62 } // namespace remoting |
114 | 63 |
115 #endif // REMOTING_CLIENT_CHROMOTING_VIEW_H_ | 64 #endif // REMOTING_CLIENT_CHROMOTING_VIEW_H_ |
OLD | NEW |