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 <utility> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | |
13 #include "base/numerics/safe_conversions.h" | 14 #include "base/numerics/safe_conversions.h" |
14 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
15 #include "media/cast/constants.h" | 16 #include "media/cast/constants.h" |
16 #include "media/cast/sender/sender_encoded_frame.h" | 17 #include "media/cast/sender/sender_encoded_frame.h" |
17 | 18 |
18 namespace media { | 19 namespace media { |
19 namespace cast { | 20 namespace cast { |
20 namespace { | 21 namespace { |
21 | 22 |
22 const int kMinSchedulingDelayMs = 1; | 23 const int kMinSchedulingDelayMs = 1; |
(...skipping 23 matching lines...) Expand all Loading... | |
46 if (frame_sender_) | 47 if (frame_sender_) |
47 frame_sender_->OnMeasuredRoundTripTime(round_trip_time); | 48 frame_sender_->OnMeasuredRoundTripTime(round_trip_time); |
48 } | 49 } |
49 | 50 |
50 void FrameSender::RtcpClient::OnReceivedPli() { | 51 void FrameSender::RtcpClient::OnReceivedPli() { |
51 if (frame_sender_) | 52 if (frame_sender_) |
52 frame_sender_->OnReceivedPli(); | 53 frame_sender_->OnReceivedPli(); |
53 } | 54 } |
54 | 55 |
55 FrameSender::FrameSender(scoped_refptr<CastEnvironment> cast_environment, | 56 FrameSender::FrameSender(scoped_refptr<CastEnvironment> cast_environment, |
56 bool is_audio, | |
57 CastTransport* const transport_sender, | 57 CastTransport* const transport_sender, |
58 int rtp_timebase, | 58 const FrameSenderConfig& config, |
59 uint32_t ssrc, | |
60 double max_frame_rate, | |
61 base::TimeDelta min_playout_delay, | |
62 base::TimeDelta max_playout_delay, | |
63 base::TimeDelta animated_playout_delay, | |
64 CongestionControl* congestion_control) | 59 CongestionControl* congestion_control) |
65 : cast_environment_(cast_environment), | 60 : cast_environment_(cast_environment), |
66 transport_sender_(transport_sender), | 61 transport_sender_(transport_sender), |
67 ssrc_(ssrc), | 62 ssrc_(config.sender_ssrc), |
68 min_playout_delay_(min_playout_delay.is_zero() ? max_playout_delay | 63 min_playout_delay_(config.min_playout_delay.is_zero() |
69 : min_playout_delay), | 64 ? config.max_playout_delay |
70 max_playout_delay_(max_playout_delay), | 65 : config.min_playout_delay), |
71 animated_playout_delay_(animated_playout_delay.is_zero() | 66 max_playout_delay_(config.max_playout_delay), |
72 ? max_playout_delay | 67 animated_playout_delay_(config.animated_playout_delay.is_zero() |
73 : animated_playout_delay), | 68 ? config.max_playout_delay |
69 : config.animated_playout_delay), | |
74 send_target_playout_delay_(false), | 70 send_target_playout_delay_(false), |
75 max_frame_rate_(max_frame_rate), | 71 max_frame_rate_(config.max_frame_rate), |
76 num_aggressive_rtcp_reports_sent_(0), | 72 num_aggressive_rtcp_reports_sent_(0), |
77 duplicate_ack_counter_(0), | 73 duplicate_ack_counter_(0), |
78 congestion_control_(congestion_control), | 74 congestion_control_(congestion_control), |
79 picture_lost_at_receiver_(false), | 75 picture_lost_at_receiver_(false), |
80 rtp_timebase_(rtp_timebase), | 76 rtp_timebase_(config.rtp_timebase), |
81 is_audio_(is_audio), | 77 is_audio_(config.rtp_payload_type <= RtpPayloadType::AUDIO_LAST), |
82 weak_factory_(this) { | 78 weak_factory_(this) { |
83 DCHECK(transport_sender_); | 79 DCHECK(transport_sender_); |
84 DCHECK_GT(rtp_timebase_, 0); | 80 DCHECK_GT(rtp_timebase_, 0); |
85 DCHECK(congestion_control_); | 81 DCHECK(congestion_control_); |
86 // We assume animated content to begin with since that is the common use | 82 // We assume animated content to begin with since that is the common use |
87 // case today. | 83 // case today. |
88 VLOG(1) << SENDER_SSRC << "min latency " | 84 VLOG(1) << SENDER_SSRC << "min latency " |
89 << min_playout_delay_.InMilliseconds() << "max latency " | 85 << min_playout_delay_.InMilliseconds() << "max latency " |
90 << max_playout_delay.InMilliseconds() << "animated latency " | 86 << max_playout_delay_.InMilliseconds() << "animated latency " |
91 << animated_playout_delay.InMilliseconds(); | 87 << animated_playout_delay_.InMilliseconds(); |
92 SetTargetPlayoutDelay(animated_playout_delay_); | 88 SetTargetPlayoutDelay(animated_playout_delay_); |
93 send_target_playout_delay_ = false; | 89 send_target_playout_delay_ = false; |
90 | |
91 CastTransportRtpConfig transport_config; | |
92 transport_config.ssrc = config.sender_ssrc; | |
93 transport_config.feedback_ssrc = config.receiver_ssrc; | |
94 transport_config.rtp_payload_type = config.rtp_payload_type; | |
95 transport_config.aes_key = config.aes_key; | |
96 transport_config.aes_iv_mask = config.aes_iv_mask; | |
97 | |
98 transport_sender->InitializeStream( | |
99 transport_config, base::WrapUnique(new FrameSender::RtcpClient( | |
dcheng
2016/07/14 03:40:27
Nit: base::MakeUnique<FrameSender::RtcpClient>(...
xjz
2016/07/14 18:29:57
Done.
| |
100 weak_factory_.GetWeakPtr()))); | |
94 } | 101 } |
95 | 102 |
96 FrameSender::~FrameSender() { | 103 FrameSender::~FrameSender() { |
97 } | 104 } |
98 | 105 |
99 void FrameSender::ScheduleNextRtcpReport() { | 106 void FrameSender::ScheduleNextRtcpReport() { |
100 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 107 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
101 | 108 |
102 cast_environment_->PostDelayedTask( | 109 cast_environment_->PostDelayedTask( |
103 CastEnvironment::MAIN, FROM_HERE, | 110 CastEnvironment::MAIN, FROM_HERE, |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 VLOG(1) << SENDER_SSRC << "Dropping: In-flight duration would be too high."; | 467 VLOG(1) << SENDER_SSRC << "Dropping: In-flight duration would be too high."; |
461 return true; | 468 return true; |
462 } | 469 } |
463 | 470 |
464 // Next frame is accepted. | 471 // Next frame is accepted. |
465 return false; | 472 return false; |
466 } | 473 } |
467 | 474 |
468 } // namespace cast | 475 } // namespace cast |
469 } // namespace media | 476 } // namespace media |
OLD | NEW |