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_ENCODER_VP8_H_ | 5 #ifndef REMOTING_CODEC_VIDEO_ENCODER_VP8_H_ |
6 #define REMOTING_CODEC_VIDEO_ENCODER_VP8_H_ | 6 #define REMOTING_CODEC_VIDEO_ENCODER_VP8_H_ |
7 | 7 |
8 #include "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "remoting/codec/video_encoder.h" | 9 #include "remoting/codec/video_encoder.h" |
10 #include "third_party/skia/include/core/SkRegion.h" | |
11 | 10 |
12 typedef struct vpx_codec_ctx vpx_codec_ctx_t; | 11 typedef struct vpx_codec_ctx vpx_codec_ctx_t; |
13 typedef struct vpx_image vpx_image_t; | 12 typedef struct vpx_image vpx_image_t; |
14 | 13 |
15 namespace webrtc { | 14 namespace webrtc { |
| 15 class DesktopRegion; |
16 class DesktopSize; | 16 class DesktopSize; |
17 } // namespace webrtc | 17 } // namespace webrtc |
18 | 18 |
19 namespace remoting { | 19 namespace remoting { |
20 | 20 |
21 // A class that uses VP8 to perform encoding. | 21 // A class that uses VP8 to perform encoding. |
22 class VideoEncoderVp8 : public VideoEncoder { | 22 class VideoEncoderVp8 : public VideoEncoder { |
23 public: | 23 public: |
24 VideoEncoderVp8(); | 24 VideoEncoderVp8(); |
25 virtual ~VideoEncoderVp8(); | 25 virtual ~VideoEncoderVp8(); |
26 | 26 |
27 // VideoEncoder interface. | 27 // VideoEncoder interface. |
28 virtual scoped_ptr<VideoPacket> Encode( | 28 virtual scoped_ptr<VideoPacket> Encode( |
29 const webrtc::DesktopFrame& frame) OVERRIDE; | 29 const webrtc::DesktopFrame& frame) OVERRIDE; |
30 | 30 |
31 private: | 31 private: |
32 FRIEND_TEST_ALL_PREFIXES(VideoEncoderVp8Test, AlignAndClipRect); | 32 FRIEND_TEST_ALL_PREFIXES(VideoEncoderVp8Test, AlignAndClipRect); |
33 | 33 |
34 // Initialize the encoder. Returns true if successful. | 34 // Initialize the encoder. Returns true if successful. |
35 bool Init(const webrtc::DesktopSize& size); | 35 bool Init(const webrtc::DesktopSize& size); |
36 | 36 |
37 // Destroy the encoder. | 37 // Destroy the encoder. |
38 void Destroy(); | 38 void Destroy(); |
39 | 39 |
40 // Prepare |image_| for encoding. Write updated rectangles into | 40 // Prepare |image_| for encoding. Write updated rectangles into |
41 // |updated_region|. | 41 // |updated_region|. |
42 // | 42 // |
43 // TODO(sergeyu): Update this code to use webrtc::DesktopRegion. | 43 // TODO(sergeyu): Update this code to use webrtc::DesktopRegion. |
44 void PrepareImage(const webrtc::DesktopFrame& frame, | 44 void PrepareImage(const webrtc::DesktopFrame& frame, |
45 SkRegion* updated_region); | 45 webrtc::DesktopRegion* updated_region); |
46 | 46 |
47 // Update the active map according to |updated_region|. Active map is then | 47 // Update the active map according to |updated_region|. Active map is then |
48 // given to the encoder to speed up encoding. | 48 // given to the encoder to speed up encoding. |
49 void PrepareActiveMap(const SkRegion& updated_region); | 49 void PrepareActiveMap(const webrtc::DesktopRegion& updated_region); |
50 | 50 |
51 // True if the encoder is initialized. | 51 // True if the encoder is initialized. |
52 bool initialized_; | 52 bool initialized_; |
53 | 53 |
54 scoped_ptr<vpx_codec_ctx_t> codec_; | 54 scoped_ptr<vpx_codec_ctx_t> codec_; |
55 scoped_ptr<vpx_image_t> image_; | 55 scoped_ptr<vpx_image_t> image_; |
56 scoped_ptr<uint8[]> active_map_; | 56 scoped_ptr<uint8[]> active_map_; |
57 int active_map_width_; | 57 int active_map_width_; |
58 int active_map_height_; | 58 int active_map_height_; |
59 int last_timestamp_; | 59 int last_timestamp_; |
60 | 60 |
61 // Buffer for storing the yuv image. | 61 // Buffer for storing the yuv image. |
62 scoped_ptr<uint8[]> yuv_image_; | 62 scoped_ptr<uint8[]> yuv_image_; |
63 | 63 |
64 DISALLOW_COPY_AND_ASSIGN(VideoEncoderVp8); | 64 DISALLOW_COPY_AND_ASSIGN(VideoEncoderVp8); |
65 }; | 65 }; |
66 | 66 |
67 } // namespace remoting | 67 } // namespace remoting |
68 | 68 |
69 #endif // REMOTING_CODEC_VIDEO_ENCODER_VP8_H_ | 69 #endif // REMOTING_CODEC_VIDEO_ENCODER_VP8_H_ |
OLD | NEW |