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