| 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> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/task.h" | 11 #include "base/task.h" |
| 12 #include "media/base/video_frame.h" | 12 #include "media/base/video_frame.h" |
| 13 #include "remoting/proto/video.pb.h" | 13 #include "remoting/proto/video.pb.h" |
| 14 #include "ui/gfx/rect.h" | 14 #include "third_party/skia/include/core/SkRect.h" |
| 15 | 15 |
| 16 namespace remoting { | 16 namespace remoting { |
| 17 | 17 |
| 18 typedef std::vector<gfx::Rect> UpdatedRects; | 18 typedef std::vector<SkIRect> RectVector; |
| 19 | 19 |
| 20 // 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 |
| 21 // outputs frames of data. | 21 // outputs frames of data. |
| 22 // | 22 // |
| 23 // TODO(ajwong): Beef up this documentation once the API stablizes. | 23 // TODO(ajwong): Beef up this documentation once the API stablizes. |
| 24 class Decoder { | 24 class Decoder { |
| 25 public: | 25 public: |
| 26 // DecodeResult is returned from DecodePacket() and indicates current state | 26 // DecodeResult is returned from DecodePacket() and indicates current state |
| 27 // of the decoder. DECODE_DONE means that last packet for the frame was | 27 // of the decoder. DECODE_DONE means that last packet for the frame was |
| 28 // processed, and the frame can be displayed now. DECODE_IN_PROGRESS | 28 // processed, and the frame can be displayed now. DECODE_IN_PROGRESS |
| (...skipping 10 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 // Initializes the decoder to draw into the given |frame|. | 40 // Initializes the decoder to draw into the given |frame|. |
| 41 virtual void Initialize(scoped_refptr<media::VideoFrame> frame) = 0; | 41 virtual void Initialize(scoped_refptr<media::VideoFrame> frame) = 0; |
| 42 | 42 |
| 43 // Feeds more data into the decoder. | 43 // Feeds more data into the decoder. |
| 44 virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0; | 44 virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0; |
| 45 | 45 |
| 46 // Returns rects that were updated in the last frame. Can be called only | 46 // Returns rects that were updated in the last frame. Can be called only |
| 47 // after DecodePacket returned DECODE_DONE. Caller keeps ownership of | 47 // after DecodePacket returned DECODE_DONE. Caller keeps ownership of |
| 48 // |rects|. |rects| is kept empty if whole screen needs to be updated. | 48 // |rects|. |rects| is kept empty if whole screen needs to be updated. |
| 49 // TODO(dmaclach): Move this over to using SkRegion. | 49 virtual void GetUpdatedRects(RectVector* rects) = 0; |
| 50 // http://crbug.com/92085 | |
| 51 virtual void GetUpdatedRects(UpdatedRects* rects) = 0; | |
| 52 | 50 |
| 53 // Reset the decoder to an uninitialized state. Release all references to | 51 // Reset the decoder to an uninitialized state. Release all references to |
| 54 // the initialized |frame|. Initialize() must be called before the decoder | 52 // the initialized |frame|. Initialize() must be called before the decoder |
| 55 // is used again. | 53 // is used again. |
| 56 virtual void Reset() = 0; | 54 virtual void Reset() = 0; |
| 57 | 55 |
| 58 // Returns true if decoder is ready to accept data via DecodePacket. | 56 // Returns true if decoder is ready to accept data via DecodePacket. |
| 59 virtual bool IsReadyForData() = 0; | 57 virtual bool IsReadyForData() = 0; |
| 60 | 58 |
| 61 virtual VideoPacketFormat::Encoding Encoding() = 0; | 59 virtual VideoPacketFormat::Encoding Encoding() = 0; |
| 62 | 60 |
| 63 // Set the scale factors of the decoded output. If the decoder doesn't support | 61 // Set the scale factors of the decoded output. If the decoder doesn't support |
| 64 // scaling then this all is ignored. | 62 // scaling then this all is ignored. |
| 65 // If both |horizontal_ratio| and |vertical_ratio| equal 1.0 then scaling is | 63 // If both |horizontal_ratio| and |vertical_ratio| equal 1.0 then scaling is |
| 66 // turned off. | 64 // turned off. |
| 67 virtual void SetScaleRatios(double horizontal_ratio, double vertical_ratio) {} | 65 virtual void SetScaleRatios(double horizontal_ratio, double vertical_ratio) {} |
| 68 | 66 |
| 69 // Set the clipping rectangle to the decoder. Decoder should respect this and | 67 // Set the clipping rectangle to the decoder. Decoder should respect this and |
| 70 // only output changes in this rectangle. The new clipping rectangle will be | 68 // only output changes in this rectangle. The new clipping rectangle will be |
| 71 // effective on the next decoded video frame. | 69 // effective on the next decoded video frame. |
| 72 // | 70 // |
| 73 // When scaling is enabled clipping rectangles are ignored. | 71 // When scaling is enabled clipping rectangles are ignored. |
| 74 virtual void SetClipRect(const gfx::Rect& clip_rect) {} | 72 virtual void SetClipRect(const SkIRect& clip_rect) {} |
| 75 | 73 |
| 76 // Force decoder to output a video frame with content in |rects| using the | 74 // Force decoder to output a video frame with content in |rects| using the |
| 77 // last decoded video frame. | 75 // last decoded video frame. |
| 78 // | 76 // |
| 79 // Coordinates of rectangles supplied here are before scaling. | 77 // Coordinates of rectangles supplied here are before scaling. |
| 80 virtual void RefreshRects(const std::vector<gfx::Rect>& rects) {} | 78 virtual void RefreshRects(const RectVector& rects) {} |
| 81 }; | 79 }; |
| 82 | 80 |
| 83 } // namespace remoting | 81 } // namespace remoting |
| 84 | 82 |
| 85 #endif // REMOTING_BASE_DECODER_H_ | 83 #endif // REMOTING_BASE_DECODER_H_ |
| OLD | NEW |