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