| 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_VP8_H_ | 5 #ifndef REMOTING_CODEC_VIDEO_DECODER_VP8_H_ |
| 6 #define REMOTING_CODEC_VIDEO_DECODER_VP8_H_ | 6 #define REMOTING_CODEC_VIDEO_DECODER_VP8_H_ |
| 7 | 7 |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "remoting/codec/video_decoder.h" | 9 #include "remoting/codec/video_decoder.h" |
| 10 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | |
| 11 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | |
| 12 | 10 |
| 13 typedef struct vpx_codec_ctx vpx_codec_ctx_t; | 11 typedef struct vpx_codec_ctx vpx_codec_ctx_t; |
| 14 typedef struct vpx_image vpx_image_t; | 12 typedef struct vpx_image vpx_image_t; |
| 15 | 13 |
| 16 namespace remoting { | 14 namespace remoting { |
| 17 | 15 |
| 18 class VideoDecoderVp8 : public VideoDecoder { | 16 class VideoDecoderVp8 : public VideoDecoder { |
| 19 public: | 17 public: |
| 20 VideoDecoderVp8(); | 18 VideoDecoderVp8(); |
| 21 virtual ~VideoDecoderVp8(); | 19 virtual ~VideoDecoderVp8(); |
| 22 | 20 |
| 23 // VideoDecoder implementations. | 21 // VideoDecoder implementations. |
| 22 virtual void Initialize(const SkISize& screen_size) OVERRIDE; |
| 23 virtual DecodeResult DecodePacket(const VideoPacket* packet) OVERRIDE; |
| 24 virtual bool IsReadyForData() OVERRIDE; | 24 virtual bool IsReadyForData() OVERRIDE; |
| 25 virtual void Initialize(const webrtc::DesktopSize& screen_size) OVERRIDE; | |
| 26 virtual DecodeResult DecodePacket(const VideoPacket* packet) OVERRIDE; | |
| 27 virtual VideoPacketFormat::Encoding Encoding() OVERRIDE; | 25 virtual VideoPacketFormat::Encoding Encoding() OVERRIDE; |
| 28 virtual void Invalidate(const webrtc::DesktopSize& view_size, | 26 virtual void Invalidate(const SkISize& view_size, |
| 29 const webrtc::DesktopRegion& region) OVERRIDE; | 27 const SkRegion& region) OVERRIDE; |
| 30 virtual void RenderFrame(const webrtc::DesktopSize& view_size, | 28 virtual void RenderFrame(const SkISize& view_size, |
| 31 const webrtc::DesktopRect& clip_area, | 29 const SkIRect& clip_area, |
| 32 uint8* image_buffer, | 30 uint8* image_buffer, |
| 33 int image_stride, | 31 int image_stride, |
| 34 webrtc::DesktopRegion* output_region) OVERRIDE; | 32 SkRegion* output_region) OVERRIDE; |
| 35 virtual const webrtc::DesktopRegion* GetImageShape() OVERRIDE; | 33 virtual const SkRegion* GetImageShape() OVERRIDE; |
| 36 | 34 |
| 37 private: | 35 private: |
| 38 enum State { | 36 enum State { |
| 39 kUninitialized, | 37 kUninitialized, |
| 40 kReady, | 38 kReady, |
| 41 kError, | 39 kError, |
| 42 }; | 40 }; |
| 43 | 41 |
| 44 // Fills the rectangle |rect| with the given ARGB color |color| in |buffer|. | 42 // Fills the rectangle |rect| with the given ARGB color |color| in |buffer|. |
| 45 void FillRect(uint8* buffer, int stride, | 43 void FillRect(uint8* buffer, int stride, const SkIRect& rect, uint32 color); |
| 46 const webrtc::DesktopRect& rect, | |
| 47 uint32 color); | |
| 48 | 44 |
| 49 // Calculates the difference between the desktop shape regions in two | 45 // Calculates the difference between the desktop shape regions in two |
| 50 // consecutive frames and updates |updated_region_| and |transparent_region_| | 46 // consecutive frames and updates |updated_region_| and |transparent_region_| |
| 51 // accordingly. | 47 // accordingly. |
| 52 void UpdateImageShapeRegion(webrtc::DesktopRegion* new_desktop_shape); | 48 void UpdateImageShapeRegion(SkRegion* new_desktop_shape); |
| 53 | 49 |
| 54 // The internal state of the decoder. | 50 // The internal state of the decoder. |
| 55 State state_; | 51 State state_; |
| 56 | 52 |
| 57 vpx_codec_ctx_t* codec_; | 53 vpx_codec_ctx_t* codec_; |
| 58 | 54 |
| 59 // Pointer to the last decoded image. | 55 // Pointer to the last decoded image. |
| 60 vpx_image_t* last_image_; | 56 vpx_image_t* last_image_; |
| 61 | 57 |
| 62 // The region updated that hasn't been copied to the screen yet. | 58 // The region updated that hasn't been copied to the screen yet. |
| 63 webrtc::DesktopRegion updated_region_; | 59 SkRegion updated_region_; |
| 64 | 60 |
| 65 // Output dimensions. | 61 // Output dimensions. |
| 66 webrtc::DesktopSize screen_size_; | 62 SkISize screen_size_; |
| 67 | 63 |
| 68 // The region occupied by the top level windows. | 64 // The region occupied by the top level windows. |
| 69 webrtc::DesktopRegion desktop_shape_; | 65 SkRegion desktop_shape_; |
| 70 | 66 |
| 71 // The region that should be make transparent. | 67 // The region that should be make transparent. |
| 72 webrtc::DesktopRegion transparent_region_; | 68 SkRegion transparent_region_; |
| 73 | 69 |
| 74 DISALLOW_COPY_AND_ASSIGN(VideoDecoderVp8); | 70 DISALLOW_COPY_AND_ASSIGN(VideoDecoderVp8); |
| 75 }; | 71 }; |
| 76 | 72 |
| 77 } // namespace remoting | 73 } // namespace remoting |
| 78 | 74 |
| 79 #endif // REMOTING_CODEC_VIDEO_DECODER_VP8_H_ | 75 #endif // REMOTING_CODEC_VIDEO_DECODER_VP8_H_ |
| OLD | NEW |