Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 | |
| 10 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 11 #include "media/base/video_frame.h" | 9 #include "media/base/video_frame.h" |
| 12 #include "remoting/proto/video.pb.h" | 10 #include "remoting/proto/video.pb.h" |
| 13 #include "third_party/skia/include/core/SkRect.h" | 11 #include "third_party/skia/include/core/SkRegion.h" |
| 14 | 12 |
| 15 namespace remoting { | 13 namespace remoting { |
| 16 | 14 |
| 17 typedef std::vector<SkIRect> RectVector; | |
| 18 | |
| 19 // Interface for a decoder that takes a stream of bytes from the network and | 15 // Interface for a decoder that takes a stream of bytes from the network and |
| 20 // outputs frames of data. | 16 // outputs frames of data. |
| 21 // | 17 // |
| 22 // TODO(ajwong): Beef up this documentation once the API stablizes. | 18 // TODO(ajwong): Beef up this documentation once the API stablizes. |
| 23 class Decoder { | 19 class Decoder { |
| 24 public: | 20 public: |
| 25 // DecodeResult is returned from DecodePacket() and indicates current state | 21 // DecodeResult is returned from DecodePacket() and indicates current state |
| 26 // of the decoder. DECODE_DONE means that last packet for the frame was | 22 // of the decoder. DECODE_DONE means that last packet for the frame was |
| 27 // processed, and the frame can be displayed now. DECODE_IN_PROGRESS | 23 // processed, and the frame can be displayed now. DECODE_IN_PROGRESS |
| 28 // indicates that the decoder must receive more data before the frame can be | 24 // indicates that the decoder must receive more data before the frame can be |
| 29 // displayed. DECODE_ERROR is returned if there was an error in the stream. | 25 // displayed. DECODE_ERROR is returned if there was an error in the stream. |
| 30 enum DecodeResult { | 26 enum DecodeResult { |
| 31 DECODE_ERROR = -1, | 27 DECODE_ERROR = -1, |
| 32 DECODE_IN_PROGRESS, | 28 DECODE_IN_PROGRESS, |
| 33 DECODE_DONE, | 29 DECODE_DONE, |
| 34 }; | 30 }; |
| 35 | 31 |
| 36 Decoder() {} | 32 Decoder() {} |
| 37 virtual ~Decoder() {} | 33 virtual ~Decoder() {} |
| 38 | 34 |
| 39 // Initializes the decoder to draw into the given |frame|. | 35 // Initializes the decoder to draw into the given |frame|. |
| 40 virtual void Initialize(scoped_refptr<media::VideoFrame> frame) = 0; | 36 virtual void Initialize(scoped_refptr<media::VideoFrame> frame) = 0; |
| 41 | 37 |
| 42 // Feeds more data into the decoder. | 38 // Feeds more data into the decoder. |
| 43 virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0; | 39 virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0; |
| 44 | 40 |
| 45 // Returns rects that were updated in the last frame. Can be called only | 41 // Returns the region affected by the most recent frame. Can be called only |
| 46 // after DecodePacket returned DECODE_DONE. Caller keeps ownership of | 42 // after DecodePacket returned DECODE_DONE. Caller keeps ownership of |
| 47 // |rects|. |rects| is kept empty if whole screen needs to be updated. | 43 // |region|. TODO: |rects| is kept empty if whole screen needs to be updated. |
|
Sergey Ulanov
2012/01/23 19:59:54
TODO(wez)?
It's better to move TODO to a separate
alexeypa (please no reviews)
2012/01/23 20:32:10
TODO: |rect| -> TODO: |region|
Wez
2012/01/23 21:37:23
As far as I can tell, that comment just isn't true
| |
| 48 virtual void GetUpdatedRects(RectVector* rects) = 0; | 44 virtual void GetUpdatedRegion(SkRegion* region) = 0; |
| 49 | 45 |
| 50 // Reset the decoder to an uninitialized state. Release all references to | 46 // Reset the decoder to an uninitialized state. Release all references to |
| 51 // the initialized |frame|. Initialize() must be called before the decoder | 47 // the initialized |frame|. Initialize() must be called before the decoder |
| 52 // is used again. | 48 // is used again. |
| 53 virtual void Reset() = 0; | 49 virtual void Reset() = 0; |
| 54 | 50 |
| 55 // Returns true if decoder is ready to accept data via DecodePacket. | 51 // Returns true if decoder is ready to accept data via DecodePacket. |
| 56 virtual bool IsReadyForData() = 0; | 52 virtual bool IsReadyForData() = 0; |
| 57 | 53 |
| 58 virtual VideoPacketFormat::Encoding Encoding() = 0; | 54 virtual VideoPacketFormat::Encoding Encoding() = 0; |
| 59 | 55 |
| 60 // Set the output dimensions for the decoder. If the dimensions are empty | 56 // Set the output dimensions for the decoder. If the dimensions are empty |
| 61 // then the source is rendered without scaling. | 57 // then the source is rendered without scaling. |
| 62 // Output dimensions are ignored if the decoder doesn't support scaling. | 58 // Output dimensions are ignored if the decoder doesn't support scaling. |
| 63 virtual void SetOutputSize(const SkISize& size) {} | 59 virtual void SetOutputSize(const SkISize& size) {} |
| 64 | 60 |
| 65 // Set the clipping rectangle to the decoder. Decoder should respect this and | 61 // Set the clipping rectangle to the decoder. Decoder should respect this and |
| 66 // only output changes in this rectangle. The new clipping rectangle will be | 62 // only output changes in this rectangle. The new clipping rectangle will be |
| 67 // effective on the next decoded video frame. | 63 // effective on the next decoded video frame. |
| 68 // | |
| 69 // When scaling is enabled clipping rectangles are ignored. | |
| 70 virtual void SetClipRect(const SkIRect& clip_rect) {} | 64 virtual void SetClipRect(const SkIRect& clip_rect) {} |
| 71 | 65 |
| 72 // Force decoder to output a video frame with content in |rects| using the | 66 // Force decoder to output a frame based on the specified |region| of the |
| 73 // last decoded video frame. |rects| are expressed in video frame rather | 67 // most recently decoded video frame. |region| is expressed in video frame |
| 74 // than output coordinates. | 68 // rather than output coordinates. |
| 75 virtual void RefreshRects(const RectVector& rects) {} | 69 virtual void RefreshRegion(const SkRegion& region) {} |
| 76 }; | 70 }; |
| 77 | 71 |
| 78 } // namespace remoting | 72 } // namespace remoting |
| 79 | 73 |
| 80 #endif // REMOTING_BASE_DECODER_H_ | 74 #endif // REMOTING_BASE_DECODER_H_ |
| OLD | NEW |