[email protected] | a43cfae | 2013-10-19 22:14:54 | [diff] [blame^] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
3 | // found in the LICENSE file. | ||||
4 | |||||
[email protected] | a43cfae | 2013-10-19 22:14:54 | [diff] [blame^] | 5 | #ifndef REMOTING_CODEC_VIDEO_DECODER_VPX_H_ |
6 | #define REMOTING_CODEC_VIDEO_DECODER_VPX_H_ | ||||
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 7 | |
[email protected] | 71f40a7 | 2012-05-16 07:26:59 | [diff] [blame] | 8 | #include "base/compiler_specific.h" |
[email protected] | a43cfae | 2013-10-19 22:14:54 | [diff] [blame^] | 9 | #include "base/memory/scoped_ptr.h" |
10 | #include "remoting/codec/scoped_vpx_codec.h" | ||||
[email protected] | 3860983 | 2012-08-23 01:36:10 | [diff] [blame] | 11 | #include "remoting/codec/video_decoder.h" |
[email protected] | e59d659 | 2013-09-25 22:16:21 | [diff] [blame] | 12 | #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
13 | #include "third_party/webrtc/modules/desktop_capture/desktop_region.h" | ||||
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 14 | |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 15 | typedef struct vpx_image vpx_image_t; |
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 16 | |
17 | namespace remoting { | ||||
18 | |||||
[email protected] | a43cfae | 2013-10-19 22:14:54 | [diff] [blame^] | 19 | class VideoDecoderVpx : public VideoDecoder { |
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 20 | public: |
[email protected] | a43cfae | 2013-10-19 22:14:54 | [diff] [blame^] | 21 | // Creates a decoder for VP8. |
22 | static scoped_ptr<VideoDecoderVpx> CreateForVP8(); | ||||
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 23 | |
[email protected] | a43cfae | 2013-10-19 22:14:54 | [diff] [blame^] | 24 | virtual ~VideoDecoderVpx(); |
25 | |||||
26 | // VideoDecoder interface. | ||||
[email protected] | e59d659 | 2013-09-25 22:16:21 | [diff] [blame] | 27 | virtual void Initialize(const webrtc::DesktopSize& screen_size) OVERRIDE; |
[email protected] | 41b93ad3 | 2013-09-23 18:53:52 | [diff] [blame] | 28 | virtual bool DecodePacket(const VideoPacket& packet) OVERRIDE; |
[email protected] | e59d659 | 2013-09-25 22:16:21 | [diff] [blame] | 29 | virtual void Invalidate(const webrtc::DesktopSize& view_size, |
30 | const webrtc::DesktopRegion& region) OVERRIDE; | ||||
31 | virtual void RenderFrame(const webrtc::DesktopSize& view_size, | ||||
32 | const webrtc::DesktopRect& clip_area, | ||||
[email protected] | 55d3688e | 2012-02-24 23:05:56 | [diff] [blame] | 33 | uint8* image_buffer, |
34 | int image_stride, | ||||
[email protected] | e59d659 | 2013-09-25 22:16:21 | [diff] [blame] | 35 | webrtc::DesktopRegion* output_region) OVERRIDE; |
36 | virtual const webrtc::DesktopRegion* GetImageShape() OVERRIDE; | ||||
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 37 | |
38 | private: | ||||
[email protected] | a43cfae | 2013-10-19 22:14:54 | [diff] [blame^] | 39 | explicit VideoDecoderVpx(ScopedVpxCodec codec); |
[email protected] | da4daa7f | 2013-06-21 10:16:41 | [diff] [blame] | 40 | |
41 | // Calculates the difference between the desktop shape regions in two | ||||
42 | // consecutive frames and updates |updated_region_| and |transparent_region_| | ||||
43 | // accordingly. | ||||
[email protected] | e59d659 | 2013-09-25 22:16:21 | [diff] [blame] | 44 | void UpdateImageShapeRegion(webrtc::DesktopRegion* new_desktop_shape); |
[email protected] | da4daa7f | 2013-06-21 10:16:41 | [diff] [blame] | 45 | |
[email protected] | a43cfae | 2013-10-19 22:14:54 | [diff] [blame^] | 46 | ScopedVpxCodec codec_; |
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 47 | |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 48 | // Pointer to the last decoded image. |
49 | vpx_image_t* last_image_; | ||||
50 | |||||
[email protected] | 55d3688e | 2012-02-24 23:05:56 | [diff] [blame] | 51 | // The region updated that hasn't been copied to the screen yet. |
[email protected] | e59d659 | 2013-09-25 22:16:21 | [diff] [blame] | 52 | webrtc::DesktopRegion updated_region_; |
[email protected] | 5068614 | 2011-02-04 02:08:32 | [diff] [blame] | 53 | |
[email protected] | 15e7b6c | 2011-12-22 10:20:33 | [diff] [blame] | 54 | // Output dimensions. |
[email protected] | e59d659 | 2013-09-25 22:16:21 | [diff] [blame] | 55 | webrtc::DesktopSize screen_size_; |
[email protected] | 47379e9 | 2011-07-26 15:33:15 | [diff] [blame] | 56 | |
[email protected] | da4daa7f | 2013-06-21 10:16:41 | [diff] [blame] | 57 | // The region occupied by the top level windows. |
[email protected] | e59d659 | 2013-09-25 22:16:21 | [diff] [blame] | 58 | webrtc::DesktopRegion desktop_shape_; |
[email protected] | da4daa7f | 2013-06-21 10:16:41 | [diff] [blame] | 59 | |
60 | // The region that should be make transparent. | ||||
[email protected] | e59d659 | 2013-09-25 22:16:21 | [diff] [blame] | 61 | webrtc::DesktopRegion transparent_region_; |
[email protected] | da4daa7f | 2013-06-21 10:16:41 | [diff] [blame] | 62 | |
[email protected] | a43cfae | 2013-10-19 22:14:54 | [diff] [blame^] | 63 | DISALLOW_COPY_AND_ASSIGN(VideoDecoderVpx); |
[email protected] | 622b788 | 2010-09-29 17:34:32 | [diff] [blame] | 64 | }; |
65 | |||||
66 | } // namespace remoting | ||||
67 | |||||
[email protected] | 3860983 | 2012-08-23 01:36:10 | [diff] [blame] | 68 | #endif // REMOTING_CODEC_VIDEO_DECODER_VP8_H_ |