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

Side by Side Diff: remoting/protocol/rtp_video_reader.cc

Issue 8116021: Switch remoting/protocol to new callbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/rtp_reader.cc ('k') | remoting/protocol/rtp_video_reader_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/task.h" 8 #include "base/task.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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 if (!initialized_) { 55 if (!initialized_) {
56 initialized_ = true; 56 initialized_ = true;
57 initialized_callback_.Run(false); 57 initialized_callback_.Run(false);
58 } 58 }
59 return; 59 return;
60 } 60 }
61 61
62 if (rtp) { 62 if (rtp) {
63 DCHECK(!rtp_channel_.get()); 63 DCHECK(!rtp_channel_.get());
64 rtp_channel_.reset(socket); 64 rtp_channel_.reset(socket);
65 rtp_reader_.Init(socket, NewCallback(this, &RtpVideoReader::OnRtpPacket)); 65 rtp_reader_.Init(socket, base::Bind(&RtpVideoReader::OnRtpPacket,
66 base::Unretained(this)));
66 } else { 67 } else {
67 DCHECK(!rtcp_channel_.get()); 68 DCHECK(!rtcp_channel_.get());
68 rtcp_channel_.reset(socket); 69 rtcp_channel_.reset(socket);
69 rtcp_writer_.Init(socket); 70 rtcp_writer_.Init(socket);
70 } 71 }
71 72
72 if (rtp_channel_.get() && rtcp_channel_.get()) { 73 if (rtp_channel_.get() && rtcp_channel_.get()) {
73 DCHECK(!initialized_); 74 DCHECK(!initialized_);
74 initialized_ = true; 75 initialized_ = true;
75 initialized_callback_.Run(true); 76 initialized_callback_.Run(true);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // packets will be ignored. 198 // packets will be ignored.
198 } 199 }
199 200
200 packet->mutable_data()->resize(content.total_bytes()); 201 packet->mutable_data()->resize(content.total_bytes());
201 content.CopyTo(const_cast<char*>(packet->mutable_data()->data()), 202 content.CopyTo(const_cast<char*>(packet->mutable_data()->data()),
202 packet->data().size()); 203 packet->data().size());
203 204
204 // Set format. 205 // Set format.
205 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8); 206 packet->mutable_format()->set_encoding(VideoPacketFormat::ENCODING_VP8);
206 207
207 video_stub_->ProcessVideoPacket(packet, new DeleteTask<VideoPacket>(packet)); 208 video_stub_->ProcessVideoPacket(
209 packet, base::Bind(&DeletePointer<VideoPacket>, packet));
208 210
209 SendReceiverReportIf(); 211 SendReceiverReportIf();
210 } 212 }
211 213
212 void RtpVideoReader::SendReceiverReportIf() { 214 void RtpVideoReader::SendReceiverReportIf() {
213 base::Time now = base::Time::Now(); 215 base::Time now = base::Time::Now();
214 216
215 // Send receiver report only if we haven't sent any bofore, or 217 // Send receiver report only if we haven't sent any bofore, or
216 // enough time has passed since the last report. 218 // enough time has passed since the last report.
217 if (last_receiver_report_.is_null() || 219 if (last_receiver_report_.is_null() ||
218 (now - last_receiver_report_).InMilliseconds() > 220 (now - last_receiver_report_).InMilliseconds() >
219 kReceiverReportsIntervalMs) { 221 kReceiverReportsIntervalMs) {
220 RtcpReceiverReport report; 222 RtcpReceiverReport report;
221 rtp_reader_.GetReceiverReport(&report); 223 rtp_reader_.GetReceiverReport(&report);
222 rtcp_writer_.SendReport(report); 224 rtcp_writer_.SendReport(report);
223 225
224 last_receiver_report_ = now; 226 last_receiver_report_ = now;
225 } 227 }
226 } 228 }
227 229
228 } // namespace protocol 230 } // namespace protocol
229 } // namespace remoting 231 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/rtp_reader.cc ('k') | remoting/protocol/rtp_video_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698