Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(92)

Side by Side Diff: media/cast/net/rtp/cast_message_builder.cc

Issue 1534273002: Switch to standard integer types in media/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/net/rtp/cast_message_builder.h" 5 #include "media/cast/net/rtp/cast_message_builder.h"
6 6
7 #include "media/cast/cast_defines.h" 7 #include "media/cast/cast_defines.h"
8 #include "media/cast/constants.h" 8 #include "media/cast/constants.h"
9 #include "media/cast/net/rtp/framer.h" 9 #include "media/cast/net/rtp/framer.h"
10 10
(...skipping 13 matching lines...) Expand all
24 // frame. 24 // frame.
25 kNackRepeatIntervalMs = 30, 25 kNackRepeatIntervalMs = 30,
26 }; 26 };
27 27
28 } // namespace 28 } // namespace
29 29
30 CastMessageBuilder::CastMessageBuilder( 30 CastMessageBuilder::CastMessageBuilder(
31 base::TickClock* clock, 31 base::TickClock* clock,
32 RtpPayloadFeedback* incoming_payload_feedback, 32 RtpPayloadFeedback* incoming_payload_feedback,
33 const Framer* framer, 33 const Framer* framer,
34 uint32 media_ssrc, 34 uint32_t media_ssrc,
35 bool decoder_faster_than_max_frame_rate, 35 bool decoder_faster_than_max_frame_rate,
36 int max_unacked_frames) 36 int max_unacked_frames)
37 : clock_(clock), 37 : clock_(clock),
38 cast_feedback_(incoming_payload_feedback), 38 cast_feedback_(incoming_payload_feedback),
39 framer_(framer), 39 framer_(framer),
40 media_ssrc_(media_ssrc), 40 media_ssrc_(media_ssrc),
41 decoder_faster_than_max_frame_rate_(decoder_faster_than_max_frame_rate), 41 decoder_faster_than_max_frame_rate_(decoder_faster_than_max_frame_rate),
42 max_unacked_frames_(max_unacked_frames), 42 max_unacked_frames_(max_unacked_frames),
43 cast_msg_(media_ssrc), 43 cast_msg_(media_ssrc),
44 slowing_down_ack_(false), 44 slowing_down_ack_(false),
45 acked_last_frame_(true), 45 acked_last_frame_(true),
46 last_acked_frame_id_(kFirstFrameId - 1) { 46 last_acked_frame_id_(kFirstFrameId - 1) {
47 cast_msg_.ack_frame_id = kFirstFrameId - 1; 47 cast_msg_.ack_frame_id = kFirstFrameId - 1;
48 } 48 }
49 49
50 CastMessageBuilder::~CastMessageBuilder() {} 50 CastMessageBuilder::~CastMessageBuilder() {}
51 51
52 void CastMessageBuilder::CompleteFrameReceived(uint32 frame_id) { 52 void CastMessageBuilder::CompleteFrameReceived(uint32_t frame_id) {
53 DCHECK_GE(static_cast<int32>(frame_id - last_acked_frame_id_), 0); 53 DCHECK_GE(static_cast<int32_t>(frame_id - last_acked_frame_id_), 0);
54 VLOG(2) << "CompleteFrameReceived: " << frame_id; 54 VLOG(2) << "CompleteFrameReceived: " << frame_id;
55 if (last_update_time_.is_null()) { 55 if (last_update_time_.is_null()) {
56 // Our first update. 56 // Our first update.
57 last_update_time_ = clock_->NowTicks(); 57 last_update_time_ = clock_->NowTicks();
58 } 58 }
59 59
60 if (!UpdateAckMessage(frame_id)) { 60 if (!UpdateAckMessage(frame_id)) {
61 return; 61 return;
62 } 62 }
63 BuildPacketList(); 63 BuildPacketList();
64 64
65 // Send cast message. 65 // Send cast message.
66 VLOG(2) << "Send cast message Ack:" << static_cast<int>(frame_id); 66 VLOG(2) << "Send cast message Ack:" << static_cast<int>(frame_id);
67 cast_feedback_->CastFeedback(cast_msg_); 67 cast_feedback_->CastFeedback(cast_msg_);
68 } 68 }
69 69
70 bool CastMessageBuilder::UpdateAckMessage(uint32 frame_id) { 70 bool CastMessageBuilder::UpdateAckMessage(uint32_t frame_id) {
71 if (!decoder_faster_than_max_frame_rate_) { 71 if (!decoder_faster_than_max_frame_rate_) {
72 int complete_frame_count = framer_->NumberOfCompleteFrames(); 72 int complete_frame_count = framer_->NumberOfCompleteFrames();
73 if (complete_frame_count > max_unacked_frames_) { 73 if (complete_frame_count > max_unacked_frames_) {
74 // We have too many frames pending in our framer; slow down ACK. 74 // We have too many frames pending in our framer; slow down ACK.
75 if (!slowing_down_ack_) { 75 if (!slowing_down_ack_) {
76 slowing_down_ack_ = true; 76 slowing_down_ack_ = true;
77 ack_queue_.push_back(last_acked_frame_id_); 77 ack_queue_.push_back(last_acked_frame_id_);
78 } 78 }
79 } else if (complete_frame_count <= 1) { 79 } else if (complete_frame_count <= 1) {
80 // We are down to one or less frames in our framer; ACK normally. 80 // We are down to one or less frames in our framer; ACK normally.
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 void CastMessageBuilder::BuildPacketList() { 162 void CastMessageBuilder::BuildPacketList() {
163 base::TimeTicks now = clock_->NowTicks(); 163 base::TimeTicks now = clock_->NowTicks();
164 164
165 // Clear message NACK list. 165 // Clear message NACK list.
166 cast_msg_.missing_frames_and_packets.clear(); 166 cast_msg_.missing_frames_and_packets.clear();
167 167
168 // Are we missing packets? 168 // Are we missing packets?
169 if (framer_->Empty()) 169 if (framer_->Empty())
170 return; 170 return;
171 171
172 uint32 newest_frame_id = framer_->NewestFrameId(); 172 uint32_t newest_frame_id = framer_->NewestFrameId();
173 uint32 next_expected_frame_id = cast_msg_.ack_frame_id + 1; 173 uint32_t next_expected_frame_id = cast_msg_.ack_frame_id + 1;
174 174
175 // Iterate over all frames. 175 // Iterate over all frames.
176 for (; !IsNewerFrameId(next_expected_frame_id, newest_frame_id); 176 for (; !IsNewerFrameId(next_expected_frame_id, newest_frame_id);
177 ++next_expected_frame_id) { 177 ++next_expected_frame_id) {
178 TimeLastNackMap::iterator it = 178 TimeLastNackMap::iterator it =
179 time_last_nacked_map_.find(next_expected_frame_id); 179 time_last_nacked_map_.find(next_expected_frame_id);
180 if (it != time_last_nacked_map_.end()) { 180 if (it != time_last_nacked_map_.end()) {
181 // We have sent a NACK in this frame before, make sure enough time have 181 // We have sent a NACK in this frame before, make sure enough time have
182 // passed. 182 // passed.
183 if (now - it->second < 183 if (now - it->second <
(...skipping 15 matching lines...) Expand all
199 } else { 199 } else {
200 time_last_nacked_map_[next_expected_frame_id] = now; 200 time_last_nacked_map_[next_expected_frame_id] = now;
201 missing.insert(kRtcpCastAllPacketsLost); 201 missing.insert(kRtcpCastAllPacketsLost);
202 cast_msg_.missing_frames_and_packets[next_expected_frame_id] = missing; 202 cast_msg_.missing_frames_and_packets[next_expected_frame_id] = missing;
203 } 203 }
204 } 204 }
205 } 205 }
206 206
207 } // namespace cast 207 } // namespace cast
208 } // namespace media 208 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698