| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_CODEC_VIDEO_DECODER_H_ | 5 #ifndef REMOTING_CODEC_VIDEO_DECODER_H_ |
| 6 #define REMOTING_CODEC_VIDEO_DECODER_H_ | 6 #define REMOTING_CODEC_VIDEO_DECODER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "remoting/proto/video.pb.h" | 9 #include "remoting/proto/video.pb.h" |
| 10 | 10 #include "third_party/skia/include/core/SkRect.h" |
| 11 namespace webrtc { | 11 #include "third_party/skia/include/core/SkRegion.h" |
| 12 class DesktopRect; | 12 #include "third_party/skia/include/core/SkSize.h" |
| 13 class DesktopRegion; | |
| 14 class DesktopSize; | |
| 15 } // namespace webrtc | |
| 16 | 13 |
| 17 namespace remoting { | 14 namespace remoting { |
| 18 | 15 |
| 19 // Interface for a decoder that takes a stream of bytes from the network and | 16 // Interface for a decoder that takes a stream of bytes from the network and |
| 20 // outputs frames of data. | 17 // outputs frames of data. |
| 21 class VideoDecoder { | 18 class VideoDecoder { |
| 22 public: | 19 public: |
| 23 // DecodeResult is returned from DecodePacket() and indicates current state | 20 // DecodeResult is returned from DecodePacket() and indicates current state |
| 24 // of the decoder. DECODE_DONE means that last packet for the frame was | 21 // of the decoder. DECODE_DONE means that last packet for the frame was |
| 25 // processed, and the frame can be displayed now. DECODE_ERROR is returned if | 22 // processed, and the frame can be displayed now. DECODE_ERROR is returned if |
| 26 // there was an error in the stream. | 23 // there was an error in the stream. |
| 27 enum DecodeResult { | 24 enum DecodeResult { |
| 28 DECODE_ERROR, | 25 DECODE_ERROR, |
| 29 DECODE_DONE, | 26 DECODE_DONE, |
| 30 }; | 27 }; |
| 31 | 28 |
| 32 VideoDecoder() {} | 29 VideoDecoder() {} |
| 33 virtual ~VideoDecoder() {} | 30 virtual ~VideoDecoder() {} |
| 34 | 31 |
| 35 // Initializes the decoder and sets the output dimensions. | 32 // Initializes the decoder and sets the output dimensions. |
| 36 // |screen size| must not be empty. | 33 // |screen size| must not be empty. |
| 37 virtual void Initialize(const webrtc::DesktopSize& screen_size) = 0; | 34 virtual void Initialize(const SkISize& screen_size) = 0; |
| 38 | 35 |
| 39 // Feeds more data into the decoder. | 36 // Feeds more data into the decoder. |
| 40 virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0; | 37 virtual DecodeResult DecodePacket(const VideoPacket* packet) = 0; |
| 41 | 38 |
| 42 // Returns true if decoder is ready to accept data via DecodePacket. | 39 // Returns true if decoder is ready to accept data via DecodePacket. |
| 43 virtual bool IsReadyForData() = 0; | 40 virtual bool IsReadyForData() = 0; |
| 44 | 41 |
| 45 virtual VideoPacketFormat::Encoding Encoding() = 0; | 42 virtual VideoPacketFormat::Encoding Encoding() = 0; |
| 46 | 43 |
| 47 // Marks the specified |region| of the view for update the next time | 44 // Marks the specified |region| of the view for update the next time |
| 48 // RenderFrame() is called. |region| is expressed in |view_size| coordinates. | 45 // RenderFrame() is called. |region| is expressed in |view_size| coordinates. |
| 49 // |view_size| must not be empty. | 46 // |view_size| must not be empty. |
| 50 virtual void Invalidate(const webrtc::DesktopSize& view_size, | 47 virtual void Invalidate(const SkISize& view_size, |
| 51 const webrtc::DesktopRegion& region) = 0; | 48 const SkRegion& region) = 0; |
| 52 | 49 |
| 53 // Copies invalidated pixels within |clip_area| to |image_buffer|. Pixels are | 50 // Copies invalidated pixels within |clip_area| to |image_buffer|. Pixels are |
| 54 // invalidated either by new data received in DecodePacket(), or by explicit | 51 // invalidated either by new data received in DecodePacket(), or by explicit |
| 55 // calls to Invalidate(). |clip_area| is specified in |view_size| coordinates. | 52 // calls to Invalidate(). |clip_area| is specified in |view_size| coordinates. |
| 56 // If |view_size| differs from the source size then the copied pixels will be | 53 // If |view_size| differs from the source size then the copied pixels will be |
| 57 // scaled accordingly. |view_size| cannot be empty. | 54 // scaled accordingly. |view_size| cannot be empty. |
| 58 // | 55 // |
| 59 // |image_buffer|'s origin must correspond to the top-left of |clip_area|, | 56 // |image_buffer|'s origin must correspond to the top-left of |clip_area|, |
| 60 // and the buffer must be large enough to hold |clip_area| RGBA32 pixels. | 57 // and the buffer must be large enough to hold |clip_area| RGBA32 pixels. |
| 61 // |image_stride| gives the output buffer's stride in pixels. | 58 // |image_stride| gives the output buffer's stride in pixels. |
| 62 // | 59 // |
| 63 // On return, |output_region| contains the updated area, in |view_size| | 60 // On return, |output_region| contains the updated area, in |view_size| |
| 64 // coordinates. | 61 // coordinates. |
| 65 virtual void RenderFrame(const webrtc::DesktopSize& view_size, | 62 virtual void RenderFrame(const SkISize& view_size, |
| 66 const webrtc::DesktopRect& clip_area, | 63 const SkIRect& clip_area, |
| 67 uint8* image_buffer, | 64 uint8* image_buffer, |
| 68 int image_stride, | 65 int image_stride, |
| 69 webrtc::DesktopRegion* output_region) = 0; | 66 SkRegion* output_region) = 0; |
| 70 | 67 |
| 71 // Returns the "shape", if any, of the most recently rendered frame. | 68 // Returns the "shape", if any, of the most recently rendered frame. |
| 72 // The shape is returned in source dimensions. | 69 // The shape is returned in source dimensions. |
| 73 virtual const webrtc::DesktopRegion* GetImageShape() = 0; | 70 virtual const SkRegion* GetImageShape() = 0; |
| 74 }; | 71 }; |
| 75 | 72 |
| 76 } // namespace remoting | 73 } // namespace remoting |
| 77 | 74 |
| 78 #endif // REMOTING_CODEC_VIDEO_DECODER_H_ | 75 #endif // REMOTING_CODEC_VIDEO_DECODER_H_ |
| OLD | NEW |