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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 | 243 |
244 const int bitrate = congestion_control_->GetBitrate( | 244 const int bitrate = congestion_control_->GetBitrate( |
245 reference_time + target_playout_delay_, target_playout_delay_); | 245 reference_time + target_playout_delay_, target_playout_delay_); |
246 if (bitrate != last_bitrate_) { | 246 if (bitrate != last_bitrate_) { |
247 video_encoder_->SetBitRate(bitrate); | 247 video_encoder_->SetBitRate(bitrate); |
248 last_bitrate_ = bitrate; | 248 last_bitrate_ = bitrate; |
249 } | 249 } |
250 | 250 |
251 TRACE_COUNTER_ID1("cast.stream", "Video Target Bitrate", this, bitrate); | 251 TRACE_COUNTER_ID1("cast.stream", "Video Target Bitrate", this, bitrate); |
252 | 252 |
253 MaybeRenderPerformanceMetricsOverlay( | 253 const scoped_refptr<VideoFrame> frame_to_encode = |
254 GetTargetPlayoutDelay(), low_latency_mode_, bitrate, | 254 MaybeRenderPerformanceMetricsOverlay( |
255 frames_in_encoder_ + 1, last_reported_encoder_utilization_, | 255 GetTargetPlayoutDelay(), low_latency_mode_, bitrate, |
256 last_reported_lossy_utilization_, video_frame.get()); | 256 frames_in_encoder_ + 1, last_reported_encoder_utilization_, |
257 | 257 last_reported_lossy_utilization_, video_frame); |
258 if (video_encoder_->EncodeVideoFrame( | 258 if (video_encoder_->EncodeVideoFrame( |
259 video_frame, | 259 frame_to_encode, reference_time, |
260 reference_time, | |
261 base::Bind(&VideoSender::OnEncodedVideoFrame, | 260 base::Bind(&VideoSender::OnEncodedVideoFrame, |
262 weak_factory_.GetWeakPtr(), | 261 weak_factory_.GetWeakPtr(), frame_to_encode, bitrate))) { |
263 video_frame, | 262 TRACE_EVENT_ASYNC_BEGIN1("cast.stream", "Video Encode", |
264 bitrate))) { | 263 frame_to_encode.get(), "rtp_timestamp", |
265 TRACE_EVENT_ASYNC_BEGIN1("cast.stream", "Video Encode", video_frame.get(), | 264 rtp_timestamp.lower_32_bits()); |
266 "rtp_timestamp", rtp_timestamp.lower_32_bits()); | |
267 frames_in_encoder_++; | 265 frames_in_encoder_++; |
268 duration_in_encoder_ += duration_added_by_next_frame; | 266 duration_in_encoder_ += duration_added_by_next_frame; |
269 last_enqueued_frame_rtp_timestamp_ = rtp_timestamp; | 267 last_enqueued_frame_rtp_timestamp_ = rtp_timestamp; |
270 last_enqueued_frame_reference_time_ = reference_time; | 268 last_enqueued_frame_reference_time_ = reference_time; |
271 } else { | 269 } else { |
272 VLOG(1) << "Encoder rejected a frame. Skipping..."; | 270 VLOG(1) << "Encoder rejected a frame. Skipping..."; |
273 TRACE_EVENT_INSTANT1("cast.stream", "Video Encode Reject", | 271 TRACE_EVENT_INSTANT1("cast.stream", "Video Encode Reject", |
274 TRACE_EVENT_SCOPE_THREAD, | 272 TRACE_EVENT_SCOPE_THREAD, |
275 "rtp_timestamp", rtp_timestamp.lower_32_bits()); | 273 "rtp_timestamp", rtp_timestamp.lower_32_bits()); |
276 } | 274 } |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 331 media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
334 encoded_frame->dependency == EncodedFrame::KEY ? | 332 encoded_frame->dependency == EncodedFrame::KEY ? |
335 std::min(1.0, attenuated_utilization) : attenuated_utilization); | 333 std::min(1.0, attenuated_utilization) : attenuated_utilization); |
336 } | 334 } |
337 | 335 |
338 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); | 336 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); |
339 } | 337 } |
340 | 338 |
341 } // namespace cast | 339 } // namespace cast |
342 } // namespace media | 340 } // namespace media |
OLD | NEW |