Refactor WebsiteSettings to operate on a SecurityInfo
[chromium-blink-merge.git] / media / cast / sender / video_encoder_impl.h
bloba8cf2075bfec15662eaa3ca32d6fa3a26952d640
1 // Copyright 2014 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 MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_
6 #define MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_
8 #include "base/memory/scoped_ptr.h"
9 #include "media/cast/cast_config.h"
10 #include "media/cast/cast_environment.h"
11 #include "media/cast/sender/software_video_encoder.h"
12 #include "media/cast/sender/video_encoder.h"
14 namespace media {
15 class VideoFrame;
17 namespace cast {
19 // This object is called external from the main cast thread and internally from
20 // the video encoder thread.
21 class VideoEncoderImpl : public VideoEncoder {
22 public:
23 struct CodecDynamicConfig {
24 bool key_frame_requested;
25 uint32 latest_frame_id_to_reference;
26 int bit_rate;
29 // Returns true if VideoEncoderImpl can be used with the given |video_config|.
30 static bool IsSupported(const VideoSenderConfig& video_config);
32 VideoEncoderImpl(scoped_refptr<CastEnvironment> cast_environment,
33 const VideoSenderConfig& video_config,
34 const StatusChangeCallback& status_change_cb);
36 ~VideoEncoderImpl() final;
38 // VideoEncoder implementation.
39 bool EncodeVideoFrame(
40 const scoped_refptr<media::VideoFrame>& video_frame,
41 const base::TimeTicks& reference_time,
42 const FrameEncodedCallback& frame_encoded_callback) final;
43 void SetBitRate(int new_bit_rate) final;
44 void GenerateKeyFrame() final;
45 void LatestFrameIdToReference(uint32 frame_id) final;
47 private:
48 scoped_refptr<CastEnvironment> cast_environment_;
49 CodecDynamicConfig dynamic_config_;
51 // This member belongs to the video encoder thread. It must not be
52 // dereferenced on the main thread. We manage the lifetime of this member
53 // manually because it needs to be initialize, used and destroyed on the
54 // video encoder thread and video encoder thread can out-live the main thread.
55 scoped_ptr<SoftwareVideoEncoder> encoder_;
57 DISALLOW_COPY_AND_ASSIGN(VideoEncoderImpl);
60 } // namespace cast
61 } // namespace media
63 #endif // MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_