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

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

Issue 7605018: Simplify channel creation callbacks in remoting::Session interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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_video_reader.h ('k') | remoting/protocol/rtp_video_writer.h » ('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 23 matching lines...) Expand all
34 } 34 }
35 35
36 void RtpVideoReader::Init(protocol::Session* session, 36 void RtpVideoReader::Init(protocol::Session* session,
37 VideoStub* video_stub, 37 VideoStub* video_stub,
38 const InitializedCallback& callback) { 38 const InitializedCallback& callback) {
39 initialized_callback_ = callback; 39 initialized_callback_ = callback;
40 video_stub_ = video_stub; 40 video_stub_ = video_stub;
41 41
42 session->CreateDatagramChannel( 42 session->CreateDatagramChannel(
43 kVideoRtpChannelName, 43 kVideoRtpChannelName,
44 base::Bind(&RtpVideoReader::OnChannelReady, base::Unretained(this))); 44 base::Bind(&RtpVideoReader::OnChannelReady,
45 base::Unretained(this), true));
45 session->CreateDatagramChannel( 46 session->CreateDatagramChannel(
46 kVideoRtcpChannelName, 47 kVideoRtcpChannelName,
47 base::Bind(&RtpVideoReader::OnChannelReady, base::Unretained(this))); 48 base::Bind(&RtpVideoReader::OnChannelReady,
49 base::Unretained(this), false));
48 } 50 }
49 51
50 void RtpVideoReader::OnChannelReady(const std::string& name, 52 void RtpVideoReader::OnChannelReady(bool rtp, net::Socket* socket) {
Wez 2011/08/09 23:42:35 Why have an |rtp| bool here, rather than the conta
Sergey Ulanov 2011/08/10 00:00:43 because we also need to initialized |rtp_reader_|
Wez 2011/08/10 00:37:13 Yes, but that could be managed with: if (socket
51 net::Socket* socket) {
52 if (!socket) { 53 if (!socket) {
53 if (!initialized_) { 54 if (!initialized_) {
54 initialized_ = true; 55 initialized_ = true;
55 initialized_callback_.Run(false); 56 initialized_callback_.Run(false);
56 } 57 }
57 return; 58 return;
58 } 59 }
59 60
60 if (name == kVideoRtpChannelName) { 61 if (rtp) {
61 DCHECK(!rtp_channel_.get()); 62 DCHECK(!rtp_channel_.get());
62 rtp_channel_.reset(socket); 63 rtp_channel_.reset(socket);
63 rtp_reader_.Init(socket, NewCallback(this, &RtpVideoReader::OnRtpPacket)); 64 rtp_reader_.Init(socket, NewCallback(this, &RtpVideoReader::OnRtpPacket));
64 } else if (name == kVideoRtcpChannelName) { 65 } else {
65 DCHECK(!rtcp_channel_.get()); 66 DCHECK(!rtcp_channel_.get());
66 rtcp_channel_.reset(socket); 67 rtcp_channel_.reset(socket);
67 rtcp_writer_.Init(socket); 68 rtcp_writer_.Init(socket);
68 } else {
69 NOTREACHED();
70 } 69 }
71 70
72 if (rtp_channel_.get() && rtcp_channel_.get()) { 71 if (rtp_channel_.get() && rtcp_channel_.get()) {
73 DCHECK(!initialized_); 72 DCHECK(!initialized_);
74 initialized_ = true; 73 initialized_ = true;
75 initialized_callback_.Run(true); 74 initialized_callback_.Run(true);
76 } 75 }
77 } 76 }
78 77
79 void RtpVideoReader::ResetQueue() { 78 void RtpVideoReader::ResetQueue() {
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 RtcpReceiverReport report; 219 RtcpReceiverReport report;
221 rtp_reader_.GetReceiverReport(&report); 220 rtp_reader_.GetReceiverReport(&report);
222 rtcp_writer_.SendReport(report); 221 rtcp_writer_.SendReport(report);
223 222
224 last_receiver_report_ = now; 223 last_receiver_report_ = now;
225 } 224 }
226 } 225 }
227 226
228 } // namespace protocol 227 } // namespace protocol
229 } // namespace remoting 228 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/rtp_video_reader.h ('k') | remoting/protocol/rtp_video_writer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698