OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_ | 5 #ifndef MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_ |
6 #define MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_ | 6 #define MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_ |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "media/cast/cast_config.h" | 9 #include "media/cast/cast_config.h" |
10 #include "media/cast/cast_environment.h" | 10 #include "media/cast/cast_environment.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 public: | 22 public: |
23 struct CodecDynamicConfig { | 23 struct CodecDynamicConfig { |
24 bool key_frame_requested; | 24 bool key_frame_requested; |
25 uint32 latest_frame_id_to_reference; | 25 uint32 latest_frame_id_to_reference; |
26 int bit_rate; | 26 int bit_rate; |
27 }; | 27 }; |
28 | 28 |
29 typedef base::Callback<void(scoped_ptr<EncodedFrame>)> | 29 typedef base::Callback<void(scoped_ptr<EncodedFrame>)> |
30 FrameEncodedCallback; | 30 FrameEncodedCallback; |
31 | 31 |
| 32 // Returns true if VideoEncoderImpl can be used with the given |video_config|. |
| 33 static bool IsSupported(const VideoSenderConfig& video_config); |
| 34 |
32 VideoEncoderImpl(scoped_refptr<CastEnvironment> cast_environment, | 35 VideoEncoderImpl(scoped_refptr<CastEnvironment> cast_environment, |
33 const VideoSenderConfig& video_config, | 36 const VideoSenderConfig& video_config, |
34 const StatusChangeCallback& status_change_cb); | 37 const StatusChangeCallback& status_change_cb); |
35 | 38 |
36 ~VideoEncoderImpl() override; | 39 ~VideoEncoderImpl() override; |
37 | 40 |
38 // VideoEncoder implementation. | 41 // VideoEncoder implementation. |
39 bool CanEncodeVariedFrameSizes() const override; | |
40 bool EncodeVideoFrame( | 42 bool EncodeVideoFrame( |
41 const scoped_refptr<media::VideoFrame>& video_frame, | 43 const scoped_refptr<media::VideoFrame>& video_frame, |
42 const base::TimeTicks& reference_time, | 44 const base::TimeTicks& reference_time, |
43 const FrameEncodedCallback& frame_encoded_callback) override; | 45 const FrameEncodedCallback& frame_encoded_callback) override; |
44 void SetBitRate(int new_bit_rate) override; | 46 void SetBitRate(int new_bit_rate) override; |
45 void GenerateKeyFrame() override; | 47 void GenerateKeyFrame() override; |
46 void LatestFrameIdToReference(uint32 frame_id) override; | 48 void LatestFrameIdToReference(uint32 frame_id) override; |
47 | 49 |
48 private: | 50 private: |
49 scoped_refptr<CastEnvironment> cast_environment_; | 51 scoped_refptr<CastEnvironment> cast_environment_; |
50 CodecDynamicConfig dynamic_config_; | 52 CodecDynamicConfig dynamic_config_; |
51 | 53 |
52 // This member belongs to the video encoder thread. It must not be | 54 // This member belongs to the video encoder thread. It must not be |
53 // dereferenced on the main thread. We manage the lifetime of this member | 55 // dereferenced on the main thread. We manage the lifetime of this member |
54 // manually because it needs to be initialize, used and destroyed on the | 56 // manually because it needs to be initialize, used and destroyed on the |
55 // video encoder thread and video encoder thread can out-live the main thread. | 57 // video encoder thread and video encoder thread can out-live the main thread. |
56 scoped_ptr<SoftwareVideoEncoder> encoder_; | 58 scoped_ptr<SoftwareVideoEncoder> encoder_; |
57 | 59 |
58 DISALLOW_COPY_AND_ASSIGN(VideoEncoderImpl); | 60 DISALLOW_COPY_AND_ASSIGN(VideoEncoderImpl); |
59 }; | 61 }; |
60 | 62 |
61 } // namespace cast | 63 } // namespace cast |
62 } // namespace media | 64 } // namespace media |
63 | 65 |
64 #endif // MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_ | 66 #endif // MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_ |
OLD | NEW |