| 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_ROW_BASED_H_ | 5 #ifndef REMOTING_BASE_DECODER_ROW_BASED_H_ |
| 6 #define REMOTING_BASE_DECODER_ROW_BASED_H_ | 6 #define REMOTING_BASE_DECODER_ROW_BASED_H_ |
| 7 | 7 |
| 8 #include "remoting/base/decoder.h" | 8 #include "remoting/base/decoder.h" |
| 9 | 9 |
| 10 namespace remoting { | 10 namespace remoting { |
| 11 | 11 |
| 12 class Decompressor; | 12 class Decompressor; |
| 13 | 13 |
| 14 class DecoderRowBased : public Decoder { | 14 class DecoderRowBased : public Decoder { |
| 15 public: | 15 public: |
| 16 virtual ~DecoderRowBased(); | 16 virtual ~DecoderRowBased(); |
| 17 | 17 |
| 18 static DecoderRowBased* CreateZlibDecoder(); | 18 static DecoderRowBased* CreateZlibDecoder(); |
| 19 static DecoderRowBased* CreateVerbatimDecoder(); | 19 static DecoderRowBased* CreateVerbatimDecoder(); |
| 20 | 20 |
| 21 // Decoder implementation. | 21 // Decoder implementation. |
| 22 virtual bool IsReadyForData(); |
| 23 virtual void Initialize(scoped_refptr<media::VideoFrame> frame); |
| 24 virtual DecodeResult DecodePacket(const VideoPacket* packet); |
| 25 virtual void GetUpdatedRects(UpdatedRects* rects); |
| 22 virtual void Reset(); | 26 virtual void Reset(); |
| 23 virtual bool IsReadyForData(); | 27 virtual VideoPacketFormat::Encoding Encoding(); |
| 24 virtual void Initialize(scoped_refptr<media::VideoFrame> frame, | |
| 25 const gfx::Rect& clip, int bytes_per_src_pixel); | |
| 26 virtual void DecodeBytes(const std::string& encoded_bytes); | |
| 27 virtual VideoPacketFormat::Encoding Encoding() { return encoding_; } | |
| 28 | 28 |
| 29 // TODO(hclam): Should make this into the Decoder interface. | 29 // TODO(hclam): Should make this into the Decoder interface. |
| 30 // TODO(ajwong): Before putting into the interface, we should decide if the | 30 // TODO(ajwong): Before putting into the interface, we should decide if the |
| 31 // Host should normalize the coordinate system. | 31 // Host should normalize the coordinate system. |
| 32 void set_reverse_rows(bool reverse) { reverse_rows_ = reverse; } | 32 void set_reverse_rows(bool reverse) { reverse_rows_ = reverse; } |
| 33 | 33 |
| 34 private: | 34 private: |
| 35 enum State { |
| 36 kUninitialized, |
| 37 kReady, |
| 38 kProcessing, |
| 39 kDone, |
| 40 kError, |
| 41 }; |
| 42 |
| 35 DecoderRowBased(Decompressor* decompressor, | 43 DecoderRowBased(Decompressor* decompressor, |
| 36 VideoPacketFormat::Encoding encoding); | 44 VideoPacketFormat::Encoding encoding); |
| 37 | 45 |
| 38 enum State { | 46 // Helper method. Called from DecodePacket to updated state of the decoder. |
| 39 kUninitialized, | 47 void UpdateStateForPacket(const VideoPacket* packet); |
| 40 kReady, | |
| 41 kError, | |
| 42 }; | |
| 43 | 48 |
| 44 // The internal state of the decoder. | 49 // The internal state of the decoder. |
| 45 State state_; | 50 State state_; |
| 46 | 51 |
| 47 // Keeps track of the updating rect. | 52 // Keeps track of the updating rect. |
| 48 gfx::Rect clip_; | 53 gfx::Rect clip_; |
| 49 | 54 |
| 50 // The video frame to write to. | 55 // The video frame to write to. |
| 51 scoped_refptr<media::VideoFrame> frame_; | 56 scoped_refptr<media::VideoFrame> frame_; |
| 52 | 57 |
| 53 // The compression for the input byte stream. | 58 // The compression for the input byte stream. |
| 54 scoped_ptr<Decompressor> decompressor_; | 59 scoped_ptr<Decompressor> decompressor_; |
| 55 | 60 |
| 56 // The encoding of the incoming stream. | 61 // The encoding of the incoming stream. |
| 57 VideoPacketFormat::Encoding encoding_; | 62 VideoPacketFormat::Encoding encoding_; |
| 58 | 63 |
| 59 // Number of bytes per pixel from source stream. | |
| 60 int bytes_per_src_pixel_; | |
| 61 | |
| 62 // The position in the row that we are updating. | 64 // The position in the row that we are updating. |
| 63 int row_pos_; | 65 int row_pos_; |
| 64 | 66 |
| 65 // The current row in the rect that we are updaing. | 67 // The current row in the rect that we are updaing. |
| 66 int row_y_; | 68 int row_y_; |
| 67 | 69 |
| 68 // True if we should decode the image upside down. | 70 // True if we should decode the image upside down. |
| 69 bool reverse_rows_; | 71 bool reverse_rows_; |
| 70 | 72 |
| 71 DISALLOW_COPY_AND_ASSIGN(DecoderRowBased); | 73 DISALLOW_COPY_AND_ASSIGN(DecoderRowBased); |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 } // namespace remoting | 76 } // namespace remoting |
| 75 | 77 |
| 76 #endif // REMOTING_BASE_DECODER_ROW_BASED_H_ | 78 #endif // REMOTING_BASE_DECODER_ROW_BASED_H_ |
| OLD | NEW |