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.
5 #ifndef REMOTING_CODEC_VIDEO_ENCODER_VPX_H_
6 #define REMOTING_CODEC_VIDEO_ENCODER_VPX_H_
8 #include "base/callback.h"
9 #include "remoting/codec/scoped_vpx_codec.h"
10 #include "remoting/codec/video_encoder.h"
12 typedef struct vpx_image vpx_image_t
;
21 class VideoEncoderVpx
: public VideoEncoder
{
23 // Create encoder for the specified protocol.
24 static scoped_ptr
<VideoEncoderVpx
> CreateForVP8();
25 static scoped_ptr
<VideoEncoderVpx
> CreateForVP9();
27 virtual ~VideoEncoderVpx();
29 // VideoEncoder interface.
30 virtual scoped_ptr
<VideoPacket
> Encode(
31 const webrtc::DesktopFrame
& frame
) OVERRIDE
;
34 typedef base::Callback
<ScopedVpxCodec(const webrtc::DesktopSize
&)>
35 InitializeCodecCallback
;
37 VideoEncoderVpx(const InitializeCodecCallback
& init_codec
);
39 // Initializes the codec for frames of |size|. Returns true if successful.
40 bool Initialize(const webrtc::DesktopSize
& size
);
42 // Prepares |image_| for encoding. Writes updated rectangles into
44 void PrepareImage(const webrtc::DesktopFrame
& frame
,
45 webrtc::DesktopRegion
* updated_region
);
47 // Updates the active map according to |updated_region|. Active map is then
48 // given to the encoder to speed up encoding.
49 void PrepareActiveMap(const webrtc::DesktopRegion
& updated_region
);
51 InitializeCodecCallback init_codec_
;
53 ScopedVpxCodec codec_
;
54 scoped_ptr
<vpx_image_t
> image_
;
55 scoped_ptr
<uint8
[]> active_map_
;
56 int active_map_width_
;
57 int active_map_height_
;
60 // Buffer for storing the yuv image.
61 scoped_ptr
<uint8
[]> yuv_image_
;
63 DISALLOW_COPY_AND_ASSIGN(VideoEncoderVpx
);
66 } // namespace remoting
68 #endif // REMOTING_CODEC_VIDEO_ENCODER_VP8_H_