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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 | 78 |
79 private: | 79 private: |
80 RtpReceiver* rtp_receiver_; | 80 RtpReceiver* rtp_receiver_; |
81 }; | 81 }; |
82 | 82 |
83 VideoReceiver::VideoReceiver(scoped_refptr<CastEnvironment> cast_environment, | 83 VideoReceiver::VideoReceiver(scoped_refptr<CastEnvironment> cast_environment, |
84 const VideoReceiverConfig& video_config, | 84 const VideoReceiverConfig& video_config, |
85 PacedPacketSender* const packet_sender) | 85 PacedPacketSender* const packet_sender) |
86 : cast_environment_(cast_environment), | 86 : cast_environment_(cast_environment), |
87 codec_(video_config.codec), | 87 codec_(video_config.codec), |
88 incoming_ssrc_(video_config.incoming_ssrc), | |
89 target_delay_delta_( | 88 target_delay_delta_( |
90 base::TimeDelta::FromMilliseconds(video_config.rtp_max_delay_ms)), | 89 base::TimeDelta::FromMilliseconds(video_config.rtp_max_delay_ms)), |
91 frame_delay_(base::TimeDelta::FromMilliseconds( | 90 frame_delay_(base::TimeDelta::FromMilliseconds( |
92 1000 / video_config.max_frame_rate)), | 91 1000 / video_config.max_frame_rate)), |
93 incoming_payload_callback_(new LocalRtpVideoData(this)), | 92 incoming_payload_callback_(new LocalRtpVideoData(this)), |
94 incoming_payload_feedback_(new LocalRtpVideoFeedback(this)), | 93 incoming_payload_feedback_(new LocalRtpVideoFeedback(this)), |
95 rtp_receiver_(cast_environment_->Clock(), NULL, &video_config, | 94 rtp_receiver_(cast_environment_->Clock(), NULL, &video_config, |
96 incoming_payload_callback_.get()), | 95 incoming_payload_callback_.get()), |
97 rtp_video_receiver_statistics_( | 96 rtp_video_receiver_statistics_( |
98 new LocalRtpReceiverStatistics(&rtp_receiver_)), | 97 new LocalRtpReceiverStatistics(&rtp_receiver_)), |
(...skipping 14 matching lines...) Expand all Loading... |
113 } | 112 } |
114 | 113 |
115 rtcp_.reset( | 114 rtcp_.reset( |
116 new Rtcp(cast_environment_->Clock(), | 115 new Rtcp(cast_environment_->Clock(), |
117 NULL, | 116 NULL, |
118 packet_sender, | 117 packet_sender, |
119 NULL, | 118 NULL, |
120 rtp_video_receiver_statistics_.get(), | 119 rtp_video_receiver_statistics_.get(), |
121 video_config.rtcp_mode, | 120 video_config.rtcp_mode, |
122 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), | 121 base::TimeDelta::FromMilliseconds(video_config.rtcp_interval), |
123 false, | |
124 video_config.feedback_ssrc, | 122 video_config.feedback_ssrc, |
| 123 video_config.incoming_ssrc, |
125 video_config.rtcp_c_name)); | 124 video_config.rtcp_c_name)); |
126 | |
127 rtcp_->SetRemoteSSRC(video_config.incoming_ssrc); | |
128 } | 125 } |
129 | 126 |
130 VideoReceiver::~VideoReceiver() {} | 127 VideoReceiver::~VideoReceiver() {} |
131 | 128 |
132 void VideoReceiver::InitializeTimers() { | 129 void VideoReceiver::InitializeTimers() { |
133 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 130 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
134 ScheduleNextRtcpReport(); | 131 ScheduleNextRtcpReport(); |
135 ScheduleNextCastMessage(); | 132 ScheduleNextCastMessage(); |
136 } | 133 } |
137 | 134 |
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 queued_encoded_callbacks_.pop_front(); | 353 queued_encoded_callbacks_.pop_front(); |
357 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, | 354 cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, |
358 base::Bind(&VideoReceiver::GetEncodedVideoFrame, | 355 base::Bind(&VideoReceiver::GetEncodedVideoFrame, |
359 weak_factory_.GetWeakPtr(), callback)); | 356 weak_factory_.GetWeakPtr(), callback)); |
360 } | 357 } |
361 | 358 |
362 // Send a cast feedback message. Actual message created in the framer (cast | 359 // Send a cast feedback message. Actual message created in the framer (cast |
363 // message builder). | 360 // message builder). |
364 void VideoReceiver::CastFeedback(const RtcpCastMessage& cast_message) { | 361 void VideoReceiver::CastFeedback(const RtcpCastMessage& cast_message) { |
365 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 362 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
366 rtcp_->SendRtcpCast(cast_message); | 363 // TODO(pwestin): wire up log messages. |
| 364 rtcp_->SendRtcpFromRtpReceiver(&cast_message, NULL); |
367 time_last_sent_cast_message_= cast_environment_->Clock()->NowTicks(); | 365 time_last_sent_cast_message_= cast_environment_->Clock()->NowTicks(); |
368 } | 366 } |
369 | 367 |
370 // Cast messages should be sent within a maximum interval. Schedule a call | 368 // Cast messages should be sent within a maximum interval. Schedule a call |
371 // if not triggered elsewhere, e.g. by the cast message_builder. | 369 // if not triggered elsewhere, e.g. by the cast message_builder. |
372 void VideoReceiver::ScheduleNextCastMessage() { | 370 void VideoReceiver::ScheduleNextCastMessage() { |
373 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 371 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
374 base::TimeTicks send_time; | 372 base::TimeTicks send_time; |
375 framer_->TimeToSendNextCastMessage(&send_time); | 373 framer_->TimeToSendNextCastMessage(&send_time); |
376 | 374 |
(...skipping 21 matching lines...) Expand all Loading... |
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 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); | 405 DCHECK(cast_environment_->CurrentlyOn(CastEnvironment::MAIN)); |
408 rtcp_->SendRtcpReport(incoming_ssrc_); | 406 rtcp_->SendRtcpFromRtpReceiver(NULL, NULL); |
409 ScheduleNextRtcpReport(); | 407 ScheduleNextRtcpReport(); |
410 } | 408 } |
411 | 409 |
412 } // namespace cast | 410 } // namespace cast |
413 } // namespace media | 411 } // namespace media |
OLD | NEW |