| 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 #include "media/cast/sender/video_sender.h" | 5 #include "media/cast/sender/video_sender.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <cstring> | 10 #include <cstring> |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 | 85 |
| 86 // Note, we use a fixed bitrate value when external video encoder is used. | 86 // Note, we use a fixed bitrate value when external video encoder is used. |
| 87 // Some hardware encoder shows bad behavior if we set the bitrate too | 87 // Some hardware encoder shows bad behavior if we set the bitrate too |
| 88 // frequently, e.g. quality drop, not abiding by target bitrate, etc. | 88 // frequently, e.g. quality drop, not abiding by target bitrate, etc. |
| 89 // See details: crbug.com/392086. | 89 // See details: crbug.com/392086. |
| 90 VideoSender::VideoSender( | 90 VideoSender::VideoSender( |
| 91 scoped_refptr<CastEnvironment> cast_environment, | 91 scoped_refptr<CastEnvironment> cast_environment, |
| 92 const FrameSenderConfig& video_config, | 92 const VideoSenderConfig& video_config, |
| 93 const StatusChangeCallback& status_change_cb, | 93 const StatusChangeCallback& status_change_cb, |
| 94 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, | 94 const CreateVideoEncodeAcceleratorCallback& create_vea_cb, |
| 95 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb, | 95 const CreateVideoEncodeMemoryCallback& create_video_encode_mem_cb, |
| 96 CastTransport* const transport_sender, | 96 CastTransport* const transport_sender, |
| 97 const PlayoutDelayChangeCB& playout_delay_change_cb) | 97 const PlayoutDelayChangeCB& playout_delay_change_cb) |
| 98 : FrameSender( | 98 : FrameSender( |
| 99 cast_environment, | 99 cast_environment, |
| 100 false, | 100 false, |
| 101 transport_sender, | 101 transport_sender, |
| 102 kVideoFrequency, | 102 kVideoFrequency, |
| 103 video_config.sender_ssrc, | 103 video_config.ssrc, |
| 104 video_config.max_frame_rate, | 104 video_config.max_frame_rate, |
| 105 video_config.min_playout_delay, | 105 video_config.min_playout_delay, |
| 106 video_config.max_playout_delay, | 106 video_config.max_playout_delay, |
| 107 video_config.animated_playout_delay, | 107 video_config.animated_playout_delay, |
| 108 video_config.use_external_encoder | 108 video_config.use_external_encoder |
| 109 ? NewFixedCongestionControl( | 109 ? NewFixedCongestionControl( |
| 110 (video_config.min_bitrate + video_config.max_bitrate) / 2) | 110 (video_config.min_bitrate + video_config.max_bitrate) / 2) |
| 111 : NewAdaptiveCongestionControl(cast_environment->Clock(), | 111 : NewAdaptiveCongestionControl(cast_environment->Clock(), |
| 112 video_config.max_bitrate, | 112 video_config.max_bitrate, |
| 113 video_config.min_bitrate, | 113 video_config.min_bitrate, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 126 create_vea_cb, | 126 create_vea_cb, |
| 127 create_video_encode_mem_cb); | 127 create_video_encode_mem_cb); |
| 128 if (!video_encoder_) { | 128 if (!video_encoder_) { |
| 129 cast_environment_->PostTask( | 129 cast_environment_->PostTask( |
| 130 CastEnvironment::MAIN, | 130 CastEnvironment::MAIN, |
| 131 FROM_HERE, | 131 FROM_HERE, |
| 132 base::Bind(status_change_cb, STATUS_UNSUPPORTED_CODEC)); | 132 base::Bind(status_change_cb, STATUS_UNSUPPORTED_CODEC)); |
| 133 } | 133 } |
| 134 | 134 |
| 135 media::cast::CastTransportRtpConfig transport_config; | 135 media::cast::CastTransportRtpConfig transport_config; |
| 136 transport_config.ssrc = video_config.sender_ssrc; | 136 transport_config.ssrc = video_config.ssrc; |
| 137 transport_config.feedback_ssrc = video_config.receiver_ssrc; | 137 transport_config.feedback_ssrc = video_config.receiver_ssrc; |
| 138 transport_config.rtp_payload_type = video_config.rtp_payload_type; | 138 transport_config.rtp_payload_type = video_config.rtp_payload_type; |
| 139 transport_config.aes_key = video_config.aes_key; | 139 transport_config.aes_key = video_config.aes_key; |
| 140 transport_config.aes_iv_mask = video_config.aes_iv_mask; | 140 transport_config.aes_iv_mask = video_config.aes_iv_mask; |
| 141 | 141 |
| 142 transport_sender->InitializeVideo( | 142 transport_sender->InitializeVideo( |
| 143 transport_config, base::WrapUnique(new FrameSender::RtcpClient( | 143 transport_config, base::WrapUnique(new FrameSender::RtcpClient( |
| 144 weak_factory_.GetWeakPtr()))); | 144 weak_factory_.GetWeakPtr()))); |
| 145 } | 145 } |
| 146 | 146 |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 351 media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
| 352 encoded_frame->dependency == EncodedFrame::KEY ? | 352 encoded_frame->dependency == EncodedFrame::KEY ? |
| 353 std::min(1.0, attenuated_utilization) : attenuated_utilization); | 353 std::min(1.0, attenuated_utilization) : attenuated_utilization); |
| 354 } | 354 } |
| 355 | 355 |
| 356 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); | 356 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); |
| 357 } | 357 } |
| 358 | 358 |
| 359 } // namespace cast | 359 } // namespace cast |
| 360 } // namespace media | 360 } // namespace media |
| OLD | NEW |