| 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 <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // This object is called external from the main cast thread and internally from | 21 // This object is called external from the main cast thread and internally from |
| 22 // the video encoder thread. | 22 // the video encoder thread. |
| 23 class VideoEncoderImpl : public VideoEncoder { | 23 class VideoEncoderImpl : public VideoEncoder { |
| 24 public: | 24 public: |
| 25 struct CodecDynamicConfig { | 25 struct CodecDynamicConfig { |
| 26 bool key_frame_requested; | 26 bool key_frame_requested; |
| 27 int bit_rate; | 27 int bit_rate; |
| 28 }; | 28 }; |
| 29 | 29 |
| 30 // Returns true if VideoEncoderImpl can be used with the given |video_config|. | 30 // Returns true if VideoEncoderImpl can be used with the given |video_config|. |
| 31 static bool IsSupported(const VideoSenderConfig& video_config); | 31 static bool IsSupported(const FrameSenderConfig& video_config); |
| 32 | 32 |
| 33 VideoEncoderImpl(scoped_refptr<CastEnvironment> cast_environment, | 33 VideoEncoderImpl(scoped_refptr<CastEnvironment> cast_environment, |
| 34 const VideoSenderConfig& video_config, | 34 const FrameSenderConfig& video_config, |
| 35 const StatusChangeCallback& status_change_cb); | 35 const StatusChangeCallback& status_change_cb); |
| 36 | 36 |
| 37 ~VideoEncoderImpl() final; | 37 ~VideoEncoderImpl() final; |
| 38 | 38 |
| 39 // VideoEncoder implementation. | 39 // VideoEncoder implementation. |
| 40 bool EncodeVideoFrame( | 40 bool EncodeVideoFrame( |
| 41 const scoped_refptr<media::VideoFrame>& video_frame, | 41 const scoped_refptr<media::VideoFrame>& video_frame, |
| 42 const base::TimeTicks& reference_time, | 42 const base::TimeTicks& reference_time, |
| 43 const FrameEncodedCallback& frame_encoded_callback) final; | 43 const FrameEncodedCallback& frame_encoded_callback) final; |
| 44 void SetBitRate(int new_bit_rate) final; | 44 void SetBitRate(int new_bit_rate) final; |
| 45 void GenerateKeyFrame() final; | 45 void GenerateKeyFrame() final; |
| 46 | 46 |
| 47 private: | 47 private: |
| 48 scoped_refptr<CastEnvironment> cast_environment_; | 48 scoped_refptr<CastEnvironment> cast_environment_; |
| 49 CodecDynamicConfig dynamic_config_; | 49 CodecDynamicConfig dynamic_config_; |
| 50 | 50 |
| 51 // This member belongs to the video encoder thread. It must not be | 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 | 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 | 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. | 54 // video encoder thread and video encoder thread can out-live the main thread. |
| 55 std::unique_ptr<SoftwareVideoEncoder> encoder_; | 55 std::unique_ptr<SoftwareVideoEncoder> encoder_; |
| 56 | 56 |
| 57 DISALLOW_COPY_AND_ASSIGN(VideoEncoderImpl); | 57 DISALLOW_COPY_AND_ASSIGN(VideoEncoderImpl); |
| 58 }; | 58 }; |
| 59 | 59 |
| 60 } // namespace cast | 60 } // namespace cast |
| 61 } // namespace media | 61 } // namespace media |
| 62 | 62 |
| 63 #endif // MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_ | 63 #endif // MEDIA_CAST_SENDER_VIDEO_ENCODER_IMPL_H_ |
| OLD | NEW |