Chromium Code Reviews| 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> | |
| 9 | |
| 8 #include "base/task.h" | 10 #include "base/task.h" |
| 9 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 10 #include "gfx/rect.h" | 12 #include "gfx/rect.h" |
| 11 #include "media/base/video_frame.h" | 13 #include "media/base/video_frame.h" |
| 12 #include "remoting/proto/video.pb.h" | 14 #include "remoting/proto/video.pb.h" |
| 13 | 15 |
| 14 namespace remoting { | 16 namespace remoting { |
| 15 | 17 |
| 16 typedef std::vector<gfx::Rect> UpdatedRects; | 18 typedef std::vector<gfx::Rect> UpdatedRects; |
| 17 | 19 |
| 18 // Interface for a decoder that takes a stream of bytes from the network and | 20 // Interface for a decoder that takes a stream of bytes from the network and |
| 19 // outputs frames of data. | 21 // outputs frames of data. |
| 20 // | 22 // |
| 21 // TODO(ajwong): Beef up this documentation once the API stablizes. | 23 // TODO(ajwong): Beef up this documentation once the API stablizes. |
| 22 class Decoder { | 24 class Decoder { |
| 23 public: | 25 public: |
| 26 // DecodeResult is returned from DecodePacket() and indicates current state of | |
| 27 // the decoder. DECODE_DONE means that last packet for the frame was | |
| 28 // processed, and the frame can be displayed now. DECODE_IN_PROGRESS | |
| 29 // indicates that the decoder must receive more data before the frame can be | |
| 30 // displayed. DECODE_ERROR is returned if there was an error in the stream. | |
| 31 enum DecodeResult { | |
| 32 DECODE_ERROR = -1, | |
| 33 DECODE_IN_PROGRESS, | |
| 34 DECODE_DONE, | |
| 35 }; | |
| 36 | |
| 24 Decoder() {} | 37 Decoder() {} |
| 25 virtual ~Decoder() {} | 38 virtual ~Decoder() {} |
| 26 | 39 |
| 27 // TODO(ajwong): This API is incorrect in the face of a streaming decode | |
| 28 // protocol like VP8. However, it breaks the layering abstraction by | |
| 29 // depending on the network packet protocol buffer type. I'm going to go | |
| 30 // forward with it as is, and then refactor again to support streaming | |
| 31 // decodes. | |
| 32 | |
| 33 // Initializes the decoder to draw into the given |frame|. The |clip| | 40 // Initializes the decoder to draw into the given |frame|. The |clip| |
| 34 // specifies the region to draw into. The clip region must fit inside | 41 // specifies the region to draw into. The clip region must fit inside |
| 35 // the dimensions of frame. Failure to do so will CHECK Fail. | 42 // the dimensions of frame. Failure to do so will CHECK fail. |
| 36 // | 43 virtual void Initialize(scoped_refptr<media::VideoFrame> frame) = 0; |
| 37 // TODO(ajwong): Should this take the source pixel format? | 44 |
| 38 // TODO(ajwong): Should the protocol be split into basic-types followed | 45 // Feeds more data into the decoder. |
| 39 // by packet types? Basic types might include the format enum below. | 46 virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0; |
| 40 virtual void Initialize(scoped_refptr<media::VideoFrame> frame, | 47 |
| 41 const gfx::Rect& clip, int bytes_per_src_pixel) = 0; | 48 // Returns rects that were updated in the last frame. Can be called only |
| 49 // after DecodePacket returned DECODE_DONE. Ownership of the result is given | |
| 50 // to the caller. Returns NULL if the whole screen needs to be updated. | |
| 51 virtual UpdatedRects* GetUpdatedRects() = 0; | |
|
awong
2010/11/09 01:54:38
I would prefer that this appends to an UpdateRects
Sergey Ulanov
2010/11/09 21:34:42
Done.
| |
| 42 | 52 |
| 43 // Reset the decoder to an uninitialized state. Release all references to | 53 // Reset the decoder to an uninitialized state. Release all references to |
| 44 // the initialized |frame|. Initialize() must be called before the decoder | 54 // the initialized |frame|. Initialize() must be called before the decoder |
| 45 // is used again. | 55 // is used again. |
| 46 virtual void Reset() = 0; | 56 virtual void Reset() = 0; |
| 47 | 57 |
| 48 // Feeds more data into the decoder. | 58 // Returns true if decoder is ready to accept data via DecodePacket. |
| 49 virtual void DecodeBytes(const std::string& encoded_bytes) = 0; | |
| 50 | |
| 51 // Returns true if decoder is ready to accept data via ProcessRectangleData. | |
| 52 virtual bool IsReadyForData() = 0; | 59 virtual bool IsReadyForData() = 0; |
| 53 | 60 |
| 54 virtual VideoPacketFormat::Encoding Encoding() = 0; | 61 virtual VideoPacketFormat::Encoding Encoding() = 0; |
| 55 }; | 62 }; |
| 56 | 63 |
| 57 } // namespace remoting | 64 } // namespace remoting |
| 58 | 65 |
| 59 #endif // REMOTING_BASE_DECODER_H_ | 66 #endif // REMOTING_BASE_DECODER_H_ |
| OLD | NEW |