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