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