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_BASE_DECODER_H_ | 5 #ifndef REMOTING_BASE_DECODER_H_ |
6 #define REMOTING_BASE_DECODER_H_ | 6 #define REMOTING_BASE_DECODER_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/task.h" | 10 #include "base/task.h" |
11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
12 #include "gfx/rect.h" | 12 #include "gfx/rect.h" |
13 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
14 #include "remoting/base/protocol/chromotocol.pb.h" | 14 #include "remoting/base/protocol/chromotocol.pb.h" |
15 | 15 |
16 namespace remoting { | 16 namespace remoting { |
17 | 17 |
18 // TODO(hclam): Merge this with the one in remoting/host/encoder.h. | 18 // TODO(hclam): Merge this with the one in remoting/host/encoder.h. |
19 typedef std::vector<gfx::Rect> UpdatedRects; | 19 typedef std::vector<gfx::Rect> UpdatedRects; |
20 | 20 |
21 // Defines the behavior of a decoder for decoding images received from the | 21 // Defines the behavior of a decoder for decoding images received from the |
22 // host. | 22 // host. |
23 // | 23 // |
24 // Sequence of actions with a decoder is as follows: | 24 // Sequence of actions with a decoder is as follows: |
25 // | 25 // |
26 // 1. BeginDecode(PartialDecodeDone, DecodeDone, VideoFrame) | 26 // 1. BeginDecode(PartialDecodeDone, DecodeDone, VideoFrame) |
27 // 2. PartialDecode(HostMessage) | 27 // 2. PartialDecode(ChromotingHostMessage) |
28 // ... | 28 // ... |
29 // 3. EndDecode() | 29 // 3. EndDecode() |
30 // | 30 // |
31 // The decoder will reply with: | 31 // The decoder will reply with: |
32 // 1. PartialDecodeDone(VideoFrame, UpdatedRects) | 32 // 1. PartialDecodeDone(VideoFrame, UpdatedRects) |
33 // ... | 33 // ... |
34 // 2. DecodeDone(VideoFrame) | 34 // 2. DecodeDone(VideoFrame) |
35 // | 35 // |
36 // The format of VideoFrame is a contract between the object that creates the | 36 // The format of VideoFrame is a contract between the object that creates the |
37 // decoder (most likely the renderer) and the decoder. | 37 // decoder (most likely the renderer) and the decoder. |
(...skipping 12 matching lines...) Expand all Loading... |
50 // is called and |update_rects| contains the updated regions. | 50 // is called and |update_rects| contains the updated regions. |
51 // If decode is completed |decode_done| is called. | 51 // If decode is completed |decode_done| is called. |
52 // Return true if the decoder can writes output to |frame| and accept | 52 // Return true if the decoder can writes output to |frame| and accept |
53 // the codec format. | 53 // the codec format. |
54 // TODO(hclam): Provide more information when calling this function. | 54 // TODO(hclam): Provide more information when calling this function. |
55 virtual bool BeginDecode(scoped_refptr<media::VideoFrame> frame, | 55 virtual bool BeginDecode(scoped_refptr<media::VideoFrame> frame, |
56 UpdatedRects* updated_rects, | 56 UpdatedRects* updated_rects, |
57 Task* partial_decode_done, | 57 Task* partial_decode_done, |
58 Task* decode_done) = 0; | 58 Task* decode_done) = 0; |
59 | 59 |
60 // Give a HostMessage that contains the update stream packet that contains | 60 // Give a ChromotingHostMessage that contains the update stream packet that |
61 // the encoded data to the decoder. | 61 // contains the encoded data to the decoder. |
62 // The decoder will own |message| and is responsible for deleting it. | 62 // The decoder will own |message| and is responsible for deleting it. |
63 // | 63 // |
64 // If the decoder has written something into |frame|, | 64 // If the decoder has written something into |frame|, |
65 // |partial_decode_done_| is called with |frame| and updated regions. | 65 // |partial_decode_done_| is called with |frame| and updated regions. |
66 // Return true if the decoder can accept |message| and decode it. | 66 // Return true if the decoder can accept |message| and decode it. |
67 // | 67 // |
68 // HostMessage returned by this method will contain a | 68 // ChromotingHostMessage returned by this method will contain a |
69 // UpdateStreamPacketMessage. | 69 // UpdateStreamPacketMessage. |
70 // This message will contain either: | 70 // This message will contain either: |
71 // 1. UpdateStreamBeginRect | 71 // 1. UpdateStreamBeginRect |
72 // 2. UpdateStreamRectData | 72 // 2. UpdateStreamRectData |
73 // 3. UpdateStreamEndRect | 73 // 3. UpdateStreamEndRect |
74 // | 74 // |
75 // See remoting/base/protocol/chromotocol.proto for more information about | 75 // See remoting/base/protocol/chromotocol.proto for more information about |
76 // these messages. | 76 // these messages. |
77 virtual bool PartialDecode(HostMessage* message) = 0; | 77 virtual bool PartialDecode(ChromotingHostMessage* message) = 0; |
78 | 78 |
79 // Notify the decoder that we have received the last update stream packet. | 79 // Notify the decoder that we have received the last update stream packet. |
80 // If the decoding of the update stream has completed |decode_done_| is | 80 // If the decoding of the update stream has completed |decode_done_| is |
81 // called with |frame|. | 81 // called with |frame|. |
82 // If the update stream is not received fully and this method is called the | 82 // If the update stream is not received fully and this method is called the |
83 // decoder should also call |decode_done_| as soon as possible. | 83 // decoder should also call |decode_done_| as soon as possible. |
84 virtual void EndDecode() = 0; | 84 virtual void EndDecode() = 0; |
85 | 85 |
86 // Return the encoding type that this decoder handles. | 86 // Return the encoding type that this decoder handles. |
87 virtual UpdateStreamEncoding Encoding() { return encoding_; } | 87 virtual UpdateStreamEncoding Encoding() { return encoding_; } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // The encoding that this decoder supports. | 121 // The encoding that this decoder supports. |
122 UpdateStreamEncoding encoding_; | 122 UpdateStreamEncoding encoding_; |
123 | 123 |
124 // Has the decoder been started? I.e., has BeginDecode() been called. | 124 // Has the decoder been started? I.e., has BeginDecode() been called. |
125 bool started_; | 125 bool started_; |
126 }; | 126 }; |
127 | 127 |
128 } // namespace remoting | 128 } // namespace remoting |
129 | 129 |
130 #endif // REMOTING_BASE_DECODER_H_ | 130 #endif // REMOTING_BASE_DECODER_H_ |
OLD | NEW |