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 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 101 |
102 private: | 102 private: |
103 RtpReceiver* rtp_receiver_; | 103 RtpReceiver* rtp_receiver_; |
104 }; | 104 }; |
105 | 105 |
106 VideoReceiver::VideoReceiver(scoped_refptr<CastEnvironment> cast_environment, | 106 VideoReceiver::VideoReceiver(scoped_refptr<CastEnvironment> cast_environment, |
107 const VideoReceiverConfig& video_config, | 107 const VideoReceiverConfig& video_config, |
108 PacedPacketSender* const packet_sender) | 108 PacedPacketSender* const packet_sender) |
109 : cast_environment_(cast_environment), | 109 : cast_environment_(cast_environment), |
110 codec_(video_config.codec), | 110 codec_(video_config.codec), |
111 incoming_ssrc_(video_config.incoming_ssrc), | |
112 target_delay_delta_( | 111 target_delay_delta_( |
113 base::TimeDelta::FromMilliseconds(video_config.rtp_max_delay_ms)), | 112 base::TimeDelta::FromMilliseconds(video_config.rtp_max_delay_ms)), |
114 frame_delay_(base::TimeDelta::FromMilliseconds( | 113 frame_delay_(base::TimeDelta::FromMilliseconds( |
115 1000 / video_config.max_frame_rate)), | 114 1000 / video_config.max_frame_rate)), |
116 incoming_payload_callback_( | 115 incoming_payload_callback_( |
117 new LocalRtpVideoData(cast_environment_->Clock(), this)), | 116 new LocalRtpVideoData(cast_environment_->Clock(), this)), |
118 incoming_payload_feedback_(new LocalRtpVideoFeedback(this)), | 117 incoming_payload_feedback_(new LocalRtpVideoFeedback(this)), |
119 rtp_receiver_(cast_environment_->Clock(), NULL, &video_config, | 118 rtp_receiver_(cast_environment_->Clock(), NULL, &video_config, |
120 incoming_payload_callback_.get()), | 119 incoming_payload_callback_.get()), |
121 rtp_video_receiver_statistics_( | 120 rtp_video_receiver_statistics_( |
(...skipping 13 matching lines...) Expand all Loading... |
135 } | 134 } |
136 | 135 |
137 rtcp_.reset( | 136 rtcp_.reset( |
138 new Rtcp(cast_environment_->Clock(), | 137 new Rtcp(cast_environment_->Clock(), |
139 NULL, | 138 NULL, |
140 packet_sender, | 139 packet_sender, |
141 NULL, | 140 NULL, |
142 rtp_video_receiver_statistics_.get(), | 141 rtp_video_receiver_statistics_.get(), |
143 video_config.rtcp_mode, | 142 video_config.rtcp_mode, |
144 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), | 143 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), |
145 false, | |
146 video_config.feedback_ssrc, | 144 video_config.feedback_ssrc, |
| 145 video_config.incoming_ssrc, |
147 video_config.rtcp_c_name)); | 146 video_config.rtcp_c_name)); |
148 | |
149 rtcp_->SetRemoteSSRC(video_config.incoming_ssrc); | |
150 ScheduleNextRtcpReport(); | 147 ScheduleNextRtcpReport(); |
151 ScheduleNextCastMessage(); | 148 ScheduleNextCastMessage(); |
152 } | 149 } |
153 | 150 |
154 VideoReceiver::~VideoReceiver() {} | 151 VideoReceiver::~VideoReceiver() {} |
155 | 152 |
156 void VideoReceiver::GetRawVideoFrame( | 153 void VideoReceiver::GetRawVideoFrame( |
157 const VideoFrameDecodedCallback& callback) { | 154 const VideoFrameDecodedCallback& callback) { |
158 GetEncodedVideoFrame(base::Bind(&VideoReceiver::DecodeVideoFrame, | 155 GetEncodedVideoFrame(base::Bind(&VideoReceiver::DecodeVideoFrame, |
159 weak_factory_.GetWeakPtr(), | 156 weak_factory_.GetWeakPtr(), |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 VideoFrameEncodedCallback callback = queued_encoded_callbacks_.front(); | 356 VideoFrameEncodedCallback callback = queued_encoded_callbacks_.front(); |
360 queued_encoded_callbacks_.pop_front(); | 357 queued_encoded_callbacks_.pop_front(); |
361 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, | 358 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, |
362 base::Bind(&VideoReceiver::GetEncodedVideoFrame, | 359 base::Bind(&VideoReceiver::GetEncodedVideoFrame, |
363 weak_factory_.GetWeakPtr(), callback)); | 360 weak_factory_.GetWeakPtr(), callback)); |
364 } | 361 } |
365 | 362 |
366 // Send a cast feedback message. Actual message created in the framer (cast | 363 // Send a cast feedback message. Actual message created in the framer (cast |
367 // message builder). | 364 // message builder). |
368 void VideoReceiver::CastFeedback(const RtcpCastMessage& cast_message) { | 365 void VideoReceiver::CastFeedback(const RtcpCastMessage& cast_message) { |
369 rtcp_->SendRtcpCast(cast_message); | 366 // TODO(pwestin): wire up log messages. |
| 367 rtcp_->SendRtcpFromRtpReceiver(&cast_message, NULL); |
370 time_last_sent_cast_message_= cast_environment_->Clock()->NowTicks(); | 368 time_last_sent_cast_message_= cast_environment_->Clock()->NowTicks(); |
371 } | 369 } |
372 | 370 |
373 // Cast messages should be sent within a maximum interval. Schedule a call | 371 // Cast messages should be sent within a maximum interval. Schedule a call |
374 // if not triggered elsewhere, e.g. by the cast message_builder. | 372 // if not triggered elsewhere, e.g. by the cast message_builder. |
375 void VideoReceiver::ScheduleNextCastMessage() { | 373 void VideoReceiver::ScheduleNextCastMessage() { |
376 base::TimeTicks send_time; | 374 base::TimeTicks send_time; |
377 framer_->TimeToSendNextCastMessage(&send_time); | 375 framer_->TimeToSendNextCastMessage(&send_time); |
378 | 376 |
379 base::TimeDelta time_to_send = send_time - | 377 base::TimeDelta time_to_send = send_time - |
(...skipping 17 matching lines...) Expand all Loading... |
397 | 395 |
398 time_to_next = std::max(time_to_next, | 396 time_to_next = std::max(time_to_next, |
399 base::TimeDelta::FromMilliseconds(kMinSchedulingDelayMs)); | 397 base::TimeDelta::FromMilliseconds(kMinSchedulingDelayMs)); |
400 | 398 |
401 cast_environment_->PostDelayedTask(CastEnvironment::MAIN, FROM_HERE, | 399 cast_environment_->PostDelayedTask(CastEnvironment::MAIN, FROM_HERE, |
402 base::Bind(&VideoReceiver::SendNextRtcpReport, | 400 base::Bind(&VideoReceiver::SendNextRtcpReport, |
403 weak_factory_.GetWeakPtr()), time_to_next); | 401 weak_factory_.GetWeakPtr()), time_to_next); |
404 } | 402 } |
405 | 403 |
406 void VideoReceiver::SendNextRtcpReport() { | 404 void VideoReceiver::SendNextRtcpReport() { |
407 rtcp_->SendRtcpReport(incoming_ssrc_); | 405 rtcp_->SendRtcpFromRtpReceiver(NULL, NULL); |
408 ScheduleNextRtcpReport(); | 406 ScheduleNextRtcpReport(); |
409 } | 407 } |
410 | 408 |
411 } // namespace cast | 409 } // namespace cast |
412 } // namespace media | 410 } // namespace media |
OLD | NEW |