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