| 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/frame_sender.h" | 5 #include "media/cast/sender/frame_sender.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <utility> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/macros.h" | 12 #include "base/macros.h" |
| 12 #include "base/trace_event/trace_event.h" | 13 #include "base/trace_event/trace_event.h" |
| 13 #include "media/cast/cast_defines.h" | 14 #include "media/cast/cast_defines.h" |
| 14 #include "media/cast/constants.h" | 15 #include "media/cast/constants.h" |
| 15 #include "media/cast/sender/sender_encoded_frame.h" | 16 #include "media/cast/sender/sender_encoded_frame.h" |
| 16 | 17 |
| 17 namespace media { | 18 namespace media { |
| 18 namespace cast { | 19 namespace cast { |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 238 encode_event->type = FRAME_ENCODED; | 239 encode_event->type = FRAME_ENCODED; |
| 239 encode_event->media_type = is_audio_ ? AUDIO_EVENT : VIDEO_EVENT; | 240 encode_event->media_type = is_audio_ ? AUDIO_EVENT : VIDEO_EVENT; |
| 240 encode_event->rtp_timestamp = encoded_frame->rtp_timestamp; | 241 encode_event->rtp_timestamp = encoded_frame->rtp_timestamp; |
| 241 encode_event->frame_id = frame_id; | 242 encode_event->frame_id = frame_id; |
| 242 encode_event->size = encoded_frame->data.size(); | 243 encode_event->size = encoded_frame->data.size(); |
| 243 encode_event->key_frame = encoded_frame->dependency == EncodedFrame::KEY; | 244 encode_event->key_frame = encoded_frame->dependency == EncodedFrame::KEY; |
| 244 encode_event->target_bitrate = requested_bitrate_before_encode; | 245 encode_event->target_bitrate = requested_bitrate_before_encode; |
| 245 encode_event->encoder_cpu_utilization = encoded_frame->deadline_utilization; | 246 encode_event->encoder_cpu_utilization = encoded_frame->deadline_utilization; |
| 246 encode_event->idealized_bitrate_utilization = | 247 encode_event->idealized_bitrate_utilization = |
| 247 encoded_frame->lossy_utilization; | 248 encoded_frame->lossy_utilization; |
| 248 cast_environment_->logger()->DispatchFrameEvent(encode_event.Pass()); | 249 cast_environment_->logger()->DispatchFrameEvent(std::move(encode_event)); |
| 249 | 250 |
| 250 RecordLatestFrameTimestamps(frame_id, | 251 RecordLatestFrameTimestamps(frame_id, |
| 251 encoded_frame->reference_time, | 252 encoded_frame->reference_time, |
| 252 encoded_frame->rtp_timestamp); | 253 encoded_frame->rtp_timestamp); |
| 253 | 254 |
| 254 if (!is_audio_) { | 255 if (!is_audio_) { |
| 255 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc | 256 // Used by chrome/browser/extension/api/cast_streaming/performance_test.cc |
| 256 TRACE_EVENT_INSTANT1( | 257 TRACE_EVENT_INSTANT1( |
| 257 "cast_perf_test", "VideoFrameEncoded", | 258 "cast_perf_test", "VideoFrameEncoded", |
| 258 TRACE_EVENT_SCOPE_THREAD, | 259 TRACE_EVENT_SCOPE_THREAD, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); | 342 base::TimeTicks now = cast_environment_->Clock()->NowTicks(); |
| 342 congestion_control_->AckFrame(cast_feedback.ack_frame_id, now); | 343 congestion_control_->AckFrame(cast_feedback.ack_frame_id, now); |
| 343 | 344 |
| 344 scoped_ptr<FrameEvent> ack_event(new FrameEvent()); | 345 scoped_ptr<FrameEvent> ack_event(new FrameEvent()); |
| 345 ack_event->timestamp = now; | 346 ack_event->timestamp = now; |
| 346 ack_event->type = FRAME_ACK_RECEIVED; | 347 ack_event->type = FRAME_ACK_RECEIVED; |
| 347 ack_event->media_type = is_audio_ ? AUDIO_EVENT : VIDEO_EVENT; | 348 ack_event->media_type = is_audio_ ? AUDIO_EVENT : VIDEO_EVENT; |
| 348 ack_event->rtp_timestamp = | 349 ack_event->rtp_timestamp = |
| 349 GetRecordedRtpTimestamp(cast_feedback.ack_frame_id); | 350 GetRecordedRtpTimestamp(cast_feedback.ack_frame_id); |
| 350 ack_event->frame_id = cast_feedback.ack_frame_id; | 351 ack_event->frame_id = cast_feedback.ack_frame_id; |
| 351 cast_environment_->logger()->DispatchFrameEvent(ack_event.Pass()); | 352 cast_environment_->logger()->DispatchFrameEvent(std::move(ack_event)); |
| 352 | 353 |
| 353 const bool is_acked_out_of_order = | 354 const bool is_acked_out_of_order = |
| 354 static_cast<int32_t>(cast_feedback.ack_frame_id - | 355 static_cast<int32_t>(cast_feedback.ack_frame_id - |
| 355 latest_acked_frame_id_) < 0; | 356 latest_acked_frame_id_) < 0; |
| 356 VLOG(2) << SENDER_SSRC | 357 VLOG(2) << SENDER_SSRC |
| 357 << "Received ACK" << (is_acked_out_of_order ? " out-of-order" : "") | 358 << "Received ACK" << (is_acked_out_of_order ? " out-of-order" : "") |
| 358 << " for frame " << cast_feedback.ack_frame_id; | 359 << " for frame " << cast_feedback.ack_frame_id; |
| 359 if (is_acked_out_of_order) { | 360 if (is_acked_out_of_order) { |
| 360 TRACE_EVENT_INSTANT2( | 361 TRACE_EVENT_INSTANT2( |
| 361 "cast.stream", "ACK out of order", TRACE_EVENT_SCOPE_THREAD, | 362 "cast.stream", "ACK out of order", TRACE_EVENT_SCOPE_THREAD, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 VLOG(1) << SENDER_SSRC << "Dropping: In-flight duration would be too high."; | 421 VLOG(1) << SENDER_SSRC << "Dropping: In-flight duration would be too high."; |
| 421 return true; | 422 return true; |
| 422 } | 423 } |
| 423 | 424 |
| 424 // Next frame is accepted. | 425 // Next frame is accepted. |
| 425 return false; | 426 return false; |
| 426 } | 427 } |
| 427 | 428 |
| 428 } // namespace cast | 429 } // namespace cast |
| 429 } // namespace media | 430 } // namespace media |
| OLD | NEW |