OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/protocol/rtp_video_reader.h" | 5 #include "remoting/protocol/rtp_video_reader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
10 #include "remoting/proto/video.pb.h" | 10 #include "remoting/proto/video.pb.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 return; | 177 return; |
178 } | 178 } |
179 | 179 |
180 // We've found first and last fragments, and we have all fragments in the | 180 // We've found first and last fragments, and we have all fragments in the |
181 // middle, so we can rebuild fill packet. | 181 // middle, so we can rebuild fill packet. |
182 RebuildVideoPacket(first, last); | 182 RebuildVideoPacket(first, last); |
183 } | 183 } |
184 | 184 |
185 void RtpVideoReader::RebuildVideoPacket(const PacketsQueue::iterator& first, | 185 void RtpVideoReader::RebuildVideoPacket(const PacketsQueue::iterator& first, |
186 const PacketsQueue::iterator& last) { | 186 const PacketsQueue::iterator& last) { |
187 VideoPacket* packet = new VideoPacket(); | 187 scoped_ptr<VideoPacket> packet(new VideoPacket()); |
188 | 188 |
189 // Set flags. | 189 // Set flags. |
190 if (first->packet->vp8_descriptor().frame_beginning) | 190 if (first->packet->vp8_descriptor().frame_beginning) |
191 packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET); | 191 packet->set_flags(packet->flags() | VideoPacket::FIRST_PACKET); |
192 | 192 |
193 if (last->packet->header().marker) | 193 if (last->packet->header().marker) |
194 packet->set_flags(packet->flags() | VideoPacket::LAST_PACKET); | 194 packet->set_flags(packet->flags() | VideoPacket::LAST_PACKET); |
195 | 195 |
196 packet->set_timestamp(first->packet->header().timestamp); | 196 packet->set_timestamp(first->packet->header().timestamp); |
197 | 197 |
(...skipping 11 matching lines...) Expand all Loading... |
209 // packets will be ignored. | 209 // packets will be ignored. |
210 } | 210 } |
211 | 211 |
212 packet->mutable_data()->resize(content.total_bytes()); | 212 packet->mutable_data()->resize(content.total_bytes()); |
213 content.CopyTo(const_cast<char*>(packet->mutable_data()->data()), | 213 content.CopyTo(const_cast<char*>(packet->mutable_data()->data()), |
214 packet->data().size()); | 214 packet->data().size()); |
215 | 215 |
216 // Set format. | 216 // Set format. |
217 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); | 217 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); |
218 | 218 |
219 video_stub_->ProcessVideoPacket( | 219 video_stub_->ProcessVideoPacket(packet.Pass(), base::Closure()); |
220 packet, base::Bind(&base::DeletePointer<VideoPacket>, packet)); | |
221 | 220 |
222 SendReceiverReportIf(); | 221 SendReceiverReportIf(); |
223 } | 222 } |
224 | 223 |
225 void RtpVideoReader::SendReceiverReportIf() { | 224 void RtpVideoReader::SendReceiverReportIf() { |
226 base::Time now = base::Time::Now(); | 225 base::Time now = base::Time::Now(); |
227 | 226 |
228 // Send receiver report only if we haven't sent any bofore, or | 227 // Send receiver report only if we haven't sent any bofore, or |
229 // enough time has passed since the last report. | 228 // enough time has passed since the last report. |
230 if (last_receiver_report_.is_null() || | 229 if (last_receiver_report_.is_null() || |
231 (now - last_receiver_report_).InMilliseconds() > | 230 (now - last_receiver_report_).InMilliseconds() > |
232 kReceiverReportsIntervalMs) { | 231 kReceiverReportsIntervalMs) { |
233 RtcpReceiverReport report; | 232 RtcpReceiverReport report; |
234 rtp_reader_.GetReceiverReport(&report); | 233 rtp_reader_.GetReceiverReport(&report); |
235 rtcp_writer_.SendReport(report); | 234 rtcp_writer_.SendReport(report); |
236 | 235 |
237 last_receiver_report_ = now; | 236 last_receiver_report_ = now; |
238 } | 237 } |
239 } | 238 } |
240 | 239 |
241 } // namespace protocol | 240 } // namespace protocol |
242 } // namespace remoting | 241 } // namespace remoting |
OLD | NEW |