| 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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 | 319 |
| 320 void VideoSender::OnEncodedVideoFrame( | 320 void VideoSender::OnEncodedVideoFrame( |
| 321 const scoped_refptr<media::VideoFrame>& video_frame, | 321 const scoped_refptr<media::VideoFrame>& video_frame, |
| 322 int encoder_bitrate, | 322 int encoder_bitrate, |
| 323 std::unique_ptr<SenderEncodedFrame> encoded_frame) { | 323 std::unique_ptr<SenderEncodedFrame> encoded_frame) { |
| 324 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 324 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
| 325 | 325 |
| 326 frames_in_encoder_--; | 326 frames_in_encoder_--; |
| 327 DCHECK_GE(frames_in_encoder_, 0); | 327 DCHECK_GE(frames_in_encoder_, 0); |
| 328 | 328 |
| 329 // Encoding was exited with errors. |
| 330 if (!encoded_frame) |
| 331 return; |
| 332 |
| 329 duration_in_encoder_ = | 333 duration_in_encoder_ = |
| 330 last_enqueued_frame_reference_time_ - encoded_frame->reference_time; | 334 last_enqueued_frame_reference_time_ - encoded_frame->reference_time; |
| 331 | 335 |
| 332 last_reported_deadline_utilization_ = encoded_frame->deadline_utilization; | 336 last_reported_deadline_utilization_ = encoded_frame->deadline_utilization; |
| 333 last_reported_lossy_utilization_ = encoded_frame->lossy_utilization; | 337 last_reported_lossy_utilization_ = encoded_frame->lossy_utilization; |
| 334 | 338 |
| 335 TRACE_EVENT_ASYNC_END2("cast.stream", "Video Encode", video_frame.get(), | 339 TRACE_EVENT_ASYNC_END2("cast.stream", "Video Encode", video_frame.get(), |
| 336 "deadline_utilization", last_reported_deadline_utilization_, | 340 "deadline_utilization", last_reported_deadline_utilization_, |
| 337 "lossy_utilization", last_reported_lossy_utilization_); | 341 "lossy_utilization", last_reported_lossy_utilization_); |
| 338 | 342 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 351 media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 355 media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
| 352 encoded_frame->dependency == EncodedFrame::KEY ? | 356 encoded_frame->dependency == EncodedFrame::KEY ? |
| 353 std::min(1.0, attenuated_utilization) : attenuated_utilization); | 357 std::min(1.0, attenuated_utilization) : attenuated_utilization); |
| 354 } | 358 } |
| 355 | 359 |
| 356 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); | 360 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); |
| 357 } | 361 } |
| 358 | 362 |
| 359 } // namespace cast | 363 } // namespace cast |
| 360 } // namespace media | 364 } // namespace media |
| OLD | NEW |