diff options
author | pwestin@google.com <pwestin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-21 21:07:41 +0000 |
---|---|---|
committer | pwestin@google.com <pwestin@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-21 21:07:41 +0000 |
commit | dc6097a75946a1d8ec46cd8fd4773fe5bf19af9f (patch) | |
tree | 0a9264850c9e534a2f626ee4dd6e2e2730cb56ca /media/cast/video_sender | |
parent | 8499a19cfb4e254c5144af70056d41f9295e25ec (diff) | |
download | chromium_src-dc6097a75946a1d8ec46cd8fd4773fe5bf19af9f.zip chromium_src-dc6097a75946a1d8ec46cd8fd4773fe5bf19af9f.tar.gz chromium_src-dc6097a75946a1d8ec46cd8fd4773fe5bf19af9f.tar.bz2 |
Cast: Cleaning up static_casts
Changed to use size_t through out the code to avoid
static_casts. Also added a few DCHECKs in the locations
where we really downcast to a smaller size.
Review URL: https://codereview.chromium.org/26253007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@229909 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/cast/video_sender')
-rw-r--r-- | media/cast/video_sender/video_sender.cc | 25 | ||||
-rw-r--r-- | media/cast/video_sender/video_sender.h | 2 |
2 files changed, 22 insertions, 5 deletions
diff --git a/media/cast/video_sender/video_sender.cc b/media/cast/video_sender/video_sender.cc index 10d83ce..52fa3e2 100644 --- a/media/cast/video_sender/video_sender.cc +++ b/media/cast/video_sender/video_sender.cc @@ -96,7 +96,7 @@ VideoSender::VideoSender( max_unacked_frames_ = static_cast<uint8>(video_config.rtp_max_delay_ms * video_config.max_frame_rate / 1000) + 1; VLOG(1) << "max_unacked_frames " << static_cast<int>(max_unacked_frames_); - DCHECK(max_unacked_frames_ > 0) << "Invalid argument"; + DCHECK_GT(max_unacked_frames_, 0) << "Invalid argument"; rtp_video_sender_statistics_.reset( new LocalRtpVideoSenderStatistics(rtp_sender_.get())); @@ -174,6 +174,9 @@ void VideoSender::SendEncodedVideoFrame(const EncodedVideoFrame* encoded_frame, void VideoSender::OnReceivedIntraFrameRequest() { if (last_sent_key_frame_id_ != -1) { + DCHECK_GE(255, last_sent_key_frame_id_); + DCHECK_LE(0, last_sent_key_frame_id_); + uint8 frames_in_flight = static_cast<uint8>(last_sent_frame_id_) - static_cast<uint8>(last_sent_key_frame_id_); if (frames_in_flight < (max_unacked_frames_ - 1)) return; @@ -183,7 +186,7 @@ void VideoSender::OnReceivedIntraFrameRequest() { last_sent_frame_id_ = -1; } -void VideoSender::IncomingRtcpPacket(const uint8* packet, int length, +void VideoSender::IncomingRtcpPacket(const uint8* packet, size_t length, const base::Closure callback) { rtcp_->IncomingRtcpPacket(packet, length); cast_environment_->PostTask(CastEnvironment::MAIN, FROM_HERE, callback); @@ -234,6 +237,9 @@ void VideoSender::ResendCheck() { last_sent_frame_id_ = -1; UpdateFramesInFlight(); } else { + DCHECK_GE(255, last_acked_frame_id_); + DCHECK_LE(0, last_acked_frame_id_); + uint8 frame_id = static_cast<uint8>(last_acked_frame_id_ + 1); VLOG(1) << "ACK timeout resend frame:" << static_cast<int>(frame_id); ResendFrame(frame_id); @@ -312,6 +318,8 @@ void VideoSender::OnReceivedCastFeedback(const RtcpCastMessage& cast_feedback) { resend_frame = static_cast<uint8>(last_acked_frame_id_ + 1); } if (resend_frame != -1) { + DCHECK_GE(255, resend_frame); + DCHECK_LE(0, resend_frame); VLOG(1) << "Received duplicate ACK for frame:" << static_cast<int>(resend_frame); ResendFrame(static_cast<uint8>(resend_frame)); @@ -336,8 +344,17 @@ void VideoSender::ReceivedAck(uint8 acked_frame_id) { void VideoSender::UpdateFramesInFlight() { if (last_sent_frame_id_ != -1) { - uint8 frames_in_flight = static_cast<uint8>(last_sent_frame_id_) - - static_cast<uint8>(last_acked_frame_id_); + DCHECK_GE(255, last_sent_frame_id_); + DCHECK_LE(0, last_sent_frame_id_); + uint8 frames_in_flight; + if (last_acked_frame_id_ != -1) { + DCHECK_GE(255, last_acked_frame_id_); + DCHECK_LE(0, last_acked_frame_id_); + frames_in_flight = static_cast<uint8>(last_sent_frame_id_) - + static_cast<uint8>(last_acked_frame_id_); + } else { + frames_in_flight = last_sent_frame_id_ + 1; + } VLOG(1) << "Frames in flight; last sent: " << last_sent_frame_id_ << " last acked:" << last_acked_frame_id_; if (frames_in_flight >= max_unacked_frames_) { diff --git a/media/cast/video_sender/video_sender.h b/media/cast/video_sender/video_sender.h index 6e86645..7bd6029 100644 --- a/media/cast/video_sender/video_sender.h +++ b/media/cast/video_sender/video_sender.h @@ -61,7 +61,7 @@ class VideoSender : public base::NonThreadSafe, const base::Closure callback); // Only called from the main cast thread. - void IncomingRtcpPacket(const uint8* packet, int length, + void IncomingRtcpPacket(const uint8* packet, size_t length, const base::Closure callback); protected: |