OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/video_receiver/video_receiver.h" | 5 #include "media/cast/video_receiver/video_receiver.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 } | 83 } |
84 | 84 |
85 private: | 85 private: |
86 RtpReceiver* rtp_receiver_; | 86 RtpReceiver* rtp_receiver_; |
87 | 87 |
88 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalRtpReceiverStatistics); | 88 DISALLOW_IMPLICIT_CONSTRUCTORS(LocalRtpReceiverStatistics); |
89 }; | 89 }; |
90 | 90 |
91 VideoReceiver::VideoReceiver(scoped_refptr<CastEnvironment> cast_environment, | 91 VideoReceiver::VideoReceiver(scoped_refptr<CastEnvironment> cast_environment, |
92 const VideoReceiverConfig& video_config, | 92 const VideoReceiverConfig& video_config, |
93 transport::PacedPacketSender* const packet_sender) | 93 transport::PacedPacketSender* const packet_sender, |
| 94 const SetTargetDelayCallback& target_delay_cb) |
94 : cast_environment_(cast_environment), | 95 : cast_environment_(cast_environment), |
95 event_subscriber_(kReceiverRtcpEventHistorySize, | 96 event_subscriber_(kReceiverRtcpEventHistorySize, |
96 ReceiverRtcpEventSubscriber::kVideoEventSubscriber), | 97 ReceiverRtcpEventSubscriber::kVideoEventSubscriber), |
97 codec_(video_config.codec), | 98 codec_(video_config.codec), |
98 target_delay_delta_( | 99 target_delay_delta_( |
99 base::TimeDelta::FromMilliseconds(video_config.rtp_max_delay_ms)), | 100 base::TimeDelta::FromMilliseconds(video_config.rtp_max_delay_ms)), |
100 frame_delay_(base::TimeDelta::FromMilliseconds( | 101 frame_delay_(base::TimeDelta::FromMilliseconds( |
101 1000 / video_config.max_frame_rate)), | 102 1000 / video_config.max_frame_rate)), |
102 incoming_payload_callback_(new LocalRtpVideoData(this)), | 103 incoming_payload_callback_(new LocalRtpVideoData(this)), |
103 incoming_payload_feedback_(new LocalRtpVideoFeedback(this)), | 104 incoming_payload_feedback_(new LocalRtpVideoFeedback(this)), |
104 rtp_receiver_(cast_environment_->Clock(), | 105 rtp_receiver_(cast_environment_->Clock(), |
105 NULL, | 106 NULL, |
106 &video_config, | 107 &video_config, |
107 incoming_payload_callback_.get()), | 108 incoming_payload_callback_.get()), |
108 rtp_video_receiver_statistics_( | 109 rtp_video_receiver_statistics_( |
109 new LocalRtpReceiverStatistics(&rtp_receiver_)), | 110 new LocalRtpReceiverStatistics(&rtp_receiver_)), |
110 decryptor_(), | 111 decryptor_(), |
111 time_incoming_packet_updated_(false), | 112 time_incoming_packet_updated_(false), |
112 incoming_rtp_timestamp_(0), | 113 incoming_rtp_timestamp_(0), |
| 114 target_delay_cb_(target_delay_cb), |
113 weak_factory_(this) { | 115 weak_factory_(this) { |
114 int max_unacked_frames = | 116 int max_unacked_frames = |
115 video_config.rtp_max_delay_ms * video_config.max_frame_rate / 1000; | 117 video_config.rtp_max_delay_ms * video_config.max_frame_rate / 1000; |
116 DCHECK(max_unacked_frames) << "Invalid argument"; | 118 DCHECK(max_unacked_frames) << "Invalid argument"; |
117 | 119 |
118 decryptor_.Initialize(video_config.aes_key, video_config.aes_iv_mask); | 120 decryptor_.Initialize(video_config.aes_key, video_config.aes_iv_mask); |
119 framer_.reset(new Framer(cast_environment->Clock(), | 121 framer_.reset(new Framer(cast_environment->Clock(), |
120 incoming_payload_feedback_.get(), | 122 incoming_payload_feedback_.get(), |
121 video_config.incoming_ssrc, | 123 video_config.incoming_ssrc, |
122 video_config.decoder_faster_than_max_frame_rate, | 124 video_config.decoder_faster_than_max_frame_rate, |
123 max_unacked_frames)); | 125 max_unacked_frames)); |
124 | 126 |
125 if (!video_config.use_external_decoder) { | 127 if (!video_config.use_external_decoder) { |
126 video_decoder_.reset(new VideoDecoder(video_config, cast_environment)); | 128 video_decoder_.reset(new VideoDecoder(video_config, cast_environment)); |
127 } | 129 } |
128 | 130 |
129 rtcp_.reset( | 131 rtcp_.reset( |
130 new Rtcp(cast_environment_, | 132 new Rtcp(cast_environment_, |
131 NULL, | 133 NULL, |
132 NULL, | 134 NULL, |
133 packet_sender, | 135 packet_sender, |
134 NULL, | 136 NULL, |
135 rtp_video_receiver_statistics_.get(), | 137 rtp_video_receiver_statistics_.get(), |
136 video_config.rtcp_mode, | 138 video_config.rtcp_mode, |
137 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), | 139 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), |
138 video_config.feedback_ssrc, | 140 video_config.feedback_ssrc, |
139 video_config.incoming_ssrc, | 141 video_config.incoming_ssrc, |
140 video_config.rtcp_c_name)); | 142 video_config.rtcp_c_name)); |
| 143 // Set the target delay that will be conveyed to the sender. |
| 144 rtcp_->SetTargetDelay(target_delay_delta_); |
141 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber_); | 145 cast_environment_->Logging()->AddRawEventSubscriber(&event_subscriber_); |
142 memset(frame_id_to_rtp_timestamp_, 0, sizeof(frame_id_to_rtp_timestamp_)); | 146 memset(frame_id_to_rtp_timestamp_, 0, sizeof(frame_id_to_rtp_timestamp_)); |
143 } | 147 } |
144 | 148 |
145 VideoReceiver::~VideoReceiver() { | 149 VideoReceiver::~VideoReceiver() { |
146 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber_); | 150 cast_environment_->Logging()->RemoveRawEventSubscriber(&event_subscriber_); |
147 } | 151 } |
148 | 152 |
149 void VideoReceiver::InitializeTimers() { | 153 void VideoReceiver::InitializeTimers() { |
150 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 154 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 weak_factory_.GetWeakPtr()), | 517 weak_factory_.GetWeakPtr()), |
514 time_to_next); | 518 time_to_next); |
515 } | 519 } |
516 | 520 |
517 void VideoReceiver::SendNextRtcpReport() { | 521 void VideoReceiver::SendNextRtcpReport() { |
518 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 522 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
519 rtcp_->SendRtcpFromRtpReceiver(NULL, NULL); | 523 rtcp_->SendRtcpFromRtpReceiver(NULL, NULL); |
520 ScheduleNextRtcpReport(); | 524 ScheduleNextRtcpReport(); |
521 } | 525 } |
522 | 526 |
| 527 void VideoReceiver::UpdateTargetDelay() { |
| 528 NOTIMPLEMENTED(); |
| 529 rtcp_->SetTargetDelay(target_delay_delta_); |
| 530 target_delay_cb_.Run(target_delay_delta_); |
| 531 } |
| 532 |
523 } // namespace cast | 533 } // namespace cast |
524 } // namespace media | 534 } // namespace media |
OLD | NEW |