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" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_; } |
88 | 88 |
89 // Return the current state of the decoder: 'true' if we're in the middle | 89 // Return the current state of the decoder: 'true' if we're in the middle |
90 // of BeginDecode() / EndDecode(). | 90 // of BeginDecode() / EndDecode(). |
91 virtual bool IsStarted() { return started_; } | 91 virtual bool IsStarted() { return started_; } |
92 | 92 |
| 93 // --- NEW API --- |
| 94 // TODO(ajwong): This API is incorrect in the face of a streaming decode |
| 95 // protocol like VP8. However, it breaks the layering abstraction by |
| 96 // depending on the network packet protocol buffer type. I'm going to go |
| 97 // forward with it as is, and then refactor again to support streaming |
| 98 // decodes. |
| 99 |
| 100 // Initializes the decoder to draw into the given |frame|. The |clip| |
| 101 // specifies the region to draw into. The clip region must fit inside |
| 102 // the dimensions of frame. Failure to do so will CHECK Fail. |
| 103 virtual void Initialize(scoped_refptr<media::VideoFrame> frame, |
| 104 const gfx::Rect& clip) {} |
| 105 |
| 106 // Reset the decoder to an uninitialized state. Release all references to |
| 107 // the initialized |frame|. Initialize() must be called before the decoder |
| 108 // is used again. |
| 109 virtual void Reset() {} |
| 110 |
| 111 // Feeds more data into the decoder. |
| 112 virtual void DecodeBytes(const std::string& encoded_bytes) {} |
| 113 |
| 114 // Returns true if decoder is ready to accept data via ProcessRectangleData. |
| 115 virtual bool IsReadyForData() { return false; } |
| 116 |
93 protected: | 117 protected: |
94 // Every decoder will have two internal states because there are three | 118 // Every decoder will have two internal states because there are three |
95 // kinds of messages send to PartialDecode(). | 119 // kinds of messages send to PartialDecode(). |
96 // | 120 // |
97 // Here's a state diagram: | 121 // Here's a state diagram: |
98 // | 122 // |
99 // UpdateStreamBeginRect UpdateStreamRectData | 123 // UpdateStreamBeginRect UpdateStreamRectData |
100 // .............. ............ | 124 // .............. ............ |
101 // . . . . | 125 // . . . . |
102 // . v . . | 126 // . v . . |
(...skipping 18 matching lines...) Expand all Loading... |
121 // The encoding that this decoder supports. | 145 // The encoding that this decoder supports. |
122 UpdateStreamEncoding encoding_; | 146 UpdateStreamEncoding encoding_; |
123 | 147 |
124 // Has the decoder been started? I.e., has BeginDecode() been called. | 148 // Has the decoder been started? I.e., has BeginDecode() been called. |
125 bool started_; | 149 bool started_; |
126 }; | 150 }; |
127 | 151 |
128 } // namespace remoting | 152 } // namespace remoting |
129 | 153 |
130 #endif // REMOTING_BASE_DECODER_H_ | 154 #endif // REMOTING_BASE_DECODER_H_ |
OLD | NEW |