| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #include "media/cast/sender/size_adaptable_video_encoder_base.h" | 5 #include "media/cast/sender/size_adaptable_video_encoder_base.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/location.h" | 10 #include "base/location.h" |
| 11 #include "media/base/video_frame.h" | 11 #include "media/base/video_frame.h" |
| 12 | 12 |
| 13 namespace media { | 13 namespace media { |
| 14 namespace cast { | 14 namespace cast { |
| 15 | 15 |
| 16 SizeAdaptableVideoEncoderBase::SizeAdaptableVideoEncoderBase( | 16 SizeAdaptableVideoEncoderBase::SizeAdaptableVideoEncoderBase( |
| 17 const scoped_refptr<CastEnvironment>& cast_environment, | 17 const scoped_refptr<CastEnvironment>& cast_environment, |
| 18 const VideoSenderConfig& video_config, | 18 const FrameSenderConfig& video_config, |
| 19 const StatusChangeCallback& status_change_cb) | 19 const StatusChangeCallback& status_change_cb) |
| 20 : cast_environment_(cast_environment), | 20 : cast_environment_(cast_environment), |
| 21 video_config_(video_config), | 21 video_config_(video_config), |
| 22 status_change_cb_(status_change_cb), | 22 status_change_cb_(status_change_cb), |
| 23 frames_in_encoder_(0), | 23 frames_in_encoder_(0), |
| 24 next_frame_id_(FrameId::first()), | 24 next_frame_id_(FrameId::first()), |
| 25 weak_factory_(this) { | 25 weak_factory_(this) { |
| 26 cast_environment_->PostTask( | 26 cast_environment_->PostTask( |
| 27 CastEnvironment::MAIN, | 27 CastEnvironment::MAIN, |
| 28 FROM_HERE, | 28 FROM_HERE, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 base::Bind(&SizeAdaptableVideoEncoderBase::OnEncodedVideoFrame, | 61 base::Bind(&SizeAdaptableVideoEncoderBase::OnEncodedVideoFrame, |
| 62 weak_factory_.GetWeakPtr(), | 62 weak_factory_.GetWeakPtr(), |
| 63 frame_encoded_callback)); | 63 frame_encoded_callback)); |
| 64 if (is_frame_accepted) | 64 if (is_frame_accepted) |
| 65 ++frames_in_encoder_; | 65 ++frames_in_encoder_; |
| 66 return is_frame_accepted; | 66 return is_frame_accepted; |
| 67 } | 67 } |
| 68 | 68 |
| 69 void SizeAdaptableVideoEncoderBase::SetBitRate(int new_bit_rate) { | 69 void SizeAdaptableVideoEncoderBase::SetBitRate(int new_bit_rate) { |
| 70 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 70 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 71 video_config_.start_bitrate = new_bit_rate; | 71 video_config_.codec_specific_params.start_bitrate = new_bit_rate; |
| 72 if (encoder_) | 72 if (encoder_) |
| 73 encoder_->SetBitRate(new_bit_rate); | 73 encoder_->SetBitRate(new_bit_rate); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void SizeAdaptableVideoEncoderBase::GenerateKeyFrame() { | 76 void SizeAdaptableVideoEncoderBase::GenerateKeyFrame() { |
| 77 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 77 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 78 if (encoder_) | 78 if (encoder_) |
| 79 encoder_->GenerateKeyFrame(); | 79 encoder_->GenerateKeyFrame(); |
| 80 } | 80 } |
| 81 | 81 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 --frames_in_encoder_; | 157 --frames_in_encoder_; |
| 158 DCHECK_GE(frames_in_encoder_, 0); | 158 DCHECK_GE(frames_in_encoder_, 0); |
| 159 | 159 |
| 160 if (encoded_frame) | 160 if (encoded_frame) |
| 161 next_frame_id_ = encoded_frame->frame_id + 1; | 161 next_frame_id_ = encoded_frame->frame_id + 1; |
| 162 frame_encoded_callback.Run(std::move(encoded_frame)); | 162 frame_encoded_callback.Run(std::move(encoded_frame)); |
| 163 } | 163 } |
| 164 | 164 |
| 165 } // namespace cast | 165 } // namespace cast |
| 166 } // namespace media | 166 } // namespace media |
| OLD | NEW |