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 | |
333 duration_in_encoder_ = | 329 duration_in_encoder_ = |
334 last_enqueued_frame_reference_time_ - encoded_frame->reference_time; | 330 last_enqueued_frame_reference_time_ - encoded_frame->reference_time; |
335 | 331 |
336 last_reported_deadline_utilization_ = encoded_frame->deadline_utilization; | 332 last_reported_deadline_utilization_ = encoded_frame->deadline_utilization; |
337 last_reported_lossy_utilization_ = encoded_frame->lossy_utilization; | 333 last_reported_lossy_utilization_ = encoded_frame->lossy_utilization; |
338 | 334 |
339 TRACE_EVENT_ASYNC_END2("cast.stream", "Video Encode", video_frame.get(), | 335 TRACE_EVENT_ASYNC_END2("cast.stream", "Video Encode", video_frame.get(), |
340 "deadline_utilization", last_reported_deadline_utilization_, | 336 "deadline_utilization", last_reported_deadline_utilization_, |
341 "lossy_utilization", last_reported_lossy_utilization_); | 337 "lossy_utilization", last_reported_lossy_utilization_); |
342 | 338 |
(...skipping 12 matching lines...) Expand all Loading... |
355 media::VideoFrameMetadata::RESOURCE_UTILIZATION, | 351 media::VideoFrameMetadata::RESOURCE_UTILIZATION, |
356 encoded_frame->dependency == EncodedFrame::KEY ? | 352 encoded_frame->dependency == EncodedFrame::KEY ? |
357 std::min(1.0, attenuated_utilization) : attenuated_utilization); | 353 std::min(1.0, attenuated_utilization) : attenuated_utilization); |
358 } | 354 } |
359 | 355 |
360 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); | 356 SendEncodedFrame(encoder_bitrate, std::move(encoded_frame)); |
361 } | 357 } |
362 | 358 |
363 } // namespace cast | 359 } // namespace cast |
364 } // namespace media | 360 } // namespace media |
OLD | NEW |